2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef _MACH_SEMAPHORE_H_
25 #define _MACH_SEMAPHORE_H_
27 #include <mach/port.h>
28 #include <mach/mach_types.h>
29 #include <mach/kern_return.h>
30 #include <mach/sync_policy.h>
33 * Forward Declarations
35 * The semaphore creation and deallocation routines are
36 * defined with the Mach task APIs in <mach/task.h>.
38 * kern_return_t semaphore_create(task_t task,
39 * semaphore_t *new_semaphore,
40 * sync_policy_t policy,
43 * kern_return_t semaphore_destroy(task_t task,
44 * semaphore_t semaphore);
47 #include <sys/cdefs.h>
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
,
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
);
59 extern kern_return_t
semaphore_wait_signal (semaphore_t wait_semaphore
,
60 semaphore_t signal_semaphore
);
62 extern kern_return_t
semaphore_timedwait_signal(semaphore_t wait_semaphore
,
63 semaphore_t signal_semaphore
,
64 mach_timespec_t wait_time
);
69 #define SEMAPHORE_OPTION_NONE 0x00000000
71 #define SEMAPHORE_SIGNAL 0x00000001
72 #define SEMAPHORE_WAIT 0x00000002
73 #define SEMAPHORE_WAIT_ON_SIGNAL 0x00000008
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
80 #define SEMAPHORE_WAIT_TIMEOUT 0x00000100
81 #define SEMAPHORE_WAIT_INTERRUPT 0x00000400 /* libmach implements */
83 #define SEMAPHORE_TIMEOUT_NOBLOCK 0x00100000
84 #define SEMAPHORE_TIMEOUT_RELATIVE 0x00200000
86 #define SEMAPHORE_USE_SAVED_RESULT 0x01000000 /* internal use only */
87 #define SEMAPHORE_SIGNAL_RELEASE 0x02000000 /* internal use only */
91 #endif /* _MACH_SEMAPHORE_H_ */