]> git.saurik.com Git - apple/libc.git/blob - pthreads/lock.s
eb2a15a1ad872f4d1082ac64af070aa0d0942512
[apple/libc.git] / pthreads / lock.s
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991
25 * All Rights Reserved
26 *
27 * Permission to use, copy, modify, and distribute this software and
28 * its documentation for any purpose and without fee is hereby granted,
29 * provided that the above copyright notice appears in all copies and
30 * that both the copyright notice and this permission notice appear in
31 * supporting documentation.
32 *
33 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
34 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
35 * FOR A PARTICULAR PURPOSE.
36 *
37 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
38 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
40 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
41 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
42 *
43 */
44
45 #define __APPLE_API_PRIVATE
46 #include <machine/cpu_capabilities.h>
47 #undef __APPLE_API_PRIVATE
48
49 #if defined(__ppc__)
50
51 #import <architecture/ppc/asm_help.h>
52 #import <architecture/ppc/pseudo_inst.h>
53
54 /* void spin_lock(int *p);
55 *
56 * Lock the lock pointed to by `p'. Spin (possibly forever) until
57 * the lock is available. Test and test and set logic used.
58 * These routines have moved to the comm page.
59 */
60
61 .text
62 .align 2
63 LEAF(__spin_lock_try)
64 ba _COMM_PAGE_SPINLOCK_TRY
65 END(__spin_lock_try)
66
67 .globl _spin_lock
68 LEAF(__spin_lock)
69 _spin_lock:
70 ba _COMM_PAGE_SPINLOCK_LOCK
71 END(__spin_lock)
72
73 /* void spin_unlock(int *p);
74 *
75 * Unlock the lock pointed to by p.
76 */
77 .globl _spin_unlock
78 LEAF(__spin_unlock)
79 _spin_unlock:
80 ba _COMM_PAGE_SPINLOCK_UNLOCK
81 END(__spin_unlock)
82
83 #elif defined(__i386__)
84
85 #include <architecture/i386/asm_help.h>
86
87 /*
88 * void
89 * _spin_lock(p)
90 * int *p;
91 *
92 * Lock the lock pointed to by p. Spin (possibly forever) until the next
93 * lock is available.
94 */
95 TEXT
96 ALIGN
97
98 .globl _spin_lock_try
99 LEAF(__spin_lock_try, 0)
100 _spin_lock_try:
101 movl $(_COMM_PAGE_SPINLOCK_TRY), %eax
102 jmpl %eax
103
104 ALIGN
105
106 .globl _spin_lock
107 LEAF(__spin_lock, 0)
108 _spin_lock:
109 movl $(_COMM_PAGE_SPINLOCK_LOCK), %eax
110 jmpl %eax
111
112 /*
113 * void
114 * _spin_unlock(p)
115 * int *p;
116 *
117 * Unlock the lock pointed to by p.
118 */
119 ALIGN
120
121 .globl _spin_unlock
122 LEAF(__spin_unlock, 0)
123 _spin_unlock:
124 movl $(_COMM_PAGE_SPINLOCK_UNLOCK), %eax
125 jmpl %eax
126
127 #else
128 #error spin_locks not defined for this architecture
129 #endif