123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef _SYS_TAS_H
- #define _SYS_TAS_H 1
- #include <features.h>
- #include <sgidefs.h>
- __BEGIN_DECLS
- extern int _test_and_set (int *p, int v) __THROW;
- #ifdef __USE_EXTERN_INLINES
- # ifndef _EXTERN_INLINE
- # define _EXTERN_INLINE __extern_inline
- # endif
- _EXTERN_INLINE int
- __NTH (_test_and_set (int *p, int v))
- {
- int r, t;
- __asm__ __volatile__
- ("/* Inline test and set */\n"
- "1:\n\t"
- ".set push\n\t"
- #if _MIPS_SIM == _ABIO32
- ".set mips2\n\t"
- #endif
- "ll %0,%3\n\t"
- "move %1,%4\n\t"
- "beq %0,%4,2f\n\t"
- "sc %1,%2\n\t"
- ".set pop\n\t"
- "beqz %1,1b\n"
- "2:\n\t"
- "/* End test and set */"
- : "=&r" (r), "=&r" (t), "=m" (*p)
- : "m" (*p), "r" (v)
- : "memory");
- return r;
- }
- #endif
- __END_DECLS
- #endif
|