internals.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /* Linuxthreads - a simple clone()-based implementation of Posix */
  2. /* threads for Linux. */
  3. /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
  4. /* */
  5. /* This program is free software; you can redistribute it and/or */
  6. /* modify it under the terms of the GNU Library General Public License */
  7. /* as published by the Free Software Foundation; either version 2 */
  8. /* of the License, or (at your option) any later version. */
  9. /* */
  10. /* This program 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 */
  13. /* GNU Library General Public License for more details. */
  14. #ifndef _INTERNALS_H
  15. #define _INTERNALS_H 1
  16. /* Internal data structures */
  17. /* Includes */
  18. #include <bits/libc-tsd.h> /* for _LIBC_TSD_KEY_N */
  19. #include <limits.h>
  20. #include <setjmp.h>
  21. #include <signal.h>
  22. #include <unistd.h>
  23. #include <bits/stackinfo.h>
  24. #include <sys/types.h>
  25. #include <sys/wait.h>
  26. #include "pt-machine.h"
  27. #include "semaphore.h"
  28. #include "../linuxthreads_db/thread_dbP.h"
  29. #ifdef __UCLIBC_HAS_XLOCALE__
  30. #include <bits/uClibc_locale.h>
  31. #endif /* __UCLIBC_HAS_XLOCALE__ */
  32. /* Use a funky version in a probably vein attempt at preventing gdb
  33. * from dlopen()'ing glibc's libthread_db library... */
  34. #define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
  35. #ifndef THREAD_GETMEM
  36. # define THREAD_GETMEM(descr, member) descr->member
  37. #endif
  38. #ifndef THREAD_GETMEM_NC
  39. # define THREAD_GETMEM_NC(descr, member) descr->member
  40. #endif
  41. #ifndef THREAD_SETMEM
  42. # define THREAD_SETMEM(descr, member, value) descr->member = (value)
  43. #endif
  44. #ifndef THREAD_SETMEM_NC
  45. # define THREAD_SETMEM_NC(descr, member, value) descr->member = (value)
  46. #endif
  47. /* Conditional variable attribute data structure. */
  48. struct pthread_condattr
  49. {
  50. /* Combination of values:
  51. Bit 0 : flag whether coditional variable will be shareable between
  52. processes.
  53. Bit 1-7: clock ID. */
  54. int value;
  55. };
  56. /* The __NWAITERS field is used as a counter and to house the number
  57. of bits for other purposes. COND_CLOCK_BITS is the number
  58. of bits needed to represent the ID of the clock. COND_NWAITERS_SHIFT
  59. is the number of bits reserved for other purposes like the clock. */
  60. #define COND_CLOCK_BITS 1
  61. #define COND_NWAITERS_SHIFT 1
  62. /* Arguments passed to thread creation routine */
  63. struct pthread_start_args {
  64. void * (*start_routine)(void *); /* function to run */
  65. void * arg; /* its argument */
  66. sigset_t mask; /* initial signal mask for thread */
  67. int schedpolicy; /* initial scheduling policy (if any) */
  68. struct sched_param schedparam; /* initial scheduling parameters (if any) */
  69. };
  70. /* We keep thread specific data in a special data structure, a two-level
  71. array. The top-level array contains pointers to dynamically allocated
  72. arrays of a certain number of data pointers. So we can implement a
  73. sparse array. Each dynamic second-level array has
  74. PTHREAD_KEY_2NDLEVEL_SIZE
  75. entries. This value shouldn't be too large. */
  76. #define PTHREAD_KEY_2NDLEVEL_SIZE 32
  77. /* We need to address PTHREAD_KEYS_MAX key with PTHREAD_KEY_2NDLEVEL_SIZE
  78. keys in each subarray. */
  79. #define PTHREAD_KEY_1STLEVEL_SIZE \
  80. ((PTHREAD_KEYS_MAX + PTHREAD_KEY_2NDLEVEL_SIZE - 1) \
  81. / PTHREAD_KEY_2NDLEVEL_SIZE)
  82. typedef void (*destr_function)(void *);
  83. struct pthread_key_struct {
  84. int in_use; /* already allocated? */
  85. destr_function destr; /* destruction routine */
  86. };
  87. #define PTHREAD_START_ARGS_INITIALIZER { NULL, NULL, {{0, }}, 0, { 0 } }
  88. /* The type of thread descriptors */
  89. typedef struct _pthread_descr_struct * pthread_descr;
  90. /* Callback interface for removing the thread from waiting on an
  91. object if it is cancelled while waiting or about to wait.
  92. This hold a pointer to the object, and a pointer to a function
  93. which ``extricates'' the thread from its enqueued state.
  94. The function takes two arguments: pointer to the wait object,
  95. and a pointer to the thread. It returns 1 if an extrication
  96. actually occured, and hence the thread must also be signalled.
  97. It returns 0 if the thread had already been extricated. */
  98. typedef struct _pthread_extricate_struct {
  99. void *pu_object;
  100. int (*pu_extricate_func)(void *, pthread_descr);
  101. } pthread_extricate_if;
  102. /* Atomic counter made possible by compare_and_swap */
  103. struct pthread_atomic {
  104. long p_count;
  105. int p_spinlock;
  106. };
  107. /* Context info for read write locks. The pthread_rwlock_info structure
  108. is information about a lock that has been read-locked by the thread
  109. in whose list this structure appears. The pthread_rwlock_context
  110. is embedded in the thread context and contains a pointer to the
  111. head of the list of lock info structures, as well as a count of
  112. read locks that are untracked, because no info structure could be
  113. allocated for them. */
  114. struct _pthread_rwlock_t;
  115. typedef struct _pthread_rwlock_info {
  116. struct _pthread_rwlock_info *pr_next;
  117. struct _pthread_rwlock_t *pr_lock;
  118. int pr_lock_count;
  119. } pthread_readlock_info;
  120. struct _pthread_descr_struct {
  121. pthread_descr p_nextlive, p_prevlive;
  122. /* Double chaining of active threads */
  123. pthread_descr p_nextwaiting; /* Next element in the queue holding the thr */
  124. pthread_descr p_nextlock; /* can be on a queue and waiting on a lock */
  125. pthread_t p_tid; /* Thread identifier */
  126. int p_pid; /* PID of Unix process */
  127. int p_priority; /* Thread priority (== 0 if not realtime) */
  128. struct _pthread_fastlock * p_lock; /* Spinlock for synchronized accesses */
  129. int p_signal; /* last signal received */
  130. sigjmp_buf * p_signal_jmp; /* where to siglongjmp on a signal or NULL */
  131. sigjmp_buf * p_cancel_jmp; /* where to siglongjmp on a cancel or NULL */
  132. char p_terminated; /* true if terminated e.g. by pthread_exit */
  133. char p_detached; /* true if detached */
  134. char p_exited; /* true if the assoc. process terminated */
  135. void * p_retval; /* placeholder for return value */
  136. int p_retcode; /* placeholder for return code */
  137. pthread_descr p_joining; /* thread joining on that thread or NULL */
  138. struct _pthread_cleanup_buffer * p_cleanup; /* cleanup functions */
  139. char p_cancelstate; /* cancellation state */
  140. char p_canceltype; /* cancellation type (deferred/async) */
  141. char p_canceled; /* cancellation request pending */
  142. int * p_errnop; /* pointer to used errno variable */
  143. int p_errno; /* error returned by last system call */
  144. int * p_h_errnop; /* pointer to used h_errno variable */
  145. int p_h_errno; /* error returned by last netdb function */
  146. char * p_in_sighandler; /* stack address of sighandler, or NULL */
  147. char p_sigwaiting; /* true if a sigwait() is in progress */
  148. struct pthread_start_args p_start_args; /* arguments for thread creation */
  149. void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE]; /* thread-specific data */
  150. void * p_libc_specific[_LIBC_TSD_KEY_N]; /* thread-specific data for libc */
  151. int p_userstack; /* nonzero if the user provided the stack */
  152. void *p_guardaddr; /* address of guard area or NULL */
  153. size_t p_guardsize; /* size of guard area */
  154. pthread_descr p_self; /* Pointer to this structure */
  155. int p_nr; /* Index of descriptor in __pthread_handles */
  156. int p_report_events; /* Nonzero if events must be reported. */
  157. td_eventbuf_t p_eventbuf; /* Data for event. */
  158. struct pthread_atomic p_resume_count; /* number of times restart() was
  159. called on thread */
  160. char p_woken_by_cancel; /* cancellation performed wakeup */
  161. char p_condvar_avail; /* flag if conditional variable became avail */
  162. char p_sem_avail; /* flag if semaphore became available */
  163. pthread_extricate_if *p_extricate; /* See above */
  164. pthread_readlock_info *p_readlock_list; /* List of readlock info structs */
  165. pthread_readlock_info *p_readlock_free; /* Free list of structs */
  166. int p_untracked_readlock_count; /* Readlocks not tracked by list */
  167. /* New elements must be added at the end. */
  168. #ifdef __UCLIBC_HAS_XLOCALE__
  169. __locale_t locale; /* thread-specific locale from uselocale() only! */
  170. #endif /* __UCLIBC_HAS_XLOCALE__ */
  171. } __attribute__ ((aligned(32))); /* We need to align the structure so that
  172. doubles are aligned properly. This is 8
  173. bytes on MIPS and 16 bytes on MIPS64.
  174. 32 bytes might give better cache
  175. utilization. */
  176. /* The type of thread handles. */
  177. typedef struct pthread_handle_struct * pthread_handle;
  178. struct pthread_handle_struct {
  179. struct _pthread_fastlock h_lock; /* Fast lock for sychronized access */
  180. pthread_descr h_descr; /* Thread descriptor or NULL if invalid */
  181. char * h_bottom; /* Lowest address in the stack thread */
  182. };
  183. /* The type of messages sent to the thread manager thread */
  184. struct pthread_request {
  185. pthread_descr req_thread; /* Thread doing the request */
  186. enum { /* Request kind */
  187. REQ_CREATE, REQ_FREE, REQ_PROCESS_EXIT, REQ_MAIN_THREAD_EXIT,
  188. REQ_POST, REQ_DEBUG, REQ_KICK
  189. } req_kind;
  190. union { /* Arguments for request */
  191. struct { /* For REQ_CREATE: */
  192. const pthread_attr_t * attr; /* thread attributes */
  193. void * (*fn)(void *); /* start function */
  194. void * arg; /* argument to start function */
  195. sigset_t mask; /* signal mask */
  196. } create;
  197. struct { /* For REQ_FREE: */
  198. pthread_t thread_id; /* identifier of thread to free */
  199. } free;
  200. struct { /* For REQ_PROCESS_EXIT: */
  201. int code; /* exit status */
  202. } exit;
  203. void * post; /* For REQ_POST: the semaphore */
  204. } req_args;
  205. };
  206. /* Signals used for suspend/restart and for cancellation notification. */
  207. extern int __pthread_sig_restart;
  208. extern int __pthread_sig_cancel;
  209. /* Signal used for interfacing with gdb */
  210. extern int __pthread_sig_debug;
  211. /* Global array of thread handles, used for validating a thread id
  212. and retrieving the corresponding thread descriptor. Also used for
  213. mapping the available stack segments. */
  214. extern struct pthread_handle_struct __pthread_handles[PTHREAD_THREADS_MAX];
  215. /* Descriptor of the initial thread */
  216. extern struct _pthread_descr_struct __pthread_initial_thread;
  217. /* Descriptor of the manager thread */
  218. extern struct _pthread_descr_struct __pthread_manager_thread;
  219. /* Descriptor of the main thread */
  220. extern pthread_descr __pthread_main_thread;
  221. /* Limit between the stack of the initial thread (above) and the
  222. stacks of other threads (below). Aligned on a STACK_SIZE boundary.
  223. Initially 0, meaning that the current thread is (by definition)
  224. the initial thread. */
  225. extern char *__pthread_initial_thread_bos;
  226. #ifndef __ARCH_USE_MMU__
  227. /* For non-MMU systems, we have no idea the bounds of the initial thread
  228. * stack, so we have to track it on the fly relative to other stacks. Do
  229. * so by scaling back our assumptions on the limits of the bos/tos relative
  230. * to the known mid point. See also the comments in pthread_initialize(). */
  231. extern char *__pthread_initial_thread_tos, *__pthread_initial_thread_mid;
  232. #define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \
  233. do { \
  234. char *__tos = (tos); \
  235. char *__bos = (bos); \
  236. if (__tos >= __pthread_initial_thread_bos && \
  237. __bos < __pthread_initial_thread_tos) { \
  238. if (__bos < __pthread_initial_thread_mid) \
  239. __pthread_initial_thread_bos = __tos; \
  240. else \
  241. __pthread_initial_thread_tos = __bos; \
  242. } \
  243. } while (0)
  244. #else
  245. #define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */
  246. #endif /* __ARCH_USE_MMU__ */
  247. /* Indicate whether at least one thread has a user-defined stack (if 1),
  248. or all threads have stacks supplied by LinuxThreads (if 0). */
  249. extern int __pthread_nonstandard_stacks;
  250. /* File descriptor for sending requests to the thread manager.
  251. Initially -1, meaning that __pthread_initialize_manager must be called. */
  252. extern int __pthread_manager_request;
  253. /* Other end of the pipe for sending requests to the thread manager. */
  254. extern int __pthread_manager_reader;
  255. /* Limits of the thread manager stack. */
  256. extern char *__pthread_manager_thread_bos;
  257. extern char *__pthread_manager_thread_tos;
  258. /* Pending request for a process-wide exit */
  259. extern int __pthread_exit_requested, __pthread_exit_code;
  260. /* Set to 1 by gdb if we're debugging */
  261. extern volatile int __pthread_threads_debug;
  262. /* Globally enabled events. */
  263. extern volatile td_thr_events_t __pthread_threads_events;
  264. /* Pointer to descriptor of thread with last event. */
  265. extern volatile pthread_descr __pthread_last_event;
  266. /* Return the handle corresponding to a thread id */
  267. static __inline__ pthread_handle thread_handle(pthread_t id)
  268. {
  269. return &__pthread_handles[id % PTHREAD_THREADS_MAX];
  270. }
  271. /* Validate a thread handle. Must have acquired h->h_spinlock before. */
  272. static __inline__ int invalid_handle(pthread_handle h, pthread_t id)
  273. {
  274. return h->h_descr == NULL || h->h_descr->p_tid != id;
  275. }
  276. /* Fill in defaults left unspecified by pt-machine.h. */
  277. /* The page size we can get from the system. This should likely not be
  278. changed by the machine file but, you never know. */
  279. #define __PAGE_SIZE (sysconf (_SC_PAGESIZE))
  280. /* The max size of the thread stack segments. If the default
  281. THREAD_SELF implementation is used, this must be a power of two and
  282. a multiple of __PAGE_SIZE. */
  283. #ifndef STACK_SIZE
  284. #ifdef __ARCH_USE_MMU__
  285. #define STACK_SIZE (2 * 1024 * 1024)
  286. #else
  287. #define STACK_SIZE (4 * __PAGE_SIZE)
  288. #endif
  289. #endif
  290. /* The initial size of the thread stack. Must be a multiple of __PAGE_SIZE. */
  291. #ifndef INITIAL_STACK_SIZE
  292. #define INITIAL_STACK_SIZE (4 * __PAGE_SIZE)
  293. #endif
  294. /* Size of the thread manager stack. The "- 32" avoids wasting space
  295. with some malloc() implementations. */
  296. #ifndef THREAD_MANAGER_STACK_SIZE
  297. #define THREAD_MANAGER_STACK_SIZE (2 * __PAGE_SIZE - 32)
  298. #endif
  299. /* The base of the "array" of thread stacks. The array will grow down from
  300. here. Defaults to the calculated bottom of the initial application
  301. stack. */
  302. #ifndef THREAD_STACK_START_ADDRESS
  303. #define THREAD_STACK_START_ADDRESS __pthread_initial_thread_bos
  304. #endif
  305. /* Get some notion of the current stack. Need not be exactly the top
  306. of the stack, just something somewhere in the current frame. */
  307. #ifndef CURRENT_STACK_FRAME
  308. #define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
  309. #endif
  310. /* If MEMORY_BARRIER isn't defined in pt-machine.h, assume the
  311. architecture doesn't need a memory barrier instruction (e.g. Intel
  312. x86). Still we need the compiler to respect the barrier and emit
  313. all outstanding operations which modify memory. Some architectures
  314. distinguish between full, read and write barriers. */
  315. #ifndef MEMORY_BARRIER
  316. #define MEMORY_BARRIER() __asm__ ("" : : : "memory")
  317. #endif
  318. #ifndef READ_MEMORY_BARRIER
  319. #define READ_MEMORY_BARRIER() MEMORY_BARRIER()
  320. #endif
  321. #ifndef WRITE_MEMORY_BARRIER
  322. #define WRITE_MEMORY_BARRIER() MEMORY_BARRIER()
  323. #endif
  324. /* Recover thread descriptor for the current thread */
  325. extern pthread_descr __pthread_find_self (void) __attribute__ ((const)) attribute_hidden;
  326. static __inline__ pthread_descr thread_self (void) __attribute__ ((const));
  327. static __inline__ pthread_descr thread_self (void)
  328. {
  329. #ifdef THREAD_SELF
  330. return THREAD_SELF;
  331. #else
  332. char *sp = CURRENT_STACK_FRAME;
  333. #ifdef __ARCH_USE_MMU__
  334. if (sp >= __pthread_initial_thread_bos)
  335. return &__pthread_initial_thread;
  336. else if (sp >= __pthread_manager_thread_bos
  337. && sp < __pthread_manager_thread_tos)
  338. return &__pthread_manager_thread;
  339. else if (__pthread_nonstandard_stacks)
  340. return __pthread_find_self();
  341. else
  342. return (pthread_descr)(((unsigned long)sp | (STACK_SIZE-1))+1) - 1;
  343. #else
  344. /* For non-MMU we need to be more careful about the initial thread stack.
  345. * We refine the initial thread stack bounds dynamically as we allocate
  346. * the other stack frame such that it doesn't overlap with them. Then
  347. * we can be sure to pick the right thread according to the current SP */
  348. /* Since we allow other stack frames to be above or below, we need to
  349. * treat this case special. When pthread_initialize() wasn't called yet,
  350. * only the initial thread is there. */
  351. if (__pthread_initial_thread_bos == NULL) {
  352. return &__pthread_initial_thread;
  353. }
  354. else if (sp >= __pthread_initial_thread_bos
  355. && sp < __pthread_initial_thread_tos) {
  356. return &__pthread_initial_thread;
  357. }
  358. else if (sp >= __pthread_manager_thread_bos
  359. && sp < __pthread_manager_thread_tos) {
  360. return &__pthread_manager_thread;
  361. }
  362. else {
  363. return __pthread_find_self();
  364. }
  365. #endif /* __ARCH_USE_MMU__ */
  366. #endif
  367. }
  368. /* Max number of times we must spin on a spinlock calling sched_yield().
  369. After MAX_SPIN_COUNT iterations, we put the calling thread to sleep. */
  370. #ifndef MAX_SPIN_COUNT
  371. #define MAX_SPIN_COUNT 50
  372. #endif
  373. /* Duration of sleep (in nanoseconds) when we can't acquire a spinlock
  374. after MAX_SPIN_COUNT iterations of sched_yield().
  375. With the 2.0 and 2.1 kernels, this MUST BE > 2ms.
  376. (Otherwise the kernel does busy-waiting for realtime threads,
  377. giving other threads no chance to run.) */
  378. #ifndef SPIN_SLEEP_DURATION
  379. #define SPIN_SLEEP_DURATION 2000001
  380. #endif
  381. /* Defined and used in libc.so. */
  382. extern int __libc_multiple_threads attribute_hidden;
  383. /* Internal global functions */
  384. void __pthread_do_exit (void *retval, char *currentframe)
  385. __attribute__ ((__noreturn__)) attribute_hidden;
  386. void __pthread_destroy_specifics(void) attribute_hidden;
  387. void __pthread_perform_cleanup(char *currentframe) attribute_hidden;
  388. int __pthread_initialize_manager(void) attribute_hidden;
  389. void __pthread_message(char * fmt, ...)
  390. __attribute__ ((__format__ (printf, 1, 2))) attribute_hidden;
  391. int __pthread_manager(void *reqfd) attribute_hidden;
  392. int __pthread_manager_event(void *reqfd) attribute_hidden;
  393. void __pthread_manager_sighandler(int sig) attribute_hidden;
  394. void __pthread_reset_main_thread(void) attribute_hidden;
  395. void __fresetlockfiles(void) attribute_hidden;
  396. void __pthread_manager_adjust_prio(int thread_prio) attribute_hidden;
  397. void __pthread_initialize_minimal (void);
  398. extern void __pthread_exit (void *retval)
  399. #if defined NOT_IN_libc && defined IS_IN_libpthread
  400. attribute_noreturn
  401. #endif
  402. ;
  403. extern int __pthread_attr_setguardsize(pthread_attr_t *__attr,
  404. size_t __guardsize) attribute_hidden;
  405. extern int __pthread_attr_getguardsize(const pthread_attr_t *__attr,
  406. size_t *__guardsize) attribute_hidden;
  407. extern int __pthread_attr_setstackaddr(pthread_attr_t *__attr,
  408. void *__stackaddr) attribute_hidden;
  409. extern int __pthread_attr_getstackaddr(const pthread_attr_t *__attr,
  410. void **__stackaddr) attribute_hidden;
  411. extern int __pthread_attr_setstacksize(pthread_attr_t *__attr,
  412. size_t __stacksize) attribute_hidden;
  413. extern int __pthread_attr_getstacksize(const pthread_attr_t *__attr,
  414. size_t *__stacksize) attribute_hidden;
  415. extern int __pthread_getconcurrency(void) attribute_hidden;
  416. extern int __pthread_setconcurrency(int __level) attribute_hidden;
  417. extern void __pthread_kill_other_threads_np(void) attribute_hidden;
  418. extern void __pthread_restart_old(pthread_descr th) attribute_hidden;
  419. extern void __pthread_suspend_old(pthread_descr self) attribute_hidden;
  420. extern int __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime) attribute_hidden;
  421. extern void __pthread_restart_new(pthread_descr th) attribute_hidden;
  422. extern void __pthread_suspend_new(pthread_descr self) attribute_hidden;
  423. extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime) attribute_hidden;
  424. extern void __pthread_wait_for_restart_signal(pthread_descr self) attribute_hidden;
  425. /* Global pointers to old or new suspend functions */
  426. extern void (*__pthread_restart)(pthread_descr) attribute_hidden;
  427. extern void (*__pthread_suspend)(pthread_descr) attribute_hidden;
  428. #if defined NOT_IN_libc && defined IS_IN_libpthread
  429. extern __typeof(pthread_mutex_init) __pthread_mutex_init attribute_hidden;
  430. extern __typeof(pthread_mutex_destroy) __pthread_mutex_destroy attribute_hidden;
  431. extern __typeof(pthread_mutex_lock) __pthread_mutex_lock attribute_hidden;
  432. extern __typeof(pthread_mutex_trylock) __pthread_mutex_trylock attribute_hidden;
  433. extern __typeof(pthread_mutex_unlock) __pthread_mutex_unlock attribute_hidden;
  434. #endif
  435. /* Prototypes for some of the new semaphore functions. */
  436. /*extern int __new_sem_post (sem_t * sem);*/
  437. /* TSD. */
  438. extern int __pthread_internal_tsd_set (int key, const void * pointer);
  439. extern void * __pthread_internal_tsd_get (int key);
  440. extern void ** __attribute__ ((__const__))
  441. __pthread_internal_tsd_address (int key);
  442. /* The functions called the signal events. */
  443. extern void __linuxthreads_create_event (void) attribute_hidden;
  444. extern void __linuxthreads_death_event (void) attribute_hidden;
  445. extern void __linuxthreads_reap_event (void) attribute_hidden;
  446. extern int * __libc_pthread_init (void);
  447. #endif /* internals.h */