2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _MACH_SEMAPHORE_H_
24 #define _MACH_SEMAPHORE_H_
26 #include <mach/port.h>
27 #include <mach/mach_types.h>
28 #include <mach/kern_return.h>
29 #include <mach/sync_policy.h>
31 #define SEMAPHORE_OPTION_NONE 0x00000000
33 #define SEMAPHORE_SIGNAL 0x00000001
34 #define SEMAPHORE_WAIT 0x00000002
35 #define SEMAPHORE_WAIT_ON_SIGNAL 0x00000008
37 #define SEMAPHORE_SIGNAL_TIMEOUT 0x00000010
38 #define SEMAPHORE_SIGNAL_ALL 0x00000020
39 #define SEMAPHORE_SIGNAL_INTERRUPT 0x00000040 /* libmach implements */
40 #define SEMAPHORE_SIGNAL_PREPOST 0x00000080
42 #define SEMAPHORE_WAIT_TIMEOUT 0x00000100
43 #define SEMAPHORE_WAIT_INTERRUPT 0x00000400 /* libmach implements */
45 #define SEMAPHORE_TIMEOUT_NOBLOCK 0x00100000
46 #define SEMAPHORE_TIMEOUT_RELATIVE 0x00200000
48 #define SEMAPHORE_USE_SAVED_RESULT 0x01000000 /* internal use only */
49 #define SEMAPHORE_SIGNAL_RELEASE 0x02000000 /* internal use only */
53 * Forward Declarations
55 * The semaphore creation and deallocation routines are
56 * defined with the Mach task APIs in <mach/task.h>.
58 * kern_return_t semaphore_create(task_t task,
59 * semaphore_t *new_semaphore,
60 * sync_policy_t policy,
63 * kern_return_t semaphore_destroy(task_t task,
64 * semaphore_t semaphore);
67 extern kern_return_t
semaphore_signal (semaphore_t semaphore
);
68 extern kern_return_t
semaphore_signal_all (semaphore_t semaphore
);
69 extern kern_return_t
semaphore_signal_thread (semaphore_t semaphore
,
70 thread_act_t thread_act
);
72 extern kern_return_t
semaphore_wait (semaphore_t semaphore
);
73 extern kern_return_t
semaphore_timedwait (semaphore_t semaphore
,
74 mach_timespec_t wait_time
);
76 extern kern_return_t
semaphore_wait_signal (semaphore_t wait_semaphore
,
77 semaphore_t signal_semaphore
);
79 extern kern_return_t
semaphore_timedwait_signal(semaphore_t wait_semaphore
,
80 semaphore_t signal_semaphore
,
81 mach_timespec_t wait_time
);
83 extern kern_return_t
semaphore_operator (int options
,
84 semaphore_t wait_semaphore
,
85 semaphore_t signal_semaphore
,
87 mach_timespec_t wait_time
);
89 #endif /* _MACH_SEMAPHORE_H_ */