xref: /titanic_51/usr/src/lib/libc/inc/thr_uberdata.h (revision 024b0a258461f282a92b1b1283c3b8b083f9f33f)
1 /*
2  * CDDL HEADER START
3  *
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _THR_UBERDATA_H
28 #define	_THR_UBERDATA_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <stdlib.h>
33 #include <unistd.h>
34 #include <sys/types.h>
35 #include <fcntl.h>
36 #include <string.h>
37 #include <signal.h>
38 #include <ucontext.h>
39 #include <thread.h>
40 #include <pthread.h>
41 #include <link.h>
42 #include <sys/resource.h>
43 #include <sys/lwp.h>
44 #include <errno.h>
45 #include <sys/asm_linkage.h>
46 #include <sys/regset.h>
47 #include <sys/fcntl.h>
48 #include <sys/mman.h>
49 #include <synch.h>
50 #include <door.h>
51 #include <limits.h>
52 #include <sys/synch32.h>
53 #include <schedctl.h>
54 #include <sys/priocntl.h>
55 #include <thread_db.h>
56 #include <setjmp.h>
57 #include "libc_int.h"
58 #include "tdb_agent.h"
59 #include "thr_debug.h"
60 
61 /*
62  * This is an implementation-specific include file for threading support.
63  * It is not to be seen by the clients of the library.
64  *
65  * This file also describes uberdata in libc.
66  *
67  * The term "uberdata" refers to data that is unique and visible across
68  * all link maps.  The name is meant to imply that such data is truly
69  * global, not just locally global to a particular link map.
70  *
71  * See the Linker and Libraries Guide for a full description of alternate
72  * link maps and how they are set up and used.
73  *
74  * Alternate link maps implement multiple global namespaces within a single
75  * process.  There may be multiple instances of identical dynamic libraries
76  * loaded in a process's address space at the same time, each on a different
77  * link map (as determined by the dynamic linker), each with its own set of
78  * global variables.  Which particular instance of a global variable is seen
79  * by a thread running in the process is determined by the link map on which
80  * the thread happens to be executing at the time.
81  *
82  * However, there are aspects of a process that are unique across all
83  * link maps, in particular the structures used to implement threads
84  * of control (in Sparc terminology, there is only one %g7 regardless
85  * of the link map on which the thread is executing).
86  *
87  * All uberdata is referenced from a base pointer in the thread's ulwp_t
88  * structure (which is also uberdata).  All allocations and deallocations
89  * of uberdata are made via the uberdata-aware lmalloc() and lfree()
90  * interfaces (malloc() and free() are simply locally-global).
91  */
92 
93 /*
94  * Special libc-private access to errno.
95  * We do this so that references to errno do not invoke the dynamic linker.
96  */
97 #undef errno
98 #define	errno (*curthread->ul_errnop)
99 
100 /*
101  * See <sys/synch32.h> for the reasons for these values
102  * and why they are different for sparc and intel.
103  */
104 #if defined(__sparc)
105 
106 /* lock.lock64.pad[x]	   4 5 6 7 */
107 #define	LOCKMASK	0xff000000
108 #define	WAITERMASK	0x000000ff
109 #define	SPINNERMASK	0x00ff0000
110 #define	SPINNERSHIFT	16
111 #define	WAITER		0x00000001
112 #define	LOCKSET		0xff
113 #define	LOCKCLEAR	0
114 
115 #define	PIDSHIFT	32
116 #define	LOCKMASK64	0xffffffffff000000ULL
117 #define	LOCKBYTE64	0x00000000ff000000ULL
118 #define	WAITERMASK64	0x00000000000000ffULL
119 #define	SPINNERMASK64	0x0000000000ff0000ULL
120 
121 #elif defined(__x86)
122 
123 /* lock.lock64.pad[x]	   7 6 5 4 */
124 #define	LOCKMASK	0xff000000
125 #define	WAITERMASK	0x00ff0000
126 #define	SPINNERMASK	0x0000ff00
127 #define	SPINNERSHIFT	8
128 #define	WAITER		0x00010000
129 #define	LOCKSET		0x01
130 #define	LOCKCLEAR	0
131 
132 #define	PIDSHIFT	0
133 #define	LOCKMASK64	0xff000000ffffffffULL
134 #define	LOCKBYTE64	0x0100000000000000ULL
135 #define	WAITERMASK64	0x00ff000000000000ULL
136 #define	SPINNERMASK64	0x0000ff0000000000ULL
137 
138 #else
139 #error "neither __sparc nor __x86 is defined"
140 #endif
141 
142 /*
143  * Fetch the owner of a USYNC_THREAD mutex.
144  * Don't use this with process-shared mutexes;
145  * the owing thread may be in a different process.
146  */
147 #define	MUTEX_OWNER(mp)	((ulwp_t *)(uintptr_t)(mp)->mutex_owner)
148 
149 /*
150  * Test if a thread owns a process-private (USYNC_THREAD) mutex.
151  * This is inappropriate for a process-shared (USYNC_PROCESS) mutex.
152  * The 'mp' argument must not have side-effects since it is evaluated twice.
153  */
154 #define	MUTEX_OWNED(mp, thrp)	\
155 	((mp)->mutex_lockw != 0 && MUTEX_OWNER(mp) == thrp)
156 
157 
158 /*
159  * uberflags.uf_tdb_register_sync is an interface with libc_db to enable the
160  * collection of lock statistics by a debugger or other collecting tool.
161  *
162  * uberflags.uf_thread_error_detection is set by an environment variable:
163  *	_THREAD_ERROR_DETECTION
164  *		0 == no detection of locking primitive errors.
165  *		1 == detect errors and issue a warning message.
166  *		2 == detect errors, issue a warning message, and dump core.
167  *
168  * We bundle these together in uberflags.uf_trs_ted to make a test of either
169  * being non-zero a single memory reference (for speed of mutex_lock(), etc).
170  *
171  * uberflags.uf_mt is set non-zero when the first thread (in addition
172  * to the main thread) is created.
173  *
174  * We bundle all these flags together in uberflags.uf_all to make a test
175  * of any being non-zero a single memory reference (again, for speed).
176  */
177 typedef union {
178 	int	uf_all;			/* combined all flags */
179 	struct {
180 		short	h_pad;
181 		short	h_trs_ted;	/* combined reg sync & error detect */
182 	} uf_h;
183 	struct {
184 		char	x_mt;
185 		char	x_pad;
186 		char	x_tdb_register_sync;
187 		char	x_thread_error_detection;
188 	} uf_x;
189 } uberflags_t;
190 
191 #define	uf_mt				uf_x.x_mt
192 #define	uf_tdb_register_sync		uf_x.x_tdb_register_sync
193 #define	uf_thread_error_detection	uf_x.x_thread_error_detection
194 #define	uf_trs_ted			uf_h.h_trs_ted	/* both of the above */
195 
196 /*
197  * NOTE WELL:
198  * To enable further optimization, the "ul_schedctl_called" member
199  * of the ulwp_t structure (below) serves double-duty:
200  *	1. If NULL, it means that the thread must call __schedctl()
201  *	   to set up its schedctl mappings before acquiring a mutex.
202  *	   This is required by the implementation of adaptive mutex locking.
203  *	2. If non-NULL, it points to uberdata.uberflags, so that tests of
204  *	   uberflags can be made without additional memory references.
205  * This allows the common case of _mutex_lock() and _mutex_unlock() for
206  * USYNC_THREAD mutexes with no error detection and no lock statistics
207  * to be optimized for speed.
208  */
209 
210 /* double the default stack size for 64-bit processes */
211 #ifdef _LP64
212 #define	MINSTACK	(8 * 1024)
213 #define	DEFAULTSTACK	(2 * 1024 * 1024)
214 #else
215 #define	MINSTACK	(4 * 1024)
216 #define	DEFAULTSTACK	(1024 * 1024)
217 #endif
218 
219 #define	MUTEX_TRY	0
220 #define	MUTEX_LOCK	1
221 #define	MUTEX_NOCEIL	0x40
222 
223 #if defined(__x86)
224 
225 typedef struct {	/* structure returned by fnstenv */
226 	int	fctrl;		/* control word */
227 	int	fstat;		/* status word (flags, etc) */
228 	int	ftag;		/* tag of which regs busy */
229 	int	misc[4];	/* other stuff, 28 bytes total */
230 } fpuenv_t;
231 
232 #ifdef _SYSCALL32
233 typedef fpuenv_t fpuenv32_t;
234 #endif	/* _SYSCALL32 */
235 
236 #elif defined(__sparc)
237 
238 typedef struct {	/* fp state structure */
239 	greg_t	fsr;
240 	greg_t	fpu_en;
241 } fpuenv_t;
242 
243 #ifdef _SYSCALL32
244 typedef struct {
245 	greg32_t	fsr;
246 	greg32_t	fpu_en;
247 } fpuenv32_t;
248 #endif	/* _SYSCALL32 */
249 
250 #endif	/* __x86 */
251 
252 #if defined(__x86)
253 extern	void	ht_pause(void);		/* "pause" instruction */
254 #define	SMT_PAUSE()	ht_pause()
255 #else
256 #define	SMT_PAUSE()
257 #endif	/* __x86 */
258 
259 /*
260  * Cleanup handler related data.
261  * This structure is exported as _cleanup_t in pthread.h.
262  * pthread.h exports only the size of this structure, so check
263  * _cleanup_t in pthread.h before making any change here.
264  */
265 typedef struct __cleanup {
266 	struct __cleanup *next;		/* pointer to next handler */
267 	caddr_t	fp;			/* current frame pointer */
268 	void	(*func)(void *);	/* cleanup handler address */
269 	void	*arg;			/* handler's argument */
270 } __cleanup_t;
271 
272 /*
273  * Thread-Specific Data (TSD)
274  * TSD_NFAST includes the invalid key zero, so there
275  * are really only (TSD_NFAST - 1) fast key slots.
276  */
277 typedef	void (*PFrV)(void *);
278 #define	TSD_UNALLOCATED	((PFrV)1)
279 #define	TSD_NFAST	9
280 
281 /*
282  * The tsd union is designed to burn a little memory (9 words) to make
283  * lookups blindingly fast.  Note that tsd_nalloc could be placed at the
284  * end of the pad region to increase the likelihood that it falls on the
285  * same cache line as the data.
286  */
287 typedef union tsd {
288 	uint_t tsd_nalloc;		/* Amount of allocated storage */
289 	void *tsd_pad[TSD_NFAST];
290 	void *tsd_data[1];
291 } tsd_t;
292 
293 typedef struct {
294 	mutex_t tsdm_lock;		/* Lock protecting the data */
295 	uint_t tsdm_nkeys;		/* Number of allocated keys */
296 	uint_t tsdm_nused;		/* Number of used keys */
297 	PFrV *tsdm_destro;		/* Per-key destructors */
298 	char tsdm_pad[64 -		/* pad to 64 bytes */
299 		(sizeof (mutex_t) + 2 * sizeof (uint_t) + sizeof (PFrV *))];
300 } tsd_metadata_t;
301 
302 #ifdef _SYSCALL32
303 typedef union tsd32 {
304 	uint_t tsd_nalloc;		/* Amount of allocated storage */
305 	caddr32_t tsd_pad[TSD_NFAST];
306 	caddr32_t tsd_data[1];
307 } tsd32_t;
308 
309 typedef struct {
310 	mutex_t tsdm_lock;		/* Lock protecting the data */
311 	uint_t tsdm_nkeys;		/* Number of allocated keys */
312 	uint_t tsdm_nused;		/* Number of used keys */
313 	caddr32_t tsdm_destro;		/* Per-key destructors */
314 	char tsdm_pad[64 -		/* pad to 64 bytes */
315 		(sizeof (mutex_t) + 2 * sizeof (uint_t) + sizeof (caddr32_t))];
316 } tsd_metadata32_t;
317 #endif	/* _SYSCALL32 */
318 
319 
320 /*
321  * Thread-Local Storage (TLS)
322  */
323 typedef struct {
324 	void		*tls_data;
325 	size_t		tls_size;
326 } tls_t;
327 
328 typedef struct {
329 	mutex_t	tls_lock;		/* Lock protecting the data */
330 	tls_t	tls_modinfo;		/* Root of all TLS_modinfo data */
331 	tls_t	static_tls;		/* Template for static TLS */
332 	char	tls_pad[64 -		/* pad to 64 bytes */
333 		(sizeof (mutex_t) + 2 * sizeof (tls_t))];
334 } tls_metadata_t;
335 
336 #ifdef _SYSCALL32
337 typedef struct {
338 	caddr32_t	tls_data;
339 	size32_t	tls_size;
340 } tls32_t;
341 
342 typedef struct {
343 	mutex_t	tls_lock;		/* Lock protecting the data */
344 	tls32_t	tls_modinfo;		/* Root of all TLS_modinfo data */
345 	tls32_t	static_tls;		/* Template for static TLS */
346 	char	tls_pad[64 -		/* pad to 64 bytes */
347 		(sizeof (mutex_t) + 2 * sizeof (tls32_t))];
348 } tls_metadata32_t;
349 #endif	/* _SYSCALL32 */
350 
351 
352 /*
353  * Sleep queue root for USYNC_THREAD condvars and mutexes.
354  * There is a default queue root for each queue head (see below).
355  * Also, each ulwp_t contains a queue root that can be used
356  * when the thread is enqueued on the queue, if necessary
357  * (when more than one wchan hashes to the same queue head).
358  */
359 typedef struct queue_root {
360 	struct queue_root	*qr_next;
361 	struct queue_root	*qr_prev;
362 	struct ulwp		*qr_head;
363 	struct ulwp		*qr_tail;
364 	void			*qr_wchan;
365 	uint32_t		qr_rtcount;
366 	uint32_t		qr_qlen;
367 	uint32_t		qr_qmax;
368 } queue_root_t;
369 
370 #ifdef _SYSCALL32
371 typedef struct queue_root32 {
372 	caddr32_t		qr_next;
373 	caddr32_t		qr_prev;
374 	caddr32_t		qr_head;
375 	caddr32_t		qr_tail;
376 	caddr32_t		qr_wchan;
377 	uint32_t		qr_rtcount;
378 	uint32_t		qr_qlen;
379 	uint32_t		qr_qmax;
380 } queue_root32_t;
381 #endif
382 
383 /*
384  * Sleep queue heads for USYNC_THREAD condvars and mutexes.
385  * The size and alignment is 128 bytes to reduce cache conflicts.
386  * Each queue head points to a list of queue roots, defined above.
387  * Each queue head contains a default queue root for use when only one
388  * is needed.  It is always at the tail of the queue root hash chain.
389  */
390 typedef union {
391 	uint64_t		qh_64[16];
392 	struct {
393 		mutex_t		q_lock;
394 		uint8_t		q_qcnt;
395 		uint8_t		q_type;		/* MX or CV */
396 		uint8_t		q_pad1[2];
397 		uint32_t	q_lockcount;
398 		uint32_t	q_qlen;
399 		uint32_t	q_qmax;
400 		void		*q_wchan;	/* valid only while locked */
401 		struct queue_root *q_root;	/* valid only while locked */
402 		struct queue_root *q_hlist;
403 #if !defined(_LP64)
404 		caddr_t		q_pad2[3];
405 #endif
406 		queue_root_t	q_def_root;
407 		uint32_t	q_hlen;
408 		uint32_t	q_hmax;
409 	} qh_qh;
410 } queue_head_t;
411 
412 #define	qh_lock		qh_qh.q_lock
413 #define	qh_qcnt		qh_qh.q_qcnt
414 #define	qh_type		qh_qh.q_type
415 #if defined(THREAD_DEBUG)
416 #define	qh_lockcount	qh_qh.q_lockcount
417 #define	qh_qlen		qh_qh.q_qlen
418 #define	qh_qmax		qh_qh.q_qmax
419 #endif
420 #define	qh_wchan	qh_qh.q_wchan
421 #define	qh_root		qh_qh.q_root
422 #define	qh_hlist	qh_qh.q_hlist
423 #define	qh_def_root	qh_qh.q_def_root
424 #define	qh_hlen		qh_qh.q_hlen
425 #define	qh_hmax		qh_qh.q_hmax
426 
427 /* queue types passed to queue_lock() */
428 #define	MX	0
429 #define	CV	1
430 #define	QHASHSHIFT	9			/* number of hashing bits */
431 #define	QHASHSIZE	(1 << QHASHSHIFT)	/* power of 2 (1<<9 == 512) */
432 #define	QUEUE_HASH(wchan, type)	((uint_t)			\
433 	((((uintptr_t)(wchan) >> 3)				\
434 	^ ((uintptr_t)(wchan) >> (QHASHSHIFT + 3)))		\
435 	& (QHASHSIZE - 1)) + (((type) == MX)? 0 : QHASHSIZE))
436 
437 extern	queue_head_t	*queue_lock(void *, int);
438 extern	void		queue_unlock(queue_head_t *);
439 extern	void		enqueue(queue_head_t *, struct ulwp *, int);
440 extern	struct ulwp	*dequeue(queue_head_t *, int *);
441 extern	struct ulwp	**queue_slot(queue_head_t *, struct ulwp **, int *);
442 extern	struct ulwp	*queue_waiter(queue_head_t *);
443 extern	int		dequeue_self(queue_head_t *);
444 extern	void		queue_unlink(queue_head_t *,
445 				struct ulwp **, struct ulwp *);
446 extern	void		unsleep_self(void);
447 extern	void		spin_lock_set(mutex_t *);
448 extern	void		spin_lock_clear(mutex_t *);
449 
450 /*
451  * Scheduling class information structure.
452  */
453 typedef struct {
454 	short		pcc_state;
455 	short		pcc_policy;
456 	pri_t		pcc_primin;
457 	pri_t		pcc_primax;
458 	pcinfo_t	pcc_info;
459 } pcclass_t;
460 
461 /*
462  * Memory block for chain of owned ceiling mutexes.
463  */
464 typedef struct mxchain {
465 	struct mxchain	*mxchain_next;
466 	mutex_t		*mxchain_mx;
467 } mxchain_t;
468 
469 /*
470  * Pointer to an rwlock that is held for reading.
471  * Used in rw_rdlock() to allow a thread that already holds a read
472  * lock to acquire another read lock on the same rwlock even if
473  * there are writers waiting.  This to avoid deadlock when acquiring
474  * a read lock more than once in the presence of pending writers.
475  * POSIX mandates this behavior.
476  */
477 typedef struct {
478 	void	*rd_rwlock;	/* the rwlock held for reading */
479 	size_t	rd_count;	/* count of read locks applied */
480 } readlock_t;
481 
482 #ifdef _SYSCALL32
483 typedef struct {
484 	caddr32_t	rd_rwlock;
485 	size32_t	rd_count;
486 } readlock32_t;
487 #endif	/* _SYSCALL32 */
488 
489 /*
490  * Maximum number of read locks allowed for one thread on one rwlock.
491  * This could be as large as INT_MAX, but the SUSV3 test suite would
492  * take an inordinately long time to complete.  This is big enough.
493  */
494 #define	READ_LOCK_MAX	100000
495 
496 #define	ul_tlsent	ul_tls.tls_data	/* array of pointers to dynamic TLS */
497 #define	ul_ntlsent	ul_tls.tls_size	/* number of entries in ul_tlsent */
498 
499 /*
500  * Round up an integral value to a multiple of 64
501  */
502 #define	roundup64(x)	(-(-(x) & -64))
503 
504 /*
505  * NOTE:  Whatever changes are made to ulwp_t must be
506  * reflected in $SRC/cmd/mdb/common/modules/libc/libc.c
507  *
508  * NOTE: ul_self *must* be the first member of ulwp_t on x86
509  * Low-level x86 code relies on this.
510  */
511 typedef struct ulwp {
512 	/*
513 	 * These members always need to come first on sparc.
514 	 * For dtrace, a ulwp_t must be aligned on a 64-byte boundary.
515 	 */
516 #if defined(__sparc)
517 	uint32_t	ul_dinstr;	/* scratch space for dtrace */
518 	uint32_t	ul_padsparc0[15];
519 	uint32_t	ul_dsave;	/* dtrace: save %g1, %g0, %sp */
520 	uint32_t	ul_drestore;	/* dtrace: restore %g0, %g0, %g0 */
521 	uint32_t	ul_dftret;	/* dtrace: return probe fasttrap */
522 	uint32_t	ul_dreturn;	/* dtrace: return %o0 */
523 #endif
524 	struct ulwp	*ul_self;	/* pointer to self */
525 #if defined(__i386)
526 	uint8_t		ul_dinstr[40];	/* scratch space for dtrace */
527 #elif defined(__amd64)
528 	uint8_t		ul_dinstr[56];	/* scratch space for dtrace */
529 #endif
530 	struct uberdata *ul_uberdata;	/* uber (super-global) data */
531 	tls_t		ul_tls;		/* dynamic thread-local storage base */
532 	struct ulwp	*ul_forw;	/* forw, back all_lwps list, */
533 	struct ulwp	*ul_back;	/* protected by link_lock */
534 	struct ulwp	*ul_next;	/* list to keep track of stacks */
535 	struct ulwp	*ul_hash;	/* hash chain linked list */
536 	void		*ul_rval;	/* return value from thr_exit() */
537 	caddr_t		ul_stk;		/* mapping base of the stack */
538 	size_t		ul_mapsiz;	/* mapping size of the stack */
539 	size_t		ul_guardsize;	/* normally _lpagesize */
540 	uintptr_t	ul_stktop;	/* broken thr_stksegment() interface */
541 	size_t		ul_stksiz;	/* broken thr_stksegment() interface */
542 	stack_t		ul_ustack;	/* current stack boundaries */
543 	int		ul_ix;		/* hash index */
544 	lwpid_t		ul_lwpid;	/* thread id, aka the lwp id */
545 	pri_t		ul_pri;		/* scheduling priority */
546 	pri_t		ul_epri;	/* real-time ceiling priority */
547 	char		ul_policy;	/* scheduling policy */
548 	char		ul_cid;		/* scheduling class id */
549 	union {
550 		struct {
551 			char	cursig;	/* deferred signal number */
552 			char	pleasestop; /* lwp requested to stop itself */
553 		} s;
554 		short	curplease;	/* for testing both at once */
555 	} ul_cp;
556 	char		ul_stop;	/* reason for stopping */
557 	char		ul_signalled;	/* this lwp was cond_signal()d */
558 	char		ul_dead;	/* this lwp has called thr_exit */
559 	char		ul_unwind;	/* posix: unwind C++ stack */
560 	char		ul_detached;	/* THR_DETACHED at thread_create() */
561 					/* or pthread_detach() was called */
562 	char		ul_writer;	/* sleeping in rw_wrlock() */
563 	char		ul_stopping;	/* set by curthread: stopping self */
564 	char		ul_cancel_prologue;	/* for _cancel_prologue() */
565 	short		ul_preempt;	/* no_preempt()/preempt() */
566 	short		ul_savpreempt;	/* pre-existing preempt value */
567 	char		ul_sigsuspend;	/* thread is in sigsuspend/pollsys */
568 	char		ul_main;	/* thread is the main thread */
569 	char		ul_fork;	/* thread is performing a fork */
570 	char		ul_primarymap;	/* primary link-map is initialized */
571 	/* per-thread copies of the corresponding global variables */
572 	uint8_t		ul_max_spinners;	/* thread_max_spinners */
573 	char		ul_door_noreserve;	/* thread_door_noreserve */
574 	char		ul_queue_fifo;		/* thread_queue_fifo */
575 	char		ul_cond_wait_defer;	/* thread_cond_wait_defer */
576 	char		ul_error_detection;	/* thread_error_detection */
577 	char		ul_async_safe;		/* thread_async_safe */
578 	char		ul_rt;			/* found on an RT queue */
579 	char		ul_rtqueued;		/* was RT when queued */
580 	int		ul_adaptive_spin;	/* thread_adaptive_spin */
581 	int		ul_queue_spin;		/* thread_queue_spin */
582 	volatile int	ul_critical;	/* non-zero == in a critical region */
583 	int		ul_sigdefer;	/* non-zero == defer signals */
584 	int		ul_vfork;	/* thread is the child of vfork() */
585 	int		ul_cancelable;	/* _cancelon()/_canceloff() */
586 	char		ul_cancel_pending;  /* pthread_cancel() was called */
587 	char		ul_cancel_disabled; /* PTHREAD_CANCEL_DISABLE */
588 	char		ul_cancel_async;    /* PTHREAD_CANCEL_ASYNCHRONOUS */
589 	char		ul_save_async;	/* saved copy of ul_cancel_async */
590 	char		ul_mutator;	/* lwp is a mutator (java interface) */
591 	char		ul_created;	/* created suspended */
592 	char		ul_replace;	/* replacement; must be free()d */
593 	uchar_t		ul_nocancel;	/* cancellation can't happen */
594 	int		ul_errno;	/* per-thread errno */
595 	int		*ul_errnop;	/* pointer to errno or self->ul_errno */
596 	__cleanup_t	*ul_clnup_hdr;	/* head of cleanup handlers list */
597 	uberflags_t	*ul_schedctl_called;	/* ul_schedctl is set up */
598 	volatile sc_shared_t *ul_schedctl;	/* schedctl data */
599 	int		ul_bindflags;	/* bind_guard() interface to ld.so.1 */
600 	uint_t		ul_libc_locks;	/* count of cancel_safe_mutex_lock()s */
601 	tsd_t		*ul_stsd;	/* slow TLS for keys >= TSD_NFAST */
602 	void		*ul_ftsd[TSD_NFAST]; /* fast TLS for keys < TSD_NFAST */
603 	td_evbuf_t	ul_td_evbuf;	/* event buffer */
604 	char		ul_td_events_enable;	/* event mechanism enabled */
605 	char		ul_sync_obj_reg;	/* tdb_sync_obj_register() */
606 	char		ul_qtype;	/* MX or CV */
607 	char		ul_cv_wake;	/* != 0: just wake up, don't requeue */
608 	int		ul_usropts;	/* flags given to thr_create() */
609 	void		*(*ul_startpc)(void *); /* start func (thr_create()) */
610 	void		*ul_startarg;	/* argument for start function */
611 	void		*ul_wchan;	/* synch object when sleeping */
612 	struct ulwp	*ul_link;	/* sleep queue link */
613 	queue_head_t	*ul_sleepq;	/* sleep queue thread is waiting on */
614 	mutex_t		*ul_cvmutex;	/* mutex dropped when waiting on a cv */
615 	mxchain_t	*ul_mxchain;	/* chain of owned ceiling mutexes */
616 	int		ul_save_state;	/* bind_guard() interface to ld.so.1 */
617 	uint_t		ul_rdlockcnt;	/* # entries in ul_readlock array */
618 				/* 0 means there is but a single entry */
619 	union {				/* single entry or pointer to array */
620 		readlock_t	single;
621 		readlock_t	*array;
622 	} ul_readlock;
623 	uint_t		ul_heldlockcnt;	/* # entries in ul_heldlocks array */
624 				/* 0 means there is but a single entry */
625 	union {				/* single entry or pointer to array */
626 		mutex_t		*single;
627 		mutex_t		**array;
628 	} ul_heldlocks;
629 	/* PROBE_SUPPORT begin */
630 	void		*ul_tpdp;
631 	/* PROBE_SUPPORT end */
632 	ucontext_t	*ul_siglink;	/* pointer to previous context */
633 	uint_t		ul_spin_lock_spin;	/* spin lock statistics */
634 	uint_t		ul_spin_lock_spin2;
635 	uint_t		ul_spin_lock_sleep;
636 	uint_t		ul_spin_lock_wakeup;
637 	queue_root_t	ul_queue_root;	/* root of a sleep queue */
638 	id_t		ul_rtclassid;	/* real-time class id */
639 	uint_t		ul_pilocks;	/* count of PI locks held */
640 		/* the following members *must* be last in the structure */
641 		/* they are discarded when ulwp is replaced on thr_exit() */
642 	sigset_t	ul_sigmask;	/* thread's current signal mask */
643 	sigset_t	ul_tmpmask;	/* signal mask for sigsuspend/pollsys */
644 	siginfo_t	ul_siginfo;	/* deferred siginfo */
645 	mutex_t		ul_spinlock;	/* used when suspending/continuing */
646 	fpuenv_t	ul_fpuenv;	/* floating point state */
647 	uintptr_t	ul_sp;		/* stack pointer when blocked */
648 	void		*ul_ex_unwind;	/* address of _ex_unwind() or -1 */
649 #if defined(sparc)
650 	void		*ul_unwind_ret;	/* used only by _ex_clnup_handler() */
651 #endif
652 } ulwp_t;
653 
654 #define	ul_cursig	ul_cp.s.cursig		/* deferred signal number */
655 #define	ul_pleasestop	ul_cp.s.pleasestop	/* lwp requested to stop */
656 #define	ul_curplease	ul_cp.curplease		/* for testing both at once */
657 
658 /*
659  * This is the size of a replacement ulwp, retained only for the benefit
660  * of thr_join().  The trailing members are unneeded for this purpose.
661  */
662 #define	REPLACEMENT_SIZE	((size_t)&((ulwp_t *)NULL)->ul_sigmask)
663 
664 /*
665  * Definitions for static initialization of signal sets,
666  * plus some sneaky optimizations in various places.
667  */
668 
669 #define	SIGMASK(sig)	((uint32_t)1 << (((sig) - 1) & (32 - 1)))
670 
671 #if (MAXSIG > 32 && MAXSIG <= 64)
672 #define	FILLSET0	0xffffffffu
673 #define	FILLSET1	((1u << (MAXSIG - 32)) - 1)
674 #else
675 #error "fix me: MAXSIG out of bounds"
676 #endif
677 
678 #define	CANTMASK0	(SIGMASK(SIGKILL) | SIGMASK(SIGSTOP))
679 #define	CANTMASK1	0
680 
681 #define	MASKSET0	(FILLSET0 & ~CANTMASK0)
682 #define	MASKSET1	(FILLSET1 & ~CANTMASK1)
683 
684 extern	const sigset_t maskset;		/* set of all maskable signals */
685 
686 extern	int	thread_adaptive_spin;
687 extern	uint_t	thread_max_spinners;
688 extern	int	thread_queue_spin;
689 extern	int	thread_queue_fifo;
690 extern	int	thread_queue_dump;
691 extern	int	thread_cond_wait_defer;
692 extern	int	thread_async_safe;
693 extern	int	thread_queue_verify;
694 
695 /*
696  * pthread_atfork() related data, used to store atfork handlers.
697  */
698 typedef struct atfork {
699 	struct atfork *forw;		/* forward pointer */
700 	struct atfork *back;		/* backward pointer */
701 	void (*prepare)(void);		/* pre-fork handler */
702 	void (*parent)(void);		/* post-fork parent handler */
703 	void (*child)(void);		/* post-fork child handler */
704 } atfork_t;
705 
706 /*
707  * Element in the table of registered process robust locks.
708  * We keep track of these to make sure that we only call
709  * ___lwp_mutex_register() once for each such lock.
710  */
711 typedef struct robust {
712 	struct robust	*robust_next;
713 	mutex_t		*robust_lock;
714 } robust_t;
715 
716 /*
717  * Parameters of the lock registration hash table.
718  */
719 #define	LOCKSHIFT	9			/* number of hashing bits */
720 #define	LOCKHASHSZ	(1 << LOCKSHIFT)	/* power of 2 (1<<9 == 512) */
721 #define	LOCK_HASH(addr)	(uint_t)			\
722 	((((uintptr_t)(addr) >> 3)			\
723 	^ ((uintptr_t)(addr) >> (LOCKSHIFT + 3)))	\
724 	& (LOCKHASHSZ - 1))
725 
726 /*
727  * Make our hot locks reside on private cache lines (64 bytes).
728  */
729 typedef struct {
730 	mutex_t	pad_lock;
731 	char	pad_pad[64 - sizeof (mutex_t)];
732 } pad_lock_t;
733 
734 /*
735  * Make our semi-hot locks reside on semi-private cache lines (32 bytes).
736  */
737 typedef struct {
738 	mutex_t	pad_lock;
739 	char	pad_pad[32 - sizeof (mutex_t)];
740 } pad32_lock_t;
741 
742 /*
743  * The threads hash table is used for fast lookup and locking of an active
744  * thread structure (ulwp_t) given a thread-id.  It is an N-element array of
745  * thr_hash_table_t structures, where N == 1 before the main thread creates
746  * the first additional thread and N == 1024 afterwards.  Each element of the
747  * table is 64 bytes in size and alignment to reduce cache conflicts.
748  */
749 typedef struct {
750 	mutex_t	hash_lock;	/* lock per bucket */
751 	cond_t	hash_cond;	/* convar per bucket */
752 	ulwp_t	*hash_bucket;	/* hash bucket points to the list of ulwps */
753 	char	hash_pad[64 -	/* pad out to 64 bytes */
754 		(sizeof (mutex_t) + sizeof (cond_t) + sizeof (ulwp_t *))];
755 } thr_hash_table_t;
756 
757 #ifdef _SYSCALL32
758 typedef struct {
759 	mutex_t	hash_lock;
760 	cond_t	hash_cond;
761 	caddr32_t hash_bucket;
762 	char	hash_pad[64 -
763 		(sizeof (mutex_t) + sizeof (cond_t) + sizeof (caddr32_t))];
764 } thr_hash_table32_t;
765 #endif	/* _SYSCALL32 */
766 
767 
768 /*
769  * siguaction members have 128-byte size and 64-byte alignment.
770  * We know that sizeof (struct sigaction) is 32 bytes for both
771  * _ILP32 and _LP64 and that sizeof (rwlock_t) is 64 bytes.
772  */
773 typedef struct {
774 	rwlock_t	sig_lock;
775 	struct sigaction sig_uaction;
776 	char	sig_pad[128 - sizeof (rwlock_t) - sizeof (struct sigaction)];
777 } siguaction_t;
778 
779 #ifdef _SYSCALL32
780 typedef struct {
781 	rwlock_t	sig_lock;
782 	struct sigaction32 sig_uaction;
783 	char	sig_pad[128 - sizeof (rwlock_t) - sizeof (struct sigaction32)];
784 } siguaction32_t;
785 #endif	/* _SYSCALL32 */
786 
787 
788 /*
789  * Bucket structures, used by lmalloc()/lfree().
790  * See port/threads/alloc.c for details.
791  * A bucket's size and alignment is 64 bytes.
792  */
793 typedef struct {
794 	mutex_t	bucket_lock;	/* protects the free list allocations */
795 	void	*free_list;	/* LIFO list of blocks to allocate/free */
796 	size_t	chunks;		/* number of 64K blocks mmap()ed last time */
797 	char	pad64[64 -	/* pad out to 64 bytes */
798 		(sizeof (mutex_t) + sizeof (void *) + sizeof (size_t))];
799 } bucket_t;
800 
801 #ifdef _SYSCALL32
802 typedef struct {
803 	mutex_t		bucket_lock;
804 	caddr32_t	free_list;
805 	size32_t	chunks;
806 	char	pad64[64 -	/* pad out to 64 bytes */
807 		(sizeof (mutex_t) + sizeof (caddr32_t) + sizeof (size32_t))];
808 } bucket32_t;
809 #endif	/* _SYSCALL32 */
810 
811 #define	NBUCKETS	10	/* sizes ranging from 64 to 32768 */
812 
813 
814 /*
815  * atexit() data structures.
816  * See port/gen/atexit.c for details.
817  */
818 typedef void (*_exithdlr_func_t) (void);
819 
820 typedef struct _exthdlr {
821 	struct _exthdlr 	*next;	/* next in handler list */
822 	_exithdlr_func_t	hdlr;	/* handler itself */
823 } _exthdlr_t;
824 
825 typedef struct {
826 	mutex_t		exitfns_lock;
827 	_exthdlr_t	*head;
828 	void		*exit_frame_monitor;
829 	char		exit_pad[64 -	/* pad out to 64 bytes */
830 		(sizeof (mutex_t) + sizeof (_exthdlr_t *) + sizeof (void *))];
831 } atexit_root_t;
832 
833 #ifdef _SYSCALL32
834 typedef struct {
835 	mutex_t		exitfns_lock;
836 	caddr32_t	head;
837 	caddr32_t	exit_frame_monitor;
838 	char		exit_pad[64 -	/* pad out to 64 bytes */
839 		(sizeof (mutex_t) + sizeof (caddr32_t) + sizeof (caddr32_t))];
840 } atexit_root32_t;
841 #endif	/* _SYSCALL32 */
842 
843 
844 /*
845  * This is data that is global to all link maps (uberdata, aka super-global).
846  */
847 typedef struct uberdata {
848 	pad_lock_t	_link_lock;
849 	pad32_lock_t	_fork_lock;
850 	pad32_lock_t	_atfork_lock;
851 	pad32_lock_t	_callout_lock;
852 	pad32_lock_t	_tdb_hash_lock;
853 	tdb_sync_stats_t tdb_hash_lock_stats;
854 	siguaction_t	siguaction[NSIG];
855 	bucket_t	bucket[NBUCKETS];
856 	atexit_root_t	atexit_root;
857 	tsd_metadata_t	tsd_metadata;
858 	tls_metadata_t	tls_metadata;
859 	/*
860 	 * Every object before this point has size and alignment of 64 bytes.
861 	 * Don't add any other type of data before this point.
862 	 */
863 	char	primary_map;	/* set when primary link map is initialized */
864 	char	bucket_init;	/* set when bucket[NBUCKETS] is initialized */
865 	char	pad[2];
866 	uberflags_t	uberflags;
867 	queue_head_t	*queue_head;
868 	thr_hash_table_t *thr_hash_table;
869 	uint_t		hash_size;	/* # of entries in thr_hash_table[] */
870 	uint_t		hash_mask;	/* hash_size - 1 */
871 	ulwp_t	*ulwp_one;	/* main thread */
872 	ulwp_t	*all_lwps;	/* circular ul_forw/ul_back list of live lwps */
873 	ulwp_t	*all_zombies;	/* circular ul_forw/ul_back list of zombies */
874 	int	nthreads;	/* total number of live threads/lwps */
875 	int	nzombies;	/* total number of zombie threads */
876 	int	ndaemons;	/* total number of THR_DAEMON threads/lwps */
877 	pid_t	pid;		/* the current process's pid */
878 	void	(*sigacthandler)(int, siginfo_t *, void *);
879 	ulwp_t	*lwp_stacks;
880 	ulwp_t	*lwp_laststack;
881 	int	nfreestack;
882 	int	thread_stack_cache;
883 	ulwp_t	*ulwp_freelist;
884 	ulwp_t	*ulwp_lastfree;
885 	ulwp_t	*ulwp_replace_free;
886 	ulwp_t	*ulwp_replace_last;
887 	atfork_t	*atforklist;	/* circular Q for fork handlers */
888 	robust_t	**robustlocks;	/* table of registered robust locks */
889 	struct uberdata **tdb_bootstrap;
890 	tdb_t	tdb;		/* thread debug interfaces (for libc_db) */
891 } uberdata_t;
892 
893 #define	link_lock	_link_lock.pad_lock
894 #define	fork_lock	_fork_lock.pad_lock
895 #define	atfork_lock	_atfork_lock.pad_lock
896 #define	callout_lock	_callout_lock.pad_lock
897 #define	tdb_hash_lock	_tdb_hash_lock.pad_lock
898 
899 #pragma align 64(__uberdata)
900 extern	uberdata_t	__uberdata;
901 extern	uberdata_t	**__tdb_bootstrap;	/* known to libc_db and mdb */
902 extern	int		primary_link_map;
903 
904 #define	ulwp_mutex(ulwp, udp)	\
905 	(&(udp)->thr_hash_table[(ulwp)->ul_ix].hash_lock)
906 #define	ulwp_condvar(ulwp, udp)	\
907 	(&(udp)->thr_hash_table[(ulwp)->ul_ix].hash_cond)
908 
909 /*
910  * Grab and release the hash table lock for the specified lwp.
911  */
912 #define	ulwp_lock(ulwp, udp)	lmutex_lock(ulwp_mutex(ulwp, udp))
913 #define	ulwp_unlock(ulwp, udp)	lmutex_unlock(ulwp_mutex(ulwp, udp))
914 
915 #ifdef _SYSCALL32	/* needed by libc_db */
916 
917 typedef struct ulwp32 {
918 #if defined(__sparc)
919 	uint32_t	ul_dinstr;	/* scratch space for dtrace */
920 	uint32_t	ul_padsparc0[15];
921 	uint32_t	ul_dsave;	/* dtrace: save %g1, %g0, %sp */
922 	uint32_t	ul_drestore;	/* dtrace: restore %g0, %g0, %g0 */
923 	uint32_t	ul_dftret;	/* dtrace: return probe fasttrap */
924 	uint32_t	ul_dreturn;	/* dtrace: return %o0 */
925 #endif
926 	caddr32_t	ul_self;	/* pointer to self */
927 #if defined(__x86)
928 	uint8_t		ul_dinstr[40];	/* scratch space for dtrace */
929 #endif
930 	caddr32_t	ul_uberdata;	/* uber (super-global) data */
931 	tls32_t		ul_tls;		/* dynamic thread-local storage base */
932 	caddr32_t	ul_forw;	/* forw, back all_lwps list, */
933 	caddr32_t	ul_back;	/* protected by link_lock */
934 	caddr32_t	ul_next;	/* list to keep track of stacks */
935 	caddr32_t	ul_hash;	/* hash chain linked list */
936 	caddr32_t	ul_rval;	/* return value from thr_exit() */
937 	caddr32_t	ul_stk;		/* mapping base of the stack */
938 	size32_t	ul_mapsiz;	/* mapping size of the stack */
939 	size32_t	ul_guardsize;	/* normally _lpagesize */
940 	caddr32_t	ul_stktop;	/* broken thr_stksegment() interface */
941 	size32_t	ul_stksiz;	/* broken thr_stksegment() interface */
942 	stack32_t	ul_ustack;	/* current stack boundaries */
943 	int		ul_ix;		/* hash index */
944 	lwpid_t		ul_lwpid;	/* thread id, aka the lwp id */
945 	pri_t		ul_pri;		/* scheduling priority */
946 	pri_t		ul_epri;	/* real-time ceiling priority */
947 	char		ul_policy;	/* scheduling policy */
948 	char		ul_cid;		/* scheduling class id */
949 	union {
950 		struct {
951 			char	cursig;	/* deferred signal number */
952 			char	pleasestop; /* lwp requested to stop itself */
953 		} s;
954 		short	curplease;	/* for testing both at once */
955 	} ul_cp;
956 	char		ul_stop;	/* reason for stopping */
957 	char		ul_signalled;	/* this lwp was cond_signal()d */
958 	char		ul_dead;	/* this lwp has called thr_exit */
959 	char		ul_unwind;	/* posix: unwind C++ stack */
960 	char		ul_detached;	/* THR_DETACHED at thread_create() */
961 					/* or pthread_detach() was called */
962 	char		ul_writer;	/* sleeping in rw_wrlock() */
963 	char		ul_stopping;	/* set by curthread: stopping self */
964 	char		ul_cancel_prologue;	/* for _cancel_prologue() */
965 	short		ul_preempt;	/* no_preempt()/preempt() */
966 	short		ul_savpreempt;	/* pre-existing preempt value */
967 	char		ul_sigsuspend;	/* thread is in sigsuspend/pollsys */
968 	char		ul_main;	/* thread is the main thread */
969 	char		ul_fork;	/* thread is performing a fork */
970 	char		ul_primarymap;	/* primary link-map is initialized */
971 	/* per-thread copies of the corresponding global variables */
972 	uint8_t		ul_max_spinners;	/* thread_max_spinners */
973 	char		ul_door_noreserve;	/* thread_door_noreserve */
974 	char		ul_queue_fifo;		/* thread_queue_fifo */
975 	char		ul_cond_wait_defer;	/* thread_cond_wait_defer */
976 	char		ul_error_detection;	/* thread_error_detection */
977 	char		ul_async_safe;		/* thread_async_safe */
978 	char		ul_rt;			/* found on an RT queue */
979 	char		ul_rtqueued;		/* was RT when queued */
980 	int		ul_adaptive_spin;	/* thread_adaptive_spin */
981 	int		ul_queue_spin;		/* thread_queue_spin */
982 	int		ul_critical;	/* non-zero == in a critical region */
983 	int		ul_sigdefer;	/* non-zero == defer signals */
984 	int		ul_vfork;	/* thread is the child of vfork() */
985 	int		ul_cancelable;	/* _cancelon()/_canceloff() */
986 	char		ul_cancel_pending;  /* pthread_cancel() was called */
987 	char		ul_cancel_disabled; /* PTHREAD_CANCEL_DISABLE */
988 	char		ul_cancel_async;    /* PTHREAD_CANCEL_ASYNCHRONOUS */
989 	char		ul_save_async;	/* saved copy of ul_cancel_async */
990 	char		ul_mutator;	/* lwp is a mutator (java interface) */
991 	char		ul_created;	/* created suspended */
992 	char		ul_replace;	/* replacement; must be free()d */
993 	uchar_t		ul_nocancel;	/* cancellation can't happen */
994 	int		ul_errno;	/* per-thread errno */
995 	caddr32_t	ul_errnop;	/* pointer to errno or self->ul_errno */
996 	caddr32_t	ul_clnup_hdr;	/* head of cleanup handlers list */
997 	caddr32_t	ul_schedctl_called; /* ul_schedctl is set up */
998 	caddr32_t	ul_schedctl;	/* schedctl data */
999 	int		ul_bindflags;	/* bind_guard() interface to ld.so.1 */
1000 	uint_t		ul_libc_locks;	/* count of cancel_safe_mutex_lock()s */
1001 	caddr32_t	ul_stsd;	/* slow TLS for keys >= TSD_NFAST */
1002 	caddr32_t	ul_ftsd[TSD_NFAST]; /* fast TLS for keys < TSD_NFAST */
1003 	td_evbuf32_t	ul_td_evbuf;	/* event buffer */
1004 	char		ul_td_events_enable;	/* event mechanism enabled */
1005 	char		ul_sync_obj_reg;	/* tdb_sync_obj_register() */
1006 	char		ul_qtype;	/* MX or CV */
1007 	char		ul_cv_wake;	/* != 0: just wake up, don't requeue */
1008 	int		ul_usropts;	/* flags given to thr_create() */
1009 	caddr32_t	ul_startpc;	/* start func (thr_create()) */
1010 	caddr32_t	ul_startarg;	/* argument for start function */
1011 	caddr32_t	ul_wchan;	/* synch object when sleeping */
1012 	caddr32_t	ul_link;	/* sleep queue link */
1013 	caddr32_t	ul_sleepq;	/* sleep queue thread is waiting on */
1014 	caddr32_t	ul_cvmutex;	/* mutex dropped when waiting on a cv */
1015 	caddr32_t	ul_mxchain;	/* chain of owned ceiling mutexes */
1016 	int		ul_save_state;	/* bind_guard() interface to ld.so.1 */
1017 	uint_t		ul_rdlockcnt;	/* # entries in ul_readlock array */
1018 				/* 0 means there is but a single entry */
1019 	union {				/* single entry or pointer to array */
1020 		readlock32_t	single;
1021 		caddr32_t	array;
1022 	} ul_readlock;
1023 	uint_t		ul_heldlockcnt;	/* # entries in ul_heldlocks array */
1024 				/* 0 means there is but a single entry */
1025 	union {				/* single entry or pointer to array */
1026 		caddr32_t	single;
1027 		caddr32_t	array;
1028 	} ul_heldlocks;
1029 	/* PROBE_SUPPORT begin */
1030 	caddr32_t	ul_tpdp;
1031 	/* PROBE_SUPPORT end */
1032 	caddr32_t	ul_siglink;	/* pointer to previous context */
1033 	uint_t		ul_spin_lock_spin;	/* spin lock statistics */
1034 	uint_t		ul_spin_lock_spin2;
1035 	uint_t		ul_spin_lock_sleep;
1036 	uint_t		ul_spin_lock_wakeup;
1037 	queue_root32_t	ul_queue_root;	/* root of a sleep queue */
1038 	id_t		ul_rtclassid;	/* real-time class id */
1039 	uint_t		ul_pilocks;	/* count of PI locks held */
1040 		/* the following members *must* be last in the structure */
1041 		/* they are discarded when ulwp is replaced on thr_exit() */
1042 	sigset32_t	ul_sigmask;	/* thread's current signal mask */
1043 	sigset32_t	ul_tmpmask;	/* signal mask for sigsuspend/pollsys */
1044 	siginfo32_t	ul_siginfo;	/* deferred siginfo */
1045 	mutex_t		ul_spinlock;	/* used when suspending/continuing */
1046 	fpuenv32_t	ul_fpuenv;	/* floating point state */
1047 	caddr32_t	ul_sp;		/* stack pointer when blocked */
1048 #if defined(sparc)
1049 	caddr32_t	ul_unwind_ret;	/* used only by _ex_clnup_handler() */
1050 #endif
1051 } ulwp32_t;
1052 
1053 #define	REPLACEMENT_SIZE32	((size_t)&((ulwp32_t *)NULL)->ul_sigmask)
1054 
1055 typedef struct uberdata32 {
1056 	pad_lock_t	_link_lock;
1057 	pad32_lock_t	_fork_lock;
1058 	pad32_lock_t	_atfork_lock;
1059 	pad32_lock_t	_callout_lock;
1060 	pad32_lock_t	_tdb_hash_lock;
1061 	tdb_sync_stats_t tdb_hash_lock_stats;
1062 	siguaction32_t	siguaction[NSIG];
1063 	bucket32_t	bucket[NBUCKETS];
1064 	atexit_root32_t	atexit_root;
1065 	tsd_metadata32_t tsd_metadata;
1066 	tls_metadata32_t tls_metadata;
1067 	char		primary_map;
1068 	char		bucket_init;
1069 	char		pad[2];
1070 	uberflags_t	uberflags;
1071 	caddr32_t	queue_head;
1072 	caddr32_t	thr_hash_table;
1073 	uint_t		hash_size;
1074 	uint_t		hash_mask;
1075 	caddr32_t	ulwp_one;
1076 	caddr32_t	all_lwps;
1077 	caddr32_t	all_zombies;
1078 	int		nthreads;
1079 	int		nzombies;
1080 	int		ndaemons;
1081 	int		pid;
1082 	caddr32_t	sigacthandler;
1083 	caddr32_t	lwp_stacks;
1084 	caddr32_t	lwp_laststack;
1085 	int		nfreestack;
1086 	int		thread_stack_cache;
1087 	caddr32_t	ulwp_freelist;
1088 	caddr32_t	ulwp_lastfree;
1089 	caddr32_t	ulwp_replace_free;
1090 	caddr32_t	ulwp_replace_last;
1091 	caddr32_t	atforklist;
1092 	caddr32_t	robustlocks;
1093 	caddr32_t	tdb_bootstrap;
1094 	tdb32_t		tdb;
1095 } uberdata32_t;
1096 
1097 #endif	/* _SYSCALL32 */
1098 
1099 /* ul_stop values */
1100 #define	TSTP_REGULAR	0x01	/* Stopped by thr_suspend() */
1101 #define	TSTP_MUTATOR	0x08	/* stopped by thr_suspend_*mutator*() */
1102 #define	TSTP_FORK	0x20	/* stopped by suspend_fork() */
1103 
1104 /*
1105  * Implementation-specific attribute types for pthread_mutexattr_init() etc.
1106  */
1107 
1108 typedef	struct	_cvattr {
1109 	int	pshared;
1110 	clockid_t clockid;
1111 } cvattr_t;
1112 
1113 typedef	struct	_mattr {
1114 	int	pshared;
1115 	int	protocol;
1116 	int	prioceiling;
1117 	int	type;
1118 	int	robustness;
1119 } mattr_t;
1120 
1121 typedef	struct	_thrattr {
1122 	size_t	stksize;
1123 	void	*stkaddr;
1124 	int	detachstate;
1125 	int	daemonstate;
1126 	int	scope;
1127 	int	prio;
1128 	int	policy;
1129 	int	inherit;
1130 	size_t	guardsize;
1131 } thrattr_t;
1132 
1133 typedef	struct	_rwlattr {
1134 	int	pshared;
1135 } rwlattr_t;
1136 
1137 /* _curthread() is inline for speed */
1138 extern	ulwp_t		*_curthread(void);
1139 #define	curthread	(_curthread())
1140 
1141 /* this version (also inline) can be tested for NULL */
1142 extern	ulwp_t		*__curthread(void);
1143 
1144 /* get the current stack pointer (also inline) */
1145 extern	greg_t		stkptr(void);
1146 
1147 /*
1148  * Suppress __attribute__((...)) if we are not compiling with gcc
1149  */
1150 #if !defined(__GNUC__)
1151 #define	__attribute__(string)
1152 #endif
1153 
1154 /* Fetch the dispatch (kernel) priority of a thread */
1155 #define	real_priority(ulwp)	\
1156 	((ulwp)->ul_schedctl? (ulwp)->ul_schedctl->sc_priority : 0)
1157 
1158 /*
1159  * Implementation functions.  Not visible outside of the library itself.
1160  */
1161 extern	int	__nanosleep(const timespec_t *, timespec_t *);
1162 extern	void	getgregs(ulwp_t *, gregset_t);
1163 extern	void	setgregs(ulwp_t *, gregset_t);
1164 extern	void	thr_panic(const char *);
1165 #pragma rarely_called(thr_panic)
1166 extern	ulwp_t	*find_lwp(thread_t);
1167 extern	void	finish_init(void);
1168 extern	void	update_sched(ulwp_t *);
1169 extern	void	queue_alloc(void);
1170 extern	void	tsd_exit(void);
1171 extern	void	tsd_free(ulwp_t *);
1172 extern	void	tls_setup(void);
1173 extern	void	tls_exit(void);
1174 extern	void	tls_free(ulwp_t *);
1175 extern	void	rwl_free(ulwp_t *);
1176 extern	void	heldlock_exit(void);
1177 extern	void	heldlock_free(ulwp_t *);
1178 extern	void	sigacthandler(int, siginfo_t *, void *);
1179 extern	void	signal_init(void);
1180 extern	int	sigequalset(const sigset_t *, const sigset_t *);
1181 extern	void	mutex_setup(void);
1182 extern	void	take_deferred_signal(int);
1183 extern	int	setup_context(ucontext_t *, void *(*func)(ulwp_t *),
1184 			ulwp_t *ulwp, caddr_t stk, size_t stksize);
1185 extern	volatile sc_shared_t *setup_schedctl(void);
1186 extern	void	*lmalloc(size_t);
1187 extern	void	lfree(void *, size_t);
1188 extern	void	*libc_malloc(size_t);
1189 extern	void	*libc_realloc(void *, size_t);
1190 extern	void	libc_free(void *);
1191 extern	char	*libc_strdup(const char *);
1192 extern	void	ultos(uint64_t, int, char *);
1193 extern	void	lock_error(const mutex_t *, const char *, void *, const char *);
1194 extern	void	rwlock_error(const rwlock_t *, const char *, const char *);
1195 extern	void	thread_error(const char *);
1196 extern	void	grab_assert_lock(void);
1197 extern	void	dump_queue_statistics(void);
1198 extern	void	collect_queue_statistics(void);
1199 extern	void	record_spin_locks(ulwp_t *);
1200 extern	void	remember_lock(mutex_t *);
1201 extern	void	forget_lock(mutex_t *);
1202 extern	void	register_lock(mutex_t *);
1203 extern	void	unregister_locks(void);
1204 #if defined(__sparc)
1205 extern	void	_flush_windows(void);
1206 #else
1207 #define	_flush_windows()
1208 #endif
1209 extern	void	set_curthread(void *);
1210 
1211 /*
1212  * Utility function used when waking up many threads (more than MAXLWPS)
1213  * all at once.  See mutex_wakeup_all(), cond_broadcast(), and rw_unlock().
1214  */
1215 #define	MAXLWPS	128	/* max remembered lwpids before overflow */
1216 #define	NEWLWPS	2048	/* max remembered lwpids at first overflow */
1217 extern	lwpid_t	*alloc_lwpids(lwpid_t *, int *, int *);
1218 
1219 /* enter a critical section */
1220 #define	enter_critical(self)	(self->ul_critical++)
1221 
1222 /* exit a critical section, take deferred actions if necessary */
1223 extern	void	do_exit_critical(void);
1224 #define	exit_critical(self)					\
1225 	(void) (self->ul_critical--,				\
1226 	    ((self->ul_curplease && self->ul_critical == 0)?	\
1227 	    (do_exit_critical(), 0) : 0))
1228 
1229 /*
1230  * Like enter_critical()/exit_critical() but just for deferring signals.
1231  * Unlike enter_critical()/exit_critical(), ul_sigdefer may be set while
1232  * calling application functions like constructors and destructors.
1233  * Care must be taken if the application function attempts to set
1234  * the signal mask while a deferred signal is present; the setting
1235  * of the signal mask must also be deferred.
1236  */
1237 #define	sigoff(self)	(self->ul_sigdefer++)
1238 extern	void	sigon(ulwp_t *);
1239 
1240 /* these are exported functions */
1241 extern	void	_sigoff(void);
1242 extern	void	_sigon(void);
1243 
1244 #define	sigorset(s1, s2)				\
1245 	(((s1)->__sigbits[0] |= (s2)->__sigbits[0]),	\
1246 	((s1)->__sigbits[1] |= (s2)->__sigbits[1]),	\
1247 	((s1)->__sigbits[2] |= (s2)->__sigbits[2]),	\
1248 	((s1)->__sigbits[3] |= (s2)->__sigbits[3]))
1249 
1250 #define	sigandset(s1, s2)				\
1251 	(((s1)->__sigbits[0] &= (s2)->__sigbits[0]),	\
1252 	((s1)->__sigbits[1] &= (s2)->__sigbits[1]),	\
1253 	((s1)->__sigbits[2] &= (s2)->__sigbits[2]),	\
1254 	((s1)->__sigbits[3] &= (s2)->__sigbits[3]))
1255 
1256 #define	sigdiffset(s1, s2)				\
1257 	(((s1)->__sigbits[0] &= ~(s2)->__sigbits[0]),	\
1258 	((s1)->__sigbits[1] &= ~(s2)->__sigbits[1]),	\
1259 	((s1)->__sigbits[2] &= ~(s2)->__sigbits[2]),	\
1260 	((s1)->__sigbits[3] &= ~(s2)->__sigbits[3]))
1261 
1262 #define	delete_reserved_signals(s)			\
1263 	(((s)->__sigbits[0] &= MASKSET0),		\
1264 	((s)->__sigbits[1] &= (MASKSET1 & ~SIGMASK(SIGCANCEL))),\
1265 	((s)->__sigbits[2] = 0),			\
1266 	((s)->__sigbits[3] = 0))
1267 
1268 extern	void	block_all_signals(ulwp_t *self);
1269 
1270 /*
1271  * When restoring the signal mask after having previously called
1272  * block_all_signals(), if we have a deferred signal present then
1273  * do nothing other than ASSERT() that we are in a critical region.
1274  * The signal mask will be set when we emerge from the critical region
1275  * and call take_deferred_signal().  There is no race condition here
1276  * because the kernel currently has all signals blocked for this thread.
1277  */
1278 #define	restore_signals(self)						\
1279 	((void) ((self)->ul_cursig?					\
1280 	(ASSERT((self)->ul_critical + (self)->ul_sigdefer != 0), 0) :	\
1281 	__lwp_sigmask(SIG_SETMASK, &(self)->ul_sigmask, NULL)))
1282 
1283 extern	void	set_cancel_pending_flag(ulwp_t *, int);
1284 extern	void	set_cancel_eintr_flag(ulwp_t *);
1285 extern	void	set_parking_flag(ulwp_t *, int);
1286 extern	int	cancel_active(void);
1287 
1288 extern	void	*_thr_setup(ulwp_t *);
1289 extern	void	_fpinherit(ulwp_t *);
1290 extern	void	_lwp_start(void);
1291 extern	void	_lwp_terminate(void);
1292 extern	void	lmutex_lock(mutex_t *);
1293 extern	void	lmutex_unlock(mutex_t *);
1294 extern	void	lrw_rdlock(rwlock_t *);
1295 extern	void	lrw_wrlock(rwlock_t *);
1296 extern	void	lrw_unlock(rwlock_t *);
1297 extern	void	sig_mutex_lock(mutex_t *);
1298 extern	void	sig_mutex_unlock(mutex_t *);
1299 extern	int	sig_mutex_trylock(mutex_t *);
1300 extern	int	sig_cond_wait(cond_t *, mutex_t *);
1301 extern	int	sig_cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
1302 extern	void	cancel_safe_mutex_lock(mutex_t *);
1303 extern	void	cancel_safe_mutex_unlock(mutex_t *);
1304 extern	int	cancel_safe_mutex_trylock(mutex_t *);
1305 extern	void	_prefork_handler(void);
1306 extern	void	_postfork_parent_handler(void);
1307 extern	void	_postfork_child_handler(void);
1308 extern	void	postfork1_child(void);
1309 extern	void	postfork1_child_aio(void);
1310 extern	void	postfork1_child_sigev_aio(void);
1311 extern	void	postfork1_child_sigev_mq(void);
1312 extern	void	postfork1_child_sigev_timer(void);
1313 extern	void	postfork1_child_tpool(void);
1314 extern	void	fork_lock_enter(void);
1315 extern	void	fork_lock_exit(void);
1316 extern	void	suspend_fork(void);
1317 extern	void	continue_fork(int);
1318 extern	void	do_sigcancel(void);
1319 extern	void	setup_cancelsig(int);
1320 extern	void	init_sigev_thread(void);
1321 extern	void	init_aio(void);
1322 extern	void	_cancelon(void);
1323 extern	void	_canceloff(void);
1324 extern	void	_canceloff_nocancel(void);
1325 extern	void	_cancel_prologue(void);
1326 extern	void	_cancel_epilogue(void);
1327 extern	void	no_preempt(ulwp_t *);
1328 extern	void	preempt(ulwp_t *);
1329 extern	void	_thrp_unwind(void *);
1330 
1331 /*
1332  * Prototypes for the strong versions of the interface functions
1333  */
1334 extern	pid_t	__forkx(int);
1335 extern	pid_t	__forkallx(int);
1336 extern	pid_t	_private_getpid(void);
1337 extern	uid_t	_private_geteuid(void);
1338 extern	int	_kill(pid_t, int);
1339 extern	int	_private_open(const char *, int, ...);
1340 extern	int	_private_close(int);
1341 extern	ssize_t	__read(int, void *, size_t);
1342 extern	ssize_t	__write(int, const void *, size_t);
1343 extern	void	*_memcpy(void *, const void *, size_t);
1344 extern	void	*_memset(void *, int, size_t);
1345 extern	int	_memcmp(const void *, const void *, size_t);
1346 extern	void	*_private_memcpy(void *, const void *, size_t);
1347 extern	void	*_private_memset(void *, int, size_t);
1348 extern	int	_private_sigfillset(sigset_t *);
1349 extern	int	_private_sigemptyset(sigset_t *);
1350 extern	int	_private_sigaddset(sigset_t *, int);
1351 extern	int	_private_sigdelset(sigset_t *, int);
1352 extern	int	_private_sigismember(sigset_t *, int);
1353 extern	void	*_private_mmap(void *, size_t, int, int, int, off_t);
1354 extern	int	_private_mprotect(void *, size_t, int);
1355 extern	int	_private_munmap(void *, size_t);
1356 extern	int	_private_getrlimit(int, struct rlimit *);
1357 extern	int	__lwp_continue(lwpid_t);
1358 extern	int	__lwp_create(ucontext_t *, uint_t, lwpid_t *);
1359 extern	int	__lwp_kill(lwpid_t, int);
1360 extern	lwpid_t	__lwp_self(void);
1361 extern	int	___lwp_suspend(lwpid_t);
1362 extern	void	lwp_yield(void);
1363 extern	int	lwp_wait(lwpid_t, lwpid_t *);
1364 extern	int	__lwp_wait(lwpid_t, lwpid_t *);
1365 extern	int	__lwp_detach(lwpid_t);
1366 extern	sc_shared_t *__schedctl(void);
1367 
1368 extern	int	_private_setcontext(const ucontext_t *);
1369 extern	int	_private_getcontext(ucontext_t *);
1370 #pragma unknown_control_flow(_private_getcontext)
1371 /* actual system call traps */
1372 extern	int	__setcontext_syscall(const ucontext_t *);
1373 extern	int	__getcontext_syscall(ucontext_t *);
1374 extern	int	_private_setustack(stack_t *);
1375 extern	int	__clock_gettime(clockid_t, timespec_t *);
1376 extern	void	abstime_to_reltime(clockid_t, const timespec_t *, timespec_t *);
1377 extern	void	hrt2ts(hrtime_t, timespec_t *);
1378 
1379 extern	int	__sigaction(int, const struct sigaction *, struct sigaction *);
1380 extern	int	__lwp_sigmask(int, const sigset_t *, sigset_t *);
1381 extern	void	__sighndlr(int, siginfo_t *, ucontext_t *, void (*)());
1382 extern	caddr_t	__sighndlrend;
1383 #pragma unknown_control_flow(__sighndlr)
1384 extern	void	_siglongjmp(sigjmp_buf, int);
1385 
1386 extern	int	_pthread_setspecific(pthread_key_t, const void *);
1387 extern	void	*_pthread_getspecific(pthread_key_t);
1388 extern	void	_pthread_exit(void *);
1389 extern	int	_pthread_setcancelstate(int, int *);
1390 extern	void	_private_testcancel(void);
1391 
1392 /* belongs in <pthread.h> */
1393 #define	PTHREAD_CREATE_DAEMON_NP	0x100	/* = THR_DAEMON */
1394 #define	PTHREAD_CREATE_NONDAEMON_NP	0
1395 extern	int	_pthread_attr_setdaemonstate_np(pthread_attr_t *, int);
1396 extern	int	_pthread_attr_getdaemonstate_np(const pthread_attr_t *, int *);
1397 
1398 /* these are private to the library */
1399 extern	int	_private_mutex_init(mutex_t *, int, void *);
1400 extern	int	_private_mutex_destroy(mutex_t *);
1401 extern	int	_private_mutex_lock(mutex_t *);
1402 extern	int	_private_mutex_trylock(mutex_t *);
1403 extern	int	_private_mutex_unlock(mutex_t *);
1404 
1405 extern	int	_mutex_init(mutex_t *, int, void *);
1406 extern	int	_mutex_destroy(mutex_t *);
1407 extern	int	_mutex_consistent(mutex_t *);
1408 extern	int	_mutex_lock(mutex_t *);
1409 extern	int	_mutex_trylock(mutex_t *);
1410 extern	int	_mutex_unlock(mutex_t *);
1411 extern	int	__mutex_init(mutex_t *, int, void *);
1412 extern	int	__mutex_destroy(mutex_t *);
1413 extern	int	__mutex_consistent(mutex_t *);
1414 extern	int	__mutex_lock(mutex_t *);
1415 extern	int	__mutex_trylock(mutex_t *);
1416 extern	int	__mutex_unlock(mutex_t *);
1417 extern	int	mutex_is_held(mutex_t *);
1418 extern	int	mutex_lock_internal(mutex_t *, timespec_t *, int);
1419 extern	int	mutex_unlock_internal(mutex_t *, int);
1420 
1421 extern	int	_cond_init(cond_t *, int, void *);
1422 extern	int	_cond_signal(cond_t *);
1423 extern	int	_cond_broadcast(cond_t *);
1424 extern	int	_cond_destroy(cond_t *);
1425 extern	int	cond_signal_internal(cond_t *);
1426 extern	int	cond_broadcast_internal(cond_t *);
1427 /* cancellation points: */
1428 extern	int	_cond_wait(cond_t *, mutex_t *);
1429 extern	int	_cond_timedwait(cond_t *, mutex_t *, const timespec_t *);
1430 extern	int	_cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
1431 /* not cancellation points: */
1432 extern	int	__cond_wait(cond_t *, mutex_t *);
1433 extern	int	__cond_timedwait(cond_t *, mutex_t *, const timespec_t *);
1434 extern	int	__cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
1435 
1436 extern	int	__rwlock_init(rwlock_t *, int, void *);
1437 extern	int	rw_read_is_held(rwlock_t *);
1438 extern	int	rw_write_is_held(rwlock_t *);
1439 
1440 extern	void	_membar_enter(void);
1441 extern	void	_membar_exit(void);
1442 extern	void	_membar_producer(void);
1443 extern	void	_membar_consumer(void);
1444 
1445 extern	int	_thr_continue(thread_t);
1446 extern	int	_thr_create(void *, size_t, void *(*)(void *), void *, long,
1447 			thread_t *);
1448 extern	int	_thrp_create(void *, size_t, void *(*)(void *), void *, long,
1449 			thread_t *, size_t);
1450 extern	int	_thr_getspecific(thread_key_t, void **);
1451 extern	int	_thr_join(thread_t, thread_t *, void **);
1452 extern	int	_thr_keycreate(thread_key_t *, PFrV);
1453 extern	int	_thr_keycreate_once(thread_key_t *, PFrV);
1454 extern	int	_thr_key_delete(thread_key_t);
1455 extern	int	_thr_main(void);
1456 extern	thread_t _thr_self(void);
1457 extern	int	_thr_getconcurrency(void);
1458 extern	int	_thr_setconcurrency(int);
1459 extern	int	_thr_setprio(thread_t, int);
1460 extern	int	_thr_setspecific(thread_key_t, void *);
1461 extern	int	_thr_stksegment(stack_t *);
1462 extern	int	_thrp_suspend(thread_t, uchar_t);
1463 extern	int	_thrp_continue(thread_t, uchar_t);
1464 extern	int	_thr_sigsetmask(int, const sigset_t *, sigset_t *);
1465 
1466 extern	void	_thr_terminate(void *);
1467 extern	void	_thr_exit(void *);
1468 extern	void	_thrp_exit(void);
1469 
1470 extern	const pcclass_t *get_info_by_class(id_t);
1471 extern	const pcclass_t *get_info_by_policy(int);
1472 extern	void	_membar_producer(void);
1473 extern	void	_membar_consumer(void);
1474 extern	const thrattr_t *def_thrattr(void);
1475 extern	id_t	setparam(idtype_t, id_t, int, int);
1476 extern	id_t	setprio(idtype_t, id_t, int, int *);
1477 extern	id_t	getparam(idtype_t, id_t, int *, struct sched_param *);
1478 extern	long	_private_priocntl(idtype_t, id_t, int, void *);
1479 
1480 /*
1481  * System call wrappers (direct interfaces to the kernel)
1482  */
1483 extern	int	___lwp_mutex_register(mutex_t *);
1484 extern	int	___lwp_mutex_trylock(mutex_t *);
1485 extern	int	___lwp_mutex_timedlock(mutex_t *, timespec_t *);
1486 extern	int	___lwp_mutex_unlock(mutex_t *);
1487 extern	int	___lwp_mutex_wakeup(mutex_t *, int);
1488 extern	int	___lwp_cond_wait(cond_t *, mutex_t *, timespec_t *, int);
1489 extern	int	__lwp_cond_signal(lwp_cond_t *);
1490 extern	int	__lwp_cond_broadcast(lwp_cond_t *);
1491 extern	int	___lwp_sema_timedwait(lwp_sema_t *, timespec_t *, int);
1492 extern	int	__lwp_sema_trywait(lwp_sema_t *);
1493 extern	int	__lwp_sema_post(lwp_sema_t *);
1494 extern	int	__lwp_rwlock_rdlock(rwlock_t *, timespec_t *);
1495 extern	int	__lwp_rwlock_wrlock(rwlock_t *, timespec_t *);
1496 extern	int	__lwp_rwlock_tryrdlock(rwlock_t *);
1497 extern	int	__lwp_rwlock_trywrlock(rwlock_t *);
1498 extern	int	__lwp_rwlock_unlock(rwlock_t *);
1499 extern	int	__lwp_park(timespec_t *, lwpid_t);
1500 extern	int	__lwp_unpark(lwpid_t);
1501 extern	int	__lwp_unpark_all(lwpid_t *, int);
1502 #if defined(__x86)
1503 extern	int	___lwp_private(int, int, void *);
1504 #endif	/* __x86 */
1505 
1506 extern	int	_private_lwp_mutex_lock(mutex_t *);
1507 extern	int	_private_lwp_mutex_unlock(mutex_t *);
1508 
1509 /*
1510  * inlines
1511  */
1512 extern	int		set_lock_byte(volatile uint8_t *);
1513 extern	uint32_t	atomic_swap_32(volatile uint32_t *, uint32_t);
1514 extern	uint32_t	atomic_cas_32(volatile uint32_t *, uint32_t, uint32_t);
1515 extern	void		atomic_inc_32(volatile uint32_t *);
1516 extern	void		atomic_dec_32(volatile uint32_t *);
1517 extern	void		atomic_and_32(volatile uint32_t *, uint32_t);
1518 extern	void		atomic_or_32(volatile uint32_t *, uint32_t);
1519 #if defined(__sparc)
1520 extern	ulong_t		caller(void);
1521 extern	ulong_t		getfp(void);
1522 #endif	/* __sparc */
1523 
1524 #include "thr_inlines.h"
1525 
1526 #endif	/* _THR_UBERDATA_H */
1527