Skip to content

Commit 9114740

Browse files
Use bitrig's pthread_once and friends.
diagnosed by drahn@
1 parent e745e9c commit 9114740

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

lib/libc/gen/_once_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ _once(pthread_once_t *once_control, void (*init_routine)(void))
5959
{
6060

6161
if (__isthreaded)
62-
return (_pthread_once(once_control, init_routine));
62+
return (_libc_pthread_once(once_control, init_routine));
6363
return (_libc_once(once_control, init_routine));
6464
}

lib/libc/gen/_pthread_stub.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,13 @@
2222
#include <pthread.h>
2323
#include <errno.h>
2424

25-
void *_pthread_getspecific(pthread_key_t key);
26-
int _pthread_setspecific(pthread_key_t key, const void *value);
27-
int _pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
28-
int _pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
29-
3025
void *pthread_getspecific(pthread_key_t key) __attribute__((weak));
3126
int pthread_setspecific(pthread_key_t key, const void *value) __attribute__((weak));
3227
int pthread_key_create(pthread_key_t *key, void (*destructor)(void *)) __attribute__((weak));
3328
int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) __attribute__((weak));
3429

3530
void *
36-
_pthread_getspecific(pthread_key_t key)
31+
_libc_pthread_getspecific(pthread_key_t key)
3732
{
3833
void *(*func)(pthread_key_t key);
3934
func = pthread_getspecific;
@@ -43,7 +38,7 @@ _pthread_getspecific(pthread_key_t key)
4338
}
4439

4540
int
46-
_pthread_setspecific(pthread_key_t key, const void *value)
41+
_libc_pthread_setspecific(pthread_key_t key, const void *value)
4742
{
4843
int (*func)(pthread_key_t key, const void *value);
4944
func = pthread_setspecific;
@@ -54,7 +49,7 @@ _pthread_setspecific(pthread_key_t key, const void *value)
5449

5550

5651
int
57-
_pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
52+
_libc_pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
5853
{
5954
int (*func)(pthread_key_t *key, void (*destructor)(void *));
6055
func = pthread_key_create;
@@ -64,7 +59,7 @@ _pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
6459
}
6560

6661
int
67-
_pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
62+
_libc_pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
6863
{
6964
int (*func)(pthread_once_t *once_control, void (*init_routine)(void));
7065
func = pthread_once;

lib/libc/include/thread_private.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,11 @@ pid_t _thread_fork(void);
193193
void *_rtld_allocate_tls(void *, size_t, size_t) __attribute__((weak));
194194
void _rtld_free_tls(void *, size_t, size_t) __attribute__((weak));
195195

196+
#include <pthread.h> /* for pthread_key_t */
197+
198+
void *_libc_pthread_getspecific(pthread_key_t key);
199+
int _libc_pthread_setspecific(pthread_key_t key, const void *value);
200+
int _libc_pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
201+
int _libc_pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
202+
196203
#endif /* _THREAD_PRIVATE_H_ */

0 commit comments

Comments
 (0)