1 /* Copyright (C) 1994-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 /* Declare the few Mach system calls (except mach_msg, in <mach/message.h>).
19 This does not include the kernel RPC shortcut calls (in <mach-shortcuts.h>).
21 This file omits the MACH_IPC_COMPAT functions. */
23 #ifndef _MACH_MACH_TRAPS_H
25 #define _MACH_MACH_TRAPS_H_ 1
27 #include <mach/port.h>
28 #include <mach/message.h> /* mach_msg_timeout_t */
29 #include <mach/kern_return.h>
31 /* Create and return a new receive right. */
32 extern mach_port_t mach_reply_port (void);
33 extern mach_port_t __mach_reply_port (void);
35 /* Return the thread control port for the calling thread. */
36 extern mach_port_t mach_thread_self (void);
37 extern mach_port_t __mach_thread_self (void);
39 /* Return the task control port for the calling task.
40 The parens are needed to protect against the macro in <mach_init.h>. */
41 extern mach_port_t (mach_task_self) (void);
42 extern mach_port_t (__mach_task_self) (void);
44 /* Return the host information port for the host of the calling task. */
45 extern mach_port_t mach_host_self (void);
46 extern mach_port_t __mach_host_self (void);
48 /* Attempt to context switch the current thread off the processor. Returns
49 true if there are other threads that can be run and false if not. */
50 extern boolean_t swtch (void);
51 extern boolean_t __swtch (void);
53 /* Attempt to context switch the current thread off the processor. Lower
54 the thread's priority as much as possible. The thread's priority will
55 be restored when it runs again. PRIORITY is currently unused. Return
56 true if there are other threads that can be run and false if not. */
57 extern boolean_t swtch_pri (int priority);
58 extern boolean_t __swtch_pri (int priority);
60 /* Attempt to context switch the current thread of the processor. Try
61 to run NEW_THREAD next, ignoring normal scheduling policies. The
62 OPTION value comes from <mach/thread_switch.h>. If OPTION is
63 SWITCH_OPTION_WAIT, then block the current thread for TIME
64 milliseconds. If OPTION is SWITCH_OPTION_DEPRESS, then block for
65 TIME milliseconds and depress the thread's priority as done by
66 swtch_pri. If OPTION is SWITCH_OPTION_NONE, ignore TIME. */
67 kern_return_t thread_switch (mach_port_t new_thread,
68 int option, mach_msg_timeout_t option_time);
69 kern_return_t __thread_switch (mach_port_t new_thread,
70 int option, mach_msg_timeout_t option_time);
72 /* Block the current thread until the kernel (or device) event
73 identified by EVENT occurs. */
74 kern_return_t evc_wait (unsigned int event);
75 kern_return_t __evc_wait (unsigned int event);
78 #endif /* mach/mach_traps.h */