Hi, I have attached a patch for NSObject.m which adds the GCC atomic increment/decrement operations, and also renames the 'modified:' labels in the existing PPC assembly increment/decrement functions so that they will now compile if they happen to be needed.
Eric On Mon, Apr 13, 2009 at 5:58 AM, David Chisnall <thera...@sucs.org> wrote: > Ooops, this one is my fault. > > Recent versions of GCC (and llvm-gcc / clang) support portable atomic > intrinsics. I've checked these on x86 and x86-64, and they generate the > same code that my inline asm uses. If you add this after the Windows bit > (it will probably work on Windows too, but I'm not completely sure) then we > will gain fast atomic operations on all platforms (e.g. SPARC / ARM) that > support them when compiling with a recent compiler. > > David > > #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) > /* Use the GCC atomic operations with recent GCC versions */ > > typedef int32_t volatile *gsatomic_t; > #define GSATOMICREAD(X) (*(X)) > #define GSAtomicIncrement(X) __sync_fetch_and_add(X, 1) > #define GSAtomicDecrement(X) __sync_fetch_and_sub(X, 1) > > > > On 13 Apr 2009, at 10:19, Eric Wasylishen wrote: > > Hi, >> I ran in to a small problem when compiling GNUstep (svn trunk) on >> Debian testing for PowerPC. GCC is "gcc (Debian 4.3.2-1.1) 4.3.2" >> >> Compiling file NSObject.m ... >> /tmp/ccF8zgwE.s: Assembler messages: >> /tmp/ccF8zgwE.s:730: Error: symbol `modified' is already defined >> make[3]: *** [obj/NSObject.m.o] Error 1 >> >> The PPC atomic increment and decrement functions starting at line 254 >> of NSObject.m both use the label 'modified:' in their asm code. I >> found that by changing the labels in one of the functions to something >> else ("modified2"), this error disappeared. >> >> I'm not sure if GCC is correct in reporting this as an error or not, >> but it's easy to fix. >> -Eric >> >> >> _______________________________________________ >> Gnustep-dev mailing list >> Gnustep-dev@gnu.org >> http://lists.gnu.org/mailman/listinfo/gnustep-dev >> > >
Index: Source/NSObject.m =================================================================== --- Source/NSObject.m (revision 28264) +++ Source/NSObject.m (working copy) @@ -218,7 +218,14 @@ #define GSAtomicIncrement(X) InterlockedIncrement((LONG volatile*)X) #define GSAtomicDecrement(X) InterlockedDecrement((LONG volatile*)X) +#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) +/* Use the GCC atomic operations with recent GCC versions */ +typedef int32_t volatile *gsatomic_t; +#define GSATOMICREAD(X) (*(X)) +#define GSAtomicIncrement(X) __sync_fetch_and_add(X, 1) +#define GSAtomicDecrement(X) __sync_fetch_and_sub(X, 1) + #elif defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) /* Set up atomic read, increment and decrement for intel style linux */ @@ -256,11 +263,11 @@ { int tmp; __asm__ __volatile__ ( - "modified:" + "incmodified:" "lwarx %0,0,%1 \n" "addic %0,%0,1 \n" "stwcx. %0,0,%1 \n" - "bne- modified \n" + "bne- incmodified \n" :"=&r" (tmp) :"r" (X) :"cc", "memory"); @@ -272,11 +279,11 @@ { int tmp; __asm__ __volatile__ ( - "modified:" + "decmodified:" "lwarx %0,0,%1 \n" "addic %0,%0,-1 \n" "stwcx. %0,0,%1 \n" - "bne- modified \n" + "bne- decmodified \n" :"=&r" (tmp) :"r" (X) :"cc", "memory");
_______________________________________________ Gnustep-dev mailing list Gnustep-dev@gnu.org http://lists.gnu.org/mailman/listinfo/gnustep-dev