10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * 3*3857Sstevel * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved. 4*3857Sstevel * Use is subject to license terms. 50Sstevel@tonic-gate * 60Sstevel@tonic-gate */ 70Sstevel@tonic-gate 80Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 90Sstevel@tonic-gate 100Sstevel@tonic-gate /* lthread.h - ldap threads header file */ 110Sstevel@tonic-gate 120Sstevel@tonic-gate #ifndef _LTHREAD_H 130Sstevel@tonic-gate #define _LTHREAD_H 140Sstevel@tonic-gate 150Sstevel@tonic-gate #if defined( THREAD_SUNOS4_LWP ) 160Sstevel@tonic-gate /*********************************** 170Sstevel@tonic-gate * * 180Sstevel@tonic-gate * thread definitions for sunos4 * 190Sstevel@tonic-gate * * 200Sstevel@tonic-gate ***********************************/ 210Sstevel@tonic-gate 220Sstevel@tonic-gate #define _THREAD 230Sstevel@tonic-gate 240Sstevel@tonic-gate #include <lwp/lwp.h> 250Sstevel@tonic-gate #include <lwp/stackdep.h> 260Sstevel@tonic-gate 270Sstevel@tonic-gate typedef void *(*VFP)(); 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* thread attributes and thread type */ 300Sstevel@tonic-gate typedef int pthread_attr_t; 310Sstevel@tonic-gate typedef thread_t pthread_t; 320Sstevel@tonic-gate 330Sstevel@tonic-gate /* default attr states */ 340Sstevel@tonic-gate #define pthread_mutexattr_default NULL 350Sstevel@tonic-gate #define pthread_condattr_default NULL 360Sstevel@tonic-gate 370Sstevel@tonic-gate /* thread state - joinable or not */ 380Sstevel@tonic-gate #define PTHREAD_CREATE_JOINABLE 0 390Sstevel@tonic-gate #define PTHREAD_CREATE_DETACHED 1 400Sstevel@tonic-gate /* thread scope - who is in scheduling pool */ 410Sstevel@tonic-gate #define PTHREAD_SCOPE_PROCESS 0 420Sstevel@tonic-gate #define PTHREAD_SCOPE_SYSTEM 1 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* mutex attributes and mutex type */ 450Sstevel@tonic-gate typedef int pthread_mutexattr_t; 460Sstevel@tonic-gate typedef mon_t pthread_mutex_t; 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* condition variable attributes and condition variable type */ 490Sstevel@tonic-gate typedef int pthread_condattr_t; 500Sstevel@tonic-gate typedef struct lwpcv { 510Sstevel@tonic-gate int lcv_created; 520Sstevel@tonic-gate cv_t lcv_cv; 530Sstevel@tonic-gate } pthread_cond_t; 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* mutex and condition variable scope - process or system */ 560Sstevel@tonic-gate #define PTHREAD_SHARE_PRIVATE 0 570Sstevel@tonic-gate #define PTHREAD_SHARE_PROCESS 1 580Sstevel@tonic-gate 590Sstevel@tonic-gate #else /* end sunos4 */ 600Sstevel@tonic-gate 610Sstevel@tonic-gate #if defined( THREAD_SUNOS5_LWP ) 620Sstevel@tonic-gate /*********************************** 630Sstevel@tonic-gate * * 640Sstevel@tonic-gate * thread definitions for sunos5 * 650Sstevel@tonic-gate * * 660Sstevel@tonic-gate ***********************************/ 670Sstevel@tonic-gate 680Sstevel@tonic-gate #define _THREAD 690Sstevel@tonic-gate 700Sstevel@tonic-gate #include <thread.h> 710Sstevel@tonic-gate #include <synch.h> 720Sstevel@tonic-gate 730Sstevel@tonic-gate typedef void *(*VFP)(); 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* sunos5 threads are preemptive */ 760Sstevel@tonic-gate #define PTHREAD_PREEMPTIVE 1 770Sstevel@tonic-gate 780Sstevel@tonic-gate #ifndef _PTHREAD_H 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* thread attributes and thread type */ 810Sstevel@tonic-gate typedef int pthread_attr_t; 820Sstevel@tonic-gate typedef thread_t pthread_t; 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* thread state - joinable or not */ 850Sstevel@tonic-gate #define PTHREAD_CREATE_JOINABLE 0 860Sstevel@tonic-gate #define PTHREAD_CREATE_DETACHED THR_DETACHED 870Sstevel@tonic-gate /* thread scope - who is in scheduling pool */ 880Sstevel@tonic-gate #define PTHREAD_SCOPE_PROCESS 0 890Sstevel@tonic-gate #define PTHREAD_SCOPE_SYSTEM THR_BOUND 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* mutex attributes and mutex type */ 920Sstevel@tonic-gate typedef int pthread_mutexattr_t; 930Sstevel@tonic-gate typedef mutex_t pthread_mutex_t; 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* condition variable attributes and condition variable type */ 960Sstevel@tonic-gate typedef int pthread_condattr_t; 970Sstevel@tonic-gate typedef cond_t pthread_cond_t; 980Sstevel@tonic-gate 990Sstevel@tonic-gate #endif /* _PTHREAD_H */ 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate /* default attr states */ 1020Sstevel@tonic-gate #define pthread_mutexattr_default NULL 1030Sstevel@tonic-gate #define pthread_condattr_default NULL 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* mutex and condition variable scope - process or system */ 1060Sstevel@tonic-gate #define PTHREAD_SHARE_PRIVATE USYNC_THREAD 1070Sstevel@tonic-gate #define PTHREAD_SHARE_PROCESS USYNC_PROCESS 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate #else /* end sunos5 */ 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate #if defined( THREAD_MIT_PTHREADS ) 1120Sstevel@tonic-gate /*********************************** 1130Sstevel@tonic-gate * * 1140Sstevel@tonic-gate * definitions for mit pthreads * 1150Sstevel@tonic-gate * * 1160Sstevel@tonic-gate ***********************************/ 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate #define _THREAD 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate #include <pthread.h> 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate #else /* end mit pthreads */ 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate #if defined( THREAD_DCE_PTHREADS ) 1250Sstevel@tonic-gate /*********************************** 1260Sstevel@tonic-gate * * 1270Sstevel@tonic-gate * definitions for dce pthreads * 1280Sstevel@tonic-gate * * 1290Sstevel@tonic-gate ***********************************/ 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate #define _THREAD 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate #include <pthread.h> 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* dce threads are preemptive */ 1360Sstevel@tonic-gate #define PTHREAD_PREEMPTIVE 1 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate #define pthread_attr_init( a ) pthread_attr_create( a ) 1390Sstevel@tonic-gate #define pthread_attr_destroy( a ) pthread_attr_delete( a ) 1400Sstevel@tonic-gate #define pthread_attr_setdetachstate( a, b ) \ 1410Sstevel@tonic-gate pthread_attr_setdetach_np( a, b ) 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate #endif /* dce pthreads */ 1440Sstevel@tonic-gate #endif /* mit pthreads */ 1450Sstevel@tonic-gate #endif /* sunos5 */ 1460Sstevel@tonic-gate #endif /* sunos4 */ 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #ifndef _THREAD 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate /*********************************** 1510Sstevel@tonic-gate * * 1520Sstevel@tonic-gate * thread definitions for no * 1530Sstevel@tonic-gate * underlying library support * 1540Sstevel@tonic-gate * * 1550Sstevel@tonic-gate ***********************************/ 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate typedef void *(*VFP)(); 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* thread attributes and thread type */ 1600Sstevel@tonic-gate typedef int pthread_attr_t; 1610Sstevel@tonic-gate typedef int pthread_t; 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* default attr states */ 1640Sstevel@tonic-gate #define pthread_mutexattr_default NULL 1650Sstevel@tonic-gate #define pthread_condattr_default NULL 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate /* thread state - joinable or not */ 1680Sstevel@tonic-gate #define PTHREAD_CREATE_JOINABLE 0 1690Sstevel@tonic-gate #define PTHREAD_CREATE_DETACHED 0 1700Sstevel@tonic-gate /* thread scope - who is in scheduling pool */ 1710Sstevel@tonic-gate #define PTHREAD_SCOPE_PROCESS 0 1720Sstevel@tonic-gate #define PTHREAD_SCOPE_SYSTEM 0 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate /* mutex attributes and mutex type */ 1750Sstevel@tonic-gate typedef int pthread_mutexattr_t; 1760Sstevel@tonic-gate typedef int pthread_mutex_t; 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate /* mutex and condition variable scope - process or system */ 1790Sstevel@tonic-gate #define PTHREAD_SHARE_PRIVATE 0 1800Sstevel@tonic-gate #define PTHREAD_SHARE_PROCESS 0 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate /* condition variable attributes and condition variable type */ 1830Sstevel@tonic-gate typedef int pthread_condattr_t; 1840Sstevel@tonic-gate typedef int pthread_cond_t; 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate #endif /* no threads support */ 1870Sstevel@tonic-gate #endif /* _LTHREAD_H */ 188