]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/semaphore.h
xnu-344.tar.gz
[apple/xnu.git] / osfmk / mach / semaphore.h
1 /*
2 * Copyright (c) 2000-2002 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 #ifndef _MACH_SEMAPHORE_H_
24 #define _MACH_SEMAPHORE_H_
25
26 #include <mach/port.h>
27 #include <mach/mach_types.h>
28 #include <mach/kern_return.h>
29 #include <mach/sync_policy.h>
30
31 /*
32 * Forward Declarations
33 *
34 * The semaphore creation and deallocation routines are
35 * defined with the Mach task APIs in <mach/task.h>.
36 *
37 * kern_return_t semaphore_create(task_t task,
38 * semaphore_t *new_semaphore,
39 * sync_policy_t policy,
40 * int value);
41 *
42 * kern_return_t semaphore_destroy(task_t task,
43 * semaphore_t semaphore);
44 */
45
46 extern kern_return_t semaphore_signal (semaphore_t semaphore);
47 extern kern_return_t semaphore_signal_all (semaphore_t semaphore);
48 extern kern_return_t semaphore_signal_thread (semaphore_t semaphore,
49 thread_act_t thread_act);
50
51 extern kern_return_t semaphore_wait (semaphore_t semaphore);
52 extern kern_return_t semaphore_timedwait (semaphore_t semaphore,
53 mach_timespec_t wait_time);
54
55 extern kern_return_t semaphore_wait_signal (semaphore_t wait_semaphore,
56 semaphore_t signal_semaphore);
57
58 extern kern_return_t semaphore_timedwait_signal(semaphore_t wait_semaphore,
59 semaphore_t signal_semaphore,
60 mach_timespec_t wait_time);
61
62 #include <sys/appleapiopts.h>
63
64 #ifdef __APPLE_API_PRIVATE
65 #ifdef __APPLE_API_EVOLVING
66
67 #define SEMAPHORE_OPTION_NONE 0x00000000
68
69 #define SEMAPHORE_SIGNAL 0x00000001
70 #define SEMAPHORE_WAIT 0x00000002
71 #define SEMAPHORE_WAIT_ON_SIGNAL 0x00000008
72
73 #define SEMAPHORE_SIGNAL_TIMEOUT 0x00000010
74 #define SEMAPHORE_SIGNAL_ALL 0x00000020
75 #define SEMAPHORE_SIGNAL_INTERRUPT 0x00000040 /* libmach implements */
76 #define SEMAPHORE_SIGNAL_PREPOST 0x00000080
77
78 #define SEMAPHORE_WAIT_TIMEOUT 0x00000100
79 #define SEMAPHORE_WAIT_INTERRUPT 0x00000400 /* libmach implements */
80
81 #define SEMAPHORE_TIMEOUT_NOBLOCK 0x00100000
82 #define SEMAPHORE_TIMEOUT_RELATIVE 0x00200000
83
84 #define SEMAPHORE_USE_SAVED_RESULT 0x01000000 /* internal use only */
85 #define SEMAPHORE_SIGNAL_RELEASE 0x02000000 /* internal use only */
86
87 extern kern_return_t semaphore_operator (int options,
88 semaphore_t wait_semaphore,
89 semaphore_t signal_semaphore,
90 thread_act_t thread,
91 mach_timespec_t wait_time);
92
93 #endif /* __APPLE_API_EVOLVING */
94
95 #endif /* __APPLE_API_PRIVATE */
96
97 #endif /* _MACH_SEMAPHORE_H_ */