From 76c3a84c29c451d164575134b29986f3bbc42656 Mon Sep 17 00:00:00 2001 From: asterix Date: Wed, 11 Jan 2012 14:40:09 +0000 Subject: [PATCH] fifobuf: introduce DECLARE_FIFO() macro 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bertos/struct/fifobuf.h b/bertos/struct/fifobuf.h index f58e1c0a..117431be 100644 --- a/bertos/struct/fifobuf.h +++ b/bertos/struct/fifobuf.h @@ -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 * -- 2.25.1