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