chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / debian / patches / hurd-i386 / local-pthread_posix-option.diff
1 Even if glibc doesn't have an integrated pthread library, it depends on the hurd
2 packages which have a pthread library.
3
4 Avoid letting glibc try to install its own headers for libpthread.
5
6 ---
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(-)
11
12 --- a/sysdeps/mach/hurd/bits/posix_opt.h
13 +++ b/sysdeps/mach/hurd/bits/posix_opt.h
14 @@ -72,24 +72,38 @@
15  /* XPG4.2 shared memory is supported.  */
16  #define        _XOPEN_SHM      1
17  
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
22  
23  /* We have the reentrant functions described in POSIX.  */
24  #define _POSIX_REENTRANT_FUNCTIONS      1
25  #define _POSIX_THREAD_SAFE_FUNCTIONS   200809L
26  
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
32 +
33 +/* We support user-defined stack sizes.  */
34 +#define _POSIX_THREAD_ATTR_STACKSIZE   200112L
35 +
36 +/* We support user-defined stacks.  */
37 +#define _POSIX_THREAD_ATTR_STACKADDR   200112L
38 +
39 +/* We do not support priority inheritence.  */
40  #define _POSIX_THREAD_PRIO_INHERIT     -1
41 +
42 +/* We do not support priority protection.  */
43  #define _POSIX_THREAD_PRIO_PROTECT     -1
44 +
45  #ifdef __USE_XOPEN2K8
46 +/* We do not support priority inheritence for robust mutexes.  */
47  # define _POSIX_THREAD_ROBUST_PRIO_INHERIT     -1
48 +
49 +/* We do not support priority protection for robust mutexes.  */
50  # define _POSIX_THREAD_ROBUST_PRIO_PROTECT     -1
51  #endif
52 -#define _POSIX_SEMAPHORES                      -1
53 +
54 +/* We support POSIX.1b semaphores.  */
55 +#define _POSIX_SEMAPHORES                      200112L
56  
57  /* Real-time signals are not yet supported.  */
58  #define _POSIX_REALTIME_SIGNALS        -1
59 @@ -122,17 +136,17 @@
60  /* GNU libc provides regular expression handling.  */
61  #define _POSIX_REGEXP  1
62  
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
67  
68  /* We have a POSIX shell.  */
69  #define _POSIX_SHELL   1
70  
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
75  
76 -/* We do not support spinlocks.  */
77 -#define _POSIX_SPIN_LOCKS      -1
78 +/* We support spinlocks.  */
79 +#define _POSIX_SPIN_LOCKS      200112L
80  
81  /* The `spawn' function family is supported.  */
82  #define _POSIX_SPAWN   200809L
83 @@ -141,7 +155,7 @@
84  #define _POSIX_TIMERS  0
85  
86  /* The barrier functions are not available.  */
87 -#define _POSIX_BARRIERS        -1
88 +#define _POSIX_BARRIERS        200112L
89  
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
94 @@ -2,3 +2,17 @@
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
98 +
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)
103 +
104 +$(shared-thread-library):
105 +       true
106 +$(static-thread-library):
107 +       true
108 +$(inst_includedir)/pthread.h:
109 +       true
110 +
111 ++force =
112 --- /dev/null
113 +++ b/sysdeps/mach/hurd/gai_misc.h
114 @@ -0,0 +1,43 @@
115 +#include <signal.h>
116 +
117 +#define gai_start_notify_thread __gai_start_notify_thread
118 +#define gai_create_helper_thread __gai_create_helper_thread
119 +
120 +extern inline void
121 +__gai_start_notify_thread (void)
122 +{
123 +  sigset_t ss;
124 +  sigemptyset (&ss);
125 +  sigprocmask(SIG_SETMASK, &ss, NULL);
126 +}
127 +
128 +extern inline int
129 +__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
130 +                           void *arg)
131 +{
132 +  pthread_attr_t attr;
133 +
134 +  /* Make sure the thread is created detached.  */
135 +  pthread_attr_init (&attr);
136 +  pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
137 +
138 +  /* The helper thread needs only very little resources.  */
139 +  (void) pthread_attr_setstacksize (&attr, 0x10000);
140 +
141 +  /* Block all signals in the helper thread.  To do this thoroughly we
142 +     temporarily have to block all signals here.  */
143 +  sigset_t ss;
144 +  sigset_t oss;
145 +  sigfillset (&ss);
146 +  sigprocmask(SIG_SETMASK, &ss, &oss);
147 +
148 +  int ret = pthread_create (threadp, &attr, tf, arg);
149 +
150 +  /* Restore the signal mask.  */
151 +  sigprocmask(SIG_SETMASK, &oss, NULL);
152 +
153 +  (void) pthread_attr_destroy (&attr);
154 +  return ret;
155 +}
156 +
157 +#include_next <gai_misc.h>