From 02aeca02db90295a2f6e21fd0438cd2748e9426b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= <rene.kijewski@fu-berlin.de>
Date: Tue, 6 May 2014 20:45:29 +0200
Subject: [PATCH] ringbuffer: add static initializer

---
 sys/include/ringbuffer.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/include/ringbuffer.h b/sys/include/ringbuffer.h
index ad463c478a..5819f2a15f 100644
--- a/sys/include/ringbuffer.h
+++ b/sys/include/ringbuffer.h
@@ -30,6 +30,15 @@ typedef struct ringbuffer {
     unsigned int avail; /**< Number of elements available for reading. */
 } ringbuffer_t;
 
+/**
+ * @def          RINGBUFFER_INIT(BUF)
+ * @brief        Initialize a ringbuffer.
+ * @details      This macro is meant for static ringbuffers.
+ * @param[in]    BUF   Buffer to use for the ringbuffer. The size is deduced through `sizeof (BUF)`.
+ * @returns      The static initializer.
+ */
+#define RINGBUFFER_INIT(BUF) { (BUF), sizeof (BUF), 0, 0 }
+
 /**
  * @brief        Initialize a ringbuffer.
  * @param[out]   rb        Datum to initialize.
-- 
GitLab