]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/simple_lock.h
xnu-792.10.96.tar.gz
[apple/xnu.git] / osfmk / i386 / simple_lock.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50 /*
51 * File: kern/simple_lock_types.h
52 * Author: Avadis Tevanian, Jr., Michael Wayne Young
53 * Date: 1985
54 *
55 * Simple lock data type definitions
56 */
57 #ifdef KERNEL_PRIVATE
58
59 #ifndef _I386_SIMPLE_LOCK_TYPES_H_
60 #define _I386_SIMPLE_LOCK_TYPES_H_
61
62 #include <mach/boolean.h>
63 #include <kern/kern_types.h>
64
65 #include <sys/appleapiopts.h>
66 #if defined(MACH_KERNEL_PRIVATE) && defined(__APPLE_API_PRIVATE)
67 #include <i386/hw_lock_types.h>
68 #include <mach_ldebug.h>
69 #endif
70
71 #if defined(MACH_KERNEL_PRIVATE) && defined(__APPLE_API_PRIVATE)
72
73 #if MACH_LDEBUG
74 #define USLOCK_DEBUG 1
75 #else
76 #define USLOCK_DEBUG 0
77 #endif /* USLOCK_DEBUG */
78
79 typedef struct uslock_debug {
80 void *lock_pc; /* pc where lock operation began */
81 void *lock_thread; /* thread that acquired lock */
82 unsigned long duration[2];
83 unsigned short state;
84 unsigned char lock_cpu;
85 void *unlock_thread; /* last thread to release lock */
86 unsigned char unlock_cpu;
87 void *unlock_pc; /* pc where lock operation ended */
88 } uslock_debug;
89
90 typedef struct slock {
91 hw_lock_data_t interlock; /* must be first... see lock.c */
92 unsigned short lock_type; /* must be second... see lock.c */
93 #define USLOCK_TAG 0x5353
94 uslock_debug debug;
95 } usimple_lock_data_t, *usimple_lock_t;
96
97 #else
98
99 typedef struct slock {
100 unsigned int lock_data[10];
101 } usimple_lock_data_t, *usimple_lock_t;
102
103 #endif /* defined(MACH_KERNEL_PRIVATE) && defined(__APPLE_API_PRIVATE) */
104
105 #define USIMPLE_LOCK_NULL ((usimple_lock_t) 0)
106
107 #if !defined(decl_simple_lock_data)
108 typedef usimple_lock_data_t *simple_lock_t;
109 typedef usimple_lock_data_t simple_lock_data_t;
110
111 #define decl_simple_lock_data(class,name) \
112 class simple_lock_data_t name;
113
114 #endif /* !defined(decl_simple_lock_data) */
115
116 #endif /* !_I386_SIMPLE_LOCK_TYPES_H_ */
117
118 #endif /* KERNEL_PRIVATE */