From: asterix Date: Wed, 11 Jan 2012 14:40:09 +0000 (+0000) Subject: fifobuf: introduce DECLARE_FIFO() macro X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=76c3a84c29c451d164575134b29986f3bbc42656;p=bertos.git 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 --- 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 *