thr_private.h revision 211742
1/* 2 * Copyright (C) 2005 Daniel M. Eischen <deischen@freebsd.org> 3 * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 4 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. 5 * 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 29 * $FreeBSD: head/lib/libthr/thread/thr_private.h 211742 2010-08-24 11:54:48Z kib $ 30 */ 31 32#ifndef _THR_PRIVATE_H 33#define _THR_PRIVATE_H 34 35/* 36 * Include files. 37 */ 38#include <sys/types.h> 39#include <sys/time.h> 40#include <sys/cdefs.h> 41#include <sys/queue.h> 42#include <sys/param.h> 43#include <sys/cpuset.h> 44#include <machine/atomic.h> 45#include <errno.h> 46#include <limits.h> 47#include <signal.h> 48#include <stddef.h> 49#include <stdio.h> 50#include <unistd.h> 51#include <ucontext.h> 52#include <sys/thr.h> 53#include <pthread.h> 54 55#define SYM_FB10(sym) __CONCAT(sym, _fb10) 56#define SYM_FBP10(sym) __CONCAT(sym, _fbp10) 57#define WEAK_REF(sym, alias) __weak_reference(sym, alias) 58#define SYM_COMPAT(sym, impl, ver) __sym_compat(sym, impl, ver) 59#define SYM_DEFAULT(sym, impl, ver) __sym_default(sym, impl, ver) 60 61#define FB10_COMPAT(func, sym) \ 62 WEAK_REF(func, SYM_FB10(sym)); \ 63 SYM_COMPAT(sym, SYM_FB10(sym), FBSD_1.0) 64 65#define FB10_COMPAT_PRIVATE(func, sym) \ 66 WEAK_REF(func, SYM_FBP10(sym)); \ 67 SYM_DEFAULT(sym, SYM_FBP10(sym), FBSDprivate_1.0) 68 69#include "pthread_md.h" 70#include "thr_umtx.h" 71#include "thread_db.h" 72 73typedef TAILQ_HEAD(pthreadlist, pthread) pthreadlist; 74typedef TAILQ_HEAD(atfork_head, pthread_atfork) atfork_head; 75TAILQ_HEAD(mutex_queue, pthread_mutex); 76 77/* Signal to do cancellation */ 78#define SIGCANCEL 32 79 80/* 81 * Kernel fatal error handler macro. 82 */ 83#define PANIC(string) _thread_exit(__FILE__,__LINE__,string) 84 85/* Output debug messages like this: */ 86#define stdout_debug(args...) _thread_printf(STDOUT_FILENO, ##args) 87#define stderr_debug(args...) _thread_printf(STDERR_FILENO, ##args) 88 89#ifdef _PTHREADS_INVARIANTS 90#define THR_ASSERT(cond, msg) do { \ 91 if (__predict_false(!(cond))) \ 92 PANIC(msg); \ 93} while (0) 94#else 95#define THR_ASSERT(cond, msg) 96#endif 97 98#ifdef PIC 99# define STATIC_LIB_REQUIRE(name) 100#else 101# define STATIC_LIB_REQUIRE(name) __asm (".globl " #name) 102#endif 103 104#define TIMESPEC_ADD(dst, src, val) \ 105 do { \ 106 (dst)->tv_sec = (src)->tv_sec + (val)->tv_sec; \ 107 (dst)->tv_nsec = (src)->tv_nsec + (val)->tv_nsec; \ 108 if ((dst)->tv_nsec >= 1000000000) { \ 109 (dst)->tv_sec++; \ 110 (dst)->tv_nsec -= 1000000000; \ 111 } \ 112 } while (0) 113 114#define TIMESPEC_SUB(dst, src, val) \ 115 do { \ 116 (dst)->tv_sec = (src)->tv_sec - (val)->tv_sec; \ 117 (dst)->tv_nsec = (src)->tv_nsec - (val)->tv_nsec; \ 118 if ((dst)->tv_nsec < 0) { \ 119 (dst)->tv_sec--; \ 120 (dst)->tv_nsec += 1000000000; \ 121 } \ 122 } while (0) 123 124struct pthread_mutex { 125 /* 126 * Lock for accesses to this structure. 127 */ 128 struct umutex m_lock; 129 enum pthread_mutextype m_type; 130 struct pthread *m_owner; 131 int m_count; 132 int m_refcount; 133 int m_spinloops; 134 int m_yieldloops; 135 /* 136 * Link for all mutexes a thread currently owns. 137 */ 138 TAILQ_ENTRY(pthread_mutex) m_qe; 139}; 140 141struct pthread_mutex_attr { 142 enum pthread_mutextype m_type; 143 int m_protocol; 144 int m_ceiling; 145}; 146 147#define PTHREAD_MUTEXATTR_STATIC_INITIALIZER \ 148 { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, MUTEX_FLAGS_PRIVATE } 149 150struct pthread_cond { 151 struct umutex c_lock; 152 struct ucond c_kerncv; 153 int c_pshared; 154 int c_clockid; 155}; 156 157struct pthread_cond_attr { 158 int c_pshared; 159 int c_clockid; 160}; 161 162struct pthread_barrier { 163 struct umutex b_lock; 164 struct ucond b_cv; 165 volatile int64_t b_cycle; 166 volatile int b_count; 167 volatile int b_waiters; 168}; 169 170struct pthread_barrierattr { 171 int pshared; 172}; 173 174struct pthread_spinlock { 175 struct umutex s_lock; 176}; 177 178/* 179 * Flags for condition variables. 180 */ 181#define COND_FLAGS_PRIVATE 0x01 182#define COND_FLAGS_INITED 0x02 183#define COND_FLAGS_BUSY 0x04 184 185/* 186 * Cleanup definitions. 187 */ 188struct pthread_cleanup { 189 struct pthread_cleanup *prev; 190 void (*routine)(void *); 191 void *routine_arg; 192 int onheap; 193}; 194 195#define THR_CLEANUP_PUSH(td, func, arg) { \ 196 struct pthread_cleanup __cup; \ 197 \ 198 __cup.routine = func; \ 199 __cup.routine_arg = arg; \ 200 __cup.onheap = 0; \ 201 __cup.prev = (td)->cleanup; \ 202 (td)->cleanup = &__cup; 203 204#define THR_CLEANUP_POP(td, exec) \ 205 (td)->cleanup = __cup.prev; \ 206 if ((exec) != 0) \ 207 __cup.routine(__cup.routine_arg); \ 208} 209 210struct pthread_atfork { 211 TAILQ_ENTRY(pthread_atfork) qe; 212 void (*prepare)(void); 213 void (*parent)(void); 214 void (*child)(void); 215}; 216 217struct pthread_attr { 218 int sched_policy; 219 int sched_inherit; 220 int prio; 221 int suspend; 222#define THR_STACK_USER 0x100 /* 0xFF reserved for <pthread.h> */ 223 int flags; 224 void *stackaddr_attr; 225 size_t stacksize_attr; 226 size_t guardsize_attr; 227 cpuset_t *cpuset; 228 size_t cpusetsize; 229}; 230 231/* 232 * Thread creation state attributes. 233 */ 234#define THR_CREATE_RUNNING 0 235#define THR_CREATE_SUSPENDED 1 236 237/* 238 * Miscellaneous definitions. 239 */ 240#define THR_STACK_DEFAULT (sizeof(void *) / 4 * 1024 * 1024) 241 242/* 243 * Maximum size of initial thread's stack. This perhaps deserves to be larger 244 * than the stacks of other threads, since many applications are likely to run 245 * almost entirely on this stack. 246 */ 247#define THR_STACK_INITIAL (THR_STACK_DEFAULT * 2) 248 249/* 250 * Define priorities returned by kernel. 251 */ 252#define THR_MIN_PRIORITY (_thr_priorities[SCHED_OTHER-1].pri_min) 253#define THR_MAX_PRIORITY (_thr_priorities[SCHED_OTHER-1].pri_max) 254#define THR_DEF_PRIORITY (_thr_priorities[SCHED_OTHER-1].pri_default) 255 256#define THR_MIN_RR_PRIORITY (_thr_priorities[SCHED_RR-1].pri_min) 257#define THR_MAX_RR_PRIORITY (_thr_priorities[SCHED_RR-1].pri_max) 258#define THR_DEF_RR_PRIORITY (_thr_priorities[SCHED_RR-1].pri_default) 259 260/* XXX The SCHED_FIFO should have same priority range as SCHED_RR */ 261#define THR_MIN_FIFO_PRIORITY (_thr_priorities[SCHED_FIFO_1].pri_min) 262#define THR_MAX_FIFO_PRIORITY (_thr_priorities[SCHED_FIFO-1].pri_max) 263#define THR_DEF_FIFO_PRIORITY (_thr_priorities[SCHED_FIFO-1].pri_default) 264 265struct pthread_prio { 266 int pri_min; 267 int pri_max; 268 int pri_default; 269}; 270 271struct pthread_rwlockattr { 272 int pshared; 273}; 274 275struct pthread_rwlock { 276 struct urwlock lock; 277 struct pthread *owner; 278}; 279 280/* 281 * Thread states. 282 */ 283enum pthread_state { 284 PS_RUNNING, 285 PS_DEAD 286}; 287 288struct pthread_specific_elem { 289 const void *data; 290 int seqno; 291}; 292 293struct pthread_key { 294 volatile int allocated; 295 int seqno; 296 void (*destructor)(void *); 297}; 298 299/* 300 * lwpid_t is 32bit but kernel thr API exports tid as long type 301 * in very earily date. 302 */ 303#define TID(thread) ((uint32_t) ((thread)->tid)) 304 305/* 306 * Thread structure. 307 */ 308struct pthread { 309 /* Kernel thread id. */ 310 long tid; 311#define TID_TERMINATED 1 312 313 /* 314 * Lock for accesses to this thread structure. 315 */ 316 struct umutex lock; 317 318 /* Internal condition variable cycle number. */ 319 uint32_t cycle; 320 321 /* How many low level locks the thread held. */ 322 int locklevel; 323 324 /* 325 * Set to non-zero when this thread has entered a critical 326 * region. We allow for recursive entries into critical regions. 327 */ 328 int critical_count; 329 330 /* Signal blocked counter. */ 331 int sigblock; 332 333 /* Queue entry for list of all threads. */ 334 TAILQ_ENTRY(pthread) tle; /* link for all threads in process */ 335 336 /* Queue entry for GC lists. */ 337 TAILQ_ENTRY(pthread) gcle; 338 339 /* Hash queue entry. */ 340 LIST_ENTRY(pthread) hle; 341 342 /* Threads reference count. */ 343 int refcount; 344 345 /* 346 * Thread start routine, argument, stack pointer and thread 347 * attributes. 348 */ 349 void *(*start_routine)(void *); 350 void *arg; 351 struct pthread_attr attr; 352 353#define SHOULD_CANCEL(thr) \ 354 ((thr)->cancel_pending && \ 355 ((thr)->cancel_point || (thr)->cancel_async) && \ 356 (thr)->cancel_enable && (thr)->cancelling == 0) 357 358 /* Cancellation is enabled */ 359 int cancel_enable; 360 361 /* Cancellation request is pending */ 362 int cancel_pending; 363 364 /* Thread is at cancellation point */ 365 int cancel_point; 366 367 /* Cancellation should be synchoronized */ 368 int cancel_defer; 369 370 /* Asynchronouse cancellation is enabled */ 371 int cancel_async; 372 373 /* Cancellation is in progress */ 374 int cancelling; 375 376 /* Thread temporary signal mask. */ 377 sigset_t sigmask; 378 379 /* Thread is in SIGCANCEL handler. */ 380 int in_sigcancel_handler; 381 382 /* New thread should unblock SIGCANCEL. */ 383 int unblock_sigcancel; 384 385 /* Force new thread to exit. */ 386 int force_exit; 387 388 /* Thread state: */ 389 enum pthread_state state; 390 391 /* 392 * Error variable used instead of errno. The function __error() 393 * returns a pointer to this. 394 */ 395 int error; 396 397 /* 398 * The joiner is the thread that is joining to this thread. The 399 * join status keeps track of a join operation to another thread. 400 */ 401 struct pthread *joiner; 402 403 /* Miscellaneous flags; only set with scheduling lock held. */ 404 int flags; 405#define THR_FLAGS_PRIVATE 0x0001 406#define THR_FLAGS_NEED_SUSPEND 0x0002 /* thread should be suspended */ 407#define THR_FLAGS_SUSPENDED 0x0004 /* thread is suspended */ 408 409 /* Thread list flags; only set with thread list lock held. */ 410 int tlflags; 411#define TLFLAGS_GC_SAFE 0x0001 /* thread safe for cleaning */ 412#define TLFLAGS_IN_TDLIST 0x0002 /* thread in all thread list */ 413#define TLFLAGS_IN_GCLIST 0x0004 /* thread in gc list */ 414#define TLFLAGS_DETACHED 0x0008 /* thread is detached */ 415 416 /* Queue of currently owned NORMAL or PRIO_INHERIT type mutexes. */ 417 struct mutex_queue mutexq; 418 419 /* Queue of all owned PRIO_PROTECT mutexes. */ 420 struct mutex_queue pp_mutexq; 421 422 void *ret; 423 struct pthread_specific_elem *specific; 424 int specific_data_count; 425 426 /* Number rwlocks rdlocks held. */ 427 int rdlock_count; 428 429 /* 430 * Current locks bitmap for rtld. */ 431 int rtld_bits; 432 433 /* Thread control block */ 434 struct tcb *tcb; 435 436 /* Cleanup handlers Link List */ 437 struct pthread_cleanup *cleanup; 438 439 /* 440 * Magic value to help recognize a valid thread structure 441 * from an invalid one: 442 */ 443#define THR_MAGIC ((u_int32_t) 0xd09ba115) 444 u_int32_t magic; 445 446 /* Enable event reporting */ 447 int report_events; 448 449 /* Event mask */ 450 int event_mask; 451 452 /* Event */ 453 td_event_msg_t event_buf; 454}; 455 456#define THR_IN_CRITICAL(thrd) \ 457 (((thrd)->locklevel > 0) || \ 458 ((thrd)->critical_count > 0)) 459 460#define THR_CRITICAL_ENTER(thrd) \ 461 (thrd)->critical_count++ 462 463#define THR_CRITICAL_LEAVE(thrd) \ 464 do { \ 465 (thrd)->critical_count--; \ 466 _thr_ast(thrd); \ 467 } while (0) 468 469#define THR_UMUTEX_TRYLOCK(thrd, lck) \ 470 _thr_umutex_trylock((lck), TID(thrd)) 471 472#define THR_UMUTEX_LOCK(thrd, lck) \ 473 _thr_umutex_lock((lck), TID(thrd)) 474 475#define THR_UMUTEX_TIMEDLOCK(thrd, lck, timo) \ 476 _thr_umutex_timedlock((lck), TID(thrd), (timo)) 477 478#define THR_UMUTEX_UNLOCK(thrd, lck) \ 479 _thr_umutex_unlock((lck), TID(thrd)) 480 481#define THR_LOCK_ACQUIRE(thrd, lck) \ 482do { \ 483 (thrd)->locklevel++; \ 484 _thr_umutex_lock(lck, TID(thrd)); \ 485} while (0) 486 487#ifdef _PTHREADS_INVARIANTS 488#define THR_ASSERT_LOCKLEVEL(thrd) \ 489do { \ 490 if (__predict_false((thrd)->locklevel <= 0)) \ 491 _thr_assert_lock_level(); \ 492} while (0) 493#else 494#define THR_ASSERT_LOCKLEVEL(thrd) 495#endif 496 497#define THR_LOCK_RELEASE(thrd, lck) \ 498do { \ 499 THR_ASSERT_LOCKLEVEL(thrd); \ 500 _thr_umutex_unlock((lck), TID(thrd)); \ 501 (thrd)->locklevel--; \ 502 _thr_ast(thrd); \ 503} while (0) 504 505#define THR_LOCK(curthrd) THR_LOCK_ACQUIRE(curthrd, &(curthrd)->lock) 506#define THR_UNLOCK(curthrd) THR_LOCK_RELEASE(curthrd, &(curthrd)->lock) 507#define THR_THREAD_LOCK(curthrd, thr) THR_LOCK_ACQUIRE(curthrd, &(thr)->lock) 508#define THR_THREAD_UNLOCK(curthrd, thr) THR_LOCK_RELEASE(curthrd, &(thr)->lock) 509 510#define THREAD_LIST_LOCK(curthrd) \ 511do { \ 512 THR_LOCK_ACQUIRE((curthrd), &_thr_list_lock); \ 513} while (0) 514 515#define THREAD_LIST_UNLOCK(curthrd) \ 516do { \ 517 THR_LOCK_RELEASE((curthrd), &_thr_list_lock); \ 518} while (0) 519 520/* 521 * Macros to insert/remove threads to the all thread list and 522 * the gc list. 523 */ 524#define THR_LIST_ADD(thrd) do { \ 525 if (((thrd)->tlflags & TLFLAGS_IN_TDLIST) == 0) { \ 526 TAILQ_INSERT_HEAD(&_thread_list, thrd, tle); \ 527 _thr_hash_add(thrd); \ 528 (thrd)->tlflags |= TLFLAGS_IN_TDLIST; \ 529 } \ 530} while (0) 531#define THR_LIST_REMOVE(thrd) do { \ 532 if (((thrd)->tlflags & TLFLAGS_IN_TDLIST) != 0) { \ 533 TAILQ_REMOVE(&_thread_list, thrd, tle); \ 534 _thr_hash_remove(thrd); \ 535 (thrd)->tlflags &= ~TLFLAGS_IN_TDLIST; \ 536 } \ 537} while (0) 538#define THR_GCLIST_ADD(thrd) do { \ 539 if (((thrd)->tlflags & TLFLAGS_IN_GCLIST) == 0) { \ 540 TAILQ_INSERT_HEAD(&_thread_gc_list, thrd, gcle);\ 541 (thrd)->tlflags |= TLFLAGS_IN_GCLIST; \ 542 _gc_count++; \ 543 } \ 544} while (0) 545#define THR_GCLIST_REMOVE(thrd) do { \ 546 if (((thrd)->tlflags & TLFLAGS_IN_GCLIST) != 0) { \ 547 TAILQ_REMOVE(&_thread_gc_list, thrd, gcle); \ 548 (thrd)->tlflags &= ~TLFLAGS_IN_GCLIST; \ 549 _gc_count--; \ 550 } \ 551} while (0) 552 553#define GC_NEEDED() (_gc_count >= 5) 554 555#define SHOULD_REPORT_EVENT(curthr, e) \ 556 (curthr->report_events && \ 557 (((curthr)->event_mask | _thread_event_mask ) & e) != 0) 558 559extern int __isthreaded; 560 561/* 562 * Global variables for the pthread kernel. 563 */ 564 565extern char *_usrstack __hidden; 566extern struct pthread *_thr_initial __hidden; 567 568/* For debugger */ 569extern int _libthr_debug; 570extern int _thread_event_mask; 571extern struct pthread *_thread_last_event; 572 573/* List of all threads: */ 574extern pthreadlist _thread_list; 575 576/* List of threads needing GC: */ 577extern pthreadlist _thread_gc_list __hidden; 578 579extern int _thread_active_threads; 580extern atfork_head _thr_atfork_list __hidden; 581extern struct umutex _thr_atfork_lock __hidden; 582 583/* Default thread attributes: */ 584extern struct pthread_attr _pthread_attr_default __hidden; 585 586/* Default mutex attributes: */ 587extern struct pthread_mutex_attr _pthread_mutexattr_default __hidden; 588 589/* Default condition variable attributes: */ 590extern struct pthread_cond_attr _pthread_condattr_default __hidden; 591 592extern struct pthread_prio _thr_priorities[] __hidden; 593 594extern pid_t _thr_pid __hidden; 595extern int _thr_is_smp __hidden; 596 597extern size_t _thr_guard_default __hidden; 598extern size_t _thr_stack_default __hidden; 599extern size_t _thr_stack_initial __hidden; 600extern int _thr_page_size __hidden; 601extern int _thr_spinloops __hidden; 602extern int _thr_yieldloops __hidden; 603 604/* Garbage thread count. */ 605extern int _gc_count __hidden; 606 607extern struct umutex _mutex_static_lock __hidden; 608extern struct umutex _cond_static_lock __hidden; 609extern struct umutex _rwlock_static_lock __hidden; 610extern struct umutex _keytable_lock __hidden; 611extern struct umutex _thr_list_lock __hidden; 612extern struct umutex _thr_event_lock __hidden; 613 614/* 615 * Function prototype definitions. 616 */ 617__BEGIN_DECLS 618int _thr_setthreaded(int) __hidden; 619int _mutex_cv_lock(pthread_mutex_t *, int count) __hidden; 620int _mutex_cv_unlock(pthread_mutex_t *, int *count) __hidden; 621int _mutex_reinit(pthread_mutex_t *) __hidden; 622void _mutex_fork(struct pthread *curthread) __hidden; 623void _libpthread_init(struct pthread *) __hidden; 624struct pthread *_thr_alloc(struct pthread *) __hidden; 625void _thread_exit(const char *, int, const char *) __hidden __dead2; 626void _thr_exit_cleanup(void) __hidden; 627int _thr_ref_add(struct pthread *, struct pthread *, int) __hidden; 628void _thr_ref_delete(struct pthread *, struct pthread *) __hidden; 629void _thr_ref_delete_unlocked(struct pthread *, struct pthread *) __hidden; 630int _thr_find_thread(struct pthread *, struct pthread *, int) __hidden; 631void _thr_rtld_init(void) __hidden; 632void _thr_rtld_fini(void) __hidden; 633int _thr_stack_alloc(struct pthread_attr *) __hidden; 634void _thr_stack_free(struct pthread_attr *) __hidden; 635void _thr_free(struct pthread *, struct pthread *) __hidden; 636void _thr_gc(struct pthread *) __hidden; 637void _thread_cleanupspecific(void) __hidden; 638void _thread_dump_info(void) __hidden; 639void _thread_printf(int, const char *, ...) __hidden; 640void _thr_spinlock_init(void) __hidden; 641void _thr_cancel_enter(struct pthread *) __hidden; 642void _thr_cancel_leave(struct pthread *) __hidden; 643void _thr_cancel_leave2(struct pthread *, int) __hidden; 644void _thr_cancel_enter_defer(struct pthread *, int) __hidden; 645void _thr_cancel_leave_defer(struct pthread *, int) __hidden; 646void _thr_testcancel(struct pthread *) __hidden; 647void _thr_signal_block(struct pthread *) __hidden; 648void _thr_signal_unblock(struct pthread *) __hidden; 649void _thr_signal_init(void) __hidden; 650void _thr_signal_deinit(void) __hidden; 651int _thr_send_sig(struct pthread *, int sig) __hidden; 652void _thr_list_init(void) __hidden; 653void _thr_hash_add(struct pthread *) __hidden; 654void _thr_hash_remove(struct pthread *) __hidden; 655struct pthread *_thr_hash_find(struct pthread *) __hidden; 656void _thr_link(struct pthread *, struct pthread *) __hidden; 657void _thr_unlink(struct pthread *, struct pthread *) __hidden; 658void _thr_suspend_check(struct pthread *) __hidden; 659void _thr_assert_lock_level(void) __hidden __dead2; 660void _thr_ast(struct pthread *) __hidden; 661void _thr_once_init(void) __hidden; 662void _thr_report_creation(struct pthread *curthread, 663 struct pthread *newthread) __hidden; 664void _thr_report_death(struct pthread *curthread) __hidden; 665int _thr_getscheduler(lwpid_t, int *, struct sched_param *) __hidden; 666int _thr_setscheduler(lwpid_t, int, const struct sched_param *) __hidden; 667int _rtp_to_schedparam(const struct rtprio *rtp, int *policy, 668 struct sched_param *param) __hidden; 669int _schedparam_to_rtp(int policy, const struct sched_param *param, 670 struct rtprio *rtp) __hidden; 671void _thread_bp_create(void); 672void _thread_bp_death(void); 673int _sched_yield(void); 674void _thr_sem_prefork(void); 675void _thr_sem_postfork(void); 676void _thr_sem_child_postfork(void); 677 678void _pthread_cleanup_push(void (*)(void *), void *); 679void _pthread_cleanup_pop(int); 680 681/* #include <fcntl.h> */ 682#ifdef _SYS_FCNTL_H_ 683int __sys_fcntl(int, int, ...); 684int __sys_open(const char *, int, ...); 685int __sys_openat(int, const char *, int, ...); 686#endif 687 688/* #include <signal.h> */ 689#ifdef _SIGNAL_H_ 690int __sys_kill(pid_t, int); 691int __sys_sigaction(int, const struct sigaction *, struct sigaction *); 692int __sys_sigpending(sigset_t *); 693int __sys_sigprocmask(int, const sigset_t *, sigset_t *); 694int __sys_sigsuspend(const sigset_t *); 695int __sys_sigreturn(ucontext_t *); 696int __sys_sigaltstack(const struct sigaltstack *, struct sigaltstack *); 697int __sys_sigwait(const sigset_t *, int *); 698int __sys_sigtimedwait(const sigset_t *, siginfo_t *, 699 const struct timespec *); 700int __sys_sigwaitinfo(const sigset_t *set, siginfo_t *info); 701#endif 702 703/* #include <time.h> */ 704#ifdef _TIME_H_ 705int __sys_nanosleep(const struct timespec *, struct timespec *); 706#endif 707 708/* #include <sys/ucontext.h> */ 709#ifdef _SYS_UCONTEXT_H_ 710int __sys_setcontext(const ucontext_t *ucp); 711int __sys_swapcontext(ucontext_t *oucp, const ucontext_t *ucp); 712#endif 713 714/* #include <unistd.h> */ 715#ifdef _UNISTD_H_ 716int __sys_close(int); 717int __sys_fork(void); 718pid_t __sys_getpid(void); 719ssize_t __sys_read(int, void *, size_t); 720ssize_t __sys_write(int, const void *, size_t); 721void __sys_exit(int); 722#endif 723 724int _umtx_op_err(void *, int op, u_long, void *, void *) __hidden; 725 726static inline int 727_thr_isthreaded(void) 728{ 729 return (__isthreaded != 0); 730} 731 732static inline int 733_thr_is_inited(void) 734{ 735 return (_thr_initial != NULL); 736} 737 738static inline void 739_thr_check_init(void) 740{ 741 if (_thr_initial == NULL) 742 _libpthread_init(NULL); 743} 744 745struct dl_phdr_info; 746void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info); 747 748__END_DECLS 749 750#endif /* !_THR_PRIVATE_H */ 751