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