2626 } while (0)
2727#endif
2828
29- /**
30- * The producer and the consumer have a head and a tail index. The particularity
29+ /* The producer and the consumer have a head and a tail index. The particularity
3130 * of these index is that they are not between 0 and size(ring). These indexes
3231 * are between 0 and 2^32, and we mask their value when we access the ring[]
3332 * field. Thanks to this assumption, we can do subtractions between 2 index
3736typedef struct {
3837 struct { /** Ring producer status. */
3938 uint32_t watermark ; /**< Maximum items before EDQUOT. */
40- uint32_t size ; /**< Size of ring. */
41- uint32_t mask ; /**< Mask (size - 1) of ring. */
39+ uint32_t size ; /**< Size of ring buffer . */
40+ uint32_t mask ; /**< Mask (size - 1) of ring buffer . */
4241 volatile uint32_t head , tail ; /**< Producer head and tail. */
4342 } prod __attribute__((__aligned__ (CACHE_LINE_SIZE )));
4443
4544 struct { /** Ring consumer status. */
46- uint32_t size ; /**< Size of the ring. */
47- uint32_t mask ; /**< Mask (size - 1) of ring. */
45+ uint32_t size ; /**< Size of the ring buffer . */
46+ uint32_t mask ; /**< Mask (size - 1) of ring buffer . */
4847 volatile uint32_t head , tail ; /**< Consumer head and tail. */
4948 } cons __attribute__((__aligned__ (CACHE_LINE_SIZE )));
5049
@@ -57,19 +56,17 @@ typedef struct {
5756#define ALIGN_CEIL (val , align ) \
5857 (typeof(val))((val) + (-(typeof(val))(val) & ((align) -1)))
5958
60-
61- /**
62- * Calculate the memory size needed for a ring buffer.
59+ /* Calculate the memory size needed for a ring buffer.
6360 *
6461 * This function returns the number of bytes needed for a ring buffer, given
6562 * the number of elements in it. This value is the sum of the size of the
6663 * structure ringbuf and the size of the memory needed by the objects pointers.
6764 * The value is aligned to a cache line size.
6865 *
6966 * @param count
70- * The number of elements in the ring (must be a power of 2).
67+ * The number of elements in the ring buffer (must be a power of 2).
7168 * @return
72- * - The memory size occupied by the ring on success.
69+ * - The memory size occupied by the ring buffer on success.
7370 * - -EINVAL if count is not a power of 2.
7471 */
7572ssize_t ringbuf_get_memsize (const unsigned count )
@@ -85,17 +82,16 @@ ssize_t ringbuf_get_memsize(const unsigned count)
8582 return sz ;
8683}
8784
88- /**
89- * Initialize a ring buffer.
85+ /* Initialize a ring buffer.
9086 *
9187 * The ring size is set to *count*, which must be a power of two. Water
9288 * marking is disabled by default. The real usable ring size is (count - 1)
93- * instead of (count) to differentiate a free ring from an empty ring.
89+ * instead of (count) to differentiate a free ring from an empty ring buffer .
9490 *
9591 * @param r
96- * The pointer to the ring structure followed by the objects table.
92+ * The pointer to the ring buffer structure followed by the objects table.
9793 * @param count
98- * The number of elements in the ring (must be a power of 2).
94+ * The number of elements in the ring buffer (must be a power of 2).
9995 * @return
10096 * 0 on success, or a negative value on error.
10197 */
@@ -109,17 +105,16 @@ int ringbuf_init(ringbuf_t *r, const unsigned count)
109105 return 0 ;
110106}
111107
112- /**
113- * Create a ring buffer.
108+ /* Create a ring buffer.
114109 *
115110 * The real usable ring size is (count - 1) instead of (count) to
116- * differentiate a free ring from an empty ring.
111+ * differentiate a free ring from an empty ring buffer .
117112 *
118113 * @param count
119114 * The size of the ring (must be a power of 2).
120115 * @return
121- * On success, the pointer to the new allocated ring. NULL on error with
122- * errno set appropriately. Possible errno values include:
116+ * On success, the pointer to the new allocated ring buffer . NULL on error
117+ * with errno set appropriately. Possible errno values include:
123118 * - EINVAL - count provided is not a power of 2
124119 * - ENOSPC - the maximum number of memzones has already been allocated
125120 * - EEXIST - a memzone with the same name already exists
@@ -137,8 +132,7 @@ ringbuf_t *ringbuf_create(const unsigned count)
137132 return r ;
138133}
139134
140- /**
141- * Release all memory used by the ring.
135+ /* Release all memory used by the ring buffer.
142136 *
143137 * @param r
144138 * Ring to free
@@ -148,7 +142,7 @@ void ringbuf_free(ringbuf_t *r)
148142 free (r );
149143}
150144
151- /* The actual enqueue of pointers on the ring.
145+ /* The actual enqueue of pointers on the ring buffer .
152146 * Placed here since identical code needed in both single- and multi- producer
153147 * enqueue functions.
154148 */
@@ -210,16 +204,14 @@ void ringbuf_free(ringbuf_t *r)
210204 } \
211205 } while (0)
212206
213- /**
214- * @internal Enqueue several objects on a ring buffer (NOT multi-producers
215- * safe).
207+ /* Enqueue several objects on a ring buffer (NOT multi-producers safe).
216208 *
217209 * @param r
218- * A pointer to the ring structure.
210+ * A pointer to the ring buffer structure.
219211 * @param obj_table
220212 * A pointer to a table of void * pointers (objects).
221213 * @param n
222- * The number of objects to add in the ring from the obj_table.
214+ * The number of objects to add in the ring buffer from the obj_table.
223215 * @return
224216 * - 0: Success; objects enqueue.
225217 * - -EDQUOT: Quota exceeded. The objects have been enqueued, but the
@@ -238,14 +230,14 @@ static inline int ringbuffer_sp_do_enqueue(ringbuf_t *r,
238230 */
239231 uint32_t free_entries = mask + cons_tail - prod_head ;
240232
241- /* check that we have enough room in ring */
233+ /* check that we have enough room in ring buffer */
242234 if ((n > free_entries ))
243235 return - ENOBUFS ;
244236
245237 uint32_t prod_next = prod_head + n ;
246238 r -> prod .head = prod_next ;
247239
248- /* write entries in ring */
240+ /* write entries in ring buffer */
249241 ENQUEUE_PTRS ();
250242 __compiler_barrier ();
251243
@@ -255,20 +247,19 @@ static inline int ringbuffer_sp_do_enqueue(ringbuf_t *r,
255247 return ((mask + 1 ) - free_entries + n ) > r -> prod .watermark ? - EDQUOT : 0 ;
256248}
257249
258- /**
259- * @internal Dequeue several objects from a ring buffer (NOT multi-consumers
260- * safe). When the request objects are more than the available objects, only
261- * dequeue the actual number of objects
250+ /* Dequeue several objects from a ring buffer (NOT multi-consumers safe).
251+ * When the request objects are more than the available objects, only dequeue
252+ * the actual number of objects
262253 *
263254 * @param r
264- * A pointer to the ring structure.
255+ * A pointer to the ring buffer structure.
265256 * @param obj_table
266257 * A pointer to a table of void * pointers (objects) that will be filled.
267258 * @param n
268- * The number of objects to dequeue from the ring to the obj_table.
259+ * The number of objects to dequeue from the ring buffer to the obj_table.
269260 * @return
270261 * - 0: Success; objects dequeued.
271- * - -ENOENT: Not enough entries in the ring to dequeue; no object is
262+ * - -ENOENT: Not enough entries in the ring buffer to dequeue; no object is
272263 * dequeued.
273264 */
274265static inline int ringbuffer_sc_do_dequeue (ringbuf_t * r ,
@@ -297,18 +288,18 @@ static inline int ringbuffer_sc_do_dequeue(ringbuf_t *r,
297288 return 0 ;
298289}
299290
300- /**
301- * Enqueue one object on a ring buffer (NOT multi-producers safe).
291+ /* Enqueue one object on a ring buffer (NOT multi-producers safe).
302292 *
303293 * @param r
304- * A pointer to the ring structure.
294+ * A pointer to the ring buffer structure.
305295 * @param obj
306296 * A pointer to the object to be added.
307297 * @return
308298 * - 0: Success; objects enqueued.
309299 * - -EDQUOT: Quota exceeded. The objects have been enqueued, but the
310300 * high water mark is exceeded.
311- * - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
301+ * - -ENOBUFS: Not enough room in the ring buffer to enqueue; no object
302+ * is enqueued.
312303 */
313304static inline int ringbuf_sp_enqueue (ringbuf_t * r , void * obj )
314305{
@@ -324,16 +315,15 @@ static inline int ringbuf_sp_enqueue(ringbuf_t *r, void *obj)
324315 * A pointer to a void * pointer (object) that will be filled.
325316 * @return
326317 * - 0: Success; objects dequeued.
327- * - -ENOENT: Not enough entries in the ring to dequeue, no object is
328- * dequeued.
318+ * - -ENOENT: Not enough entries in the ring buffer to dequeue, no object
319+ * is dequeued.
329320 */
330321static inline int ringbuf_sc_dequeue (ringbuf_t * r , void * * obj_p )
331322{
332323 return ringbuffer_sc_do_dequeue (r , obj_p , 1 );
333324}
334325
335- /**
336- * Test if a ring buffer is full.
326+ /* Test if a ring buffer is full.
337327 *
338328 * @param r
339329 * A pointer to the ring structure.
@@ -347,8 +337,7 @@ static inline bool ringbuf_is_full(const ringbuf_t *r)
347337 return ((cons_tail - prod_tail - 1 ) & r -> prod .mask ) == 0 ;
348338}
349339
350- /**
351- * Test if a ring buffer is empty.
340+ /* Test if a ring buffer is empty.
352341 *
353342 * @param r
354343 * A pointer to the ring structure.
0 commit comments