ring: use a different type for read/write pointers

uint_least32_t could be larger than uint32_t, so the return values of
mp_ring_get_wpos/rpos must be adjusted. Actually just use unsigned long
as type instead, because that is less awkward than uint_least32_t.
This commit is contained in:
wm4 2014-05-29 23:56:37 +02:00
parent e127cfa0b5
commit d87a84ca89
1 changed files with 3 additions and 3 deletions

View File

@ -30,15 +30,15 @@ struct mp_ring {
/* Positions of the first readable/writeable chunks. Do not read this
* fields but use the atomic private accessors `mp_ring_get_wpos`
* and `mp_ring_get_rpos`. */
atomic_uint_least32_t rpos, wpos;
atomic_ulong rpos, wpos;
};
static uint32_t mp_ring_get_wpos(struct mp_ring *buffer)
static unsigned long mp_ring_get_wpos(struct mp_ring *buffer)
{
return atomic_load(&buffer->wpos);
}
static uint32_t mp_ring_get_rpos(struct mp_ring *buffer)
static unsigned long mp_ring_get_rpos(struct mp_ring *buffer)
{
return atomic_load(&buffer->rpos);
}