1/* 2** GNU Pth - The GNU Portable Threads 3** Copyright (c) 1999-2006 Ralf S. Engelschall <rse@engelschall.com> 4** 5** This file is part of GNU Pth, a non-preemptive thread scheduling 6** library which can be found at http://www.gnu.org/software/pth/. 7** 8** This library is free software; you can redistribute it and/or 9** modify it under the terms of the GNU Lesser General Public 10** License as published by the Free Software Foundation; either 11** version 2.1 of the License, or (at your option) any later version. 12** 13** This library is distributed in the hope that it will be useful, 14** but WITHOUT ANY WARRANTY; without even the implied warranty of 15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16** Lesser General Public License for more details. 17** 18** You should have received a copy of the GNU Lesser General Public 19** License along with this library; if not, write to the Free Software 20** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 21** USA, or contact Ralf S. Engelschall <rse@engelschall.com>. 22** 23** pth.h: Pth public API definitions 24*/ 25 /* ``What you see is all you get.'' 26 -- Brian Kernighan */ 27#ifndef _PTH_H_ 28#define _PTH_H_ 29 30 /* the library version */ 31#ifndef PTH_VERSION_STR 32#define PTH_VERSION_STR "@PTH_VERSION_STR@" 33#endif 34#ifndef PTH_VERSION_HEX 35#define PTH_VERSION_HEX @PTH_VERSION_HEX@ 36#endif 37#ifndef PTH_VERSION 38#define PTH_VERSION PTH_VERSION_HEX 39#endif 40 41 /* essential headers */ 42#include <sys/types.h> /* for ssize_t, off_t */ 43#include <time.h> /* for struct timespec */ 44#include <sys/time.h> /* for struct timeval */ 45#include <sys/socket.h> /* for sockaddr */ 46#include <sys/signal.h> /* for sigset_t */ 47@EXTRA_INCLUDE_SYS_SELECT_H@ 48 49 /* fallbacks for essential typedefs */ 50#ifndef _PTHREAD_PRIVATE 51@FALLBACK_PID_T@ 52@FALLBACK_SIZE_T@ 53@FALLBACK_SSIZE_T@ 54/* 55 * CYGWIN pulls a trick on the preprocessor for the socklen_t type. 56 * Until AC_CHECK_TYPEDEF macro in aclocal.m4 is aware of this, this 57 * is a work-around to disable the warning 58 */ 59#ifdef __CYGWIN__ 60#undef socklen_t 61#endif 62@FALLBACK_SOCKLEN_T@ 63@FALLBACK_OFF_T@ 64@FALLBACK_SIG_ATOMIC_T@ 65@FALLBACK_NFDS_T@ 66#endif /* !_PTHREAD_PRIVATE */ 67 68 /* extra structure definitions */ 69struct timeval; 70struct timespec; 71 72 /* essential values */ 73#ifndef FALSE 74#define FALSE (0) 75#endif 76#ifndef TRUE 77#define TRUE (!FALSE) 78#endif 79#ifndef NUL 80#define NUL '\0' 81#endif 82#ifndef NULL 83#define NULL (void *)0 84#endif 85 86 /* bitmask generation */ 87#define _BIT(n) (1<<(n)) 88 89 /* C++ support */ 90#ifdef __cplusplus 91#define BEGIN_DECLARATION extern "C" { 92#define END_DECLARATION } 93#else 94#define BEGIN_DECLARATION /*nop*/ 95#define END_DECLARATION /*nop*/ 96#endif 97 98 /* check if the user requests a bigger FD_SETSIZE than we can handle */ 99#if defined(FD_SETSIZE) 100#if FD_SETSIZE > @PTH_FDSETSIZE@ 101#error "FD_SETSIZE is larger than what GNU Pth can handle." 102#endif 103#endif 104 105BEGIN_DECLARATION 106 107 /* some global constants */ 108#define PTH_KEY_MAX 256 109#define PTH_ATFORK_MAX 128 110#define PTH_DESTRUCTOR_ITERATIONS 4 111 112 /* system call mapping support type (soft variant can be overridden) */ 113#define PTH_SYSCALL_HARD @PTH_SYSCALL_HARD@ 114#ifndef PTH_SYSCALL_SOFT 115#define PTH_SYSCALL_SOFT @PTH_SYSCALL_SOFT@ 116#endif 117 118 /* queries for pth_ctrl() */ 119#define PTH_CTRL_GETAVLOAD _BIT(1) 120#define PTH_CTRL_GETPRIO _BIT(2) 121#define PTH_CTRL_GETNAME _BIT(3) 122#define PTH_CTRL_GETTHREADS_NEW _BIT(4) 123#define PTH_CTRL_GETTHREADS_READY _BIT(5) 124#define PTH_CTRL_GETTHREADS_RUNNING _BIT(6) 125#define PTH_CTRL_GETTHREADS_WAITING _BIT(7) 126#define PTH_CTRL_GETTHREADS_SUSPENDED _BIT(8) 127#define PTH_CTRL_GETTHREADS_DEAD _BIT(9) 128#define PTH_CTRL_GETTHREADS (PTH_CTRL_GETTHREADS_NEW|\ 129 PTH_CTRL_GETTHREADS_READY|\ 130 PTH_CTRL_GETTHREADS_RUNNING|\ 131 PTH_CTRL_GETTHREADS_WAITING|\ 132 PTH_CTRL_GETTHREADS_SUSPENDED|\ 133 PTH_CTRL_GETTHREADS_DEAD) 134#define PTH_CTRL_DUMPSTATE _BIT(10) 135#define PTH_CTRL_FAVOURNEW _BIT(11) 136 137 /* the time value structure */ 138typedef struct timeval pth_time_t; 139 140 /* the unique thread id/handle */ 141typedef struct pth_st *pth_t; 142struct pth_st; 143 144 /* thread states */ 145typedef enum pth_state_en { 146 PTH_STATE_SCHEDULER = 0, /* the special scheduler thread only */ 147 PTH_STATE_NEW, /* spawned, but still not dispatched */ 148 PTH_STATE_READY, /* ready, waiting to be dispatched */ 149 PTH_STATE_WAITING, /* suspended, waiting until event occurred */ 150 PTH_STATE_DEAD /* terminated, waiting to be joined */ 151} pth_state_t; 152 153 /* thread priority values */ 154#define PTH_PRIO_MAX +5 155#define PTH_PRIO_STD 0 156#define PTH_PRIO_MIN -5 157 158 /* the thread attribute structure */ 159typedef struct pth_attr_st *pth_attr_t; 160struct pth_attr_st; 161 162 /* attribute set/get commands for pth_attr_{get,set}() */ 163enum { 164 PTH_ATTR_PRIO, /* RW [int] priority of thread */ 165 PTH_ATTR_NAME, /* RW [char *] name of thread */ 166 PTH_ATTR_JOINABLE, /* RW [int] thread detachment type */ 167 PTH_ATTR_CANCEL_STATE, /* RW [unsigned int] thread cancellation state */ 168 PTH_ATTR_STACK_SIZE, /* RW [unsigned int] stack size */ 169 PTH_ATTR_STACK_ADDR, /* RW [char *] stack lower address */ 170 PTH_ATTR_DISPATCHES, /* RO [int] total number of thread dispatches */ 171 PTH_ATTR_TIME_SPAWN, /* RO [pth_time_t] time thread was spawned */ 172 PTH_ATTR_TIME_LAST, /* RO [pth_time_t] time thread was last dispatched */ 173 PTH_ATTR_TIME_RAN, /* RO [pth_time_t] time thread was running */ 174 PTH_ATTR_START_FUNC, /* RO [void *(*)(void *)] thread start function */ 175 PTH_ATTR_START_ARG, /* RO [void *] thread start argument */ 176 PTH_ATTR_STATE, /* RO [pth_state_t] scheduling state */ 177 PTH_ATTR_EVENTS, /* RO [pth_event_t] events the thread is waiting for */ 178 PTH_ATTR_BOUND /* RO [int] whether object is bound to thread */ 179}; 180 181 /* default thread attribute */ 182#define PTH_ATTR_DEFAULT (pth_attr_t)(0) 183 184 /* the event structure */ 185typedef struct pth_event_st *pth_event_t; 186struct pth_event_st; 187 188 /* event subject classes */ 189#define PTH_EVENT_FD _BIT(1) 190#define PTH_EVENT_SELECT _BIT(2) 191#define PTH_EVENT_SIGS _BIT(3) 192#define PTH_EVENT_TIME _BIT(4) 193#define PTH_EVENT_MSG _BIT(5) 194#define PTH_EVENT_MUTEX _BIT(6) 195#define PTH_EVENT_COND _BIT(7) 196#define PTH_EVENT_TID _BIT(8) 197#define PTH_EVENT_FUNC _BIT(9) 198#define PTH_EVENT_SEM _BIT(10) 199#define PTH_EVENT_RTIME (PTH_EVENT_TIME | PTH_TIME_REL) 200 201 /* event occurange restrictions */ 202#define PTH_UNTIL_OCCURRED _BIT(11) 203#define PTH_UNTIL_FD_READABLE _BIT(12) 204#define PTH_UNTIL_FD_WRITEABLE _BIT(13) 205#define PTH_UNTIL_FD_EXCEPTION _BIT(14) 206#define PTH_UNTIL_TID_NEW _BIT(15) 207#define PTH_UNTIL_TID_READY _BIT(16) 208#define PTH_UNTIL_TID_WAITING _BIT(17) 209#define PTH_UNTIL_TID_DEAD _BIT(18) 210#define PTH_UNTIL_DECREMENT _BIT(19) 211#define PTH_UNTIL_COUNT _BIT(23) 212#define PTH_TIME_REL _BIT(24) 213 214 /* event structure handling modes */ 215#define PTH_MODE_REUSE _BIT(20) 216#define PTH_MODE_CHAIN _BIT(21) 217#define PTH_MODE_STATIC _BIT(22) 218 219 /* event deallocation types */ 220enum { PTH_FREE_THIS, PTH_FREE_ALL }; 221 222 /* event walking directions */ 223#define PTH_WALK_NEXT _BIT(1) 224#define PTH_WALK_PREV _BIT(2) 225 226 /* event status codes */ 227typedef enum { 228 PTH_STATUS_PENDING, 229 PTH_STATUS_OCCURRED, 230 PTH_STATUS_FAILED 231} pth_status_t; 232 233 /* the key type and init value */ 234typedef int pth_key_t; 235#define PTH_KEY_INIT (-1) 236 237 /* the once structure and init value */ 238typedef int pth_once_t; 239#define PTH_ONCE_INIT FALSE 240 241 /* general ring structure */ 242typedef struct pth_ringnode_st pth_ringnode_t; 243struct pth_ringnode_st { 244 pth_ringnode_t *rn_next; 245 pth_ringnode_t *rn_prev; 246}; 247typedef struct pth_ring_st pth_ring_t; 248struct pth_ring_st { 249 pth_ringnode_t *r_hook; 250 unsigned int r_nodes; 251}; 252#define PTH_RING_INIT { NULL } 253 254 /* cancellation values */ 255#define PTH_CANCEL_ENABLE _BIT(0) 256#define PTH_CANCEL_DISABLE _BIT(1) 257#define PTH_CANCEL_ASYNCHRONOUS _BIT(2) 258#define PTH_CANCEL_DEFERRED _BIT(3) 259#define PTH_CANCEL_DEFAULT (PTH_CANCEL_ENABLE|PTH_CANCEL_DEFERRED) 260#define PTH_CANCELED ((void *)-1) 261 262 /* mutex values */ 263#define PTH_MUTEX_INITIALIZED _BIT(0) 264#define PTH_MUTEX_LOCKED _BIT(1) 265#define PTH_MUTEX_INIT { {NULL, NULL}, PTH_MUTEX_INITIALIZED, NULL, 0 } 266 267 /* read-write lock values */ 268enum { PTH_RWLOCK_RD, PTH_RWLOCK_RW }; 269#define PTH_RWLOCK_INITIALIZED _BIT(0) 270#define PTH_RWLOCK_INIT { PTH_RWLOCK_INITIALIZED, PTH_RWLOCK_RD, 0, \ 271 PTH_MUTEX_INIT, PTH_MUTEX_INIT } 272 273 /* condition variable values */ 274#define PTH_COND_INITIALIZED _BIT(0) 275#define PTH_COND_SIGNALED _BIT(1) 276#define PTH_COND_BROADCAST _BIT(2) 277#define PTH_COND_HANDLED _BIT(3) 278#define PTH_COND_INIT { PTH_COND_INITIALIZED, 0 } 279 280 /* semaphore variable values */ 281#define PTH_SEM_INITIALIZED _BIT(0) 282#define PTH_SEM_INIT { PTH_SEM_INITIALIZED, 0 } 283 284 /* barrier variable values */ 285#define PTH_BARRIER_INITIALIZED _BIT(0) 286#define PTH_BARRIER_INIT(threshold) { PTH_BARRIER_INITIALIZED, \ 287 (threshold), (threshold), FALSE, \ 288 PTH_COND_INIT, PTH_MUTEX_INIT } 289#define PTH_BARRIER_HEADLIGHT (-1) 290#define PTH_BARRIER_TAILLIGHT (-2) 291 292 /* the message port structure */ 293typedef struct pth_msgport_st *pth_msgport_t; 294struct pth_msgport_st; 295 296 /* the message structure */ 297typedef struct pth_message_st pth_message_t; 298struct pth_message_st { /* not hidden to allow inclusion */ 299 pth_ringnode_t m_node; 300 pth_msgport_t m_replyport; 301 unsigned int m_size; 302 void *m_data; 303}; 304 305 /* the mutex structure */ 306typedef struct pth_mutex_st pth_mutex_t; 307struct pth_mutex_st { /* not hidden to avoid destructor */ 308 pth_ringnode_t mx_node; 309 int mx_state; 310 pth_t mx_owner; 311 unsigned long mx_count; 312}; 313 314 /* the read-write lock structure */ 315typedef struct pth_rwlock_st pth_rwlock_t; 316struct pth_rwlock_st { /* not hidden to avoid destructor */ 317 int rw_state; 318 unsigned int rw_mode; 319 unsigned long rw_readers; 320 pth_mutex_t rw_mutex_rd; 321 pth_mutex_t rw_mutex_rw; 322}; 323 324 /* the condition variable structure */ 325typedef struct pth_cond_st pth_cond_t; 326struct pth_cond_st { /* not hidden to avoid destructor */ 327 unsigned long cn_state; 328 unsigned int cn_waiters; 329}; 330 331 /* the semaphore variable structure */ 332typedef struct pth_sem_st pth_sem_t; 333struct pth_sem_st { /* not hidden to avoid destructor */ 334 unsigned long sem_state; 335 unsigned int sem_count; 336}; 337 338 /* the barrier variable structure */ 339typedef struct pth_barrier_st pth_barrier_t; 340struct pth_barrier_st { /* not hidden to avoid destructor */ 341 unsigned long br_state; 342 int br_threshold; 343 int br_count; 344 int br_cycle; 345 pth_cond_t br_cond; 346 pth_mutex_t br_mutex; 347}; 348 349 /* the user-space context structure */ 350typedef struct pth_uctx_st *pth_uctx_t; 351struct pth_uctx_st; 352 353 /* filedescriptor blocking modes */ 354enum { 355 PTH_FDMODE_ERROR = -1, 356 PTH_FDMODE_POLL = 0, 357 PTH_FDMODE_BLOCK, 358 PTH_FDMODE_NONBLOCK 359}; 360 361 /* optionally fake poll(2) data structure and options */ 362#ifndef _PTHREAD_PRIVATE 363#define PTH_FAKE_POLL @PTH_FAKE_POLL@ 364#if !(PTH_FAKE_POLL) 365/* use vendor poll(2) environment */ 366#ifndef _XOPEN_SOURCE 367#define _XOPEN_SOURCE 368#define _XOPEN_SOURCE_set 369#endif 370#include <poll.h> 371#ifdef _XOPEN_SOURCE_set 372#undef _XOPEN_SOURCE_set 373#undef _XOPEN_SOURCE 374#endif 375#ifndef POLLRDNORM 376#define POLLRDNORM POLLIN 377#endif 378#ifndef POLLRDBAND 379#define POLLRDBAND POLLIN 380#endif 381#ifndef POLLWRNORM 382#define POLLWRNORM POLLOUT 383#endif 384#ifndef POLLWRBAND 385#define POLLWRBAND POLLOUT 386#endif 387#ifndef INFTIM 388#define INFTIM (-1) 389#endif 390#else 391/* fake a poll(2) environment */ 392#define POLLIN 0x0001 /* any readable data available */ 393#define POLLPRI 0x0002 /* OOB/Urgent readable data */ 394#define POLLOUT 0x0004 /* file descriptor is writeable */ 395#define POLLERR 0x0008 /* some poll error occurred */ 396#define POLLHUP 0x0010 /* file descriptor was "hung up" */ 397#define POLLNVAL 0x0020 /* requested events "invalid" */ 398#define POLLRDNORM POLLIN 399#define POLLRDBAND POLLIN 400#define POLLWRNORM POLLOUT 401#define POLLWRBAND POLLOUT 402#ifndef INFTIM 403#define INFTIM (-1) /* poll infinite */ 404#endif 405struct pollfd { 406 int fd; /* which file descriptor to poll */ 407 short events; /* events we are interested in */ 408 short revents; /* events found on return */ 409}; 410#endif 411#endif /* !_PTHREAD_PRIVATE */ 412 413 /* optionally fake readv(2)/writev(2) data structure and options */ 414#ifndef _PTHREAD_PRIVATE 415#define PTH_FAKE_RWV @PTH_FAKE_RWV@ 416#if !(PTH_FAKE_RWV) 417/* use vendor readv(2)/writev(2) environment */ 418#include <sys/uio.h> 419#ifndef UIO_MAXIOV 420#define UIO_MAXIOV 1024 421#endif 422#else 423/* fake a readv(2)/writev(2) environment */ 424struct iovec { 425 void *iov_base; /* memory base address */ 426 size_t iov_len; /* memory chunk length */ 427}; 428#ifndef UIO_MAXIOV 429#define UIO_MAXIOV 1024 430#endif 431#endif 432#endif /* !_PTHREAD_PRIVATE */ 433 434 /* extension support */ 435#define PTH_EXT_SFIO @PTH_EXT_SFIO@ 436 437 /* Sfio extension support */ 438#if @PTH_EXT_SFIO@ 439#include <sfio.h> 440#else 441typedef void *Sfdisc_t; 442#endif 443 444 /* global functions */ 445extern int pth_init(void); 446extern int pth_kill(void); 447extern long pth_ctrl(unsigned long, ...); 448extern long pth_version(void); 449 450 /* thread attribute functions */ 451extern pth_attr_t pth_attr_of(pth_t); 452extern pth_attr_t pth_attr_new(void); 453extern int pth_attr_init(pth_attr_t); 454extern int pth_attr_set(pth_attr_t, int, ...); 455extern int pth_attr_get(pth_attr_t, int, ...); 456extern int pth_attr_destroy(pth_attr_t); 457 458 /* thread functions */ 459extern pth_t pth_spawn(pth_attr_t, void *(*)(void *), void *); 460extern int pth_once(pth_once_t *, void (*)(void *), void *); 461extern pth_t pth_self(void); 462extern int pth_suspend(pth_t); 463extern int pth_resume(pth_t); 464extern int pth_yield(pth_t); 465extern int pth_nap(pth_time_t); 466extern int pth_wait(pth_event_t); 467extern int pth_cancel(pth_t); 468extern int pth_abort(pth_t); 469extern int pth_raise(pth_t, int); 470extern int pth_join(pth_t, void **); 471extern void pth_exit(void *); 472 473 /* utility functions */ 474extern int pth_fdmode(int, int); 475extern pth_time_t pth_time(long, long); 476extern pth_time_t pth_timeout(long, long); 477extern void pth_int_time(struct timespec *); 478 479 /* cancellation functions */ 480extern void pth_cancel_state(int, int *); 481extern void pth_cancel_point(void); 482 483 /* event functions */ 484extern pth_event_t pth_event(unsigned long, ...); 485extern unsigned long pth_event_typeof(pth_event_t); 486extern int pth_event_extract(pth_event_t ev, ...); 487extern pth_event_t pth_event_concat(pth_event_t, ...); 488extern pth_event_t pth_event_isolate(pth_event_t); 489extern pth_event_t pth_event_walk(pth_event_t, unsigned int); 490extern pth_status_t pth_event_status(pth_event_t); 491extern int pth_event_free(pth_event_t, int); 492 493 /* key-based storage functions */ 494extern int pth_key_create(pth_key_t *, void (*)(void *)); 495extern int pth_key_delete(pth_key_t); 496extern int pth_key_setdata(pth_key_t, const void *); 497extern void *pth_key_getdata(pth_key_t); 498 499 /* message port functions */ 500extern pth_msgport_t pth_msgport_create(const char *); 501extern void pth_msgport_destroy(pth_msgport_t); 502extern pth_msgport_t pth_msgport_find(const char *); 503extern int pth_msgport_pending(pth_msgport_t); 504extern int pth_msgport_put(pth_msgport_t, pth_message_t *); 505extern pth_message_t *pth_msgport_get(pth_msgport_t); 506extern int pth_msgport_reply(pth_message_t *); 507 508 /* cleanup handler functions */ 509extern int pth_cleanup_push(void (*)(void *), void *); 510extern int pth_cleanup_pop(int); 511 512 /* process forking functions */ 513extern int pth_atfork_push(void (*)(void *), void (*)(void *), void (*)(void *), void *); 514extern int pth_atfork_pop(void); 515extern pid_t pth_fork(void); 516 517 /* synchronization functions */ 518extern int pth_mutex_init(pth_mutex_t *); 519extern int pth_mutex_acquire(pth_mutex_t *, int, pth_event_t); 520extern int pth_mutex_release(pth_mutex_t *); 521extern int pth_rwlock_init(pth_rwlock_t *); 522extern int pth_rwlock_acquire(pth_rwlock_t *, int, int, pth_event_t); 523extern int pth_rwlock_release(pth_rwlock_t *); 524extern int pth_cond_init(pth_cond_t *); 525extern int pth_cond_await(pth_cond_t *, pth_mutex_t *, pth_event_t); 526extern int pth_cond_notify(pth_cond_t *, int); 527extern int pth_barrier_init(pth_barrier_t *, int); 528extern int pth_barrier_reach(pth_barrier_t *); 529extern int pth_sem_init(pth_sem_t *); 530extern int pth_sem_dec(pth_sem_t *); 531extern int pth_sem_dec_value(pth_sem_t *, unsigned); 532extern int pth_sem_inc(pth_sem_t *, int); 533extern int pth_sem_inc_value(pth_sem_t *, unsigned, int); 534extern int pth_sem_set_value(pth_sem_t *, unsigned); 535extern int pth_sem_get_value(pth_sem_t *, unsigned *); 536 537 /* user-space context functions */ 538extern int pth_uctx_create(pth_uctx_t *); 539extern int pth_uctx_make(pth_uctx_t, char *, size_t, const sigset_t *, void (*)(void *), void *, pth_uctx_t); 540extern int pth_uctx_switch(pth_uctx_t, pth_uctx_t); 541extern int pth_uctx_destroy(pth_uctx_t); 542 543 /* extension functions */ 544extern Sfdisc_t *pth_sfiodisc(void); 545 546 /* generalized variants of replacement functions */ 547extern int pth_sigwait_ev(const sigset_t *, int *, pth_event_t); 548extern int pth_connect_ev(int, const struct sockaddr *, socklen_t, pth_event_t); 549extern int pth_accept_ev(int, struct sockaddr *, socklen_t *, pth_event_t); 550extern int pth_select_ev(int, fd_set *, fd_set *, fd_set *, struct timeval *, pth_event_t); 551extern int pth_poll_ev(struct pollfd *, nfds_t, int, pth_event_t); 552extern ssize_t pth_read_ev(int, void *, size_t, pth_event_t); 553extern ssize_t pth_write_ev(int, const void *, size_t, pth_event_t); 554extern ssize_t pth_readv_ev(int, const struct iovec *, int, pth_event_t); 555extern ssize_t pth_writev_ev(int, const struct iovec *, int, pth_event_t); 556extern ssize_t pth_recv_ev(int, void *, size_t, int, pth_event_t); 557extern ssize_t pth_send_ev(int, const void *, size_t, int, pth_event_t); 558extern ssize_t pth_recvfrom_ev(int, void *, size_t, int, struct sockaddr *, socklen_t *, pth_event_t); 559extern ssize_t pth_sendto_ev(int, const void *, size_t, int, const struct sockaddr *, socklen_t, pth_event_t); 560 561 /* standard replacement functions */ 562extern int pth_nanosleep(const struct timespec *, struct timespec *); 563extern int pth_usleep(unsigned int); 564extern unsigned int pth_sleep(unsigned int); 565extern pid_t pth_waitpid(pid_t, int *, int); 566extern int pth_system(const char *); 567extern int pth_sigmask(int, const sigset_t *, sigset_t *); 568extern int pth_sigwait(const sigset_t *, int *); 569extern int pth_connect(int, const struct sockaddr *, socklen_t); 570extern int pth_accept(int, struct sockaddr *, socklen_t *); 571extern int pth_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 572extern int pth_pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *); 573extern int pth_poll(struct pollfd *, nfds_t, int); 574extern ssize_t pth_read(int, void *, size_t); 575extern ssize_t pth_write(int, const void *, size_t); 576extern ssize_t pth_readv(int, const struct iovec *, int); 577extern ssize_t pth_writev(int, const struct iovec *, int); 578extern ssize_t pth_recv(int, void *, size_t, int); 579extern ssize_t pth_send(int, const void *, size_t, int); 580extern ssize_t pth_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *); 581extern ssize_t pth_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t); 582extern ssize_t pth_pread(int, void *, size_t, off_t); 583extern ssize_t pth_pwrite(int, const void *, size_t, off_t); 584 585END_DECLARATION 586 587 /* soft system call mapping support */ 588#if PTH_SYSCALL_SOFT && !defined(_PTH_PRIVATE) 589#define fork pth_fork 590#define waitpid pth_waitpid 591#define system pth_system 592#define nanosleep pth_nanosleep 593#define usleep pth_usleep 594#define sleep pth_sleep 595#define sigprocmask pth_sigmask 596#define sigwait pth_sigwait 597#define select pth_select 598#define pselect pth_pselect 599#define poll pth_poll 600#define connect pth_connect 601#define accept pth_accept 602#define read pth_read 603#define write pth_write 604#define readv pth_readv 605#define writev pth_writev 606#define recv pth_recv 607#define send pth_send 608#define recvfrom pth_recvfrom 609#define sendto pth_sendto 610#define pread pth_pread 611#define pwrite pth_pwrite 612#endif 613 614 /* backward compatibility (Pth < 1.5.0) */ 615#define pth_event_occurred(ev) \ 616 ( pth_event_status(ev) == PTH_STATUS_OCCURRED \ 617 || pth_event_status(ev) == PTH_STATUS_FAILED ) 618 619#endif /* _PTH_H_ */ 620 621