📄 pthread.h.in
字号:
/*** GNU Pth - The GNU Portable Threads** Copyright (c) 1999-2004 Ralf S. Engelschall <rse@engelschall.com>**** This file is part of GNU Pth, a non-preemptive thread scheduling** library which can be found at http://www.gnu.org/software/pth/.**** This library is free software; you can redistribute it and/or** modify it under the terms of the GNU Lesser General Public** License as published by the Free Software Foundation; either** version 2.1 of the License, or (at your option) any later version.**** This library is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU** Lesser General Public License for more details.**** You should have received a copy of the GNU Lesser General Public** License along with this library; if not, write to the Free Software** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307** USA, or contact Ralf S. Engelschall <rse@engelschall.com>.**** pthread.h: POSIX Thread ("Pthread") API for Pth*/ /* ``Only those who attempt the absurd can achieve the impossible.'' -- Unknown */#ifndef _PTH_PTHREAD_H_#define _PTH_PTHREAD_H_/***** BOOTSTRAPPING***//* * Prevent system includes from implicitly including * possibly existing vendor Pthread headers */#define PTHREAD#define PTHREAD_H#define _PTHREAD_T#define _PTHREAD_H#define _PTHREAD_H_#define PTHREAD_INCLUDED#define _PTHREAD_INCLUDED#define SYS_PTHREAD_H#define _SYS_PTHREAD_H#define _SYS_PTHREAD_H_#define SYS_PTHREAD_INCLUDED#define _SYS_PTHREAD_INCLUDED#define BITS_PTHREADTYPES_H#define _BITS_PTHREADTYPES_H#define _BITS_PTHREADTYPES_H_#define _BITS_SIGTHREAD_H/* * Special adjustments */#if defined(__hpux)#define _PTHREADS_DRAFT4#endif/* * Check if the user requests a bigger FD_SETSIZE than we can handle */#if defined(FD_SETSIZE)#if FD_SETSIZE > @PTH_FDSETSIZE@#error "FD_SETSIZE is larger than what GNU Pth can handle."#endif#endif/* * Protect namespace, because possibly existing vendor Pthread stuff * would certainly conflict with our defintions of pthread*_t. */#define pthread_t __vendor_pthread_t#define pthread_attr_t __vendor_pthread_attr_t#define pthread_key_t __vendor_pthread_key_t#define pthread_once_t __vendor_pthread_once_t#define pthread_mutex_t __vendor_pthread_mutex_t#define pthread_mutexattr_t __vendor_pthread_mutexattr_t#define pthread_cond_t __vendor_pthread_cond_t#define pthread_condattr_t __vendor_pthread_condattr_t#define pthread_rwlock_t __vendor_pthread_rwlock_t#define pthread_rwlockattr_t __vendor_pthread_rwlockattr_t#define sched_param __vendor_sched_param/* * Allow structs containing pthread*_t in vendor headers * to have some type definitions */#if 0typedef int __vendor_pthread_t;typedef int __vendor_pthread_attr_t;typedef int __vendor_pthread_key_t;typedef int __vendor_pthread_once_t;typedef int __vendor_pthread_mutex_t;typedef int __vendor_pthread_mutexattr_t;typedef int __vendor_pthread_cond_t;typedef int __vendor_pthread_condattr_t;typedef int __vendor_pthread_rwlock_t;typedef int __vendor_pthread_rwlockattr_t;typedef int __vendor_sched_param;#endif/* * Include essential vendor headers */#include <sys/types.h> /* for ssize_t */#include <sys/time.h> /* for struct timeval */#include <sys/socket.h> /* for sockaddr */#include <sys/signal.h> /* for sigset_t */#include <time.h> /* for struct timespec */#include <unistd.h> /* for off_t */@EXTRA_INCLUDE_SYS_SELECT_H@/* * Unprotect namespace, so we can define our own variants now */#undef pthread_t#undef pthread_attr_t#undef pthread_key_t#undef pthread_once_t#undef pthread_mutex_t#undef pthread_mutexattr_t#undef pthread_cond_t#undef pthread_condattr_t#undef pthread_rwlock_t#undef pthread_rwlockattr_t#undef sched_param/* * Cleanup more Pthread namespace from vendor values */#undef _POSIX_THREADS#undef _POSIX_THREAD_ATTR_STACKADDR#undef _POSIX_THREAD_ATTR_STACKSIZE#undef _POSIX_THREAD_PRIORITY_SCHEDULING#undef _POSIX_THREAD_PRIO_INHERIT#undef _POSIX_THREAD_PRIO_PROTECT#undef _POSIX_THREAD_PROCESS_SHARED#undef _POSIX_THREAD_SAFE_FUNCTIONS#undef PTHREAD_DESTRUCTOR_ITERATIONS#undef PTHREAD_KEYS_MAX#undef PTHREAD_STACK_MIN#undef PTHREAD_THREADS_MAX#undef PTHREAD_CREATE_DETACHED#undef PTHREAD_CREATE_JOINABLE#undef PTHREAD_SCOPE_SYSTEM#undef PTHREAD_SCOPE_PROCESS#undef PTHREAD_INHERIT_SCHED#undef PTHREAD_EXPLICIT_SCHED#undef PTHREAD_CANCEL_ENABLE#undef PTHREAD_CANCEL_DISABLE#undef PTHREAD_CANCEL_ASYNCHRONOUS#undef PTHREAD_CANCEL_DEFERRED#undef PTHREAD_CANCELED#undef PTHREAD_PROCESS_PRIVATE#undef PTHREAD_PROCESS_SHARED#undef PTHREAD_ONCE_INIT#undef PTHREAD_MUTEX_DEFAULT#undef PTHREAD_MUTEX_RECURSIVE#undef PTHREAD_MUTEX_NORMAL#undef PTHREAD_MUTEX_ERRORCHECK#undef PTHREAD_MUTEX_INITIALIZER#undef PTHREAD_COND_INITIALIZER#undef PTHREAD_RWLOCK_INITIALIZER/* * Cleanup special adjustments */#if defined(__hpux)#undef _PTHREADS_DRAFT4#endif/***** API DEFINITION***/#ifdef __cplusplusextern "C" {#endif/* * Fallbacks for essential typedefs */@FALLBACK_PID_T@@FALLBACK_SIZE_T@@FALLBACK_SSIZE_T@@FALLBACK_SOCKLEN_T@@FALLBACK_OFF_T@@FALLBACK_NFDS_T@/* * Extra structure definitions */struct timeval;struct timespec;/* * GNU Pth indentification */#define _POSIX_THREAD_IS_GNU_PTH @PTH_VERSION_HEX@/* * Compile time symbolic feature macros for portability * specification to applications using pthreads */#define _POSIX_THREADS#define _POSIX_THREAD_ATTR_STACKADDR#define _POSIX_THREAD_ATTR_STACKSIZE#undef _POSIX_THREAD_PRIORITY_SCHEDULING#undef _POSIX_THREAD_PRIO_INHERIT#undef _POSIX_THREAD_PRIO_PROTECT#undef _POSIX_THREAD_PROCESS_SHARED#undef _POSIX_THREAD_SAFE_FUNCTIONS/* * System call mapping support type * (soft variant can be overridden) */#define _POSIX_THREAD_SYSCALL_HARD @PTH_SYSCALL_HARD@#ifndef _POSIX_THREAD_SYSCALL_SOFT#define _POSIX_THREAD_SYSCALL_SOFT @PTH_SYSCALL_SOFT@#endif/* * Run-time invariant values */#define PTHREAD_DESTRUCTOR_ITERATIONS 4#define PTHREAD_KEYS_MAX 256#define PTHREAD_STACK_MIN 8192#define PTHREAD_THREADS_MAX 10000 /* actually yet no restriction *//* * Flags for threads and thread attributes. */#define PTHREAD_CREATE_DETACHED 0x01#define PTHREAD_CREATE_JOINABLE 0x02#define PTHREAD_SCOPE_SYSTEM 0x03#define PTHREAD_SCOPE_PROCESS 0x04#define PTHREAD_INHERIT_SCHED 0x05#define PTHREAD_EXPLICIT_SCHED 0x06/* * Values for cancellation */#define PTHREAD_CANCEL_ENABLE 0x01#define PTHREAD_CANCEL_DISABLE 0x02#define PTHREAD_CANCEL_ASYNCHRONOUS 0x01#define PTHREAD_CANCEL_DEFERRED 0x02#define PTHREAD_CANCELED ((void *)-1)/* * Flags for mutex priority attributes */#define PTHREAD_PRIO_INHERIT 0x00#define PTHREAD_PRIO_NONE 0x01#define PTHREAD_PRIO_PROTECT 0x02/* * Flags for read/write lock attributes */#define PTHREAD_PROCESS_PRIVATE 0x00#define PTHREAD_PROCESS_SHARED 0x01/* * Forward structure definitions. * These are mostly opaque to the application. */struct pthread_st;struct pthread_attr_st;struct pthread_cond_st;struct pthread_mutex_st;struct pthread_rwlock_st;struct sched_param;/* * Primitive system data type definitions required by P1003.1c */typedef struct pthread_st *pthread_t;typedef struct pthread_attr_st *pthread_attr_t;typedef int pthread_key_t;typedef int pthread_once_t;typedef int pthread_mutexattr_t;typedef struct pthread_mutex_st *pthread_mutex_t;typedef int pthread_condattr_t;typedef struct pthread_cond_st *pthread_cond_t;typedef int pthread_rwlockattr_t;typedef struct pthread_rwlock_st *pthread_rwlock_t;/* * Once support.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -