1 /* Machine-specific definition for spin locks. MIPS version.
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #ifndef _MACHINE_LOCK_H
21 #define _MACHINE_LOCK_H
23 /* To get the TAS pseudo-instruction. */
24 #include <mach/mips/mips_instruction.h>
26 /* The type of a spin lock variable. */
28 typedef __volatile
int __spin_lock_t
;
30 /* Value to initialize `__spin_lock_t' variables to. */
32 #define __SPIN_LOCK_INITIALIZER 0
35 #ifndef _EXTERN_INLINE
36 #define _EXTERN_INLINE extern __inline
42 __spin_unlock (__spin_lock_t
*__lock
)
47 /* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
50 __spin_try_lock (register __spin_lock_t
*__lock
)
55 __asm__
__volatile (".set noreorder");
57 __asm__
__volatile ("lld %0,0(%1)" : "=r" (__rtn
) : "r" (__lock
));
59 __asm__
__volatile ("ll %0,0(%1)" : "=r" (__rtn
) : "r" (__lock
));
63 __asm__
__volatile ("move %0,%1" : "=r" (__rtn
) : "r" (__lock
));
65 __asm__
__volatile ("scd %0,0(%1)" : "=r" (__rtn
) : "r" (__lock
));
67 __asm__
__volatile ("sc %0,0(%1)" : "=r" (__rtn
) : "r" (__lock
));
69 __asm__
__volatile (".set reorder");
72 register int __rtn
__asm__ ("a0");
74 /* Use the Mach microkernel's emulated TAS pseudo-instruction. */
75 __asm__
__volatile (".set noreorder");
76 __asm__
__volatile (".word %1" : "=r" (__rtn
) : "i" (op_tas
), "0" (__lock
));
77 __asm__
__volatile ("nop");
78 __asm__
__volatile (".set reorder");
79 return __rtn
^ (int) __lock
;
83 /* Return nonzero if LOCK is locked. */
86 __spin_lock_locked (__spin_lock_t
*__lock
)
92 #endif /* machine-lock.h */