--- postgresql-8.1.4/src/include/storage/s_lock.h 2005-10-11 13:41:32.000000000 -0700 +++ postgresql-8.1.4.dev/src/include/storage/s_lock.h 2006-05-26 05:48:32.000000000 -0700 @@ -299,6 +299,30 @@ tas(volatile slock_t *lock) #endif /* __s390__ || __s390x__ */ +#if defined(__sh__) +#define HAS_TEST_AND_SET + +typedef unsigned char slock_t; + +#define TAS(lock) tas(lock) + +static __inline__ int +tas(volatile slock_t *lock) +{ + register int _res = 1; + + __asm__ __volatile__( + "tas.b @%1\n\t" + "movt %0\n\t" + "xor #1,%0" +: "=z"(_res) +: "r"(lock) +: "t","memory"); + return _res; +} + +#endif /* __sh__ */ + #if defined(__sparc__) #define HAS_TEST_AND_SET