1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _THREAD_H 28*7c478bd9Sstevel@tonic-gate #define _THREAD_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * thread.h: 34*7c478bd9Sstevel@tonic-gate * definitions needed to use the thread interface except synchronization. 35*7c478bd9Sstevel@tonic-gate * use <synch.h> for thread synchronization. 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifndef _ASM 39*7c478bd9Sstevel@tonic-gate #include <sys/signal.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 41*7c478bd9Sstevel@tonic-gate #include <synch.h> 42*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 45*7c478bd9Sstevel@tonic-gate extern "C" { 46*7c478bd9Sstevel@tonic-gate #endif 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate #ifndef _ASM 49*7c478bd9Sstevel@tonic-gate typedef unsigned int thread_t; 50*7c478bd9Sstevel@tonic-gate typedef unsigned int thread_key_t; 51*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate #ifndef _ASM 54*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate extern int thr_create(void *, size_t, void *(*)(void *), void *, long, 57*7c478bd9Sstevel@tonic-gate thread_t *); 58*7c478bd9Sstevel@tonic-gate extern int thr_join(thread_t, thread_t *, void **); 59*7c478bd9Sstevel@tonic-gate extern int thr_setconcurrency(int); 60*7c478bd9Sstevel@tonic-gate extern int thr_getconcurrency(void); 61*7c478bd9Sstevel@tonic-gate extern void thr_exit(void *) __NORETURN; 62*7c478bd9Sstevel@tonic-gate extern thread_t thr_self(void); 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * the definition of thr_sigsetmask() is not strict ansi-c since sigset_t is 66*7c478bd9Sstevel@tonic-gate * not in the strict ansi-c name space. Hence, include the prototype for 67*7c478bd9Sstevel@tonic-gate * thr_sigsetmask() only if strict ansi-c conformance is not turned on. 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) 70*7c478bd9Sstevel@tonic-gate extern int thr_sigsetmask(int, const sigset_t *, sigset_t *); 71*7c478bd9Sstevel@tonic-gate #endif 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate /* 74*7c478bd9Sstevel@tonic-gate * the definition of thr_stksegment() is not strict ansi-c since stack_t is 75*7c478bd9Sstevel@tonic-gate * not in the strict ansi-c name space. Hence, include the prototype for 76*7c478bd9Sstevel@tonic-gate * thr_stksegment() only if strict ansi-c conformance is not turned on. 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) 79*7c478bd9Sstevel@tonic-gate extern int thr_stksegment(stack_t *); 80*7c478bd9Sstevel@tonic-gate #endif 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate extern int thr_main(void); 83*7c478bd9Sstevel@tonic-gate extern int thr_kill(thread_t, int); 84*7c478bd9Sstevel@tonic-gate extern int thr_suspend(thread_t); 85*7c478bd9Sstevel@tonic-gate extern int thr_continue(thread_t); 86*7c478bd9Sstevel@tonic-gate extern void thr_yield(void); 87*7c478bd9Sstevel@tonic-gate extern int thr_setprio(thread_t, int); 88*7c478bd9Sstevel@tonic-gate extern int thr_getprio(thread_t, int *); 89*7c478bd9Sstevel@tonic-gate extern int thr_keycreate(thread_key_t *, void(*)(void *)); 90*7c478bd9Sstevel@tonic-gate extern int thr_setspecific(thread_key_t, void *); 91*7c478bd9Sstevel@tonic-gate extern int thr_getspecific(thread_key_t, void **); 92*7c478bd9Sstevel@tonic-gate extern size_t thr_min_stack(void); 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate #else /* __STDC */ 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate extern int thr_create(); 97*7c478bd9Sstevel@tonic-gate extern int thr_join(); 98*7c478bd9Sstevel@tonic-gate extern int thr_setconcurrency(); 99*7c478bd9Sstevel@tonic-gate extern int thr_getconcurrency(); 100*7c478bd9Sstevel@tonic-gate extern void thr_exit(); 101*7c478bd9Sstevel@tonic-gate extern thread_t thr_self(); 102*7c478bd9Sstevel@tonic-gate extern int thr_sigsetmask(); 103*7c478bd9Sstevel@tonic-gate extern int thr_stksegment(); 104*7c478bd9Sstevel@tonic-gate extern int thr_main(); 105*7c478bd9Sstevel@tonic-gate extern int thr_kill(); 106*7c478bd9Sstevel@tonic-gate extern int thr_suspend(); 107*7c478bd9Sstevel@tonic-gate extern int thr_continue(); 108*7c478bd9Sstevel@tonic-gate extern void thr_yield(); 109*7c478bd9Sstevel@tonic-gate extern int thr_setprio(); 110*7c478bd9Sstevel@tonic-gate extern int thr_getprio(); 111*7c478bd9Sstevel@tonic-gate extern int thr_keycreate(); 112*7c478bd9Sstevel@tonic-gate extern int thr_setspecific(); 113*7c478bd9Sstevel@tonic-gate extern int thr_getspecific(); 114*7c478bd9Sstevel@tonic-gate extern size_t thr_min_stack(); 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #endif /* __STDC */ 117*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate #define THR_MIN_STACK thr_min_stack() 120*7c478bd9Sstevel@tonic-gate /* 121*7c478bd9Sstevel@tonic-gate * thread flags (one word bit mask) 122*7c478bd9Sstevel@tonic-gate */ 123*7c478bd9Sstevel@tonic-gate /* 124*7c478bd9Sstevel@tonic-gate * POSIX.1c Note: 125*7c478bd9Sstevel@tonic-gate * THR_BOUND is defined same as PTHREAD_SCOPE_SYSTEM in <pthread.h> 126*7c478bd9Sstevel@tonic-gate * THR_DETACHED is defined same as PTHREAD_CREATE_DETACHED in <pthread.h> 127*7c478bd9Sstevel@tonic-gate * Any changes in these definitions should be reflected in <pthread.h> 128*7c478bd9Sstevel@tonic-gate */ 129*7c478bd9Sstevel@tonic-gate #define THR_BOUND 0x00000001 /* = PTHREAD_SCOPE_SYSTEM */ 130*7c478bd9Sstevel@tonic-gate #define THR_NEW_LWP 0x00000002 131*7c478bd9Sstevel@tonic-gate #define THR_DETACHED 0x00000040 /* = PTHREAD_CREATE_DETACHED */ 132*7c478bd9Sstevel@tonic-gate #define THR_SUSPENDED 0x00000080 133*7c478bd9Sstevel@tonic-gate #define THR_DAEMON 0x00000100 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate /* 136*7c478bd9Sstevel@tonic-gate * The available register states returned by thr_getstate(). 137*7c478bd9Sstevel@tonic-gate */ 138*7c478bd9Sstevel@tonic-gate #define TRS_VALID 0 139*7c478bd9Sstevel@tonic-gate #define TRS_NONVOLATILE 1 140*7c478bd9Sstevel@tonic-gate #define TRS_LWPID 2 141*7c478bd9Sstevel@tonic-gate #define TRS_INVALID 3 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 144*7c478bd9Sstevel@tonic-gate } 145*7c478bd9Sstevel@tonic-gate #endif 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate #endif /* _THREAD_H */ 148