]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/semaphore.h
xnu-344.49.tar.gz
[apple/xnu.git] / osfmk / mach / semaphore.h
CommitLineData
1c79356b 1/*
9bccf70c 2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
1c79356b
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26#ifndef _MACH_SEMAPHORE_H_
27#define _MACH_SEMAPHORE_H_
28
29#include <mach/port.h>
30#include <mach/mach_types.h>
31#include <mach/kern_return.h>
32#include <mach/sync_policy.h>
33
1c79356b
A
34/*
35 * Forward Declarations
36 *
37 * The semaphore creation and deallocation routines are
38 * defined with the Mach task APIs in <mach/task.h>.
39 *
40 * kern_return_t semaphore_create(task_t task,
41 * semaphore_t *new_semaphore,
42 * sync_policy_t policy,
43 * int value);
44 *
45 * kern_return_t semaphore_destroy(task_t task,
46 * semaphore_t semaphore);
47 */
48
49extern kern_return_t semaphore_signal (semaphore_t semaphore);
50extern kern_return_t semaphore_signal_all (semaphore_t semaphore);
51extern kern_return_t semaphore_signal_thread (semaphore_t semaphore,
52 thread_act_t thread_act);
53
54extern kern_return_t semaphore_wait (semaphore_t semaphore);
55extern kern_return_t semaphore_timedwait (semaphore_t semaphore,
56 mach_timespec_t wait_time);
57
58extern kern_return_t semaphore_wait_signal (semaphore_t wait_semaphore,
59 semaphore_t signal_semaphore);
60
61extern kern_return_t semaphore_timedwait_signal(semaphore_t wait_semaphore,
62 semaphore_t signal_semaphore,
63 mach_timespec_t wait_time);
64
9bccf70c
A
65#include <sys/appleapiopts.h>
66
67#ifdef __APPLE_API_PRIVATE
68#ifdef __APPLE_API_EVOLVING
69
70#define SEMAPHORE_OPTION_NONE 0x00000000
71
72#define SEMAPHORE_SIGNAL 0x00000001
73#define SEMAPHORE_WAIT 0x00000002
74#define SEMAPHORE_WAIT_ON_SIGNAL 0x00000008
75
76#define SEMAPHORE_SIGNAL_TIMEOUT 0x00000010
77#define SEMAPHORE_SIGNAL_ALL 0x00000020
78#define SEMAPHORE_SIGNAL_INTERRUPT 0x00000040 /* libmach implements */
79#define SEMAPHORE_SIGNAL_PREPOST 0x00000080
80
81#define SEMAPHORE_WAIT_TIMEOUT 0x00000100
82#define SEMAPHORE_WAIT_INTERRUPT 0x00000400 /* libmach implements */
83
84#define SEMAPHORE_TIMEOUT_NOBLOCK 0x00100000
85#define SEMAPHORE_TIMEOUT_RELATIVE 0x00200000
86
87#define SEMAPHORE_USE_SAVED_RESULT 0x01000000 /* internal use only */
88#define SEMAPHORE_SIGNAL_RELEASE 0x02000000 /* internal use only */
89
1c79356b
A
90extern kern_return_t semaphore_operator (int options,
91 semaphore_t wait_semaphore,
92 semaphore_t signal_semaphore,
93 thread_act_t thread,
94 mach_timespec_t wait_time);
95
9bccf70c
A
96#endif /* __APPLE_API_EVOLVING */
97
98#endif /* __APPLE_API_PRIVATE */
99
1c79356b 100#endif /* _MACH_SEMAPHORE_H_ */