Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  24  * Copyright 2016 Joyent, Inc.
  25  *
  26  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  27  * Use is subject to license terms.
  28  */
  29 
  30 #ifndef _PTHREAD_H
  31 #define _PTHREAD_H
  32 
  33 #include <sys/feature_tests.h>
  34 
  35 #ifndef _ASM
  36 #include <sys/types.h>
  37 #include <time.h>
  38 #include <sched.h>
  39 #endif  /* _ASM */
  40 
  41 #ifdef  __cplusplus
  42 extern "C" {
  43 #endif
  44 


 122 #define PTHREAD_CANCEL_DISABLE          0x01
 123 #define PTHREAD_CANCEL_DEFERRED         0x00
 124 #define PTHREAD_CANCEL_ASYNCHRONOUS     0x02
 125 #define PTHREAD_CANCELED                (void *)-19
 126 
 127 /* pthread_once related values */
 128 #define PTHREAD_ONCE_NOTDONE    0
 129 #define PTHREAD_ONCE_DONE       1
 130 #define PTHREAD_ONCE_INIT       { {0, 0, 0, PTHREAD_ONCE_NOTDONE} }
 131 
 132 /*
 133  * The key to be created by pthread_key_create_once_np()
 134  * must be statically initialized with PTHREAD_ONCE_KEY_NP.
 135  * This must be the same as THR_ONCE_KEY in <thread.h>
 136  */
 137 #define PTHREAD_ONCE_KEY_NP     (pthread_key_t)(-1)
 138 
 139 /* barriers */
 140 #define PTHREAD_BARRIER_SERIAL_THREAD   -2
 141 



 142 #ifndef _ASM
 143 
 144 /*
 145  * cancellation cleanup structure
 146  */
 147 typedef struct _cleanup {
 148         uintptr_t       pthread_cleanup_pad[4];
 149 } _cleanup_t;
 150 
 151 void    __pthread_cleanup_push(void (*)(void *), void *, caddr_t, _cleanup_t *);
 152 void    __pthread_cleanup_pop(int, _cleanup_t *);
 153 caddr_t _getfp(void);
 154 
 155 #if __cplusplus
 156 extern "C" {
 157 #endif
 158 
 159 typedef void (*_Voidfp)(void*); /* pointer to extern "C" function */
 160 
 161 #if __cplusplus


 192 extern int pthread_attr_getstacksize(const pthread_attr_t *_RESTRICT_KYWD,
 193                 size_t *_RESTRICT_KYWD);
 194 extern int pthread_attr_setstackaddr(pthread_attr_t *, void *);
 195 extern int pthread_attr_getstackaddr(const pthread_attr_t *_RESTRICT_KYWD,
 196                 void **_RESTRICT_KYWD);
 197 extern int pthread_attr_setdetachstate(pthread_attr_t *, int);
 198 extern int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
 199 extern int pthread_attr_setscope(pthread_attr_t *, int);
 200 extern int pthread_attr_getscope(const pthread_attr_t *_RESTRICT_KYWD,
 201         int *_RESTRICT_KYWD);
 202 extern int pthread_attr_setinheritsched(pthread_attr_t *, int);
 203 extern int pthread_attr_getinheritsched(const pthread_attr_t *_RESTRICT_KYWD,
 204         int *_RESTRICT_KYWD);
 205 extern int pthread_attr_setschedpolicy(pthread_attr_t *, int);
 206 extern int pthread_attr_getschedpolicy(const pthread_attr_t *_RESTRICT_KYWD,
 207         int *_RESTRICT_KYWD);
 208 extern int pthread_attr_setschedparam(pthread_attr_t *_RESTRICT_KYWD,
 209                 const struct sched_param *_RESTRICT_KYWD);
 210 extern int pthread_attr_getschedparam(const pthread_attr_t *_RESTRICT_KYWD,
 211                 struct sched_param *_RESTRICT_KYWD);




 212 extern int pthread_create(pthread_t *_RESTRICT_KYWD,
 213                 const pthread_attr_t *_RESTRICT_KYWD, void * (*)(void *),
 214                 void *_RESTRICT_KYWD);
 215 extern int pthread_once(pthread_once_t *, void (*)(void));
 216 extern int pthread_join(pthread_t, void **);
 217 extern int pthread_detach(pthread_t);
 218 extern void pthread_exit(void *) __NORETURN;
 219 extern int pthread_cancel(pthread_t);
 220 extern int pthread_setschedparam(pthread_t, int, const struct sched_param *);
 221 extern int pthread_getschedparam(pthread_t, int *_RESTRICT_KYWD,
 222                 struct sched_param *_RESTRICT_KYWD);
 223 extern int pthread_setschedprio(pthread_t, int);
 224 extern int pthread_setcancelstate(int, int *);
 225 extern int pthread_setcanceltype(int, int *);
 226 extern void pthread_testcancel(void);
 227 extern int pthread_equal(pthread_t, pthread_t);
 228 extern int pthread_key_create(pthread_key_t *, void (*)(void *));
 229 extern int pthread_key_create_once_np(pthread_key_t *, void (*)(void *));
 230 extern int pthread_key_delete(pthread_key_t);
 231 extern int pthread_setspecific(pthread_key_t, const void *);
 232 extern void *pthread_getspecific(pthread_key_t);
 233 extern pthread_t pthread_self(void);


 234 
 235 /*
 236  * function prototypes - synchronization related calls
 237  */
 238 extern int pthread_mutexattr_init(pthread_mutexattr_t *);
 239 extern int pthread_mutexattr_destroy(pthread_mutexattr_t *);
 240 extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
 241 extern int pthread_mutexattr_getpshared(
 242         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 243 extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
 244 extern int pthread_mutexattr_getprotocol(
 245         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 246 extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
 247 extern int pthread_mutexattr_getprioceiling(
 248         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 249 extern int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
 250 extern int pthread_mutexattr_getrobust(
 251         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 252 extern int pthread_mutex_init(pthread_mutex_t *_RESTRICT_KYWD,
 253         const pthread_mutexattr_t *_RESTRICT_KYWD);




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  24  * Copyright 2018 Joyent, Inc.
  25  *
  26  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  27  * Use is subject to license terms.
  28  */
  29 
  30 #ifndef _PTHREAD_H
  31 #define _PTHREAD_H
  32 
  33 #include <sys/feature_tests.h>
  34 
  35 #ifndef _ASM
  36 #include <sys/types.h>
  37 #include <time.h>
  38 #include <sched.h>
  39 #endif  /* _ASM */
  40 
  41 #ifdef  __cplusplus
  42 extern "C" {
  43 #endif
  44 


 122 #define PTHREAD_CANCEL_DISABLE          0x01
 123 #define PTHREAD_CANCEL_DEFERRED         0x00
 124 #define PTHREAD_CANCEL_ASYNCHRONOUS     0x02
 125 #define PTHREAD_CANCELED                (void *)-19
 126 
 127 /* pthread_once related values */
 128 #define PTHREAD_ONCE_NOTDONE    0
 129 #define PTHREAD_ONCE_DONE       1
 130 #define PTHREAD_ONCE_INIT       { {0, 0, 0, PTHREAD_ONCE_NOTDONE} }
 131 
 132 /*
 133  * The key to be created by pthread_key_create_once_np()
 134  * must be statically initialized with PTHREAD_ONCE_KEY_NP.
 135  * This must be the same as THR_ONCE_KEY in <thread.h>
 136  */
 137 #define PTHREAD_ONCE_KEY_NP     (pthread_key_t)(-1)
 138 
 139 /* barriers */
 140 #define PTHREAD_BARRIER_SERIAL_THREAD   -2
 141 
 142 /* For pthread_{get,set}name_np(). */
 143 #define PTHREAD_MAX_NAMELEN_NP (32)
 144 
 145 #ifndef _ASM
 146 
 147 /*
 148  * cancellation cleanup structure
 149  */
 150 typedef struct _cleanup {
 151         uintptr_t       pthread_cleanup_pad[4];
 152 } _cleanup_t;
 153 
 154 void    __pthread_cleanup_push(void (*)(void *), void *, caddr_t, _cleanup_t *);
 155 void    __pthread_cleanup_pop(int, _cleanup_t *);
 156 caddr_t _getfp(void);
 157 
 158 #if __cplusplus
 159 extern "C" {
 160 #endif
 161 
 162 typedef void (*_Voidfp)(void*); /* pointer to extern "C" function */
 163 
 164 #if __cplusplus


 195 extern int pthread_attr_getstacksize(const pthread_attr_t *_RESTRICT_KYWD,
 196                 size_t *_RESTRICT_KYWD);
 197 extern int pthread_attr_setstackaddr(pthread_attr_t *, void *);
 198 extern int pthread_attr_getstackaddr(const pthread_attr_t *_RESTRICT_KYWD,
 199                 void **_RESTRICT_KYWD);
 200 extern int pthread_attr_setdetachstate(pthread_attr_t *, int);
 201 extern int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
 202 extern int pthread_attr_setscope(pthread_attr_t *, int);
 203 extern int pthread_attr_getscope(const pthread_attr_t *_RESTRICT_KYWD,
 204         int *_RESTRICT_KYWD);
 205 extern int pthread_attr_setinheritsched(pthread_attr_t *, int);
 206 extern int pthread_attr_getinheritsched(const pthread_attr_t *_RESTRICT_KYWD,
 207         int *_RESTRICT_KYWD);
 208 extern int pthread_attr_setschedpolicy(pthread_attr_t *, int);
 209 extern int pthread_attr_getschedpolicy(const pthread_attr_t *_RESTRICT_KYWD,
 210         int *_RESTRICT_KYWD);
 211 extern int pthread_attr_setschedparam(pthread_attr_t *_RESTRICT_KYWD,
 212                 const struct sched_param *_RESTRICT_KYWD);
 213 extern int pthread_attr_getschedparam(const pthread_attr_t *_RESTRICT_KYWD,
 214                 struct sched_param *_RESTRICT_KYWD);
 215 extern int pthread_attr_setname_np(pthread_attr_t *_RESTRICT_KYWD,
 216     const char *_RESTRICT_KYWD);
 217 extern int pthread_attr_getname_np(pthread_attr_t *_RESTRICT_KYWD,
 218     char *_RESTRICT_KYWD, size_t);
 219 extern int pthread_create(pthread_t *_RESTRICT_KYWD,
 220                 const pthread_attr_t *_RESTRICT_KYWD, void * (*)(void *),
 221                 void *_RESTRICT_KYWD);
 222 extern int pthread_once(pthread_once_t *, void (*)(void));
 223 extern int pthread_join(pthread_t, void **);
 224 extern int pthread_detach(pthread_t);
 225 extern void pthread_exit(void *) __NORETURN;
 226 extern int pthread_cancel(pthread_t);
 227 extern int pthread_setschedparam(pthread_t, int, const struct sched_param *);
 228 extern int pthread_getschedparam(pthread_t, int *_RESTRICT_KYWD,
 229                 struct sched_param *_RESTRICT_KYWD);
 230 extern int pthread_setschedprio(pthread_t, int);
 231 extern int pthread_setcancelstate(int, int *);
 232 extern int pthread_setcanceltype(int, int *);
 233 extern void pthread_testcancel(void);
 234 extern int pthread_equal(pthread_t, pthread_t);
 235 extern int pthread_key_create(pthread_key_t *, void (*)(void *));
 236 extern int pthread_key_create_once_np(pthread_key_t *, void (*)(void *));
 237 extern int pthread_key_delete(pthread_key_t);
 238 extern int pthread_setspecific(pthread_key_t, const void *);
 239 extern void *pthread_getspecific(pthread_key_t);
 240 extern pthread_t pthread_self(void);
 241 extern int pthread_setname_np(pthread_t, const char *);
 242 extern int pthread_getname_np(pthread_t, char *, size_t);
 243 
 244 /*
 245  * function prototypes - synchronization related calls
 246  */
 247 extern int pthread_mutexattr_init(pthread_mutexattr_t *);
 248 extern int pthread_mutexattr_destroy(pthread_mutexattr_t *);
 249 extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
 250 extern int pthread_mutexattr_getpshared(
 251         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 252 extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
 253 extern int pthread_mutexattr_getprotocol(
 254         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 255 extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
 256 extern int pthread_mutexattr_getprioceiling(
 257         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 258 extern int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
 259 extern int pthread_mutexattr_getrobust(
 260         const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 261 extern int pthread_mutex_init(pthread_mutex_t *_RESTRICT_KYWD,
 262         const pthread_mutexattr_t *_RESTRICT_KYWD);