17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*cb620785Sraf * Common Development and Distribution License (the "License"). 6*cb620785Sraf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*cb620785Sraf 227c478bd9Sstevel@tonic-gate /* 23*cb620785Sraf * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _THREAD_H 287c478bd9Sstevel@tonic-gate #define _THREAD_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * thread.h: 347c478bd9Sstevel@tonic-gate * definitions needed to use the thread interface except synchronization. 357c478bd9Sstevel@tonic-gate * use <synch.h> for thread synchronization. 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifndef _ASM 397c478bd9Sstevel@tonic-gate #include <sys/signal.h> 407c478bd9Sstevel@tonic-gate #include <sys/time.h> 417c478bd9Sstevel@tonic-gate #include <synch.h> 427c478bd9Sstevel@tonic-gate #endif /* _ASM */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #ifdef __cplusplus 457c478bd9Sstevel@tonic-gate extern "C" { 467c478bd9Sstevel@tonic-gate #endif 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #ifndef _ASM 497c478bd9Sstevel@tonic-gate typedef unsigned int thread_t; 507c478bd9Sstevel@tonic-gate typedef unsigned int thread_key_t; 517c478bd9Sstevel@tonic-gate #endif /* _ASM */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #ifndef _ASM 547c478bd9Sstevel@tonic-gate #ifdef __STDC__ 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate extern int thr_create(void *, size_t, void *(*)(void *), void *, long, 577c478bd9Sstevel@tonic-gate thread_t *); 587c478bd9Sstevel@tonic-gate extern int thr_join(thread_t, thread_t *, void **); 597c478bd9Sstevel@tonic-gate extern int thr_setconcurrency(int); 607c478bd9Sstevel@tonic-gate extern int thr_getconcurrency(void); 617c478bd9Sstevel@tonic-gate extern void thr_exit(void *) __NORETURN; 627c478bd9Sstevel@tonic-gate extern thread_t thr_self(void); 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * the definition of thr_sigsetmask() is not strict ansi-c since sigset_t is 667c478bd9Sstevel@tonic-gate * not in the strict ansi-c name space. Hence, include the prototype for 677c478bd9Sstevel@tonic-gate * thr_sigsetmask() only if strict ansi-c conformance is not turned on. 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) 707c478bd9Sstevel@tonic-gate extern int thr_sigsetmask(int, const sigset_t *, sigset_t *); 717c478bd9Sstevel@tonic-gate #endif 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate /* 747c478bd9Sstevel@tonic-gate * the definition of thr_stksegment() is not strict ansi-c since stack_t is 757c478bd9Sstevel@tonic-gate * not in the strict ansi-c name space. Hence, include the prototype for 767c478bd9Sstevel@tonic-gate * thr_stksegment() only if strict ansi-c conformance is not turned on. 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__) 797c478bd9Sstevel@tonic-gate extern int thr_stksegment(stack_t *); 807c478bd9Sstevel@tonic-gate #endif 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate extern int thr_main(void); 837c478bd9Sstevel@tonic-gate extern int thr_kill(thread_t, int); 847c478bd9Sstevel@tonic-gate extern int thr_suspend(thread_t); 857c478bd9Sstevel@tonic-gate extern int thr_continue(thread_t); 867c478bd9Sstevel@tonic-gate extern void thr_yield(void); 877c478bd9Sstevel@tonic-gate extern int thr_setprio(thread_t, int); 887c478bd9Sstevel@tonic-gate extern int thr_getprio(thread_t, int *); 897c478bd9Sstevel@tonic-gate extern int thr_keycreate(thread_key_t *, void(*)(void *)); 90*cb620785Sraf extern int thr_keycreate_once(thread_key_t *, void(*)(void *)); 917c478bd9Sstevel@tonic-gate extern int thr_setspecific(thread_key_t, void *); 927c478bd9Sstevel@tonic-gate extern int thr_getspecific(thread_key_t, void **); 937c478bd9Sstevel@tonic-gate extern size_t thr_min_stack(void); 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #else /* __STDC */ 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate extern int thr_create(); 987c478bd9Sstevel@tonic-gate extern int thr_join(); 997c478bd9Sstevel@tonic-gate extern int thr_setconcurrency(); 1007c478bd9Sstevel@tonic-gate extern int thr_getconcurrency(); 1017c478bd9Sstevel@tonic-gate extern void thr_exit(); 1027c478bd9Sstevel@tonic-gate extern thread_t thr_self(); 1037c478bd9Sstevel@tonic-gate extern int thr_sigsetmask(); 1047c478bd9Sstevel@tonic-gate extern int thr_stksegment(); 1057c478bd9Sstevel@tonic-gate extern int thr_main(); 1067c478bd9Sstevel@tonic-gate extern int thr_kill(); 1077c478bd9Sstevel@tonic-gate extern int thr_suspend(); 1087c478bd9Sstevel@tonic-gate extern int thr_continue(); 1097c478bd9Sstevel@tonic-gate extern void thr_yield(); 1107c478bd9Sstevel@tonic-gate extern int thr_setprio(); 1117c478bd9Sstevel@tonic-gate extern int thr_getprio(); 1127c478bd9Sstevel@tonic-gate extern int thr_keycreate(); 113*cb620785Sraf extern int thr_keycreate_once(); 1147c478bd9Sstevel@tonic-gate extern int thr_setspecific(); 1157c478bd9Sstevel@tonic-gate extern int thr_getspecific(); 1167c478bd9Sstevel@tonic-gate extern size_t thr_min_stack(); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate #endif /* __STDC */ 1197c478bd9Sstevel@tonic-gate #endif /* _ASM */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #define THR_MIN_STACK thr_min_stack() 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * thread flags (one word bit mask) 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * POSIX.1c Note: 1277c478bd9Sstevel@tonic-gate * THR_BOUND is defined same as PTHREAD_SCOPE_SYSTEM in <pthread.h> 1287c478bd9Sstevel@tonic-gate * THR_DETACHED is defined same as PTHREAD_CREATE_DETACHED in <pthread.h> 1297c478bd9Sstevel@tonic-gate * Any changes in these definitions should be reflected in <pthread.h> 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate #define THR_BOUND 0x00000001 /* = PTHREAD_SCOPE_SYSTEM */ 1327c478bd9Sstevel@tonic-gate #define THR_NEW_LWP 0x00000002 1337c478bd9Sstevel@tonic-gate #define THR_DETACHED 0x00000040 /* = PTHREAD_CREATE_DETACHED */ 1347c478bd9Sstevel@tonic-gate #define THR_SUSPENDED 0x00000080 1357c478bd9Sstevel@tonic-gate #define THR_DAEMON 0x00000100 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 138*cb620785Sraf * The key to be created by thr_keycreate_once() 139*cb620785Sraf * must be statically initialized with THR_ONCE_KEY. 140*cb620785Sraf * This must be the same as PTHREAD_ONCE_KEY_NP in <pthread.h> 141*cb620785Sraf */ 142*cb620785Sraf #define THR_ONCE_KEY (thread_key_t)(-1) 143*cb620785Sraf 144*cb620785Sraf /* 1457c478bd9Sstevel@tonic-gate * The available register states returned by thr_getstate(). 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate #define TRS_VALID 0 1487c478bd9Sstevel@tonic-gate #define TRS_NONVOLATILE 1 1497c478bd9Sstevel@tonic-gate #define TRS_LWPID 2 1507c478bd9Sstevel@tonic-gate #define TRS_INVALID 3 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate #endif 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate #endif /* _THREAD_H */ 157