attempt multithreading bugfix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33107 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-05-25 09:20:42 +00:00
parent 9c75389ee7
commit cf144e76f1
2 changed files with 23 additions and 12 deletions

View file

@ -1,3 +1,8 @@
2011-05-25 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSObject.m:
Attempt fix for atomic assembler on x86 (bug #33392)
2011-05-24 David Chisnall <theraven@gna.org> 2011-05-24 David Chisnall <theraven@gna.org>
* Source/NSBundle.m * Source/NSBundle.m
@ -6,12 +11,12 @@
* Source/NSZone.m * Source/NSZone.m
* Source/NSObject.m * Source/NSObject.m
* Source/NSAutoreleasePool.m * Source/NSAutoreleasePool.m
First pass at supporting fully Apple-compatible GC in -base. Code sitting First pass at supporting fully Apple-compatible GC in -base.
Code sitting
on top of -base should not require modifying (in theory, at least, and on top of -base should not require modifying (in theory, at least, and
unless it does the sort of evil tricks that LanguageKit does for unless it does the sort of evil tricks that LanguageKit does for
performance). performance).
2011-05-24 Richard Frith-Macdonald <rfm@gnu.org> 2011-05-24 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAutoreleasePool.m: * Source/NSAutoreleasePool.m:

View file

@ -226,22 +226,28 @@ typedef int32_t volatile *gsatomic_t;
#define GSATOMICREAD(X) (*(X)) #define GSATOMICREAD(X) (*(X))
static __inline__ int int
GSAtomicIncrement(gsatomic_t X) GSAtomicIncrement(gsatomic_t X)
{ {
int32_t tmp = 1;
__asm__ __volatile__ ( __asm__ __volatile__ (
"lock addl $1, %0" "lock xaddl %0, %1"
:"=m" (*X)); :"=r" (tmp), "=m" (*X)
return *X; :"r" (tmp), "m" (*X)
:"memory" );
return tmp;
} }
static __inline__ int int
GSAtomicDecrement(gsatomic_t X) GSAtomicDecrement(gsatomic_t X)
{ {
int32_t tmp = -1;
__asm__ __volatile__ ( __asm__ __volatile__ (
"lock subl $1, %0" "lock xaddl %0, %1"
:"=m" (*X)); :"=r" (tmp), "=m" (*X)
return *X; :"r" (tmp), "m" (*X)
:"memory" );
return tmp;
} }
#elif defined(__PPC__) || defined(__POWERPC__) #elif defined(__PPC__) || defined(__POWERPC__)