diff --git a/include/jemalloc/internal/atomic.h b/include/jemalloc/internal/atomic.h index b68440c4..adadb1a3 100644 --- a/include/jemalloc/internal/atomic.h +++ b/include/jemalloc/internal/atomic.h @@ -52,69 +52,24 @@ # define JEMALLOC_ATOMIC_U64 #endif -/* - * In order to let us transition atomics usage piecemeal (and reason locally - * about memory orders), we'll support the previous API for a while. - */ -#define JEMALLOC_GENERATE_COMPATABILITY_ATOMICS(type, short_type) \ -ATOMIC_INLINE type \ -atomic_read_##short_type(type *p) { \ - return atomic_load_##short_type ((atomic_##short_type##_t *)p, \ - ATOMIC_SEQ_CST); \ -} \ - \ -ATOMIC_INLINE void \ -atomic_write_##short_type(type *p, const type val) { \ - atomic_store_##short_type((atomic_##short_type##_t *)p, \ - (type)val, ATOMIC_SEQ_CST); \ -} \ -ATOMIC_INLINE bool \ -atomic_cas_##short_type(type *p, type c, type s) { \ - /* Note the '!' -- atomic_cas inverts the usual semantics. */ \ - return !atomic_compare_exchange_strong_##short_type( \ - (atomic_##short_type##_t *)p, &c, s, ATOMIC_SEQ_CST, \ - ATOMIC_SEQ_CST); \ -} - -#define JEMALLOC_GENERATE_COMPATABILITY_INT_ATOMICS(type, short_type) \ -JEMALLOC_GENERATE_COMPATABILITY_ATOMICS(type, short_type) \ - \ -ATOMIC_INLINE type \ -atomic_add_##short_type(type *p, type x) { \ - return atomic_fetch_add_##short_type( \ - (atomic_##short_type##_t *)p, x, ATOMIC_SEQ_CST) + x; \ -} \ -ATOMIC_INLINE type \ -atomic_sub_##short_type(type *p, type x) { \ - return atomic_fetch_sub_##short_type( \ - (atomic_##short_type##_t *)p, x, ATOMIC_SEQ_CST) - x; \ -} - JEMALLOC_GENERATE_ATOMICS(void *, p, LG_SIZEOF_PTR) -JEMALLOC_GENERATE_COMPATABILITY_ATOMICS(void *, p) /* * There's no actual guarantee that sizeof(bool) == 1, but it's true on the only * platform that actually needs to know the size, MSVC. */ JEMALLOC_GENERATE_ATOMICS(bool, b, 0) -JEMALLOC_GENERATE_COMPATABILITY_ATOMICS(bool, b) JEMALLOC_GENERATE_INT_ATOMICS(unsigned, u, LG_SIZEOF_INT) -JEMALLOC_GENERATE_COMPATABILITY_INT_ATOMICS(unsigned, u) JEMALLOC_GENERATE_INT_ATOMICS(size_t, zu, LG_SIZEOF_PTR) -JEMALLOC_GENERATE_COMPATABILITY_INT_ATOMICS(size_t, zu) JEMALLOC_GENERATE_INT_ATOMICS(ssize_t, zd, LG_SIZEOF_PTR) -JEMALLOC_GENERATE_COMPATABILITY_INT_ATOMICS(ssize_t, zd) JEMALLOC_GENERATE_INT_ATOMICS(uint32_t, u32, 2) -JEMALLOC_GENERATE_COMPATABILITY_INT_ATOMICS(uint32_t, u32) #ifdef JEMALLOC_ATOMIC_U64 JEMALLOC_GENERATE_INT_ATOMICS(uint64_t, u64, 3) -JEMALLOC_GENERATE_COMPATABILITY_INT_ATOMICS(uint64_t, u64) #endif #undef ATOMIC_INLINE diff --git a/test/unit/atomic.c b/test/unit/atomic.c index fa24415a..572d8d23 100644 --- a/test/unit/atomic.c +++ b/test/unit/atomic.c @@ -17,7 +17,6 @@ #define DO_TESTS(t, ta, val1, val2, val3) do { \ t val; \ - t raw_atomic; \ t expected; \ bool success; \ /* This (along with the load below) also tests ATOMIC_LOAD. */ \ @@ -81,37 +80,11 @@ } \ \ \ - /* Previous atomics API. */ \ - \ - /* Read. */ \ - raw_atomic = val1; \ - val = atomic_read_##ta(&raw_atomic); \ - assert_##ta##_eq(val1, val, "Read failed"); \ - \ - /* Write. */ \ - raw_atomic = val1; \ - atomic_write_##ta(&raw_atomic, val2); \ - assert_##ta##_eq(val2, raw_atomic, "Write failed"); \ - \ - /* CAS. */ \ - raw_atomic = val1; \ - success = !atomic_cas_##ta(&raw_atomic, val2, val3); \ - assert_b_eq(val1 == val2, success, \ - "CAS did the wrong state update"); \ - val = raw_atomic; \ - if (success) { \ - assert_##ta##_eq(val3, val, \ - "Successful CAS should update atomic"); \ - } else { \ - assert_##ta##_eq(val1, val, \ - "Unsuccessful CAS should not update atomic"); \ - } \ } while (0) #define DO_INTEGER_TESTS(t, ta, val1, val2) do { \ atomic_##ta##_t atom; \ t val; \ - t raw_atomic; \ \ /* Fetch-add. */ \ atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \ @@ -157,24 +130,6 @@ val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \ assert_##ta##_eq(val1 ^ val2, val, \ "Fetch-xor should update atomic"); \ - \ - /* Previous atomics API. */ \ - \ - /* Add. */ \ - raw_atomic = val1; \ - val = atomic_add_##ta(&raw_atomic, val2); \ - assert_##ta##_eq(val1 + val2, val, \ - "atomic_add should return new value"); \ - assert_##ta##_eq(val1 + val2, raw_atomic, \ - "atomic_add should update atomic"); \ - \ - /* Sub. */ \ - raw_atomic = val1; \ - val = atomic_sub_##ta(&raw_atomic, val2); \ - assert_##ta##_eq(val1 - val2, val, \ - "atomic_sub should return new value"); \ - assert_##ta##_eq(val1 - val2, raw_atomic, \ - "atomic_add should update atomic"); \ } while (0) #define TEST_STRUCT(t, ta) \