fifobuf: introduce DECLARE_FIFO() macro
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 11 Jan 2012 14:40:09 +0000 (14:40 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 11 Jan 2012 14:40:09 +0000 (14:40 +0000)
Introduce a macro to declare a static and correctly initialized
FIFOBuffer.

git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5234 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/struct/fifobuf.h

index f58e1c0a7d0f4e99999298d5af2f63029a4de566..117431be59980fac7d2fbdb6e78088e309c14281 100644 (file)
@@ -92,6 +92,19 @@ typedef struct FIFOBuffer
        )
 
 
+/**
+ * Declare a static fifo buffer
+ */
+#define DECLARE_FIFO(_name, _ptr, _size)                       \
+       FIFOBuffer _name =                                      \
+       {                                                       \
+               .head = (_ptr),                                 \
+               .tail = (_ptr),                                 \
+               .begin = (_ptr),                                \
+               .end = (_ptr) + (_size) - 1,                    \
+       };                                                      \
+       STATIC_ASSERT((_size) > 1)
+
 /**
  * Check whether the fifo is empty
  *