1/* Internal definitions for pthreads library.
2 Copyright (C) 2000-2024 Free Software Foundation, Inc.
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
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.
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
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _PT_SYSDEP_H
20#define _PT_SYSDEP_H 1
21
22#include <stddef.h>
23#include <mach.h>
24
25/* XXX */
26#define _POSIX_THREAD_THREADS_MAX 64
27
28/* The default stack size. */
29#define PTHREAD_STACK_DEFAULT (8 * 1024 * 1024)
30
31#define PTHREAD_SYSDEP_MEMBERS \
32 thread_t kernel_thread; \
33 mach_msg_header_t wakeupmsg;
34
35extern __thread struct __pthread *___pthread_self;
36libc_hidden_tls_proto (___pthread_self)
37
38#ifdef DEBUG
39#define _pthread_self() \
40 ({ \
41 struct __pthread *thread; \
42 \
43 assert (GL (dl_pthread_threads)); \
44 thread = ___pthread_self; \
45 \
46 assert (thread); \
47 assert (({ mach_port_t ktid = __mach_thread_self (); \
48 int ok = thread->kernel_thread == ktid; \
49 __mach_port_deallocate (__mach_task_self (), ktid);\
50 ok; })); \
51 thread; \
52 })
53#else
54#define _pthread_self() ___pthread_self
55#endif
56
57extern inline void
58__attribute__ ((__always_inline__))
59__pthread_stack_dealloc (void *stackaddr, size_t stacksize)
60{
61 __vm_deallocate (__mach_task_self (), (vm_offset_t) stackaddr, stacksize);
62}
63
64/* Change thread THREAD's program counter to PC if SET_PC is true,
65 its stack pointer to SP if SET_IP is true, and its thread pointer
66 to TP if SET_TP is true. */
67extern int __thread_set_pcsptp (thread_t thread,
68 int set_pc, void *pc,
69 int set_sp, void *sp, int set_tp, void *tp);
70
71
72#endif /* pt-sysdep.h */
73

source code of glibc/sysdeps/mach/hurd/htl/pt-sysdep.h