> On Mar 9, 2017, at 6:01 PM, Matt Wette <matt.we...@gmail.com> wrote: > > >> On Mar 9, 2017, at 1:33 PM, Andy Wingo <wi...@pobox.com >> <mailto:wi...@pobox.com>> wrote: >> On Wed 25 Jan 2017 04:35, Matt Wette <matt.we...@gmail.com >> <mailto:matt.we...@gmail.com>> writes: >>> So I am trying to compile using clang. This has detected issues with >>> atomics-internal.h. I can fix most issues with casts: >>> static inline uint32_t >>> scm_atomic_subtract_uint32 (uint32_t *loc, uint32_t arg) >>> { >>> - return atomic_fetch_sub (loc, arg); >>> + return atomic_fetch_sub ((_Atomic uint32_t *)loc, arg); >>> } >>> >>> But problems remain with scm_atomic_set_pointer and scm_atomic_ref_pointer >>> which use void** and is apparently not defined for use with atomics. >>> >>> Apparently gcc does not have a problem with this use but I’m guessing the >>> C11 standard may have an issue with it. >> >> WDYT about this? >> >> Andy > > Have not tried to chase this down but ... > > In file included from async.c:27: > ../libguile/atomics-internal.h:75:20: error: address argument to atomic > operation must be a pointer to _Atomic type ('SCM *' (aka 'struct > scm_unused_struct **') invalid) > return SCM_PACK (atomic_exchange (loc, val)); > ^ ~~~ > /opt/local/libexec/llvm-3.9/bin/../lib/clang/3.9.1/include/stdatomic.h:137:42: > note: expanded from macro 'atomic_exchange' > #define atomic_exchange(object, desired) __c11_atomic_exchange(object, > desired, __ATOMIC_SEQ_CST) > ^ ~~~~~~ > ../libguile/tags.h:105:32: note: expanded from macro 'SCM_PACK' > # define SCM_PACK(x) ((SCM) (x)) > ^ > 1 error generated. >
With this change it compiles under clang-3.9, though generates warning, and gets through make check (with required other unrelated patches) OK: static inline SCM scm_atomic_swap_scm (SCM *loc, SCM val) { volatile atomic_uintptr_t *a_loc = (volatile atomic_uintptr_t *)loc; return SCM_PACK (atomic_exchange (a_loc, val)); }