12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #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
|