diff --git a/m-buffer.h b/m-buffer.h index 5d216580..a3e4926a 100644 --- a/m-buffer.h +++ b/m-buffer.h @@ -291,9 +291,9 @@ M_C(name, _init)(buffer_t v, size_t size) \ thread which has the push lock. As such, it has to be handled \ like an atomic variable. */ \ /* Increment number of elements of the buffer */ \ - previousSize = atomic_fetch_add (&v->number[0], 1); \ + previousSize = atomic_fetch_add (&v->number[0], 1UL); \ if (BUFFERI_POLICY_P((policy), BUFFER_DEFERRED_POP)) { \ - atomic_fetch_add (&v->number[1], 1); \ + atomic_fetch_add (&v->number[1], 1UL); \ } \ } \ \ @@ -360,9 +360,9 @@ M_C(name, _init)(buffer_t v, size_t size) \ /* Decrement number of elements in the buffer */ \ size_t previousSize; \ if (!BUFFERI_POLICY_P((policy), BUFFER_DEFERRED_POP)) { \ - previousSize = atomic_fetch_sub (&v->number[0], 1); \ + previousSize = atomic_fetch_sub (&v->number[0], 1UL); \ } else { \ - atomic_fetch_sub (&v->number[1], 1); \ + atomic_fetch_sub (&v->number[1], 1UL); \ } \ \ /* BUFFER unlock */ \ @@ -416,7 +416,7 @@ M_C(name, _init)(buffer_t v, size_t size) \ { \ /* Decrement the effective number of elements in the buffer */ \ if (BUFFERI_POLICY_P((policy), BUFFER_DEFERRED_POP)) { \ - size_t previousSize = atomic_fetch_sub (&v->number[0], 1); \ + size_t previousSize = atomic_fetch_sub (&v->number[0], 1UL); \ if (previousSize == BUFFERI_SIZE(m_size)) { \ m_mutex_lock(v->mutexPush); \ m_cond_broadcast(v->there_is_room_for_data); \ diff --git a/m-shared.h b/m-shared.h index 463943dd..7fdfb5af 100644 --- a/m-shared.h +++ b/m-shared.h @@ -328,7 +328,7 @@ static inline int sharedi_integer_cref(int *p) { return *p; } } \ for(size_t i = 0; i < n; i++) { \ M_GET_INIT oplist (s->buffer[i].x); \ - atomic_init (&s->buffer[i].cpt, 0); \ + atomic_init (&s->buffer[i].cpt, 0U); \ } \ genint_init(s->core, n); \ SHAREDI_RESOURCE_CONTRACT(s); \ @@ -392,7 +392,7 @@ static inline int sharedi_integer_cref(int *p) { return *p; } assert (it->ref == s); \ unsigned int idx = it->idx; \ if (M_LIKELY (idx != -1U)) { \ - unsigned int c = atomic_fetch_sub (&it->ref->buffer[idx].cpt, 1); \ + unsigned int c = atomic_fetch_sub (&it->ref->buffer[idx].cpt, 1U); \ if (c == 1) { \ genint_push(it->ref->core, idx); \ } \ @@ -409,7 +409,7 @@ static inline int sharedi_integer_cref(int *p) { return *p; } unsigned int idx = its->idx; \ itd->idx = idx; \ if (M_LIKELY (idx != -1U)) { \ - unsigned int c = atomic_fetch_add(&itd->ref->buffer[idx].cpt, 1); \ + unsigned int c = atomic_fetch_add(&itd->ref->buffer[idx].cpt, 1U); \ assert (c >= 1); \ } \ } \ diff --git a/m-snapshot.h b/m-snapshot.h index 17a9d951..cc4b19ab 100644 --- a/m-snapshot.h +++ b/m-snapshot.h @@ -318,12 +318,12 @@ static inline void snapshot_mrsw_int_init(snapshot_mrsw_int_t s, size_t n) // Get a free buffer and set it as available for readers unsigned int w = genint_pop(s->freeList); assert (w != -1U); - atomic_store(&s->cptTab[w], 1); + atomic_store(&s->cptTab[w], 1U); atomic_init(&s->lastNext, SNAPSHOTI_SPMC_INT_FLAG(w, true)); // Get working buffer s->currentWrite = genint_pop(s->freeList); assert (s->currentWrite != -1U); - atomic_store(&s->cptTab[s->currentWrite], 1); + atomic_store(&s->cptTab[s->currentWrite], 1U); SNAPSHOTI_SPMC_INT_CONTRACT(s); } @@ -358,7 +358,7 @@ static inline unsigned int snapshot_mrsw_int_write_idx(snapshot_mrsw_int_t s, un } else { // Free the write index idx = SNAPSHOTI_SPMC_INT_FLAG_W(previous); - unsigned int c = atomic_fetch_sub(&s->cptTab[idx], 1); + unsigned int c = atomic_fetch_sub(&s->cptTab[idx], 1U); assert (c != 0 && c <= s->n + 1); // Get a new buffer. if (c != 1) { @@ -370,7 +370,7 @@ static inline unsigned int snapshot_mrsw_int_write_idx(snapshot_mrsw_int_t s, un } assert (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER); assert (atomic_load(&s->cptTab[idx]) == 0); - atomic_store(&s->cptTab[idx], 1); + atomic_store(&s->cptTab[idx], 1U); } SNAPSHOTI_SPMC_INT_CONTRACT(s); return idx; @@ -391,7 +391,7 @@ static inline unsigned int snapshot_mrsw_int_write_start(snapshot_mrsw_int_t s) assert (idx != -1U); assert (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER); assert (atomic_load(&s->cptTab[idx]) == 0); - atomic_store(&s->cptTab[idx], 1); + atomic_store(&s->cptTab[idx], 1U); SNAPSHOTI_SPMC_INT_CONTRACT(s); return idx; } @@ -406,7 +406,7 @@ static inline void snapshot_mrsw_int_write_end(snapshot_mrsw_int_t s, unsigned i // Free the previous write buffer idx = SNAPSHOTI_SPMC_INT_FLAG_W(previous); - unsigned int c = atomic_fetch_sub(&s->cptTab[idx], 1); + unsigned int c = atomic_fetch_sub(&s->cptTab[idx], 1U); assert (c != 0 && c <= s->n + 1); if (c == 1) { genint_push(s->freeList, idx); @@ -445,7 +445,7 @@ static inline unsigned int snapshot_mrsw_int_read_start(snapshot_mrsw_int_t s) break; } // Free the reserved index as we failed it to ack it - c = atomic_fetch_sub(&s->cptTab[idx], 1); + c = atomic_fetch_sub(&s->cptTab[idx], 1U); assert (c != 0 && c <= s->n+1); if (c == 1) { genint_push(s->freeList, idx); @@ -460,7 +460,7 @@ static inline void snapshot_mrsw_int_read_end(snapshot_mrsw_int_t s, unsigned in SNAPSHOTI_SPMC_INT_CONTRACT(s); assert (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER); // Decrement reference counter of the buffer - unsigned int c = atomic_fetch_sub(&s->cptTab[idx], 1); + unsigned int c = atomic_fetch_sub(&s->cptTab[idx], 1U); assert (c != 0 && c <= s->n+1); if (c == 1) { // Buffer no longer used by any reader thread.