summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/inc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc/inc')
-rw-r--r--usr/src/lib/libc/inc/asyncio.h346
-rw-r--r--usr/src/lib/libc/inc/mtlib.h11
-rw-r--r--usr/src/lib/libc/inc/rtsched.h44
-rw-r--r--usr/src/lib/libc/inc/synonyms.h47
-rw-r--r--usr/src/lib/libc/inc/thr_debug.h44
-rw-r--r--usr/src/lib/libc/inc/thr_uberdata.h69
-rw-r--r--usr/src/lib/libc/inc/thread_pool.h74
7 files changed, 594 insertions, 41 deletions
diff --git a/usr/src/lib/libc/inc/asyncio.h b/usr/src/lib/libc/inc/asyncio.h
new file mode 100644
index 0000000000..02d33cd700
--- /dev/null
+++ b/usr/src/lib/libc/inc/asyncio.h
@@ -0,0 +1,346 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _ASYNCIO_H
+#define _ASYNCIO_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <thread.h>
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <siginfo.h>
+#include <aio.h>
+#include <limits.h>
+#include <ucontext.h>
+#include <sys/asynch.h>
+#include <sys/mman.h>
+
+#if !defined(_LP64)
+#define AIOSTKSIZE (64 * 1024)
+#else
+#define AIOSTKSIZE (128 * 1024)
+#endif
+
+#define SIGAIOCANCEL SIGLWP /* special aio cancelation signal */
+
+#define AIO_WAITN_MAXIOCBS 32768 /* max. iocbs per system call */
+
+/*
+ * Declare structure types. The structures themselves are defined below.
+ */
+typedef struct aio_args aio_args_t;
+typedef struct aio_lio aio_lio_t;
+typedef struct notif_param notif_param_t;
+typedef struct aio_req aio_req_t;
+typedef struct aio_worker aio_worker_t;
+typedef struct aio_hash aio_hash_t;
+
+struct aio_args {
+ int fd;
+ caddr_t buf;
+ size_t bufsz;
+ offset_t offset;
+};
+
+/*
+ * list head for UFS list I/O
+ */
+struct aio_lio {
+ mutex_t lio_mutex; /* list mutex */
+ cond_t lio_cond_cv; /* list notification for I/O done */
+ aio_lio_t *lio_next; /* pointer to next on freelist */
+ char lio_mode; /* LIO_WAIT/LIO_NOWAIT */
+ char lio_canned; /* lio was canceled */
+ char lio_largefile; /* largefile operation */
+ char lio_waiting; /* waiting in __lio_listio() */
+ int lio_nent; /* Number of list I/O's */
+ int lio_refcnt; /* outstanding I/O's */
+ int lio_event; /* Event number for notification */
+ int lio_port; /* Port number for notification */
+ int lio_signo; /* Signal number for notification */
+ union sigval lio_sigval; /* Signal parameter */
+ uintptr_t lio_object; /* for SIGEV_THREAD or SIGEV_PORT */
+ struct sigevent *lio_sigevent; /* Notification function and attr. */
+};
+
+/*
+ * Notification parameters
+ */
+struct notif_param {
+ int np_signo; /* SIGEV_SIGNAL */
+ int np_port; /* SIGEV_THREAD or SIGEV_PORT */
+ void *np_user;
+ int np_event;
+ uintptr_t np_object;
+ int np_lio_signo; /* listio: SIGEV_SIGNAL */
+ int np_lio_port; /* listio: SIGEV_THREAD or SIGEV_PORT */
+ void *np_lio_user;
+ int np_lio_event;
+ uintptr_t np_lio_object;
+};
+
+struct aio_req {
+ /*
+ * fields protected by _aio_mutex lock.
+ */
+ aio_req_t *req_link; /* hash/freelist chain link */
+ /*
+ * when req is on the doneq, then req_next is protected by
+ * the _aio_mutex lock. when the req is on a work q, then
+ * req_next is protected by a worker's work_qlock1 lock.
+ */
+ aio_req_t *req_next; /* request/done queue link */
+ aio_req_t *req_prev; /* double linked list */
+ /*
+ * fields protected by a worker's work_qlock1 lock.
+ */
+ char req_state; /* AIO_REQ_QUEUED, ... */
+ /*
+ * fields require no locking.
+ */
+ char req_type; /* AIO_POSIX_REQ or not */
+ char req_largefile; /* largefile operation */
+ char req_op; /* AIOREAD, etc. */
+ aio_worker_t *req_worker; /* associate request with worker */
+ aio_result_t *req_resultp; /* address of result buffer */
+ aio_args_t req_args; /* arglist */
+ aio_lio_t *req_head; /* list head for LIO */
+ struct sigevent req_sigevent;
+ void *req_aiocbp; /* ptr to aiocb or aiocb64 */
+ notif_param_t req_notify; /* notification parameters */
+};
+
+/* special lio type that destroys itself when lio refcnt becomes zero */
+#define LIO_FSYNC LIO_WAIT+1
+#define LIO_DESTROY LIO_FSYNC+1
+
+/* lio flags */
+#define LIO_FSYNC_CANCELED 0x1
+
+/* values for aio_state */
+
+#define AIO_REQ_QUEUED 1
+#define AIO_REQ_INPROGRESS 2
+#define AIO_REQ_CANCELED 3
+#define AIO_REQ_DONE 4
+#define AIO_REQ_FREE 5
+#define AIO_REQ_DONEQ 6
+
+/* use KAIO in _aio_rw() */
+#define AIO_NO_KAIO 0x0
+#define AIO_KAIO 0x1
+#define AIO_NO_DUPS 0x2
+
+#define AIO_POSIX_REQ 0x1
+
+#define CHECK 1
+#define NOCHECK 2
+#define CHECKED 3
+#define USERAIO 4
+#define USERAIO_DONE 5
+
+/* values for _aio_flags */
+
+/* if set, _aiodone() notifies aio_waitn about done requests */
+#define AIO_WAIT_INPROGRESS 0x1
+/* if set, _aiodone() wakes up functions waiting for completed I/Os */
+#define AIO_IO_WAITING 0x2
+#define AIO_LIB_WAITN 0x4 /* aio_waitn in progress */
+#define AIO_LIB_WAITN_PENDING 0x8 /* aio_waitn requests pending */
+
+/*
+ * Before a kaio() system call, the fd will be checked
+ * to ensure that kernel async. I/O is supported for this file.
+ * The only way to find out is if a kaio() call returns ENOTSUP,
+ * so the default will always be to try the kaio() call. Only in
+ * the specific instance of a kaio() call returning ENOTSUP
+ * will we stop submitting kaio() calls for that fd.
+ * If the fd is outside the array bounds, we will allow the kaio()
+ * call.
+ *
+ * The only way that an fd entry can go from ENOTSUP to supported
+ * is if that fd is freed up by a close(), and close will clear
+ * the entry for that fd.
+ *
+ * Each fd gets a bit in the array _kaio_supported[].
+ *
+ * uint32_t _kaio_supported[MAX_KAIO_FDARRAY_SIZE];
+ *
+ * Array is MAX_KAIO_ARRAY_SIZE of 32-bit elements, for 8kb.
+ * If more than (MAX_KAIO_FDARRAY_SIZE * KAIO_FDARRAY_ELEM_SIZE)
+ * files are open, this can be expanded.
+ */
+
+#define MAX_KAIO_FDARRAY_SIZE 2048
+#define KAIO_FDARRAY_ELEM_SIZE WORD_BIT /* uint32_t */
+
+#define MAX_KAIO_FDS (MAX_KAIO_FDARRAY_SIZE * KAIO_FDARRAY_ELEM_SIZE)
+
+#define VALID_FD(fdes) ((fdes) >= 0 && (fdes) < MAX_KAIO_FDS)
+
+#define KAIO_SUPPORTED(fdes) \
+ (!VALID_FD(fdes) || \
+ ((_kaio_supported[(fdes) / KAIO_FDARRAY_ELEM_SIZE] & \
+ (uint32_t)(1 << ((fdes) % KAIO_FDARRAY_ELEM_SIZE))) == 0))
+
+#define SET_KAIO_NOT_SUPPORTED(fdes) \
+ if (VALID_FD(fdes)) \
+ _kaio_supported[(fdes) / KAIO_FDARRAY_ELEM_SIZE] |= \
+ (uint32_t)(1 << ((fdes) % KAIO_FDARRAY_ELEM_SIZE))
+
+#define CLEAR_KAIO_SUPPORTED(fdes) \
+ if (VALID_FD(fdes)) \
+ _kaio_supported[(fdes) / KAIO_FDARRAY_ELEM_SIZE] &= \
+ ~(uint32_t)(1 << ((fdes) % KAIO_FDARRAY_ELEM_SIZE))
+
+struct aio_worker {
+ aio_worker_t *work_forw; /* forward link in list of workers */
+ aio_worker_t *work_backw; /* backwards link in list of workers */
+ mutex_t work_qlock1; /* lock for work queue 1 */
+ cond_t work_idle_cv; /* place to sleep when idle */
+ aio_req_t *work_head1; /* head of work request queue 1 */
+ aio_req_t *work_tail1; /* tail of work request queue 1 */
+ aio_req_t *work_next1; /* work queue one's next pointer */
+ aio_req_t *work_prev1; /* last request done from queue 1 */
+ aio_req_t *work_req; /* active work request */
+ thread_t work_tid; /* worker's thread-id */
+ int work_count1; /* length of work queue one */
+ int work_done1; /* number of requests done */
+ int work_minload1; /* min length of queue */
+ int work_idleflg; /* when set, worker is idle */
+ sigjmp_buf work_jmp_buf; /* cancellation point */
+};
+
+struct aio_hash { /* resultp hash table */
+ mutex_t hash_lock;
+ aio_req_t *hash_ptr;
+#if !defined(_LP64)
+ void *hash_pad; /* ensure sizeof (aio_hash_t) == 32 */
+#endif
+};
+
+extern aio_hash_t *_aio_hash;
+
+#define HASHSZ 2048 /* power of 2 */
+#define AIOHASH(resultp) ((((uintptr_t)(resultp) >> 17) ^ \
+ ((uintptr_t)(resultp) >> 2)) & (HASHSZ - 1))
+#define POSIX_AIO(x) ((x)->req_type == AIO_POSIX_REQ)
+
+extern int __uaio_init(void);
+extern void _kaio_init(void);
+extern intptr_t _kaio(int, ...);
+extern int _aiorw(int, caddr_t, int, offset_t, int, aio_result_t *, int);
+extern int _aio_rw(aiocb_t *, aio_lio_t *, aio_worker_t **, int, int);
+#if !defined(_LP64)
+extern int _aio_rw64(aiocb64_t *, aio_lio_t *, aio_worker_t **, int, int);
+#endif
+extern int _aio_create_worker(aio_req_t *, int);
+extern int _aio_cancel_req(aio_worker_t *, aio_req_t *, int *, int *);
+extern int aiocancel_all(int);
+extern void aio_panic(const char *);
+extern aio_req_t *_aio_hash_find(aio_result_t *);
+extern aio_req_t *_aio_hash_del(aio_result_t *);
+extern void _aio_req_mark_done(aio_req_t *);
+extern void _aio_waitn_wakeup(void);
+extern aio_worker_t *_aio_worker_alloc(void);
+extern void _aio_worker_free(void *);
+extern aio_req_t *_aio_req_alloc(void);
+extern void _aio_req_free(aio_req_t *);
+extern aio_lio_t *_aio_lio_alloc(void);
+extern void _aio_lio_free(aio_lio_t *);
+extern int _aio_idle(aio_worker_t *);
+extern void *_aio_do_request(void *);
+extern void *_aio_do_notify(void *);
+extern void _lio_remove(aio_req_t *);
+extern aio_req_t *_aio_req_remove(aio_req_t *);
+extern int _aio_get_timedelta(timespec_t *, timespec_t *);
+extern aio_result_t *_aio_req_done(void);
+extern void _aio_set_result(aio_req_t *, ssize_t, int);
+extern int _aio_sigev_thread_init(struct sigevent *);
+extern int _aio_sigev_thread(aiocb_t *);
+#if !defined(_LP64)
+extern int _aio_sigev_thread64(aiocb64_t *);
+#endif
+
+extern aio_worker_t *_kaiowp; /* points to kaio cleanup thread */
+extern aio_worker_t *__workers_rw; /* list of all rw workers */
+extern aio_worker_t *__nextworker_rw; /* worker chosen for next rw request */
+extern int __rw_workerscnt; /* number of rw workers */
+extern aio_worker_t *__workers_no; /* list of all notification workers */
+extern aio_worker_t *__nextworker_no; /* worker chosen, next notification */
+extern int __no_workerscnt; /* number of notification workers */
+extern mutex_t __aio_initlock; /* makes aio initialization atomic */
+extern cond_t __aio_initcv;
+extern int __aio_initbusy;
+extern mutex_t __aio_mutex; /* global aio lock */
+extern cond_t _aio_iowait_cv; /* wait for userland I/Os */
+extern cond_t _aio_waitn_cv; /* wait for end of aio_waitn */
+extern int _max_workers; /* max number of workers permitted */
+extern int _min_workers; /* min number of workers */
+extern sigset_t _worker_set; /* worker's signal mask */
+extern int _aio_worker_cnt; /* number of AIO workers */
+extern int _sigio_enabled; /* when set, send SIGIO signal */
+extern pid_t __pid; /* process's PID */
+extern int __uaio_ok; /* indicates if aio is initialized */
+extern int _kaio_ok; /* indicates if kaio is initialized */
+extern pthread_key_t _aio_key; /* for thread-specific data */
+extern aio_req_t *_aio_done_tail; /* list of done requests */
+extern aio_req_t *_aio_done_head;
+extern aio_req_t *_aio_doneq;
+extern int _aio_freelist_cnt;
+extern int _aio_allocated_cnt;
+extern int _aio_donecnt;
+extern int _aio_doneq_cnt;
+extern int _aio_waitncnt; /* # of requests for aio_waitn */
+extern int _aio_outstand_cnt; /* # of outstanding requests */
+extern int _kaio_outstand_cnt; /* # of outstanding kaio requests */
+extern int _aio_req_done_cnt; /* req. done but not in "done queue" */
+extern int _aio_kernel_suspend; /* active kernel kaio calls */
+extern int _aio_suscv_cnt; /* aio_suspend calls waiting on cv's */
+extern int _aiowait_flag; /* when set, aiowait() is inprogress */
+extern int _aio_flags; /* see defines, above */
+extern uint32_t *_kaio_supported;
+
+extern const sigset_t maskset; /* all maskable signals */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ASYNCIO_H */
diff --git a/usr/src/lib/libc/inc/mtlib.h b/usr/src/lib/libc/inc/mtlib.h
index 89c2376949..d864e8e75a 100644
--- a/usr/src/lib/libc/inc/mtlib.h
+++ b/usr/src/lib/libc/inc/mtlib.h
@@ -57,6 +57,15 @@ extern int __rw_unlock(rwlock_t *);
extern void lrw_rdlock(rwlock_t *);
extern void lrw_wrlock(rwlock_t *);
extern void lrw_unlock(rwlock_t *);
+extern void sig_mutex_lock(mutex_t *);
+extern void sig_mutex_unlock(mutex_t *);
+extern int sig_mutex_trylock(mutex_t *);
+extern int sig_cond_wait(cond_t *, mutex_t *);
+extern int sig_cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
+
+/* the private libc thread-safe allocator */
+extern void *lmalloc(size_t);
+extern void lfree(void *, size_t);
/* the rest are public functions */
extern int _mutex_init(mutex_t *, int, void *);
@@ -91,6 +100,8 @@ extern thread_t _thr_self(void);
extern void _thr_exit(void *);
extern size_t _thr_min_stack(void);
extern int _thr_kill(thread_t, int);
+extern int _thr_create(void *, size_t, void *(*)(void *), void *, long,
+ thread_t *);
extern int _thr_keycreate(thread_key_t *, void (*)(void *));
extern int _thr_setspecific(thread_key_t, void *);
extern int _thr_getspecific(thread_key_t, void **);
diff --git a/usr/src/lib/libc/inc/rtsched.h b/usr/src/lib/libc/inc/rtsched.h
new file mode 100644
index 0000000000..90ae11c3b2
--- /dev/null
+++ b/usr/src/lib/libc/inc/rtsched.h
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _RTSCHED_H
+#define _RTSCHED_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/priocntl.h>
+
+/*
+ * This definition is private to libc but is used in more than one subsystem.
+ */
+struct pcclass {
+ short pcc_state;
+ pri_t pcc_primin;
+ pri_t pcc_primax;
+ pcinfo_t pcc_info;
+};
+
+#endif /* _RTSCHED_H */
diff --git a/usr/src/lib/libc/inc/synonyms.h b/usr/src/lib/libc/inc/synonyms.h
index 179f25f627..4de926dc9f 100644
--- a/usr/src/lib/libc/inc/synonyms.h
+++ b/usr/src/lib/libc/inc/synonyms.h
@@ -223,6 +223,10 @@ extern "C" {
#define chown _chown
#define chroot _chroot
#define _cladm __cladm
+#define clock_getres _clock_getres
+#define clock_gettime _clock_gettime
+#define clock_nanosleep _clock_nanosleep
+#define clock_settime _clock_settime
#define close _close
#define closedir _closedir
#define closefrom _closefrom
@@ -264,8 +268,8 @@ extern "C" {
#define decimal_to_single _decimal_to_single
#define dgettext _dgettext
#define dirname _dirname
-#define dladdr _dladdr
#define dladdr1 _dladdr1
+#define dladdr _dladdr
#define dlamd64getunwind _dlamd64getunwind
#define dlclose _dlclose
#define dldump _dldump
@@ -495,7 +499,6 @@ extern "C" {
#define iswupper _iswupper
#define iswxdigit _iswxdigit
#define jrand48 _jrand48
-#define kaio _kaio
#define kill _kill
#define l64a _l64a
#define ladd _ladd
@@ -590,12 +593,19 @@ extern "C" {
#define munlockall _munlockall
#define munlock _munlock
#define munmap _munmap
-#define mutex_destroy _mutex_destroy
-#define mutex_held _mutex_held
-#define mutex_init _mutex_init
-#define mutex_lock _mutex_lock
-#define mutex_trylock _mutex_trylock
-#define mutex_unlock _mutex_unlock
+#define _mutex_destroy __mutex_destroy
+#define mutex_destroy __mutex_destroy
+#define _mutex_held __mutex_held
+#define mutex_held __mutex_held
+#define _mutex_init __mutex_init
+#define mutex_init __mutex_init
+#define _mutex_lock __mutex_lock
+#define mutex_lock __mutex_lock
+#define _mutex_trylock __mutex_trylock
+#define mutex_trylock __mutex_trylock
+#define _mutex_unlock __mutex_unlock
+#define mutex_unlock __mutex_unlock
+#define nanosleep _nanosleep
#define nfs_getfh _nfs_getfh
#define nfssvc _nfssvc
#define nftw64 _nftw64
@@ -627,7 +637,6 @@ extern "C" {
#define port_alert _port_alert
#define port_associate _port_associate
#define port_create _port_create
-#define port_dispatch _port_dispatch
#define port_dissociate _port_dissociate
#define port_getn _port_getn
#define port_get _port_get
@@ -865,12 +874,23 @@ extern "C" {
#define sema_timedwait _sema_timedwait
#define sema_trywait _sema_trywait
#define sema_wait _sema_wait
+#define sem_close _sem_close
#define semctl64 _semctl64
#define semctl _semctl
+#define sem_destroy _sem_destroy
#define semget _semget
+#define sem_getvalue _sem_getvalue
#define semids _semids
+#define sem_init _sem_init
+#define sem_open _sem_open
#define semop _semop
+#define sem_post _sem_post
+#define sem_reltimedwait_np _sem_reltimedwait_np
#define semtimedop _semtimedop
+#define sem_timedwait _sem_timedwait
+#define sem_trywait _sem_trywait
+#define sem_unlink _sem_unlink
+#define sem_wait _sem_wait
#define setcontext _setcontext
#define setegid _setegid
#define setenv _setenv
@@ -927,12 +947,16 @@ extern "C" {
#define sigpause _sigpause
#define sigpending _sigpending
#define sigprocmask _sigprocmask
+#define sigqueue _sigqueue
#define sigrelse _sigrelse
#define sigsendset _sigsendset
#define sigsend _sigsend
#define sigsetjmp _sigsetjmp
#define sigset _sigset
+#define sigstack _sigstack
#define sigsuspend _sigsuspend
+#define sigtimedwait _sigtimedwait
+#define sigwaitinfo _sigwaitinfo
#define sigwait _sigwait
#define single_to_decimal _single_to_decimal
#define s_ioctl _s_ioctl
@@ -1018,6 +1042,11 @@ extern "C" {
#define thr_suspend _thr_suspend
#define thr_wait_mutator _thr_wait_mutator
#define thr_yield _thr_yield
+#define timer_create _timer_create
+#define timer_delete _timer_delete
+#define timer_getoverrun _timer_getoverrun
+#define timer_gettime _timer_gettime
+#define timer_settime _timer_settime
#define times _times
#define time _time
#define tmpnam_r _tmpnam_r
diff --git a/usr/src/lib/libc/inc/thr_debug.h b/usr/src/lib/libc/inc/thr_debug.h
new file mode 100644
index 0000000000..5e8de4ef0a
--- /dev/null
+++ b/usr/src/lib/libc/inc/thr_debug.h
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _THR_DEBUG_H
+#define _THR_DEBUG_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#if defined(THREAD_DEBUG)
+
+extern void __assfail(const char *, const char *, int);
+#pragma rarely_called(__assfail)
+#define ASSERT(EX) (void)((EX) || (__assfail(#EX, __FILE__, __LINE__), 0))
+
+#else
+
+#define ASSERT(EX) ((void)0)
+
+#endif
+
+#endif /* _THR_DEBUG_H */
diff --git a/usr/src/lib/libc/inc/thr_uberdata.h b/usr/src/lib/libc/inc/thr_uberdata.h
index c7b6001926..2671ac0a69 100644
--- a/usr/src/lib/libc/inc/thr_uberdata.h
+++ b/usr/src/lib/libc/inc/thr_uberdata.h
@@ -53,12 +53,10 @@
#include <schedctl.h>
#include <sys/priocntl.h>
#include <thread_db.h>
+#include <setjmp.h>
#include "libc_int.h"
#include "tdb_agent.h"
-
-/* belongs in <pthread.h> */
-#define PTHREAD_CREATE_DAEMON_NP 0x100 /* = THR_DAEMON */
-#define PTHREAD_CREATE_NONDAEMON_NP 0
+#include "thr_debug.h"
/*
* This is an implementation-specific include file for threading support.
@@ -208,14 +206,6 @@ typedef union {
#define PRIO_INHERIT 2
#define PRIO_DISINHERIT 3
-struct pcclass {
- short pcc_state;
- pri_t pcc_primin;
- pri_t pcc_primax;
- pcinfo_t pcc_info;
-};
-extern struct pcclass ts_class, rt_class;
-
#define MUTEX_TRY 0
#define MUTEX_LOCK 1
@@ -608,7 +598,7 @@ typedef struct ulwp {
#define MASKSET0 (FILLSET0 & ~CANTMASK0)
#define MASKSET1 (FILLSET1 & ~CANTMASK1)
-extern const sigset_t maskset; /* set of all maskable signals */
+extern const sigset_t maskset; /* set of all maskable signals */
extern int thread_adaptive_spin;
extern uint_t thread_max_spinners;
@@ -1048,7 +1038,7 @@ extern greg_t stkptr(void);
/*
* Implementation functions. Not visible outside of the library itself.
*/
-extern int ___nanosleep(const timespec_t *, timespec_t *);
+extern int __nanosleep(const timespec_t *, timespec_t *);
extern void getgregs(ulwp_t *, gregset_t);
extern void setgregs(ulwp_t *, gregset_t);
extern void thr_panic(const char *);
@@ -1092,18 +1082,6 @@ extern void _flush_windows(void);
#endif
extern void set_curthread(void *);
-#if defined(THREAD_DEBUG)
-
-extern void __assfail(const char *, const char *, int);
-#pragma rarely_called(__assfail)
-#define ASSERT(EX) (void)((EX) || (__assfail(#EX, __FILE__, __LINE__), 0))
-
-#else /* THREAD_DEBUG */
-
-#define ASSERT(EX) ((void)0)
-
-#endif /* THREAD_DEBUG */
-
/* enter a critical section */
#define enter_critical(self) (self->ul_critical++)
@@ -1174,21 +1152,35 @@ extern void *_thr_setup(ulwp_t *);
extern void _fpinherit(ulwp_t *);
extern void _lwp_start(void);
extern void _lwp_terminate(void);
-extern void lmutex_unlock(mutex_t *);
extern void lmutex_lock(mutex_t *);
+extern void lmutex_unlock(mutex_t *);
+extern void sig_mutex_lock(mutex_t *);
+extern void sig_mutex_unlock(mutex_t *);
+extern int sig_mutex_trylock(mutex_t *);
+extern int sig_cond_wait(cond_t *, mutex_t *);
+extern int sig_cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
extern void _prefork_handler(void);
extern void _postfork_parent_handler(void);
extern void _postfork_child_handler(void);
-extern void _postfork1_child(void);
+extern void postfork1_child(void);
+extern void postfork1_child_aio(void);
+extern void postfork1_child_sigev_aio(void);
+extern void postfork1_child_sigev_mq(void);
+extern void postfork1_child_sigev_timer(void);
+extern void postfork1_child_tpool(void);
extern int fork_lock_enter(const char *);
extern void fork_lock_exit(void);
extern void suspend_fork(void);
extern void continue_fork(int);
extern void do_sigcancel(void);
-extern void init_sigcancel(void);
+extern void setup_cancelsig(int);
+extern void init_sigev_thread(void);
+extern void init_aio(void);
extern void _cancelon(void);
extern void _canceloff(void);
extern void _canceloff_nocancel(void);
+extern void _cancel_prologue(void);
+extern void _cancel_epilogue(void);
extern void no_preempt(ulwp_t *);
extern void preempt(ulwp_t *);
extern void _thrp_unwind(void *);
@@ -1249,8 +1241,18 @@ extern int __lwp_sigmask(int, const sigset_t *, sigset_t *);
extern void __sighndlr(int, siginfo_t *, ucontext_t *, void (*)());
extern caddr_t __sighndlrend;
#pragma unknown_control_flow(__sighndlr)
+extern void _siglongjmp(sigjmp_buf, int);
+extern int _pthread_setspecific(pthread_key_t, const void *);
+extern void *_pthread_getspecific(pthread_key_t);
extern void _pthread_exit(void *);
+extern void _private_testcancel(void);
+
+/* belongs in <pthread.h> */
+#define PTHREAD_CREATE_DAEMON_NP 0x100 /* = THR_DAEMON */
+#define PTHREAD_CREATE_NONDAEMON_NP 0
+extern int _pthread_attr_setdaemonstate_np(pthread_attr_t *, int);
+extern int _pthread_attr_getdaemonstate_np(const pthread_attr_t *, int *);
/* these are private to the library */
extern int _private_mutex_init(mutex_t *, int, void *);
@@ -1293,8 +1295,10 @@ extern int rw_read_is_held(rwlock_t *);
extern int rw_write_is_held(rwlock_t *);
extern int _thr_continue(thread_t);
-extern int _thrp_create(void *, size_t, void *(*func)(void *), void *,
- long, thread_t *, pri_t, int, size_t);
+extern int _thr_create(void *, size_t, void *(*)(void *), void *, long,
+ thread_t *);
+extern int _thrp_create(void *, size_t, void *(*)(void *), void *, long,
+ thread_t *, pri_t, int, size_t);
extern int _thr_getprio(thread_t, int *);
extern int _thr_getspecific(thread_key_t, void **);
extern int _thr_join(thread_t, thread_t *, void **);
@@ -1320,7 +1324,8 @@ extern int _thread_setschedparam_main(pthread_t, int,
const struct sched_param *, int);
extern int _validate_rt_prio(int, int);
extern int _thrp_setlwpprio(lwpid_t, int, int);
-extern pri_t _map_rtpri_to_gp(pri_t);
+extern pri_t map_rtpri_to_gp(pri_t);
+extern int get_info_by_policy(int);
/*
* System call wrappers (direct interfaces to the kernel)
diff --git a/usr/src/lib/libc/inc/thread_pool.h b/usr/src/lib/libc/inc/thread_pool.h
new file mode 100644
index 0000000000..200323703c
--- /dev/null
+++ b/usr/src/lib/libc/inc/thread_pool.h
@@ -0,0 +1,74 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _THREAD_POOL_H_
+#define _THREAD_POOL_H_
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+#include <thread.h>
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct tpool tpool_t; /* opaque thread pool descriptor */
+
+#if defined(__STDC__)
+
+extern tpool_t *tpool_create(uint_t min_threads, uint_t max_threads,
+ uint_t linger, pthread_attr_t *attr);
+extern int tpool_dispatch(tpool_t *tpool,
+ void (*func)(void *), void *arg);
+extern void tpool_destroy(tpool_t *tpool);
+extern void tpool_abandon(tpool_t *tpool);
+extern void tpool_wait(tpool_t *tpool);
+extern void tpool_suspend(tpool_t *tpool);
+extern int tpool_suspended(tpool_t *tpool);
+extern void tpool_resume(tpool_t *tpool);
+extern int tpool_member(tpool_t *tpool);
+
+#else /* Non ANSI */
+
+extern tpool_t *tpool_create();
+extern int tpool_dispatch();
+extern void tpool_destroy();
+extern void tpool_abandon();
+extern void tpool_wait();
+extern void tpool_suspend();
+extern int tpool_suspended();
+extern void tpool_resume();
+extern int tpool_member();
+
+#endif /* __STDC__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _THREAD_POOL_H_ */