6666#ifndef _LLRING_H_
6767#define _LLRING_H_
6868
69+ #if defined(__has_cpp_attribute)
70+ #if __has_cpp_attribute(fallthrough)
71+ #define FALLTHROUGH [[fallthrough]]
72+ #elif __has_cpp_attribute(clang::fallthrough)
73+ #define FALLTHROUGH [[clang::fallthrough]]
74+ #else
75+ #define FALLTHROUGH
76+ #endif
77+ #else
78+ #define FALLTHROUGH
79+ #endif
80+
6981/* *
7082 * Note: the ring implementation is not preemptable. A producer must not
7183 * be interrupted by another producer that uses the same ring.
@@ -111,14 +123,14 @@ static inline void llring_pause(void) { _mm_pause(); }
111123
112124#endif
113125
114- /* llring can be used between execution contexts having different address widths.
115- * In such circumstances, use phys_addr_t rather than void *, whose size would
116- * be different in 32 bit versus 64 bit contexts.
126+ /* llring can be used between execution contexts having different address
127+ * widths. In such circumstances, use phys_addr_t rather than void *, whose size
128+ * would be different in 32 bit versus 64 bit contexts.
117129 */
118130#ifdef __LLRING_USE_PHYS_ADDR__
119131typedef phys_addr_t llring_addr_t ;
120132#else
121- typedef void * llring_addr_t ;
133+ typedef void *llring_addr_t ;
122134#endif
123135
124136/* dummy assembly operation to prevent compiler re-ordering of instructions */
@@ -210,10 +222,11 @@ struct llring {
210222 /* it seems to help */
211223 char _pad[LLRING_CACHELINE_SIZE ];
212224
213- llring_addr_t ring [0 ]
214- __llring_cache_aligned ; /**< Memory space of ring starts here.
215- * not volatile so need to be careful
216- * about compiler re-ordering */
225+ llring_addr_t ring[0 ] __llring_cache_aligned; /* *< Memory space of ring
226+ * starts here. not
227+ * volatile so need to be
228+ * careful about compiler
229+ * re-ordering */
217230} __llring_cache_aligned;
218231
219232#define RING_QUOT_EXCEED (1 << 31 ) /* *< Quota exceed for burst ops */
@@ -236,7 +249,9 @@ struct llring {
236249 r->stats [__lcore_id].name ##_bulk += 1 ; \
237250 } while (0 )
238251#else
239- #define __RING_STAT_ADD (r , name , n ) do {} while(0)
252+ #define __RING_STAT_ADD (r, name, n ) \
253+ do { \
254+ } while (0 )
240255#endif
241256
242257static inline int llring_bytes_with_slots (unsigned int slots)
@@ -324,8 +339,10 @@ static inline int llring_set_water_mark(struct llring *r, unsigned count)
324339 switch (n & 0x3 ) { \
325340 case 3 : \
326341 r->ring [idx++] = obj_table[i++]; \
342+ FALLTHROUGH ; \
327343 case 2 : \
328344 r->ring [idx++] = obj_table[i++]; \
345+ FALLTHROUGH ; \
329346 case 1 : \
330347 r->ring [idx++] = obj_table[i++]; \
331348 } \
@@ -355,8 +372,10 @@ static inline int llring_set_water_mark(struct llring *r, unsigned count)
355372 switch (n & 0x3 ) { \
356373 case 3 : \
357374 obj_table[i++] = r->ring [idx++]; \
375+ FALLTHROUGH ; \
358376 case 2 : \
359377 obj_table[i++] = r->ring [idx++]; \
378+ FALLTHROUGH ; \
360379 case 1 : \
361380 obj_table[i++] = r->ring [idx++]; \
362381 } \
@@ -395,8 +414,8 @@ static inline int llring_set_water_mark(struct llring *r, unsigned count)
395414 * - n: Actual number of objects enqueued.
396415 */
397416static inline int __attribute__ ((always_inline))
398- __llring_mp_do_enqueue (struct llring * r , llring_addr_t const * obj_table , unsigned n ,
399- enum llring_queue_behavior behavior )
417+ __llring_mp_do_enqueue(struct llring *r, llring_addr_t const *obj_table,
418+ unsigned n, enum llring_queue_behavior behavior)
400419{
401420 uint32_t prod_head, prod_next;
402421 uint32_t cons_tail, free_entries;
@@ -491,8 +510,8 @@ __llring_mp_do_enqueue(struct llring *r, llring_addr_t const *obj_table, unsigne
491510 * - n: Actual number of objects enqueued.
492511 */
493512static inline int __attribute__ ((always_inline))
494- __llring_sp_do_enqueue (struct llring * r , llring_addr_t const * obj_table , unsigned n ,
495- enum llring_queue_behavior behavior )
513+ __llring_sp_do_enqueue(struct llring *r, llring_addr_t const *obj_table,
514+ unsigned n, enum llring_queue_behavior behavior)
496515{
497516 uint32_t prod_head, cons_tail;
498517 uint32_t prod_next, free_entries;
@@ -723,19 +742,22 @@ __llring_sc_do_dequeue(struct llring *r, llring_addr_t *obj_table, unsigned n,
723742 * enqueued.
724743 */
725744static inline int __attribute__ ((always_inline))
726- llring_mp_enqueue_bulk (struct llring * r , llring_addr_t const * obj_table , unsigned n )
745+ llring_mp_enqueue_bulk(struct llring *r, llring_addr_t const *obj_table,
746+ unsigned n)
727747{
728748 return __llring_mp_do_enqueue (r, obj_table, n, LLRING_QUEUE_FIXED );
729749}
730750
731751static inline int __attribute__ ((always_inline))
732- llring_sp_enqueue_bulk (struct llring * r , llring_addr_t const * obj_table , unsigned n )
752+ llring_sp_enqueue_bulk(struct llring *r, llring_addr_t const *obj_table,
753+ unsigned n)
733754{
734755 return __llring_sp_do_enqueue (r, obj_table, n, LLRING_QUEUE_FIXED );
735756}
736757
737758static inline int __attribute__ ((always_inline))
738- llring_enqueue_bulk (struct llring * r , llring_addr_t const * obj_table , unsigned n )
759+ llring_enqueue_bulk(struct llring *r, llring_addr_t const *obj_table,
760+ unsigned n)
739761{
740762 if (r->common .sp_enqueue )
741763 return llring_sp_enqueue_bulk (r, obj_table, n);
@@ -1057,7 +1079,8 @@ llring_sp_enqueue_burst(struct llring *r, llring_addr_t const *obj_table,
10571079 * - n: Actual number of objects enqueued.
10581080 */
10591081static inline int __attribute__ ((always_inline))
1060- llring_enqueue_burst (struct llring * r , llring_addr_t const * obj_table , unsigned n )
1082+ llring_enqueue_burst(struct llring *r, llring_addr_t const *obj_table,
1083+ unsigned n)
10611084{
10621085 if (r->common .sp_enqueue )
10631086 return llring_sp_enqueue_burst (r, obj_table, n);
0 commit comments