1 Even if glibc doesn't have an integrated pthread library, it depends on the hurd
2 packages which have a pthread library.
4 Avoid letting glibc try to install its own headers for libpthread.
7 sysdeps/mach/hurd/Makeconfig | 14 +++++++++++
8 sysdeps/mach/hurd/bits/posix_opt.h | 40 +++++++++++++++++++++++-----------
9 sysdeps/mach/hurd/gai_misc.h | 43 +++++++++++++++++++++++++++++++++++++
10 3 files changed, 80 insertions(+), 13 deletions(-)
12 --- a/sysdeps/mach/hurd/bits/posix_opt.h
13 +++ b/sysdeps/mach/hurd/bits/posix_opt.h
15 /* XPG4.2 shared memory is supported. */
18 -/* We do not have the POSIX threads interface. */
19 -#define _POSIX_THREADS -1
20 +/* Tell we have POSIX threads. */
21 +#define _POSIX_THREADS 200112L
23 /* We have the reentrant functions described in POSIX. */
24 #define _POSIX_REENTRANT_FUNCTIONS 1
25 #define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
27 -/* These are all things that won't be supported when _POSIX_THREADS is not. */
28 +/* We do not provide priority scheduling for threads. */
29 #define _POSIX_THREAD_PRIORITY_SCHEDULING -1
30 -#define _POSIX_THREAD_ATTR_STACKSIZE -1
31 -#define _POSIX_THREAD_ATTR_STACKADDR -1
33 +/* We support user-defined stack sizes. */
34 +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
36 +/* We support user-defined stacks. */
37 +#define _POSIX_THREAD_ATTR_STACKADDR 200112L
39 +/* We do not support priority inheritence. */
40 #define _POSIX_THREAD_PRIO_INHERIT -1
42 +/* We do not support priority protection. */
43 #define _POSIX_THREAD_PRIO_PROTECT -1
46 +/* We do not support priority inheritence for robust mutexes. */
47 # define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1
49 +/* We do not support priority protection for robust mutexes. */
50 # define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
52 -#define _POSIX_SEMAPHORES -1
54 +/* We support POSIX.1b semaphores. */
55 +#define _POSIX_SEMAPHORES 200112L
57 /* Real-time signals are not yet supported. */
58 #define _POSIX_REALTIME_SIGNALS -1
60 /* GNU libc provides regular expression handling. */
61 #define _POSIX_REGEXP 1
63 -/* Reader/Writer locks are not available. */
64 -#define _POSIX_READER_WRITER_LOCKS -1
65 +/* Reader/Writer locks are available. */
66 +#define _POSIX_READER_WRITER_LOCKS 200112L
68 /* We have a POSIX shell. */
69 #define _POSIX_SHELL 1
71 -/* We cannot support the Timeouts option without _POSIX_THREADS. */
72 -#define _POSIX_TIMEOUTS -1
73 +/* We support the Timeouts option. */
74 +#define _POSIX_TIMEOUTS 200112L
76 -/* We do not support spinlocks. */
77 -#define _POSIX_SPIN_LOCKS -1
78 +/* We support spinlocks. */
79 +#define _POSIX_SPIN_LOCKS 200112L
81 /* The `spawn' function family is supported. */
82 #define _POSIX_SPAWN 200809L
84 #define _POSIX_TIMERS 0
86 /* The barrier functions are not available. */
87 -#define _POSIX_BARRIERS -1
88 +#define _POSIX_BARRIERS 200112L
90 /* POSIX message queues could be available in future. */
91 #define _POSIX_MESSAGE_PASSING 0
92 --- a/sysdeps/mach/hurd/Makeconfig
93 +++ b/sysdeps/mach/hurd/Makeconfig
95 # See Makefile in this directory for the rule that builds this.
96 # We must define this variable earlier than sysdeps Makefiles are included.
97 static-start-installed-name = crt0.o
99 +have-thread-library = yes
100 +shared-thread-library = /lib/libpthread.so
101 +static-thread-library = /lib/libpthread.a
102 +bounded-thread-library = $(static-thread-library)
104 +$(shared-thread-library):
106 +$(static-thread-library):
108 +$(inst_includedir)/pthread.h:
113 +++ b/sysdeps/mach/hurd/gai_misc.h
117 +#define gai_start_notify_thread __gai_start_notify_thread
118 +#define gai_create_helper_thread __gai_create_helper_thread
121 +__gai_start_notify_thread (void)
125 + sigprocmask(SIG_SETMASK, &ss, NULL);
129 +__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
132 + pthread_attr_t attr;
134 + /* Make sure the thread is created detached. */
135 + pthread_attr_init (&attr);
136 + pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
138 + /* The helper thread needs only very little resources. */
139 + (void) pthread_attr_setstacksize (&attr, 0x10000);
141 + /* Block all signals in the helper thread. To do this thoroughly we
142 + temporarily have to block all signals here. */
146 + sigprocmask(SIG_SETMASK, &ss, &oss);
148 + int ret = pthread_create (threadp, &attr, tf, arg);
150 + /* Restore the signal mask. */
151 + sigprocmask(SIG_SETMASK, &oss, NULL);
153 + (void) pthread_attr_destroy (&attr);
157 +#include_next <gai_misc.h>