]>
Commit | Line | Data |
---|---|---|
33574c17 | 1 | /* Internal definitions for pthreads library. |
04277e02 | 2 | Copyright (C) 2000-2019 Free Software Foundation, Inc. |
33574c17 ST |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
ad2b41bf ST |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
33574c17 ST |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
ad2b41bf | 13 | Lesser General Public License for more details. |
33574c17 | 14 | |
ad2b41bf ST |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
33574c17 ST |
18 | |
19 | #ifndef _PT_SYSDEP_H | |
20 | #define _PT_SYSDEP_H 1 | |
21 | ||
22 | #include <mach.h> | |
23 | ||
24 | /* XXX */ | |
25 | #define _POSIX_THREAD_THREADS_MAX 64 | |
26 | ||
27 | /* The default stack size. */ | |
28 | #define PTHREAD_STACK_DEFAULT (8 * 1024 * 1024) | |
29 | ||
30 | #define PTHREAD_SYSDEP_MEMBERS \ | |
31 | thread_t kernel_thread; \ | |
32 | mach_msg_header_t wakeupmsg; | |
33 | ||
34 | extern __thread struct __pthread *___pthread_self; | |
35 | #define _pthread_self() \ | |
36 | ({ \ | |
37 | struct __pthread *thread; \ | |
38 | \ | |
39 | assert (__pthread_threads); \ | |
40 | thread = ___pthread_self; \ | |
41 | \ | |
42 | assert (thread); \ | |
43 | assert (({ mach_port_t ktid = __mach_thread_self (); \ | |
44 | int ok = thread->kernel_thread == ktid; \ | |
45 | __mach_port_deallocate (__mach_task_self (), ktid);\ | |
46 | ok; })); \ | |
47 | thread; \ | |
48 | }) | |
49 | ||
50 | extern inline void | |
51 | __attribute__ ((__always_inline__)) | |
52 | __pthread_stack_dealloc (void *stackaddr, size_t stacksize) | |
53 | { | |
54 | __vm_deallocate (__mach_task_self (), (vm_offset_t) stackaddr, stacksize); | |
55 | } | |
56 | ||
57 | /* Change thread THREAD's program counter to PC if SET_PC is true, | |
58 | its stack pointer to SP if SET_IP is true, and its thread pointer | |
59 | to TP if SET_TP is true. */ | |
60 | extern int __thread_set_pcsptp (thread_t thread, | |
61 | int set_pc, void *pc, | |
62 | int set_sp, void *sp, int set_tp, void *tp); | |
63 | ||
64 | ||
65 | #endif /* pt-sysdep.h */ |