* return a pointer to the first entry in the ring * without modifying it, or NULL if the ring is empty * race-prone if not protected by a lock */
| 282 | * race-prone if not protected by a lock |
| 283 | */ |
| 284 | static __inline void * |
| 285 | buf_ring_peek(struct buf_ring *br) |
| 286 | { |
| 287 | |
| 288 | #ifdef DEBUG_BUFRING |
| 289 | if ((br->br_lock != NULL) && !mtx_owned(br->br_lock)) |
| 290 | panic("lock not held on single consumer dequeue"); |
| 291 | #endif |
| 292 | /* |
| 293 | * I believe it is safe to not have a memory barrier |
| 294 | * here because we control cons and tail is worst case |
| 295 | * a lagging indicator so we worst case we might |
| 296 | * return NULL immediately after a buffer has been enqueued |
| 297 | */ |
| 298 | if (br->br_cons_head == br->br_prod_tail) |
| 299 | return (NULL); |
| 300 | |
| 301 | return (br->br_ring[br->br_cons_head]); |
| 302 | } |
| 303 | |
| 304 | static __inline void * |
| 305 | buf_ring_peek_clear_sc(struct buf_ring *br) |
no test coverage detected