Well, in principle I always have a bit of a problem with fixed sizes with no obvious justification. The buffer is 32 elements. Depending on the use case, this may be too much or too little, and does not appear to be tunable. But for the most part, this will work. However, some details:
Code:
#define DEFINE_RING32(name, type) \
struct rbuf32 { \
uint8_t ri:5; \
uint8_t ci:5; \
type buf[RINGBUF32_SIZE];\
} rbuf32_t; \
typedef struct rbuf32 name;
This creates an instance of "struct rbuf32" named "rbuf32_t". I believe you wanted to make a new type here, although I also fail to see what use those names are given that you do everything else in macros, and those names prevent reuse (if you define two different ring buffers, they will get the same name, and the compiler will complain about that). Also, the base type of a bitfield can only be signed int or unsigned int or int (yielding a signed, unsigned, or implementation-defined bitfield, respectively), everything else is a GCC extension. So putting it all together, I'd go with
Code:
#define DEFINE_RING32(name, type) \
typedef struct { \
unsigned ri:5; \
unsigned ci:5; \
type buf[32]; \
} name
That also makes the macro not end in a semicolon, so you can add those to the macro calls again, which will likely be less confusing for readers.