Rev 1392 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1392 | Rev 1481 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | #include <malloc.h> |
42 | #include <malloc.h> |
43 | 43 | ||
44 | typedef unsigned long fifo_count_t; |
44 | typedef unsigned long fifo_count_t; |
45 | typedef unsigned long fifo_index_t; |
45 | typedef unsigned long fifo_index_t; |
46 | 46 | ||
- | 47 | #define FIFO_CREATE_STATIC(name, t, itms) \ |
|
- | 48 | struct { \ |
|
- | 49 | t fifo[(itms)]; \ |
|
- | 50 | fifo_count_t items; \ |
|
- | 51 | fifo_index_t head; \ |
|
- | 52 | fifo_index_t tail; \ |
|
- | 53 | } name |
|
- | 54 | ||
47 | /** Create and initialize static FIFO. |
55 | /** Create and initialize static FIFO. |
48 | * |
56 | * |
49 | * FIFO is allocated statically. |
57 | * FIFO is allocated statically. |
50 | * This macro is suitable for creating smaller FIFOs. |
58 | * This macro is suitable for creating smaller FIFOs. |
51 | * |
59 | * |
52 | * @param name Name of FIFO. |
60 | * @param name Name of FIFO. |
53 | * @param t Type of values stored in FIFO. |
61 | * @param t Type of values stored in FIFO. |
54 | * @param itms Number of items that can be stored in FIFO. |
62 | * @param itms Number of items that can be stored in FIFO. |
55 | */ |
63 | */ |
56 | #define FIFO_INITIALIZE_STATIC(name, t, itms) \ |
64 | #define FIFO_INITIALIZE_STATIC(name, t, itms) \ |
57 | struct { \ |
- | |
58 | t fifo[(itms)]; \ |
- | |
59 | fifo_count_t items; \ |
65 | FIFO_CREATE_STATIC(name, t, itms) = { \ |
60 | fifo_index_t head; \ |
- | |
61 | fifo_index_t tail; \ |
- | |
62 | } name = { \ |
- | |
63 | .items = (itms), \ |
66 | .items = (itms), \ |
64 | .head = 0, \ |
67 | .head = 0, \ |
65 | .tail = 0 \ |
68 | .tail = 0 \ |
66 | } |
69 | } |
67 | 70 |