Skip to content

Commit

Permalink
fixes nanomsg#1586 Undefined reference to nni_atomic_swap & nni_atomi…
Browse files Browse the repository at this point in the history
…c_cas(Built by gcc 4.8.5 ). (nanomsg#1587)
  • Loading branch information
alvin1221 authored May 30, 2022
1 parent 722bf46 commit c6d2d1f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/platform/posix/posix_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ nni_atomic_cas64(nni_atomic_u64 *v, uint64_t comp, uint64_t new)
&v->v, &comp, new, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST));
}

int
nni_atomic_swap(nni_atomic_int *v, int u)
{
return (__atomic_exchange_n(&v->v, u, __ATOMIC_SEQ_CST));
}

void
nni_atomic_init(nni_atomic_int *v)
{
Expand Down Expand Up @@ -331,6 +337,13 @@ nni_atomic_dec_nv(nni_atomic_int *v)
return (__atomic_sub_fetch(&v->v, 1, __ATOMIC_SEQ_CST));
}

bool
nni_atomic_cas(nni_atomic_int *v, int comp, int new)
{
return (__atomic_compare_exchange_n(
&v->v, &comp, new, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST));
}

void *
nni_atomic_get_ptr(nni_atomic_ptr *v)
{
Expand Down

0 comments on commit c6d2d1f

Please sign in to comment.