Fix issue with C++ not supporting passing an int constant value to an unsigned atomic type...
I definitely find this disturbing.
This commit is contained in:
1 parent
5dded0d9aa
commit
f2b2335080
3 files changed
+16
-16
No files matched your search
+5
-5
@@ -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 \
|
thread which has the push lock. As such, it has to be handled \
|
||||||
like an atomic variable. */ \
|
like an atomic variable. */ \
|
||||||
/* Increment number of elements of the buffer */ \
|
/* 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)) { \
|
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 */ \
|
/* Decrement number of elements in the buffer */ \
|
||||||
size_t previousSize; \
|
size_t previousSize; \
|
||||||
if (!BUFFERI_POLICY_P((policy), BUFFER_DEFERRED_POP)) { \
|
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 { \
|
} else { \
|
||||||
atomic_fetch_sub (&v->number[1], 1); \
|
atomic_fetch_sub (&v->number[1], 1UL); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
/* BUFFER unlock */ \
|
/* 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 */ \
|
/* Decrement the effective number of elements in the buffer */ \
|
||||||
if (BUFFERI_POLICY_P((policy), BUFFER_DEFERRED_POP)) { \
|
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)) { \
|
if (previousSize == BUFFERI_SIZE(m_size)) { \
|
||||||
m_mutex_lock(v->mutexPush); \
|
m_mutex_lock(v->mutexPush); \
|
||||||
m_cond_broadcast(v->there_is_room_for_data); \
|
m_cond_broadcast(v->there_is_room_for_data); \
|
||||||
|
|||||||
+3
-3
@@ -328,7 +328,7 @@ static inline int sharedi_integer_cref(int *p) { return *p; }
|
|||||||
} \
|
} \
|
||||||
for(size_t i = 0; i < n; i++) { \
|
for(size_t i = 0; i < n; i++) { \
|
||||||
M_GET_INIT oplist (s->buffer[i].x); \
|
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); \
|
genint_init(s->core, n); \
|
||||||
SHAREDI_RESOURCE_CONTRACT(s); \
|
SHAREDI_RESOURCE_CONTRACT(s); \
|
||||||
@@ -392,7 +392,7 @@ static inline int sharedi_integer_cref(int *p) { return *p; }
|
|||||||
assert (it->ref == s); \
|
assert (it->ref == s); \
|
||||||
unsigned int idx = it->idx; \
|
unsigned int idx = it->idx; \
|
||||||
if (M_LIKELY (idx != -1U)) { \
|
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) { \
|
if (c == 1) { \
|
||||||
genint_push(it->ref->core, idx); \
|
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; \
|
unsigned int idx = its->idx; \
|
||||||
itd->idx = idx; \
|
itd->idx = idx; \
|
||||||
if (M_LIKELY (idx != -1U)) { \
|
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); \
|
assert (c >= 1); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
|||||||
+8
-8
@@ -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
|
// Get a free buffer and set it as available for readers
|
||||||
unsigned int w = genint_pop(s->freeList);
|
unsigned int w = genint_pop(s->freeList);
|
||||||
assert (w != -1U);
|
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));
|
atomic_init(&s->lastNext, SNAPSHOTI_SPMC_INT_FLAG(w, true));
|
||||||
// Get working buffer
|
// Get working buffer
|
||||||
s->currentWrite = genint_pop(s->freeList);
|
s->currentWrite = genint_pop(s->freeList);
|
||||||
assert (s->currentWrite != -1U);
|
assert (s->currentWrite != -1U);
|
||||||
atomic_store(&s->cptTab[s->currentWrite], 1);
|
atomic_store(&s->cptTab[s->currentWrite], 1U);
|
||||||
SNAPSHOTI_SPMC_INT_CONTRACT(s);
|
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 {
|
} else {
|
||||||
// Free the write index
|
// Free the write index
|
||||||
idx = SNAPSHOTI_SPMC_INT_FLAG_W(previous);
|
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);
|
assert (c != 0 && c <= s->n + 1);
|
||||||
// Get a new buffer.
|
// Get a new buffer.
|
||||||
if (c != 1) {
|
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 (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER);
|
||||||
assert (atomic_load(&s->cptTab[idx]) == 0);
|
assert (atomic_load(&s->cptTab[idx]) == 0);
|
||||||
atomic_store(&s->cptTab[idx], 1);
|
atomic_store(&s->cptTab[idx], 1U);
|
||||||
}
|
}
|
||||||
SNAPSHOTI_SPMC_INT_CONTRACT(s);
|
SNAPSHOTI_SPMC_INT_CONTRACT(s);
|
||||||
return idx;
|
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 != -1U);
|
||||||
assert (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER);
|
assert (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER);
|
||||||
assert (atomic_load(&s->cptTab[idx]) == 0);
|
assert (atomic_load(&s->cptTab[idx]) == 0);
|
||||||
atomic_store(&s->cptTab[idx], 1);
|
atomic_store(&s->cptTab[idx], 1U);
|
||||||
SNAPSHOTI_SPMC_INT_CONTRACT(s);
|
SNAPSHOTI_SPMC_INT_CONTRACT(s);
|
||||||
return idx;
|
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
|
// Free the previous write buffer
|
||||||
idx = SNAPSHOTI_SPMC_INT_FLAG_W(previous);
|
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);
|
assert (c != 0 && c <= s->n + 1);
|
||||||
if (c == 1) {
|
if (c == 1) {
|
||||||
genint_push(s->freeList, idx);
|
genint_push(s->freeList, idx);
|
||||||
@@ -445,7 +445,7 @@ static inline unsigned int snapshot_mrsw_int_read_start(snapshot_mrsw_int_t s)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Free the reserved index as we failed it to ack it
|
// 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);
|
assert (c != 0 && c <= s->n+1);
|
||||||
if (c == 1) {
|
if (c == 1) {
|
||||||
genint_push(s->freeList, idx);
|
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);
|
SNAPSHOTI_SPMC_INT_CONTRACT(s);
|
||||||
assert (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER);
|
assert (idx < s->n + SNAPSHOTI_SPMC_EXTRA_BUFFER);
|
||||||
// Decrement reference counter of the 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);
|
assert (c != 0 && c <= s->n+1);
|
||||||
if (c == 1) {
|
if (c == 1) {
|
||||||
// Buffer no longer used by any reader thread.
|
// Buffer no longer used by any reader thread.
|
||||||
|
|||||||
Reference in new issue
Block a user