--- src/backend/storage/lmgr/s_lock.c +++ src/backend/storage/lmgr/s_lock.c @@ -144,31 +144,6 @@ } #endif /* __APPLE__ && __ppc__ */ -#if defined(__powerpc__) -/* Note: need a nice gcc constrained asm version so it can be inlined */ -static void -tas_dummy() -{ - __asm__ __volatile__( - "\ -.global tas \n\ -tas: \n\ - lwarx 5,0,3 \n\ - cmpwi 5,0 \n\ - bne fail \n\ - addi 5,5,1 \n\ - stwcx. 5,0,3 \n\ - beq success \n\ -fail: li 3,1 \n\ - blr \n\ -success: \n\ - isync \n\ - li 3,0 \n\ - blr \n\ -"); -} -#endif /* __powerpc__ */ - #if defined(__mips__) && !defined(__sgi) static void tas_dummy() --- src/include/port/linux.h +++ src/include/port/linux.h @@ -8,6 +8,11 @@ #define HAS_TEST_AND_SET +#elif defined(__powerpc64__) +typedef unsigned long slock_t; + +#define HAS_TEST_AND_SET + #elif defined(__powerpc__) typedef unsigned int slock_t; --- src/include/storage/s_lock.h +++ src/include/storage/s_lock.h @@ -192,6 +192,35 @@ #endif /* __sparc__ */ +#if defined(__powerpc__) || defined(__powerpc64__) +static __inline__ int +tas(volatile slock_t *lock) +{ + slock_t _t; + int _res; + + __asm__ __volatile__( +" lwarx %0,0,%3 \n" +" cmpwi %0,0 \n" +" bne 1f \n" +" addi %0,%0,1 \n" +" stwcx. %0,0,%3 \n" +" isync \n" +" beq 2f \n" +"1: li %2,1 \n" +" b 3f \n" +"2: \n" +" li %2,0 \n" +"3: \n" + +: "=&r" (_t), "=m" (lock), "=r" (_res) +: "r" (lock) +: "cc", "memory" + ); + return _res; +} +#endif + #if defined(__mc68000__) && defined(__linux__) #define TAS(lock) tas(lock)