summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-03-10 09:10:50 +0100
committerAndy Wingo <wingo@pobox.com>2017-03-10 09:10:50 +0100
commit9b4826563104fb5c6d5448b31953f9a126a5d15b (patch)
treecc81af2c3224c581596d11a47c5dda3f0ba8b15b /libguile
parentef4a2af8036f245e1329c7d7db0900c75ed19335 (diff)
Fix atomics compilation on clang
* libguile/atomics-internal.h (scm_atomic_subtract_uint32): (scm_atomic_compare_and_swap_uint32, scm_atomic_set_pointer): (scm_atomic_ref_pointer, scm_atomic_set_scm): (scm_atomic_ref_scm, scm_atomic_swap_scm): (scm_atomic_compare_and_swap_scm): Use C11 atomic types if we have loaded C11 stdatomic.h.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/atomics-internal.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/libguile/atomics-internal.h b/libguile/atomics-internal.h
index f2d17e102..3c4f0cbbd 100644
--- a/libguile/atomics-internal.h
+++ b/libguile/atomics-internal.h
@@ -31,46 +31,57 @@
#ifdef HAVE_STDATOMIC_H
#include <stdatomic.h>
+
static inline uint32_t
scm_atomic_subtract_uint32 (uint32_t *loc, uint32_t arg)
{
- return atomic_fetch_sub (loc, arg);
+ atomic_uint_least32_t *a_loc = (atomic_uint_least32_t *) loc;
+ return atomic_fetch_sub (a_loc, arg);
}
static inline _Bool
scm_atomic_compare_and_swap_uint32 (uint32_t *loc, uint32_t *expected,
uint32_t desired)
{
- return atomic_compare_exchange_weak (loc, expected, desired);
+ atomic_uint_least32_t *a_loc = (atomic_uint_least32_t *) loc;
+ return atomic_compare_exchange_weak (a_loc, expected, desired);
}
static inline void
scm_atomic_set_pointer (void **loc, void *val)
{
- atomic_store (loc, val);
+ atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
+ atomic_store (a_loc, (uintptr_t) val);
}
static inline void *
scm_atomic_ref_pointer (void **loc)
{
- return atomic_load (loc);
+ atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
+ return (void *) atomic_load (a_loc);
}
static inline void
scm_atomic_set_scm (SCM *loc, SCM val)
{
- atomic_store (loc, val);
+ atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
+ atomic_store (a_loc, SCM_UNPACK (val));
}
static inline SCM
scm_atomic_ref_scm (SCM *loc)
{
- return atomic_load (loc);
+ atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
+ return SCM_PACK (atomic_load (a_loc));
}
static inline SCM
scm_atomic_swap_scm (SCM *loc, SCM val)
{
- return atomic_exchange (loc, val);
+ atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
+ return SCM_PACK (atomic_exchange (a_loc, SCM_UNPACK (val)));
}
static inline _Bool
scm_atomic_compare_and_swap_scm (SCM *loc, SCM *expected, SCM desired)
{
- return atomic_compare_exchange_weak (loc, expected, desired);
+ atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
+ return atomic_compare_exchange_weak (a_loc,
+ (uintptr_t *) expected,
+ SCM_UNPACK (desired));
}
#else /* HAVE_STDATOMIC_H */