diff options
author | Ulrich Drepper <drepper@redhat.com> | 2009-02-08 23:50:23 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2009-02-08 23:50:23 +0000 |
commit | 6c03cd11e9c253211c831a70dfece6f5bd07e12c (patch) | |
tree | b934f05fab05e9ab7e65859d400ce8b28847cc01 /sysdeps | |
parent | 6dd6a580dff2b88b3bf6a37f59068bbfeb51c97d (diff) | |
download | glibc-6c03cd11e9c253211c831a70dfece6f5bd07e12c.tar.gz glibc-6c03cd11e9c253211c831a70dfece6f5bd07e12c.tar.xz glibc-6c03cd11e9c253211c831a70dfece6f5bd07e12c.zip |
* include/atomic.h: Define catomic_and if not already defined.
* sysdeps/x86_64/bits/atomic.h: Define catomic_and. * sysdeps/i386/i486/bits/atomic.h: Likewise.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/i386/i486/bits/atomic.h | 31 | ||||
-rw-r--r-- | sysdeps/x86_64/bits/atomic.h | 36 |
2 files changed, 41 insertions, 26 deletions
diff --git a/sysdeps/i386/i486/bits/atomic.h b/sysdeps/i386/i486/bits/atomic.h index 21eea7112c..4ee6fef692 100644 --- a/sysdeps/i386/i486/bits/atomic.h +++ b/sysdeps/i386/i486/bits/atomic.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -500,24 +500,34 @@ typedef uintmax_t uatomic_max_t; #define atomic_delay() asm ("rep; nop") -#define atomic_and(mem, mask) \ +#define __arch_and_body(lock, mem, mask) \ do { \ if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "andb %b1, %0" \ + __asm __volatile (lock "andb %b1, %0" \ : "=m" (*mem) \ - : "iq" (mask), "m" (*mem)); \ + : "iq" (mask), "m" (*mem), \ + "i" (offsetof (tcbhead_t, multiple_threads))); \ else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "andw %w1, %0" \ + __asm __volatile (lock "andw %w1, %0" \ : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ + : "ir" (mask), "m" (*mem), \ + "i" (offsetof (tcbhead_t, multiple_threads))); \ else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "andl %1, %0" \ + __asm __volatile (lock "andl %1, %0" \ : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ + : "ir" (mask), "m" (*mem), \ + "i" (offsetof (tcbhead_t, multiple_threads))); \ else \ abort (); \ } while (0) +#define __arch_cprefix \ + "cmpl $0, %%gs:%P3\n\tje 0f\n\tlock\n0:\t" + +#define atomic_and(mem, mask) __arch_and_body (LOCK_PREFIX, mem, mask) + +#define catomic_and(mem, mask) __arch_and_body (__arch_cprefix, mem, mask) + #define __arch_or_body(lock, mem, mask) \ do { \ @@ -542,7 +552,4 @@ typedef uintmax_t uatomic_max_t; #define atomic_or(mem, mask) __arch_or_body (LOCK_PREFIX, mem, mask) -#define __arch_or_cprefix \ - "cmpl $0, %%gs:%P3\n\tje 0f\n\tlock\n0:\t" - -#define catomic_or(mem, mask) __arch_or_body (__arch_or_cprefix, mem, mask) +#define catomic_or(mem, mask) __arch_or_body (__arch_cprefix, mem, mask) diff --git a/sysdeps/x86_64/bits/atomic.h b/sysdeps/x86_64/bits/atomic.h index 39c6ecba83..7c138eb2f3 100644 --- a/sysdeps/x86_64/bits/atomic.h +++ b/sysdeps/x86_64/bits/atomic.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -437,26 +437,37 @@ typedef uintmax_t uatomic_max_t; #define atomic_delay() asm ("rep; nop") -#define atomic_and(mem, mask) \ +#define __arch_and_body(lock, mem, mask) \ do { \ if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "andb %b1, %0" \ + __asm __volatile (lock "andb %b1, %0" \ : "=m" (*mem) \ - : "iq" (mask), "m" (*mem)); \ + : "iq" (mask), "m" (*mem), \ + "i" (offsetof (tcbhead_t, multiple_threads))); \ else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "andw %w1, %0" \ + __asm __volatile (lock "andw %w1, %0" \ : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ + : "ir" (mask), "m" (*mem), \ + "i" (offsetof (tcbhead_t, multiple_threads))); \ else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "andl %1, %0" \ + __asm __volatile (lock "andl %1, %0" \ : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ + : "ir" (mask), "m" (*mem), \ + "i" (offsetof (tcbhead_t, multiple_threads))); \ else \ - __asm __volatile (LOCK_PREFIX "andq %q1, %0" \ + __asm __volatile (lock "andq %q1, %0" \ : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ + : "ir" (mask), "m" (*mem), \ + "i" (offsetof (tcbhead_t, multiple_threads))); \ } while (0) +#define __arch_cprefix \ + "cmpl $0, %%fs:%P3\n\tje 0f\n\tlock\n0:\t" + +#define atomic_and(mem, mask) __arch_and_body (LOCK_PREFIX, mem, mask) + +#define catomic_and(mem, mask) __arch_and_body (__arch_cprefix, mem, mask) + #define __arch_or_body(lock, mem, mask) \ do { \ @@ -484,7 +495,4 @@ typedef uintmax_t uatomic_max_t; #define atomic_or(mem, mask) __arch_or_body (LOCK_PREFIX, mem, mask) -#define __arch_or_cprefix \ - "cmpl $0, %%fs:%P3\n\tje 0f\n\tlock\n0:\t" - -#define catomic_or(mem, mask) __arch_or_body (__arch_or_cprefix, mem, mask) +#define catomic_or(mem, mask) __arch_or_body (__arch_cprefix, mem, mask) |