@@ -228,7 +228,7 @@ __pthread_create_internal (struct __pthread **thread,
the number of threads from within the new thread isn't an option
since this thread might return and call `pthread_exit' before the
new thread runs. */
- atomic_increment (&__pthread_total);
+ atomic_fetch_add_relaxed (&__pthread_total, 1);
/* Store a pointer to this thread in the thread ID lookup table. We
could use __thread_setid, however, we only lock for reading as no
@@ -187,23 +187,6 @@
#endif
-#ifndef atomic_increment
-# define atomic_increment(mem) atomic_add ((mem), 1)
-#endif
-
-
-#ifndef atomic_increment_val
-# define atomic_increment_val(mem) (atomic_exchange_and_add ((mem), 1) + 1)
-#endif
-
-
-/* Add one to *MEM and return true iff it's now zero. */
-#ifndef atomic_increment_and_test
-# define atomic_increment_and_test(mem) \
- (atomic_exchange_and_add ((mem), 1) + 1 == 0)
-#endif
-
-
#ifndef atomic_decrement
# define atomic_decrement(mem) atomic_add ((mem), -1)
#endif
@@ -85,7 +85,7 @@ by @theglibc{}.
@deftypefun int sem_wait (sem_t *@var{sem});
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
-@c atomic_increment (nwaiters) acucorrupt
+@c atomic_fetch_add_relaxed (nwaiters) acucorrupt
@c
@c Given the use atomic operations this function seems
@c to be AS-safe. It is AC-unsafe because there is still
@@ -2528,7 +2528,7 @@ aiocb64}, since the LFS transparently replaces the old interface.
@c _dl_allocate_tls_init ok
@c GET_DTV ok
@c mmap ok
-@c atomic_increment_val ok
+@c atomic_fetch_add_relaxed ok
@c munmap ok
@c change_stack_perm ok
@c mprotect ok
@@ -2567,7 +2567,7 @@ aiocb64}, since the LFS transparently replaces the old interface.
@c do_clone @asulock @ascuheap @aculock @acsmem
@c PREPARE_CREATE ok
@c lll_lock (pd->lock) @asulock @aculock
-@c atomic_increment ok
+@c atomic_fetch_add_relaxed ok
@c clone ok
@c atomic_decrement ok
@c atomic_exchange_acquire ok
@@ -128,45 +128,6 @@ do_test (void)
ret = 1;
}
- mem = -1;
- atomic_increment (&mem);
- if (mem != 0)
- {
- puts ("atomic_increment test failed");
- ret = 1;
- }
-
- mem = 2;
- if (atomic_increment_val (&mem) != 3)
- {
- puts ("atomic_increment_val test failed");
- ret = 1;
- }
-
- mem = 0;
- if (atomic_increment_and_test (&mem)
- || mem != 1)
- {
- puts ("atomic_increment_and_test test 1 failed");
- ret = 1;
- }
-
- mem = 35;
- if (atomic_increment_and_test (&mem)
- || mem != 36)
- {
- puts ("atomic_increment_and_test test 2 failed");
- ret = 1;
- }
-
- mem = -1;
- if (! atomic_increment_and_test (&mem)
- || mem != 0)
- {
- puts ("atomic_increment_and_test test 3 failed");
- ret = 1;
- }
-
mem = 17;
atomic_decrement (&mem);
if (mem != 16)
@@ -163,7 +163,7 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
/* If this failed, it must have had not started yet or else exited. */
if (!INTERNAL_SYSCALL_ERROR_P (val))
{
- atomic_increment (&cmdp->cntr);
+ atomic_fetch_add_relaxed (&cmdp->cntr, 1);
return 1;
}
else
@@ -759,7 +759,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
we momentarily store a false value; this doesn't matter because there
is no kosher thing a signal handler interrupting us right here can do
that cares whether the thread count is correct. */
- atomic_increment (&__nptl_nthreads);
+ atomic_fetch_add_relaxed (&__nptl_nthreads, 1);
/* Our local value of stopped_start and thread_ran can be accessed at
any time. The PD->stopped_start may only be accessed if we have
@@ -91,7 +91,7 @@ __old_sem_post (sem_t *sem)
/* We must need to synchronize with consumers of this token, so the atomic
increment must have release MO semantics. */
atomic_write_barrier ();
- (void) atomic_increment_val (futex);
+ atomic_fetch_add_release (futex, 1);
/* We always have to assume it is a shared semaphore. */
futex_wake (futex, 1, LLL_SHARED);
return 0;
@@ -192,7 +192,7 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet,
/* We depend on this value being correct and at least as high as the
real number of entries. */
- atomic_increment (&table->head->nentries);
+ atomic_fetch_add_relaxed (&table->head->nentries, 1);
/* It does not matter that we are not loading the just increment
value, this is just for statistics. */
@@ -425,7 +425,7 @@ __nscd_get_map_ref (request_type type, const char *name,
0))
cur = NO_MAPPING;
else
- atomic_increment (&cur->counter);
+ atomic_fetch_add_relaxed (&cur->counter, 1);
}
}
@@ -157,37 +157,6 @@
} \
})
-#define atomic_increment_and_test(mem) \
- ({ char __result; \
- if (sizeof (*(mem)) == 1) \
- __asm __volatile ("addq%.b %#1,%1; seq %0" \
- : "=dm" (__result), "+m" (*(mem))); \
- else if (sizeof (*(mem)) == 2) \
- __asm __volatile ("addq%.w %#1,%1; seq %0" \
- : "=dm" (__result), "+m" (*(mem))); \
- else if (sizeof (*(mem)) == 4) \
- __asm __volatile ("addq%.l %#1,%1; seq %0" \
- : "=dm" (__result), "+m" (*(mem))); \
- else \
- { \
- __typeof (mem) __memp = (mem); \
- __typeof (*(mem)) __oldval = *__memp; \
- __typeof (*(mem)) __temp; \
- __asm __volatile ("1: move%.l %1,%2;" \
- " move%.l %R1,%R2;" \
- " addq%.l %#1,%R2;" \
- " addx%.l %5,%2;" \
- " seq %0;" \
- " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \
- " jbne 1b" \
- : "=&dm" (__result), "=d" (__oldval), \
- "=&d" (__temp) \
- : "r" (__memp), "r" ((char *) __memp + 4), \
- "d" (0), "1" (__oldval) \
- : "memory"); \
- } \
- __result; })
-
#define atomic_decrement_and_test(mem) \
({ char __result; \
if (sizeof (*(mem)) == 1) \
@@ -173,45 +173,6 @@
__result; \
})
-#define __arch_atomic_increment_val_32(mem) \
- ({ \
- __typeof (*(mem)) __val; \
- int test; \
- __asm __volatile ( \
- " addc r0, r0, r0;" \
- "1: lwx %0, %3, r0;" \
- " addic %1, r0, 0;" \
- " bnei %1, 1b;" \
- " addi %0, %0, 1;" \
- " swx %0, %3, r0;" \
- " addic %1, r0, 0;" \
- " bnei %1, 1b;" \
- : "=&r" (__val), \
- "=&r" (test), \
- "=m" (*mem) \
- : "r" (mem), \
- "m" (*mem) \
- : "cc", "memory"); \
- __val; \
- })
-
-#define __arch_atomic_increment_val_64(mem) \
- (abort (), (__typeof (*mem)) 0)
-
-#define atomic_increment_val(mem) \
- ({ \
- __typeof (*(mem)) __result; \
- if (sizeof (*(mem)) == 4) \
- __result = __arch_atomic_increment_val_32 (mem); \
- else if (sizeof (*(mem)) == 8) \
- __result = __arch_atomic_increment_val_64 (mem); \
- else \
- abort (); \
- __result; \
- })
-
-#define atomic_increment(mem) ({ atomic_increment_val (mem); (void) 0; })
-
#define __arch_atomic_decrement_val_32(mem) \
({ \
__typeof (*(mem)) __val; \
@@ -151,19 +151,6 @@
__val; \
})
-#define __arch_atomic_increment_val_32(mem) \
- ({ \
- __typeof (*(mem)) __val; \
- __asm __volatile ("1: lwarx %0,0,%2\n" \
- " addi %0,%0,1\n" \
- " stwcx. %0,0,%2\n" \
- " bne- 1b" \
- : "=&b" (__val), "=m" (*mem) \
- : "b" (mem), "m" (*mem) \
- : "cr0", "memory"); \
- __val; \
- })
-
#define __arch_atomic_decrement_val_32(mem) \
({ \
__typeof (*(mem)) __val; \
@@ -274,20 +261,6 @@
__result; \
})
-#define atomic_increment_val(mem) \
- ({ \
- __typeof (*(mem)) __result; \
- if (sizeof (*(mem)) == 4) \
- __result = __arch_atomic_increment_val_32 (mem); \
- else if (sizeof (*(mem)) == 8) \
- __result = __arch_atomic_increment_val_64 (mem); \
- else \
- abort (); \
- __result; \
- })
-
-#define atomic_increment(mem) ({ atomic_increment_val (mem); (void) 0; })
-
#define atomic_decrement_val(mem) \
({ \
__typeof (*(mem)) __result; \
@@ -85,9 +85,6 @@
#define __arch_atomic_exchange_and_add_64_rel(mem, value) \
({ abort (); (*mem) = (value); })
-#define __arch_atomic_increment_val_64(mem) \
- ({ abort (); (*mem)++; })
-
#define __arch_atomic_decrement_val_64(mem) \
({ abort (); (*mem)--; })
@@ -181,19 +181,6 @@
__val; \
})
-#define __arch_atomic_increment_val_64(mem) \
- ({ \
- __typeof (*(mem)) __val; \
- __asm __volatile ("1: ldarx %0,0,%2\n" \
- " addi %0,%0,1\n" \
- " stdcx. %0,0,%2\n" \
- " bne- 1b" \
- : "=&b" (__val), "=m" (*mem) \
- : "b" (mem), "m" (*mem) \
- : "cr0", "memory"); \
- __val; \
- })
-
#define __arch_atomic_decrement_val_64(mem) \
({ \
__typeof (*(mem)) __val; \
@@ -72,8 +72,8 @@ static uint32_t nl_timestamp;
uint32_t
__bump_nl_timestamp (void)
{
- if (atomic_increment_val (&nl_timestamp) == 0)
- atomic_increment (&nl_timestamp);
+ if (atomic_fetch_add_relaxed (&nl_timestamp, 1) + 1 == 0)
+ atomic_fetch_add_relaxed (&nl_timestamp, 1);
return nl_timestamp;
}
@@ -309,7 +309,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
if (cache_valid_p ())
{
data = cache;
- atomic_increment (&cache->usecnt);
+ atomic_fetch_add_relaxed (&cache->usecnt, 1);
}
else
{
@@ -299,5 +299,4 @@
abort (); \
__result; })
-#define atomic_increment_and_test(mem) atomic_add_zero((mem), 1)
#define atomic_decrement_and_test(mem) atomic_add_zero((mem), -1)
@@ -124,9 +124,7 @@
#define __arch_add_body(lock, pfx, apfx, mem, value) \
do { \
- if (__builtin_constant_p (value) && (value) == 1) \
- pfx##_increment (mem); \
- else if (__builtin_constant_p (value) && (value) == -1) \
+ if (__builtin_constant_p (value) && (value) == -1) \
pfx##_decrement (mem); \
else if (sizeof (*mem) == 1) \
__asm __volatile (lock "addb %b1, %0" \
@@ -200,53 +198,6 @@
__result; })
-#define __arch_increment_body(lock, pfx, mem) \
- do { \
- if (sizeof (*mem) == 1) \
- __asm __volatile (lock "incb %b0" \
- : "=m" (*mem) \
- : "m" (*mem)); \
- else if (sizeof (*mem) == 2) \
- __asm __volatile (lock "incw %w0" \
- : "=m" (*mem) \
- : "m" (*mem)); \
- else if (sizeof (*mem) == 4) \
- __asm __volatile (lock "incl %0" \
- : "=m" (*mem) \
- : "m" (*mem)); \
- else if (__HAVE_64B_ATOMICS) \
- __asm __volatile (lock "incq %q0" \
- : "=m" (*mem) \
- : "m" (*mem)); \
- else \
- do_add_val_64_acq (pfx, mem, 1); \
- } while (0)
-
-#define atomic_increment(mem) __arch_increment_body (LOCK_PREFIX, __arch, mem)
-
-#define atomic_increment_and_test(mem) \
- ({ unsigned char __result; \
- if (sizeof (*mem) == 1) \
- __asm __volatile (LOCK_PREFIX "incb %b0; sete %b1" \
- : "=m" (*mem), "=qm" (__result) \
- : "m" (*mem)); \
- else if (sizeof (*mem) == 2) \
- __asm __volatile (LOCK_PREFIX "incw %w0; sete %w1" \
- : "=m" (*mem), "=qm" (__result) \
- : "m" (*mem)); \
- else if (sizeof (*mem) == 4) \
- __asm __volatile (LOCK_PREFIX "incl %0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
- : "m" (*mem)); \
- else if (__HAVE_64B_ATOMICS) \
- __asm __volatile (LOCK_PREFIX "incq %q0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
- : "m" (*mem)); \
- else \
- __atomic_link_error (); \
- __result; })
-
-
#define __arch_decrement_body(lock, pfx, mem) \
do { \
if (sizeof (*mem) == 1) \