We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 43b2aa9 + c66ec56 commit 937dfefCopy full SHA for 937dfef
ringbuffer/ringbuffer.c
@@ -54,8 +54,9 @@ typedef struct {
54
/* true if x is a power of 2 */
55
#define IS_POWEROF2(x) ((((x) -1) & (x)) == 0)
56
#define RING_SIZE_MASK (unsigned) (0x0fffffff) /**< Ring size mask */
57
-#define ALIGN_FLOOR(val, align) \
58
- (typeof(val))((val) & (~((typeof(val))((align) -1))))
+#define ALIGN_CEIL(val, align) \
+ (typeof(val))((val) + (-(typeof(val))(val) & ((align) -1)))
59
+
60
61
/**
62
* Calculate the memory size needed for a ring buffer.
@@ -80,7 +81,7 @@ ssize_t ringbuf_get_memsize(const unsigned count)
80
81
return -EINVAL;
82
83
ssize_t sz = sizeof(ringbuf_t) + count * sizeof(void *);
- sz = ALIGN_FLOOR(sz, CACHE_LINE_SIZE);
84
+ sz = ALIGN_CEIL(sz, CACHE_LINE_SIZE);
85
return sz;
86
}
87
0 commit comments