Skip to content

Commit

Permalink
Properly define GC_cptr_* atomic primitives for CHERI
Browse files Browse the repository at this point in the history
(fix of commit 1fcf50d)

Issue #627 (bdwgc).

* include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC]: Check
__CHERI_PURE_CAPABILITY__ instead of CPP_PTRSZ>CPP_WORDSZ (because the
later ones might not be defined when the header is included from a
test).
  • Loading branch information
ivmai committed Oct 29, 2024
1 parent 9ac83d6 commit ab6f4e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/private/gc_atomic_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ AO_compare_and_swap_release(volatile AO_t *p, AO_t ov, AO_t nv)

#endif /* !GC_BUILTIN_ATOMIC */

#if defined(GC_BUILTIN_ATOMIC) || CPP_PTRSZ > CPP_WORDSZ
#if defined(GC_BUILTIN_ATOMIC) || defined(__CHERI_PURE_CAPABILITY__)
/* Assume that GCC atomic intrinsics are available (and have correct */
/* implementation). p should be of a pointer to ptr_t (char*) value. */
# define GC_cptr_load(p) __atomic_load_n(p, __ATOMIC_RELAXED)
Expand Down Expand Up @@ -173,6 +173,6 @@ GC_cptr_compare_and_swap(char *volatile *p, char *ov, char *nv)
# define GC_cptr_compare_and_swap(p, ov, nv) \
AO_compare_and_swap((volatile AO_t *)(p), (AO_t)(ov), (AO_t)(nv))
# endif
#endif /* !GC_BUILTIN_ATOMIC && CPP_PTRSZ == CPP_WORDSZ */
#endif /* !GC_BUILTIN_ATOMIC */

#endif /* GC_ATOMIC_OPS_H */

0 comments on commit ab6f4e7

Please sign in to comment.