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