[kaffe] CVS kaffe (guilhem): Updated atomic functions. Fixed a few deadlocks.
Kaffe CVS
cvs-commits at kaffe.org
Sun Mar 20 12:38:09 PST 2005
PatchSet 5574
Date: 2005/03/20 20:30:32
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Updated atomic functions. Fixed a few deadlocks.
* config/Makefile.am: Updated EXTRA_DIST and noinst_HEADERS.
* config/Makefile.in, config/config.h.in: Regenerated.
* config/katomic.h,
config/alpha/atomic.h,
config/generic/comparexch.h,
config/generic/genatomic.h,
config/i386/atomic.h,
config/ia64/atomic.h,
config/m68k/atomic.h,
config/powerpc/atomic.h,
config/s390/atomic.h,
config/sparc/atomic-sparc32.h,
config/sparc/atomic-sparc32v9.h,
config/sparc/atomic-sparc64.h,
config/x86_64/atomic.h: New files.
* config/alpha/atomicity.h,
config/ia64/atomicity.h,
config/m68k/atomicity.h,
config/s390/atomicity32.h,
config/s390/atomicity64.h,
config/sparc/atomicity-sparc32.h,
config/sparc/atomicity-sparc32v9.h,
config/sparc/atomicity-sparc64.h: Removed files.
* config/arm/atomicity.h
(compare_and_swap): Modified to return the old value as needed by
katomic.h.
* config/alpha/common.h,
config/arm/common.h,
config/i386/common.h,
config/ia64/common.h,
config/m68k/common.h,
config/mips/common.h,
config/parisc/common.h,
config/powerpc/common.h,
config/s390/common.h,
config/sh/common.h,
config/sparc/common.h,
config/x86_64/common.h: Use the common code in generic/*.
* kaffe/kaffe/main.c: Removed some parenthesis.
* kaffe/kaffevm/locks.c: Fixed warnings which has appeared after
atomic* merge. Fixed the use of the volatile modifier.
(getHeavyLock): Use atomic_decrement and atomic_increment.
* kaffe/kaffevm/ksem.c, kaffe/kaffevm/ksem.h:
Fixed the use of the volatile modifier.
* kaffe/kaffevm/locks.h
(iLock): Use uintp for num_wait because COMPARE_AND_EXCHANGE likes
big registers and uint16 could have cause overlap with the next field.
* kaffe-gc/gc-incremental.c:
(gcMan): Use KTHREAD(lockGC) to prevent deadlocks.
(startGC, stopGC): Moved lock to these functions.
* kaffe/kaffevm/systems/unix-jthreads/jthread.c,
kaffe/kaffevm/systems/unix-jthreads/jthread.h
(jthread_lockGC, jthread_unlockGC): New functions.
(jthread_init): Initialize GClock.
(jthread_createfirst): Remember the first thread.
(jthread_exit): Follows JNI specification when exiting the VM.
* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,
kaffe/kaffevm/systems/unix-pthreads/thread-impl.h
(jthread_lockGC, jthread_unlockGC): New functions.
Members:
ChangeLog:1.3748->1.3749
config/Makefile.am:1.53->1.54
config/Makefile.in:1.175->1.176
config/katomic.h:INITIAL->1.1
config/alpha/atomic.h:INITIAL->1.1
config/alpha/atomicity.h:1.1->1.2(DEAD)
config/alpha/common.h:1.12->1.13
config/arm/atomicity.h:1.1->1.2
config/arm/common.h:1.10->1.11
config/generic/comparexch.h:INITIAL->1.1
config/generic/genatomic.h:INITIAL->1.1
config/i386/atomic.h:INITIAL->1.1
config/i386/common.h:1.18->1.19
config/ia64/atomic.h:INITIAL->1.1
config/ia64/atomicity.h:1.1->1.2(DEAD)
config/ia64/common.h:1.4->1.5
config/m68k/atomic.h:INITIAL->1.1
config/m68k/atomicity.h:1.1->1.2(DEAD)
config/m68k/common.h:1.15->1.16
config/mips/common.h:1.11->1.12
config/parisc/common.h:1.5->1.6
config/powerpc/atomic.h:INITIAL->1.1
config/powerpc/common.h:1.9->1.10
config/s390/atomic.h:INITIAL->1.1
config/s390/atomicity32.h:1.1->1.2(DEAD)
config/s390/atomicity64.h:1.1->1.2(DEAD)
config/s390/common.h:1.4->1.5
config/sh/common.h:1.2->1.3
config/sparc/atomic-sparc32.h:INITIAL->1.1
config/sparc/atomic-sparc32v9.h:INITIAL->1.1
config/sparc/atomic-sparc64.h:INITIAL->1.1
config/sparc/atomicity-sparc32.h:1.1->1.2(DEAD)
config/sparc/atomicity-sparc32v9.h:1.1->1.2(DEAD)
config/sparc/atomicity-sparc64.h:1.1->1.2(DEAD)
config/sparc/common.h:1.10->1.11
config/x86_64/atomic.h:INITIAL->1.1
config/x86_64/common.h:1.3->1.4
kaffe/kaffe/main.c:1.80->1.81
kaffe/kaffevm/ksem.c:1.13->1.14
kaffe/kaffevm/ksem.h:1.11->1.12
kaffe/kaffevm/locks.c:1.59->1.60
kaffe/kaffevm/locks.h:1.28->1.29
kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.21->1.22
kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.129->1.130
kaffe/kaffevm/systems/unix-jthreads/jthread.h:1.66->1.67
kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.76->1.77
kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.37->1.38
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3748 kaffe/ChangeLog:1.3749
--- kaffe/ChangeLog:1.3748 Sun Mar 20 18:34:46 2005
+++ kaffe/ChangeLog Sun Mar 20 20:30:32 2005
@@ -1,3 +1,77 @@
+2005-03-20 Guilhem Lavaux <guilhem at kaffe.org>
+
+ * config/Makefile.am: Updated EXTRA_DIST and noinst_HEADERS.
+
+ * config/Makefile.in, config/config.h.in: Regenerated.
+
+ * config/katomic.h,
+ config/alpha/atomic.h,
+ config/generic/comparexch.h,
+ config/generic/genatomic.h,
+ config/i386/atomic.h,
+ config/ia64/atomic.h,
+ config/m68k/atomic.h,
+ config/powerpc/atomic.h,
+ config/s390/atomic.h,
+ config/sparc/atomic-sparc32.h,
+ config/sparc/atomic-sparc32v9.h,
+ config/sparc/atomic-sparc64.h,
+ config/x86_64/atomic.h: New files.
+
+ * config/alpha/atomicity.h,
+ config/ia64/atomicity.h,
+ config/m68k/atomicity.h,
+ config/s390/atomicity32.h,
+ config/s390/atomicity64.h,
+ config/sparc/atomicity-sparc32.h,
+ config/sparc/atomicity-sparc32v9.h,
+ config/sparc/atomicity-sparc64.h: Removed files.
+
+ * config/arm/atomicity.h
+ (compare_and_swap): Modified to return the old value as needed by
+ katomic.h.
+
+ * config/alpha/common.h,
+ config/arm/common.h,
+ config/i386/common.h,
+ config/ia64/common.h,
+ config/m68k/common.h,
+ config/mips/common.h,
+ config/parisc/common.h,
+ config/powerpc/common.h,
+ config/s390/common.h,
+ config/sh/common.h,
+ config/sparc/common.h,
+ config/x86_64/common.h: Use the common code in generic/*.
+
+ * kaffe/kaffe/main.c: Removed some parenthesis.
+
+ * kaffe/kaffevm/locks.c: Fixed warnings which has appeared after
+ atomic* merge. Fixed the use of the volatile modifier.
+ (getHeavyLock): Use atomic_decrement and atomic_increment.
+
+ * kaffe/kaffevm/ksem.c, kaffe/kaffevm/ksem.h:
+ Fixed the use of the volatile modifier.
+
+ * kaffe/kaffevm/locks.h
+ (iLock): Use uintp for num_wait because COMPARE_AND_EXCHANGE likes
+ big registers and uint16 could have cause overlap with the next field.
+
+ * kaffe-gc/gc-incremental.c:
+ (gcMan): Use KTHREAD(lockGC) to prevent deadlocks.
+ (startGC, stopGC): Moved lock to these functions.
+
+ * kaffe/kaffevm/systems/unix-jthreads/jthread.c,
+ kaffe/kaffevm/systems/unix-jthreads/jthread.h
+ (jthread_lockGC, jthread_unlockGC): New functions.
+ (jthread_init): Initialize GClock.
+ (jthread_createfirst): Remember the first thread.
+ (jthread_exit): Follows JNI specification when exiting the VM.
+
+ * kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,
+ kaffe/kaffevm/systems/unix-pthreads/thread-impl.h
+ (jthread_lockGC, jthread_unlockGC): New functions.
+
2005-03-20 Jeff Bailey <jbailey at raspberryginger.com>
* kaffe/kaffevm/jit/Makefile.am,
Index: kaffe/config/Makefile.am
diff -u kaffe/config/Makefile.am:1.53 kaffe/config/Makefile.am:1.54
--- kaffe/config/Makefile.am:1.53 Wed Mar 16 10:30:55 2005
+++ kaffe/config/Makefile.am Sun Mar 20 20:30:36 2005
@@ -46,6 +46,7 @@
config-setjmp.h \
config-signal.h \
config-std.h \
+ katomic.h \
kaffe-unix-stack.h \
sysdepCallMethod-ffi.h
@@ -53,8 +54,10 @@
config.alias \
regen-forward \
stamp-h1.in \
+ generic/comparexch.h \
+ generic/genatomic.h \
alpha/alpha.c \
- alpha/atomicity.h \
+ alpha/atomic.h \
alpha/callKaffeException.h \
alpha/common.h \
alpha/jit-alpha.def \
@@ -101,7 +104,7 @@
arm/threads.h \
arm/sysdepCallMethod.h \
arm/trampolines.S \
- ia64/atomicity.h \
+ ia64/atomic.h \
ia64/common.h \
ia64/linux/config.frag \
ia64/linux/md.c \
@@ -109,12 +112,14 @@
ia64/threads.h \
ia64/sysdepCallMethod.h \
x86_64/common.h \
+ x86_64/atomic.h \
x86_64/linux/config.frag \
x86_64/linux/md.c \
x86_64/linux/md.h \
x86_64/linux/sigcontextinfo.h \
x86_64/threads.h \
x86_64/sysdepCallMethod.h \
+ i386/atomic.h \
i386/beos/config.frag \
i386/beos/jit-md.h \
i386/beos/jit3-md.h \
@@ -206,7 +211,7 @@
i386/win32/jit-md.h \
i386/win32/md.h \
i386/win32/win32-md.asm \
- m68k/atomicity.h \
+ m68k/atomic.h \
m68k/a-ux/config.frag \
m68k/a-ux/jit-md.h \
m68k/a-ux/md.c \
@@ -316,8 +321,8 @@
powerpc/sysdepCallMethod.h \
powerpc/threads.h \
powerpc/trampolines.S \
- s390/atomicity32.h \
- s390/atomicity64.h \
+ powerpc/atomic.h \
+ s390/atomic.h \
s390/common.h \
s390/linux/config.frag \
s390/linux/md.c \
@@ -325,9 +330,9 @@
s390/linux/sigcontextinfo.h \
s390/sysdepCallMethod.h \
s390/threads.h \
- sparc/atomicity-sparc32.h \
- sparc/atomicity-sparc32v9.h \
- sparc/atomicity-sparc64.h \
+ sparc/atomic-sparc32.h \
+ sparc/atomic-sparc32v9.h \
+ sparc/atomic-sparc64.h \
sparc/bsdi3/config.frag \
sparc/bsdi3/jit-md.h \
sparc/bsdi3/md.c \
Index: kaffe/config/Makefile.in
diff -u kaffe/config/Makefile.in:1.175 kaffe/config/Makefile.in:1.176
--- kaffe/config/Makefile.in:1.175 Wed Mar 16 10:30:55 2005
+++ kaffe/config/Makefile.in Sun Mar 20 20:30:37 2005
@@ -386,6 +386,7 @@
config-setjmp.h \
config-signal.h \
config-std.h \
+ katomic.h \
kaffe-unix-stack.h \
sysdepCallMethod-ffi.h
@@ -393,8 +394,10 @@
config.alias \
regen-forward \
stamp-h1.in \
+ generic/comparexch.h \
+ generic/genatomic.h \
alpha/alpha.c \
- alpha/atomicity.h \
+ alpha/atomic.h \
alpha/callKaffeException.h \
alpha/common.h \
alpha/jit-alpha.def \
@@ -441,7 +444,7 @@
arm/threads.h \
arm/sysdepCallMethod.h \
arm/trampolines.S \
- ia64/atomicity.h \
+ ia64/atomic.h \
ia64/common.h \
ia64/linux/config.frag \
ia64/linux/md.c \
@@ -449,12 +452,14 @@
ia64/threads.h \
ia64/sysdepCallMethod.h \
x86_64/common.h \
+ x86_64/atomic.h \
x86_64/linux/config.frag \
x86_64/linux/md.c \
x86_64/linux/md.h \
x86_64/linux/sigcontextinfo.h \
x86_64/threads.h \
x86_64/sysdepCallMethod.h \
+ i386/atomic.h \
i386/beos/config.frag \
i386/beos/jit-md.h \
i386/beos/jit3-md.h \
@@ -546,7 +551,7 @@
i386/win32/jit-md.h \
i386/win32/md.h \
i386/win32/win32-md.asm \
- m68k/atomicity.h \
+ m68k/atomic.h \
m68k/a-ux/config.frag \
m68k/a-ux/jit-md.h \
m68k/a-ux/md.c \
@@ -656,8 +661,8 @@
powerpc/sysdepCallMethod.h \
powerpc/threads.h \
powerpc/trampolines.S \
- s390/atomicity32.h \
- s390/atomicity64.h \
+ powerpc/atomic.h \
+ s390/atomic.h \
s390/common.h \
s390/linux/config.frag \
s390/linux/md.c \
@@ -665,9 +670,9 @@
s390/linux/sigcontextinfo.h \
s390/sysdepCallMethod.h \
s390/threads.h \
- sparc/atomicity-sparc32.h \
- sparc/atomicity-sparc32v9.h \
- sparc/atomicity-sparc64.h \
+ sparc/atomic-sparc32.h \
+ sparc/atomic-sparc32v9.h \
+ sparc/atomic-sparc64.h \
sparc/bsdi3/config.frag \
sparc/bsdi3/jit-md.h \
sparc/bsdi3/md.c \
@@ -828,7 +833,7 @@
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
- $(mkdir_p) $(distdir)/alpha $(distdir)/alpha/linux $(distdir)/alpha/netbsd1 $(distdir)/alpha/osf $(distdir)/arm $(distdir)/arm/linux $(distdir)/arm/netbsd1 $(distdir)/arm/riscos $(distdir)/i386 $(distdir)/i386/beos $(distdir)/i386/bsdi $(distdir)/i386/cygwin32 $(distdir)/i386/darwin $(distdir)/i386/dgux $(distdir)/i386/freebsd2 $(distdir)/i386/gnu $(distdir)/i386/linux $(distdir)/i386/netbsd1 $(distdir)/i386/nextstep3 $(distdir)/i386/openbsd2 $(distdir)/i386/oskit $(distdir)/i386/qnx $(distdir)/i386/sco3.2v5 $(distdir)/i386/solaris2 $(distdir)/i386/univel_svr4 $(distdir)/i386/win32 $(distdir)/ia64 $(distdir)/ia64/linux $(distdir)/m68k $(distdir)/m68k/a-ux $(distdir)/m68k/amigaos $(distdir)/m68k/linux $(distdir)/m68k/netbsd1 $(distdir)/m68k/nextstep3 $(distdir)/m68k/openbsd2 $(distdir)/m68k/sunos4 $(distdir)/mips $(distdir)/mips/irix5 $(distdir)/mips/linux $(distdir)/mips/netbsd1 $(distdir)/mips/ultrix4 $(distdir)/parisc $(distdir)/parisc/hpux $(distdir)/parisc/linux $(distdir)/powerpc $(distdir)/powerpc/aix $(distdir)/powerpc/darwin $(distdir)/powerpc/linux $(distdir)/powerpc/machten $(distdir)/powerpc/netbsd1 $(distdir)/s390 $(distdir)/s390/linux $(distdir)/sh $(distdir)/sh/linux $(distdir)/sparc $(distdir)/sparc/bsdi3 $(distdir)/sparc/linux $(distdir)/sparc/netbsd1 $(distdir)/sparc/nextstep3 $(distdir)/sparc/openbsd2 $(distdir)/sparc/solaris2 $(distdir)/sparc/sunos4 $(distdir)/sparc/uxpds $(distdir)/x86_64 $(distdir)/x86_64/linux
+ $(mkdir_p) $(distdir)/alpha $(distdir)/alpha/linux $(distdir)/alpha/netbsd1 $(distdir)/alpha/osf $(distdir)/arm $(distdir)/arm/linux $(distdir)/arm/netbsd1 $(distdir)/arm/riscos $(distdir)/generic $(distdir)/i386 $(distdir)/i386/beos $(distdir)/i386/bsdi $(distdir)/i386/cygwin32 $(distdir)/i386/darwin $(distdir)/i386/dgux $(distdir)/i386/freebsd2 $(distdir)/i386/gnu $(distdir)/i386/linux $(distdir)/i386/netbsd1 $(distdir)/i386/nextstep3 $(distdir)/i386/openbsd2 $(distdir)/i386/oskit $(distdir)/i386/qnx $(distdir)/i386/sco3.2v5 $(distdir)/i386/solaris2 $(distdir)/i386/univel_svr4 $(distdir)/i386/win32 $(distdir)/ia64 $(distdir)/ia64/linux $(distdir)/m68k $(distdir)/m68k/a-ux $(distdir)/m68k/amigaos $(distdir)/m68k/linux $(distdir)/m68k/netbsd1 $(distdir)/m68k/nextstep3 $(distdir)/m68k/openbsd2 $(distdir)/m68k/sunos4 $(distdir)/mips $(distdir)/mips/irix5 $(distdir)/mips/linux $(distdir)/mips/netbsd1 $(distdir)/mips/ultrix4 $(distdir)/parisc $(distdir)/parisc/hpux $(distdir)/parisc/linux $(distdir)/powerpc $(distdir)/powerpc/aix $(distdir)/powerpc/darwin $(distdir)/powerpc/linux $(distdir)/powerpc/machten $(distdir)/powerpc/netbsd1 $(distdir)/s390 $(distdir)/s390/linux $(distdir)/sh $(distdir)/sh/linux $(distdir)/sparc $(distdir)/sparc/bsdi3 $(distdir)/sparc/linux $(distdir)/sparc/netbsd1 $(distdir)/sparc/nextstep3 $(distdir)/sparc/openbsd2 $(distdir)/sparc/solaris2 $(distdir)/sparc/sunos4 $(distdir)/sparc/uxpds $(distdir)/x86_64 $(distdir)/x86_64/linux
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
===================================================================
Checking out kaffe/config/katomic.h
RCS: /home/cvs/kaffe/kaffe/config/katomic.h,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/config/katomic.h Sun Mar 20 20:38:08 2005
@@ -0,0 +1,259 @@
+/* Internal macros for atomic operations for GNU C Library.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper at redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _ATOMIC_H
+#define _ATOMIC_H 1
+
+#include <stdlib.h>
+
+/* Wrapper macros to call pre_NN_post (mem, ...) where NN is the
+ bit width of *MEM. The calling macro puts parens around MEM
+ and following args. */
+#define __atomic_val_bysize(pre, post, mem, ...) \
+ ({ \
+ __typeof (*mem) __result; \
+ if (sizeof (*mem) == 1) \
+ __result = pre##_8_##post (mem, __VA_ARGS__); \
+ else if (sizeof (*mem) == 2) \
+ __result = pre##_16_##post (mem, __VA_ARGS__); \
+ else if (sizeof (*mem) == 4) \
+ __result = pre##_32_##post (mem, __VA_ARGS__); \
+ else if (sizeof (*mem) == 8) \
+ __result = pre##_64_##post (mem, __VA_ARGS__); \
+ else \
+ abort (); \
+ __result; \
+ })
+#define __atomic_bool_bysize(pre, post, mem, ...) \
+ ({ \
+ int __result; \
+ if (sizeof (*mem) == 1) \
+ __result = pre##_8_##post (mem, __VA_ARGS__); \
+ else if (sizeof (*mem) == 2) \
+ __result = pre##_16_##post (mem, __VA_ARGS__); \
+ else if (sizeof (*mem) == 4) \
+ __result = pre##_32_##post (mem, __VA_ARGS__); \
+ else if (sizeof (*mem) == 8) \
+ __result = pre##_64_##post (mem, __VA_ARGS__); \
+ else \
+ abort (); \
+ __result; \
+ })
+
+
+/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
+ Return the old *MEM value. */
+#if !defined atomic_compare_and_exchange_val_acq \
+ && defined __arch_compare_and_exchange_val_32_acq
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ __atomic_val_bysize (__arch_compare_and_exchange_val,acq, \
+ mem, newval, oldval)
+#endif
+
+
+#ifndef atomic_compare_and_exchange_val_rel
+# define atomic_compare_and_exchange_val_rel(mem, newval, oldval) \
+ atomic_compare_and_exchange_val_acq (mem, newval, oldval)
+#endif
+
+
+/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
+ Return zero if *MEM was changed or non-zero if no exchange happened. */
+#ifndef atomic_compare_and_exchange_bool_acq
+# ifdef __arch_compare_and_exchange_bool_32_acq
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ __atomic_bool_bysize (__arch_compare_and_exchange_bool,acq, \
+ mem, newval, oldval)
+# else
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ /* Cannot use __oldval here, because macros later in this file might \
+ call this macro with __oldval argument. */ \
+ __typeof (oldval) __old = (oldval); \
+ atomic_compare_and_exchange_val_acq (mem, newval, __old) != __old; \
+ })
+# endif
+#endif
+
+
+#ifndef atomic_compare_and_exchange_bool_rel
+# define atomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
+ atomic_compare_and_exchange_bool_acq (mem, newval, oldval)
+#endif
+
+
+/* Store NEWVALUE in *MEM and return the old value. */
+#ifndef atomic_exchange_acq
+# define atomic_exchange_acq(mem, newvalue) \
+ ({ __typeof (*(mem)) __oldval; \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*(mem)) __value = (newvalue); \
+ \
+ do \
+ __oldval = (*__memp); \
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __value, \
+ __oldval),\
+ 0)); \
+ \
+ __oldval; })
+#endif
+
+#ifndef atomic_exchange_rel
+# define atomic_exchange_rel(mem, newvalue) atomic_exchange_acq (mem, newvalue)
+#endif
+
+
+/* Add VALUE to *MEM and return the old value of *MEM. */
+#ifndef atomic_exchange_and_add
+# define atomic_exchange_and_add(mem, value) \
+ ({ __typeof (*(mem)) __oldval; \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*(mem)) __value = (value); \
+ \
+ do \
+ __oldval = (*__memp); \
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __oldval \
+ + __value,\
+ __oldval),\
+ 0)); \
+ \
+ __oldval; })
+#endif
+
+
+#ifndef atomic_add
+# define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value))
+#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
+
+
+#ifndef atomic_decrement_val
+# define atomic_decrement_val(mem) (atomic_exchange_and_add ((mem), -1) - 1)
+#endif
+
+
+/* Subtract 1 from *MEM and return true iff it's now zero. */
+#ifndef atomic_decrement_and_test
+# define atomic_decrement_and_test(mem) \
+ (atomic_exchange_and_add ((mem), -1) == 1)
+#endif
+
+
+/* Decrement *MEM if it is > 0, and return the old value. */
+#ifndef atomic_decrement_if_positive
+# define atomic_decrement_if_positive(mem) \
+ ({ __typeof (*(mem)) __oldval; \
+ __typeof (mem) __memp = (mem); \
+ \
+ do \
+ { \
+ __oldval = *__memp; \
+ if (__builtin_expect (__oldval <= 0, 0)) \
+ break; \
+ } \
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __oldval \
+ - 1, \
+ __oldval),\
+ 0));\
+ __oldval; })
+#endif
+
+
+#ifndef atomic_add_negative
+# define atomic_add_negative(mem, value) \
+ ({ __typeof (value) __aan_value = (value); \
+ atomic_exchange_and_add (mem, __aan_value) < -__aan_value; })
+#endif
+
+
+#ifndef atomic_add_zero
+# define atomic_add_zero(mem, value) \
+ ({ __typeof (value) __aaz_value = (value); \
+ atomic_exchange_and_add (mem, __aaz_value) == -__aaz_value; })
+#endif
+
+
+#ifndef atomic_bit_set
+# define atomic_bit_set(mem, bit) \
+ (void) atomic_bit_test_set(mem, bit)
+#endif
+
+
+#ifndef atomic_bit_test_set
+# define atomic_bit_test_set(mem, bit) \
+ ({ __typeof (*(mem)) __oldval; \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*(mem)) __mask = ((__typeof (*(mem))) 1 << (bit)); \
+ \
+ do \
+ __oldval = (*__memp); \
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __oldval \
+ | __mask, \
+ __oldval),\
+ 0)); \
+ \
+ __oldval & __mask; })
+#endif
+
+
+#ifndef atomic_full_barrier
+# define atomic_full_barrier() __asm ("" ::: "memory")
+#endif
+
+
+#ifndef atomic_read_barrier
+# define atomic_read_barrier() atomic_full_barrier ()
+#endif
+
+
+#ifndef atomic_write_barrier
+# define atomic_write_barrier() atomic_full_barrier ()
+#endif
+
+
+#ifndef atomic_delay
+# define atomic_delay() do { /* nothing */ } while (0)
+#endif
+
+#endif /* atomic.h */
===================================================================
Checking out kaffe/config/alpha/atomic.h
RCS: /home/cvs/kaffe/kaffe/config/alpha/atomic.h,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/config/alpha/atomic.h Sun Mar 20 20:38:08 2005
@@ -0,0 +1,369 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdint.h>
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+typedef int16_t atomic16_t;
+typedef uint16_t uatomic16_t;
+typedef int_fast16_t atomic_fast16_t;
+typedef uint_fast16_t uatomic_fast16_t;
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef int64_t atomic64_t;
+typedef uint64_t uatomic64_t;
+typedef int_fast64_t atomic_fast64_t;
+typedef uint_fast64_t uatomic_fast64_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+
+#ifdef UP
+# define __MB /* nothing */
+#else
+# define __MB " mb\n"
+#endif
+
+
+/* Compare and exchange. For all of the "xxx" routines, we expect a
+ "__prev" and a "__cmp" variable to be provided by the enclosing scope,
+ in which values are returned. */
+
+#define __arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2) \
+({ \
+ unsigned long __tmp, __snew, __addr64; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ " andnot %[__addr8],7,%[__addr64]\n" \
+ " insbl %[__new],%[__addr8],%[__snew]\n" \
+ "1: ldq_l %[__tmp],0(%[__addr64])\n" \
+ " extbl %[__tmp],%[__addr8],%[__prev]\n" \
+ " cmpeq %[__prev],%[__old],%[__cmp]\n" \
+ " beq %[__cmp],2f\n" \
+ " mskbl %[__tmp],%[__addr8],%[__tmp]\n" \
+ " or %[__snew],%[__tmp],%[__tmp]\n" \
+ " stq_c %[__tmp],0(%[__addr64])\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
+ "2:" \
+ : [__prev] "=&r" (__prev), \
+ [__snew] "=&r" (__snew), \
+ [__tmp] "=&r" (__tmp), \
+ [__cmp] "=&r" (__cmp), \
+ [__addr64] "=&r" (__addr64) \
+ : [__addr8] "r" (mem), \
+ [__old] "Ir" ((uint64_t)(uint8_t)(uint64_t)(old)), \
+ [__new] "r" (new) \
+ : "memory"); \
+})
+
+#define __arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2) \
+({ \
+ unsigned long __tmp, __snew, __addr64; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ " andnot %[__addr16],7,%[__addr64]\n" \
+ " inswl %[__new],%[__addr16],%[__snew]\n" \
+ "1: ldq_l %[__tmp],0(%[__addr64])\n" \
+ " extwl %[__tmp],%[__addr16],%[__prev]\n" \
+ " cmpeq %[__prev],%[__old],%[__cmp]\n" \
+ " beq %[__cmp],2f\n" \
+ " mskwl %[__tmp],%[__addr16],%[__tmp]\n" \
+ " or %[__snew],%[__tmp],%[__tmp]\n" \
+ " stq_c %[__tmp],0(%[__addr64])\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
+ "2:" \
+ : [__prev] "=&r" (__prev), \
+ [__snew] "=&r" (__snew), \
+ [__tmp] "=&r" (__tmp), \
+ [__cmp] "=&r" (__cmp), \
+ [__addr64] "=&r" (__addr64) \
+ : [__addr16] "r" (mem), \
+ [__old] "Ir" ((uint64_t)(uint16_t)(uint64_t)(old)), \
+ [__new] "r" (new) \
+ : "memory"); \
+})
+
+#define __arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2) \
+({ \
+ __asm__ __volatile__ ( \
+ mb1 \
+ "1: ldl_l %[__prev],%[__mem]\n" \
+ " cmpeq %[__prev],%[__old],%[__cmp]\n" \
+ " beq %[__cmp],2f\n" \
+ " mov %[__new],%[__cmp]\n" \
+ " stl_c %[__cmp],%[__mem]\n" \
+ " beq %[__cmp],1b\n" \
+ mb2 \
+ "2:" \
+ : [__prev] "=&r" (__prev), \
+ [__cmp] "=&r" (__cmp) \
+ : [__mem] "m" (*(mem)), \
+ [__old] "Ir" ((uint64_t)(atomic32_t)(uint64_t)(old)), \
+ [__new] "Ir" (new) \
+ : "memory"); \
+})
+
+#define __arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2) \
+({ \
+ __asm__ __volatile__ ( \
+ mb1 \
+ "1: ldq_l %[__prev],%[__mem]\n" \
+ " cmpeq %[__prev],%[__old],%[__cmp]\n" \
+ " beq %[__cmp],2f\n" \
+ " mov %[__new],%[__cmp]\n" \
+ " stq_c %[__cmp],%[__mem]\n" \
+ " beq %[__cmp],1b\n" \
+ mb2 \
+ "2:" \
+ : [__prev] "=&r" (__prev), \
+ [__cmp] "=&r" (__cmp) \
+ : [__mem] "m" (*(mem)), \
+ [__old] "Ir" ((uint64_t)(old)), \
+ [__new] "Ir" (new) \
+ : "memory"); \
+})
+
+/* For all "bool" routines, we return FALSE if exchange succesful. */
+
+#define __arch_compare_and_exchange_bool_8_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2); \
+ !__cmp; })
+
+#define __arch_compare_and_exchange_bool_16_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2); \
+ !__cmp; })
+
+#define __arch_compare_and_exchange_bool_32_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2); \
+ !__cmp; })
+
+#define __arch_compare_and_exchange_bool_64_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2); \
+ !__cmp; })
+
+/* For all "val" routines, return the old value whether exchange
+ successful or not. */
+
+#define __arch_compare_and_exchange_val_8_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2); \
+ (typeof (*mem))__prev; })
+
+#define __arch_compare_and_exchange_val_16_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2); \
+ (typeof (*mem))__prev; })
+
+#define __arch_compare_and_exchange_val_32_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2); \
+ (typeof (*mem))__prev; })
+
+#define __arch_compare_and_exchange_val_64_int(mem, new, old, mb1, mb2) \
+({ unsigned long __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2); \
+ (typeof (*mem))__prev; })
+
+/* Compare and exchange with "acquire" semantics, ie barrier after. */
+
+#define atomic_compare_and_exchange_bool_acq(mem, new, old) \
+ __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
+ mem, new, old, "", __MB)
+
+#define atomic_compare_and_exchange_val_acq(mem, new, old) \
+ __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
+ mem, new, old, "", __MB)
+
+/* Compare and exchange with "release" semantics, ie barrier before. */
+
+#define atomic_compare_and_exchange_bool_rel(mem, new, old) \
+ __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
+ mem, new, old, __MB, "")
+
+#define atomic_compare_and_exchange_val_rel(mem, new, old) \
+ __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
+ mem, new, old, __MB, "")
+
+
+/* Atomically store value and return the previous value. */
+
+#define __arch_exchange_8_int(mem, value, mb1, mb2) \
+({ \
+ unsigned long __ret, __tmp, __addr64, __sval; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ " andnot %[__addr8],7,%[__addr64]\n" \
+ " insbl %[__value],%[__addr8],%[__sval]\n" \
+ "1: ldq_l %[__tmp],0(%[__addr64])\n" \
+ " extbl %[__tmp],%[__addr8],%[__ret]\n" \
+ " mskbl %[__tmp],%[__addr8],%[__tmp]\n" \
+ " or %[__sval],%[__tmp],%[__tmp]\n" \
+ " stq_c %[__tmp],0(%[__addr64])\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
+ : [__ret] "=&r" (__ret), \
+ [__sval] "=&r" (__sval), \
+ [__tmp] "=&r" (__tmp), \
+ [__addr64] "=&r" (__addr64) \
+ : [__addr8] "r" (mem), \
+ [__value] "r" (value) \
+ : "memory"); \
+ __ret; })
+
+#define __arch_exchange_16_int(mem, value, mb1, mb2) \
+({ \
+ unsigned long __ret, __tmp, __addr64, __sval; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ " andnot %[__addr16],7,%[__addr64]\n" \
+ " inswl %[__value],%[__addr16],%[__sval]\n" \
+ "1: ldq_l %[__tmp],0(%[__addr64])\n" \
+ " extwl %[__tmp],%[__addr16],%[__ret]\n" \
+ " mskwl %[__tmp],%[__addr16],%[__tmp]\n" \
+ " or %[__sval],%[__tmp],%[__tmp]\n" \
+ " stq_c %[__tmp],0(%[__addr64])\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
+ : [__ret] "=&r" (__ret), \
+ [__sval] "=&r" (__sval), \
+ [__tmp] "=&r" (__tmp), \
+ [__addr64] "=&r" (__addr64) \
+ : [__addr16] "r" (mem), \
+ [__value] "r" (value) \
+ : "memory"); \
+ __ret; })
+
+#define __arch_exchange_32_int(mem, value, mb1, mb2) \
+({ \
+ signed int __ret, __tmp; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ "1: ldl_l %[__ret],%[__mem]\n" \
+ " mov %[__val],%[__tmp]\n" \
+ " stl_c %[__tmp],%[__mem]\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
+ : [__ret] "=&r" (__ret), \
+ [__tmp] "=&r" (__tmp) \
+ : [__mem] "m" (*(mem)), \
+ [__val] "Ir" (value) \
+ : "memory"); \
+ __ret; })
+
+#define __arch_exchange_64_int(mem, value, mb1, mb2) \
+({ \
+ unsigned long __ret, __tmp; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ "1: ldq_l %[__ret],%[__mem]\n" \
+ " mov %[__val],%[__tmp]\n" \
+ " stq_c %[__tmp],%[__mem]\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
+ : [__ret] "=&r" (__ret), \
+ [__tmp] "=&r" (__tmp) \
+ : [__mem] "m" (*(mem)), \
+ [__val] "Ir" (value) \
+ : "memory"); \
+ __ret; })
+
+#define atomic_exchange_acq(mem, value) \
+ __atomic_val_bysize (__arch_exchange, int, mem, value, "", __MB)
+
+#define atomic_exchange_rel(mem, value) \
+ __atomic_val_bysize (__arch_exchange, int, mem, value, __MB, "")
+
+
+/* Atomically add value and return the previous (unincremented) value. */
+
+#define __arch_exchange_and_add_8_int(mem, value, mb1, mb2) \
+ ({ __builtin_trap (); 0; })
+
+#define __arch_exchange_and_add_16_int(mem, value, mb1, mb2) \
+ ({ __builtin_trap (); 0; })
+
+#define __arch_exchange_and_add_32_int(mem, value, mb1, mb2) \
+({ \
+ signed int __ret, __tmp; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ "1: ldl_l %[__ret],%[__mem]\n" \
+ " addl %[__ret],%[__val],%[__tmp]\n" \
+ " stl_c %[__tmp],%[__mem]\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
+ : [__ret] "=&r" (__ret), \
+ [__tmp] "=&r" (__tmp) \
+ : [__mem] "m" (*(mem)), \
+ [__val] "Ir" ((signed int)(value)) \
+ : "memory"); \
+ __ret; })
+
+#define __arch_exchange_and_add_64_int(mem, value, mb1, mb2) \
+({ \
+ unsigned long __ret, __tmp; \
+ __asm__ __volatile__ ( \
+ mb1 \
+ "1: ldq_l %[__ret],%[__mem]\n" \
+ " addq %[__ret],%[__val],%[__tmp]\n" \
+ " stq_c %[__tmp],%[__mem]\n" \
+ " beq %[__tmp],1b\n" \
+ mb2 \
*** Patch too long, truncated ***
More information about the kaffe
mailing list