]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/semaphore.h
e5241b51ff6c60b2cc4b542eee0a5fa9aa2c8211
[apple/xnu.git] / osfmk / mach / semaphore.h
1 /*
2 * Copyright (c) 2000-2005 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 #include <sys/cdefs.h>
47 __BEGIN_DECLS
48
49 extern kern_return_t semaphore_signal (semaphore_t semaphore);
50 extern kern_return_t semaphore_signal_all (semaphore_t semaphore);
51 extern kern_return_t semaphore_signal_thread (semaphore_t semaphore,
52 thread_t thread);
53
54 extern kern_return_t semaphore_wait (semaphore_t semaphore);
55 extern kern_return_t semaphore_timedwait (semaphore_t semaphore,
56 mach_timespec_t wait_time);
57
58 extern kern_return_t semaphore_wait_signal (semaphore_t wait_semaphore,
59 semaphore_t signal_semaphore);
60
61 extern kern_return_t semaphore_timedwait_signal(semaphore_t wait_semaphore,
62 semaphore_t signal_semaphore,
63 mach_timespec_t wait_time);
64 __END_DECLS
65
66 #ifdef PRIVATE
67
68 #define SEMAPHORE_OPTION_NONE 0x00000000
69
70 #define SEMAPHORE_SIGNAL 0x00000001
71 #define SEMAPHORE_WAIT 0x00000002
72 #define SEMAPHORE_WAIT_ON_SIGNAL 0x00000008
73
74 #define SEMAPHORE_SIGNAL_TIMEOUT 0x00000010
75 #define SEMAPHORE_SIGNAL_ALL 0x00000020
76 #define SEMAPHORE_SIGNAL_INTERRUPT 0x00000040 /* libmach implements */
77 #define SEMAPHORE_SIGNAL_PREPOST 0x00000080
78
79 #define SEMAPHORE_WAIT_TIMEOUT 0x00000100
80 #define SEMAPHORE_WAIT_INTERRUPT 0x00000400 /* libmach implements */
81
82 #define SEMAPHORE_TIMEOUT_NOBLOCK 0x00100000
83 #define SEMAPHORE_TIMEOUT_RELATIVE 0x00200000
84
85 #define SEMAPHORE_USE_SAVED_RESULT 0x01000000 /* internal use only */
86 #define SEMAPHORE_SIGNAL_RELEASE 0x02000000 /* internal use only */
87
88 #endif /* PRIVATE */
89
90 #endif /* _MACH_SEMAPHORE_H_ */