@@ -165,14 +165,15 @@
atomic_exchange_and_add_acq(mem, value)
#endif
-#ifndef atomic_max
-# define atomic_max(mem, value) \
+#ifndef atomic_max_relaxed
+# define atomic_max_relaxed(mem, value) \
do { \
__typeof (*(mem)) __atg8_oldval; \
__typeof (mem) __atg8_memp = (mem); \
__typeof (*(mem)) __atg8_value = (value); \
do { \
__atg8_oldval = *__atg8_memp; \
+ /* This early-exit means the atomic has relaxed memory ordering. */ \
if (__atg8_oldval >= __atg8_value) \
break; \
} while (__builtin_expect \
@@ -181,24 +182,6 @@
} while (0)
#endif
-#ifndef atomic_min
-# define atomic_min(mem, value) \
- do { \
- __typeof (*(mem)) __atg10_oldval; \
- __typeof (mem) __atg10_memp = (mem); \
- __typeof (*(mem)) __atg10_value = (value); \
- do { \
- __atg10_oldval = *__atg10_memp; \
- if (__atg10_oldval <= __atg10_value) \
- break; \
- } while (__builtin_expect \
- (atomic_compare_and_exchange_bool_acq (__atg10_memp, \
- __atg10_value, \
- __atg10_oldval), 0)); \
- } while (0)
-#endif
-
-
#ifndef atomic_add
# define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value))
#endif
@@ -2486,11 +2486,11 @@ sysmalloc_mmap (INTERNAL_SIZE_T nb, size_t pagesize, int extra_flags, mstate av)
/* update statistics */
int new = atomic_fetch_add_relaxed (&mp_.n_mmaps, 1) + 1;
- atomic_max (&mp_.max_n_mmaps, new);
+ atomic_max_relaxed (&mp_.max_n_mmaps, new);
unsigned long sum;
sum = atomic_fetch_add_relaxed (&mp_.mmapped_mem, size) + size;
- atomic_max (&mp_.max_mmapped_mem, sum);
+ atomic_max_relaxed (&mp_.max_mmapped_mem, sum);
check_chunk (av, p);
@@ -3111,7 +3111,7 @@ mremap_chunk (mchunkptr p, size_t new_size)
INTERNAL_SIZE_T new;
new = atomic_fetch_add_relaxed (&mp_.mmapped_mem, new_size - size - offset)
+ new_size - size - offset;
- atomic_max (&mp_.max_mmapped_mem, new);
+ atomic_max_relaxed (&mp_.max_mmapped_mem, new);
return p;
}
#endif /* HAVE_MREMAP */
@@ -149,7 +149,7 @@ update_data (struct header *result, size_t len, size_t old_len)
/* Compute current heap usage and compare it with the maximum value. */
size_t heap
= atomic_fetch_add_relaxed (¤t_heap, len - old_len) + len - old_len;
- atomic_max (&peak_heap, heap);
+ atomic_max_relaxed (&peak_heap, heap);
/* Compute current stack usage and compare it with the maximum
value. The base stack pointer might not be set if this is not
@@ -172,10 +172,10 @@ update_data (struct header *result, size_t len, size_t old_len)
start_sp = sp;
size_t current_stack = start_sp - sp;
#endif
- atomic_max (&peak_stack, current_stack);
+ atomic_max_relaxed (&peak_stack, current_stack);
/* Add up heap and stack usage and compare it with the maximum value. */
- atomic_max (&peak_total, heap + current_stack);
+ atomic_max_relaxed (&peak_total, heap + current_stack);
/* Store the value only if we are writing to a file. */
if (fd != -1)
@@ -157,8 +157,7 @@
abort (); \
__tmp; })
-# define atomic_max(mem, value) asm_amo ("amomaxu", ".aq", mem, value)
-# define atomic_min(mem, value) asm_amo ("amominu", ".aq", mem, value)
+# define atomic_max_relaxed(mem, value) asm_amo ("amomaxu", "", mem, value)
# define atomic_bit_test_set(mem, bit) \
({ typeof (*mem) __mask = (typeof (*mem))1 << (bit); \