1 | /* Copyright (C) 1994-2022 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. |
3 | |
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. |
8 | |
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. |
13 | |
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 | <https://www.gnu.org/licenses/>. */ |
17 | |
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>). |
20 | */ |
21 | |
22 | #ifndef _MACH_MACH_TRAPS_H |
23 | |
24 | #define _MACH_MACH_TRAPS_H_ 1 |
25 | |
26 | #include <mach/port.h> |
27 | #include <mach/message.h> /* mach_msg_timeout_t */ |
28 | #include <mach/kern_return.h> |
29 | |
30 | /* Create and return a new receive right. */ |
31 | extern mach_port_t mach_reply_port (void); |
32 | |
33 | /* Return the thread control port for the calling thread. */ |
34 | extern mach_port_t mach_thread_self (void); |
35 | |
36 | /* Return the task control port for the calling task. |
37 | The parens are needed to protect against the macro in <mach_init.h>. */ |
38 | extern mach_port_t (mach_task_self) (void); |
39 | |
40 | /* Return the host information port for the host of the calling task. |
41 | The parens are needed to protect against the macro in <mach_init.h>. */ |
42 | extern mach_port_t (mach_host_self) (void); |
43 | |
44 | /* Attempt to context switch the current thread off the processor. Returns |
45 | true if there are other threads that can be run and false if not. */ |
46 | extern boolean_t swtch (void); |
47 | |
48 | /* Attempt to context switch the current thread off the processor. Lower |
49 | the thread's priority as much as possible. The thread's priority will |
50 | be restored when it runs again. PRIORITY is currently unused. Return |
51 | true if there are other threads that can be run and false if not. */ |
52 | extern boolean_t swtch_pri (int priority); |
53 | |
54 | /* Attempt to context switch the current thread off the processor. Try |
55 | to run NEW_THREAD next, ignoring normal scheduling policies. The |
56 | OPTION value comes from <mach/thread_switch.h>. If OPTION is |
57 | SWITCH_OPTION_WAIT, then block the current thread for TIME |
58 | milliseconds. If OPTION is SWITCH_OPTION_DEPRESS, then block for |
59 | TIME milliseconds and depress the thread's priority as done by |
60 | swtch_pri. If OPTION is SWITCH_OPTION_NONE, ignore TIME. */ |
61 | kern_return_t thread_switch (mach_port_t new_thread, |
62 | int option, mach_msg_timeout_t option_time); |
63 | |
64 | /* Block the current thread until the kernel (or device) event |
65 | identified by EVENT occurs. */ |
66 | kern_return_t evc_wait (unsigned int event); |
67 | |
68 | /* Display a null-terminated character string on the Mach console. This |
69 | system call is meant as a debugging tool useful to circumvent messaging |
70 | altogether. */ |
71 | |
72 | extern void mach_print(const char *s); |
73 | |
74 | #endif /* mach/mach_traps.h */ |
75 | |