diff options
Diffstat (limited to 'usr/src/lib/libc/port/threads')
| -rw-r--r-- | usr/src/lib/libc/port/threads/assfail.c | 18 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/cancel.c | 24 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/door_calls.c | 16 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthr_attr.c | 80 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthr_barrier.c | 43 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthr_cond.c | 34 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthr_mutex.c | 57 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthr_rwlock.c | 26 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthread.c | 43 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/rwlock.c | 98 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/scalls.c | 196 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/sema.c | 36 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/sigaction.c | 52 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/spawn.c | 90 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/synch.c | 203 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/tdb_agent.c | 4 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/thr.c | 214 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/tls.c | 2 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/tsd.c | 65 |
19 files changed, 569 insertions, 732 deletions
diff --git a/usr/src/lib/libc/port/threads/assfail.c b/usr/src/lib/libc/port/threads/assfail.c index 5a911d2875..54fbe959a0 100644 --- a/usr/src/lib/libc/port/threads/assfail.c +++ b/usr/src/lib/libc/port/threads/assfail.c @@ -69,7 +69,7 @@ Abort(const char *msg) panic_thread = self; lwpid = self->ul_lwpid; } else { - lwpid = __lwp_self(); + lwpid = _lwp_self(); } /* set SIGABRT signal handler to SIG_DFL w/o grabbing any locks */ @@ -82,8 +82,8 @@ Abort(const char *msg) (void) sigaddset(&sigmask, SIGABRT); (void) __lwp_sigmask(SIG_UNBLOCK, &sigmask, NULL); - (void) __lwp_kill(lwpid, SIGABRT); /* never returns */ - (void) _kill(getpid(), SIGABRT); /* if it does, try harder */ + (void) _lwp_kill(lwpid, SIGABRT); /* never returns */ + (void) kill(getpid(), SIGABRT); /* if it does, try harder */ _exit(127); } @@ -182,7 +182,7 @@ lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg) } else { self = NULL; (void) _lwp_mutex_lock(&assert_lock); - lwpid = __lwp_self(); + lwpid = _lwp_self(); udp = &__uberdata; pid = getpid(); } @@ -200,7 +200,7 @@ lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg) if (msg != NULL) { (void) strcat(buf, ": "); (void) strcat(buf, msg); - } else if (!mutex_is_held(&mcopy)) { + } else if (!mutex_held(&mcopy)) { (void) strcat(buf, ": calling thread does not own the lock"); } else if (mcopy.mutex_rcount) { (void) strcat(buf, ": mutex rcount = "); @@ -212,7 +212,7 @@ lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg) ultos((uint64_t)(uintptr_t)self, 16, buf + strlen(buf)); (void) strcat(buf, " thread-id "); ultos((uint64_t)lwpid, 10, buf + strlen(buf)); - if (msg != NULL || mutex_is_held(&mcopy)) + if (msg != NULL || mutex_held(&mcopy)) /* EMPTY */; else if (mcopy.mutex_lockw == 0) (void) strcat(buf, "\nthe lock is unowned"); @@ -269,7 +269,7 @@ rwlock_error(const rwlock_t *rp, const char *who, const char *msg) } else { self = NULL; (void) _lwp_mutex_lock(&assert_lock); - lwpid = __lwp_self(); + lwpid = _lwp_self(); udp = &__uberdata; pid = getpid(); } @@ -347,7 +347,7 @@ thread_error(const char *msg) } else { self = NULL; (void) _lwp_mutex_lock(&assert_lock); - lwpid = __lwp_self(); + lwpid = _lwp_self(); udp = &__uberdata; } @@ -395,7 +395,7 @@ __assfail(const char *assertion, const char *filename, int line_num) } else { self = NULL; (void) _lwp_mutex_lock(&assert_lock); - lwpid = __lwp_self(); + lwpid = _lwp_self(); } (void) strcpy(buf, "assertion failed for thread "); diff --git a/usr/src/lib/libc/port/threads/cancel.c b/usr/src/lib/libc/port/threads/cancel.c index 5236ff5073..8a77f42088 100644 --- a/usr/src/lib/libc/port/threads/cancel.c +++ b/usr/src/lib/libc/port/threads/cancel.c @@ -34,9 +34,8 @@ * If the target thread has already exited no action is taken. * Else send SIGCANCEL to request the other thread to cancel itself. */ -#pragma weak pthread_cancel = _pthread_cancel int -_pthread_cancel(thread_t tid) +pthread_cancel(thread_t tid) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -77,7 +76,7 @@ _pthread_cancel(thread_t tid) /* * Request the other thread to cancel itself. */ - error = __lwp_kill(tid, SIGCANCEL); + error = _lwp_kill(tid, SIGCANCEL); ulwp_unlock(ulwp, udp); } @@ -91,9 +90,8 @@ _pthread_cancel(thread_t tid) * is pending, then the thread is cancelled right here. * Otherwise, pthread_setcancelstate() is not a cancellation point. */ -#pragma weak pthread_setcancelstate = _pthread_setcancelstate int -_pthread_setcancelstate(int state, int *oldstate) +pthread_setcancelstate(int state, int *oldstate) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -130,7 +128,7 @@ _pthread_setcancelstate(int state, int *oldstate) if ((!self->ul_cancel_disabled || !was_disabled) && self->ul_cancel_async && self->ul_cancel_pending) { ulwp_unlock(self, udp); - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); } ulwp_unlock(self, udp); @@ -149,9 +147,8 @@ _pthread_setcancelstate(int state, int *oldstate) * If the type is being set as ASYNC, then it becomes * a cancellation point if there is a cancellation pending. */ -#pragma weak pthread_setcanceltype = _pthread_setcanceltype int -_pthread_setcanceltype(int type, int *oldtype) +pthread_setcanceltype(int type, int *oldtype) { ulwp_t *self = curthread; int was_async; @@ -184,7 +181,7 @@ _pthread_setcanceltype(int type, int *oldtype) if ((self->ul_cancel_async || was_async) && self->ul_cancel_pending && !self->ul_cancel_disabled) { exit_critical(self); - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); } exit_critical(self); @@ -204,14 +201,13 @@ _pthread_setcanceltype(int type, int *oldtype) * it by calling thr_exit. thr_exit takes care of calling * cleanup handlers. */ -#pragma weak pthread_testcancel = _pthread_testcancel void -_pthread_testcancel(void) +pthread_testcancel(void) { ulwp_t *self = curthread; if (self->ul_cancel_pending && !self->ul_cancel_disabled) - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); } /* @@ -229,7 +225,7 @@ _cancelon() ASSERT(self->ul_cancelable >= 0); self->ul_cancelable++; if (self->ul_cancel_pending) - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); } } @@ -245,7 +241,7 @@ _canceloff() ASSERT(!(self->ul_cancelable && self->ul_cancel_disabled)); if (!self->ul_cancel_disabled) { if (self->ul_cancel_pending) - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); self->ul_cancelable--; ASSERT(self->ul_cancelable >= 0); } diff --git a/usr/src/lib/libc/port/threads/door_calls.c b/usr/src/lib/libc/port/threads/door_calls.c index a298722759..3dae1445d8 100644 --- a/usr/src/lib/libc/port/threads/door_calls.c +++ b/usr/src/lib/libc/port/threads/door_calls.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,20 +18,15 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#pragma weak door_create = _door_create -#pragma weak door_ucred = _door_ucred -#pragma weak door_cred = _door_cred -#pragma weak door_return = _door_return -#pragma weak door_server_create = _door_server_create - -#include "synonyms.h" +#include "lint.h" #include "thr_uberdata.h" #include "libc.h" diff --git a/usr/src/lib/libc/port/threads/pthr_attr.c b/usr/src/lib/libc/port/threads/pthr_attr.c index 8809209083..3bbd1c0f1a 100644 --- a/usr/src/lib/libc/port/threads/pthr_attr.c +++ b/usr/src/lib/libc/port/threads/pthr_attr.c @@ -57,9 +57,9 @@ def_thrattr(void) * pthread_attr_init: allocates the attribute object and initializes it * with the default values. */ -#pragma weak pthread_attr_init = _pthread_attr_init +#pragma weak _pthread_attr_init = pthread_attr_init int -_pthread_attr_init(pthread_attr_t *attr) +pthread_attr_init(pthread_attr_t *attr) { thrattr_t *ap; @@ -75,9 +75,8 @@ _pthread_attr_init(pthread_attr_t *attr) * pthread_attr_destroy: frees the attribute object and invalidates it * with NULL value. */ -#pragma weak pthread_attr_destroy = _pthread_attr_destroy int -_pthread_attr_destroy(pthread_attr_t *attr) +pthread_attr_destroy(pthread_attr_t *attr) { if (attr == NULL || attr->__pthread_attrp == NULL) return (EINVAL); @@ -87,10 +86,10 @@ _pthread_attr_destroy(pthread_attr_t *attr) } /* - * _pthread_attr_clone: make a copy of a pthread_attr_t. + * pthread_attr_clone: make a copy of a pthread_attr_t. */ int -_pthread_attr_clone(pthread_attr_t *attr, const pthread_attr_t *old_attr) +pthread_attr_clone(pthread_attr_t *attr, const pthread_attr_t *old_attr) { thrattr_t *ap; const thrattr_t *old_ap = @@ -106,12 +105,12 @@ _pthread_attr_clone(pthread_attr_t *attr, const pthread_attr_t *old_attr) } /* - * _pthread_attr_equal: compare two pthread_attr_t's, return 1 if equal. + * pthread_attr_equal: compare two pthread_attr_t's, return 1 if equal. * A NULL pthread_attr_t pointer implies default attributes. * This is a consolidation-private interface, for librt. */ int -_pthread_attr_equal(const pthread_attr_t *attr1, const pthread_attr_t *attr2) +pthread_attr_equal(const pthread_attr_t *attr1, const pthread_attr_t *attr2) { const thrattr_t *ap1 = attr1? attr1->__pthread_attrp : def_thrattr(); const thrattr_t *ap2 = attr2? attr2->__pthread_attrp : def_thrattr(); @@ -126,9 +125,8 @@ _pthread_attr_equal(const pthread_attr_t *attr1, const pthread_attr_t *attr2) * be PTHREAD_STACK_MIN (MINSTACK). * This is equivalent to stksize argument in thr_create(). */ -#pragma weak pthread_attr_setstacksize = _pthread_attr_setstacksize int -_pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) +pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) { thrattr_t *ap; @@ -143,9 +141,9 @@ _pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) /* * pthread_attr_getstacksize: gets the user stack size. */ -#pragma weak pthread_attr_getstacksize = _pthread_attr_getstacksize +#pragma weak _pthread_attr_getstacksize = pthread_attr_getstacksize int -_pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) +pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) { thrattr_t *ap; @@ -161,9 +159,8 @@ _pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) * pthread_attr_setstackaddr: sets the user stack addr. * This is equivalent to stkaddr argument in thr_create(). */ -#pragma weak pthread_attr_setstackaddr = _pthread_attr_setstackaddr int -_pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) +pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) { thrattr_t *ap; @@ -177,9 +174,9 @@ _pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) /* * pthread_attr_getstackaddr: gets the user stack addr. */ -#pragma weak pthread_attr_getstackaddr = _pthread_attr_getstackaddr +#pragma weak _pthread_attr_getstackaddr = pthread_attr_getstackaddr int -_pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr) +pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr) { thrattr_t *ap; @@ -195,9 +192,8 @@ _pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr) * pthread_attr_setdetachstate: sets the detach state to DETACHED or JOINABLE. * PTHREAD_CREATE_DETACHED is equivalent to thr_create(THR_DETACHED). */ -#pragma weak pthread_attr_setdetachstate = _pthread_attr_setdetachstate int -_pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) +pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) { thrattr_t *ap; @@ -213,9 +209,9 @@ _pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) /* * pthread_attr_getdetachstate: gets the detach state. */ -#pragma weak pthread_attr_getdetachstate = _pthread_attr_getdetachstate +#pragma weak _pthread_attr_getdetachstate = pthread_attr_getdetachstate int -_pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) +pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) { thrattr_t *ap; @@ -233,7 +229,7 @@ _pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) * For now, this is a private interface in libc. */ int -_pthread_attr_setdaemonstate_np(pthread_attr_t *attr, int daemonstate) +pthread_attr_setdaemonstate_np(pthread_attr_t *attr, int daemonstate) { thrattr_t *ap; @@ -251,7 +247,7 @@ _pthread_attr_setdaemonstate_np(pthread_attr_t *attr, int daemonstate) * For now, this is a private interface in libc. */ int -_pthread_attr_getdaemonstate_np(const pthread_attr_t *attr, int *daemonstate) +pthread_attr_getdaemonstate_np(const pthread_attr_t *attr, int *daemonstate) { thrattr_t *ap; @@ -267,9 +263,8 @@ _pthread_attr_getdaemonstate_np(const pthread_attr_t *attr, int *daemonstate) * pthread_attr_setscope: sets the scope to SYSTEM or PROCESS. * This is equivalent to setting THR_BOUND flag in thr_create(). */ -#pragma weak pthread_attr_setscope = _pthread_attr_setscope int -_pthread_attr_setscope(pthread_attr_t *attr, int scope) +pthread_attr_setscope(pthread_attr_t *attr, int scope) { thrattr_t *ap; @@ -285,9 +280,9 @@ _pthread_attr_setscope(pthread_attr_t *attr, int scope) /* * pthread_attr_getscope: gets the scheduling scope. */ -#pragma weak pthread_attr_getscope = _pthread_attr_getscope +#pragma weak _pthread_attr_getscope = pthread_attr_getscope int -_pthread_attr_getscope(const pthread_attr_t *attr, int *scope) +pthread_attr_getscope(const pthread_attr_t *attr, int *scope) { thrattr_t *ap; @@ -303,9 +298,8 @@ _pthread_attr_getscope(const pthread_attr_t *attr, int *scope) * pthread_attr_setinheritsched: sets the scheduling parameters to be * EXPLICIT or INHERITED from parent thread. */ -#pragma weak pthread_attr_setinheritsched = _pthread_attr_setinheritsched int -_pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit) +pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit) { thrattr_t *ap; @@ -321,9 +315,9 @@ _pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit) /* * pthread_attr_getinheritsched: gets the scheduling inheritance. */ -#pragma weak pthread_attr_getinheritsched = _pthread_attr_getinheritsched +#pragma weak _pthread_attr_getinheritsched = pthread_attr_getinheritsched int -_pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit) +pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit) { thrattr_t *ap; @@ -338,9 +332,8 @@ _pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit) /* * pthread_attr_setschedpolicy: sets the scheduling policy. */ -#pragma weak pthread_attr_setschedpolicy = _pthread_attr_setschedpolicy int -_pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) +pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) { thrattr_t *ap; @@ -355,9 +348,9 @@ _pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) /* * pthread_attr_getpolicy: gets the scheduling policy. */ -#pragma weak pthread_attr_getschedpolicy = _pthread_attr_getschedpolicy +#pragma weak _pthread_attr_getschedpolicy = pthread_attr_getschedpolicy int -_pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) +pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) { thrattr_t *ap; @@ -373,9 +366,8 @@ _pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) * pthread_attr_setschedparam: sets the scheduling parameters. * Currently, we support priority only. */ -#pragma weak pthread_attr_setschedparam = _pthread_attr_setschedparam int -_pthread_attr_setschedparam(pthread_attr_t *attr, +pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param) { thrattr_t *ap; @@ -392,9 +384,9 @@ _pthread_attr_setschedparam(pthread_attr_t *attr, * pthread_attr_getschedparam: gets the scheduling parameters. * Currently, only priority is defined as sched parameter. */ -#pragma weak pthread_attr_getschedparam = _pthread_attr_getschedparam +#pragma weak _pthread_attr_getschedparam = pthread_attr_getschedparam int -_pthread_attr_getschedparam(const pthread_attr_t *attr, +pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param) { thrattr_t *ap; @@ -411,9 +403,8 @@ _pthread_attr_getschedparam(const pthread_attr_t *attr, * UNIX98 * pthread_attr_setguardsize: sets the guardsize */ -#pragma weak pthread_attr_setguardsize = _pthread_attr_setguardsize int -_pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) +pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) { thrattr_t *ap; @@ -428,9 +419,8 @@ _pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) * UNIX98 * pthread_attr_getguardsize: gets the guardsize */ -#pragma weak pthread_attr_getguardsize = _pthread_attr_getguardsize int -_pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize) +pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize) { thrattr_t *ap; @@ -447,9 +437,8 @@ _pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize) * This is equivalent to the stack_base and stack_size arguments * to thr_create(). */ -#pragma weak pthread_attr_setstack = _pthread_attr_setstack int -_pthread_attr_setstack(pthread_attr_t *attr, +pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize) { thrattr_t *ap; @@ -466,9 +455,8 @@ _pthread_attr_setstack(pthread_attr_t *attr, /* * pthread_attr_getstack: gets the user stack addr and stack size. */ -#pragma weak pthread_attr_getstack = _pthread_attr_getstack int -_pthread_attr_getstack(const pthread_attr_t *attr, +pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize) { thrattr_t *ap; diff --git a/usr/src/lib/libc/port/threads/pthr_barrier.c b/usr/src/lib/libc/port/threads/pthr_barrier.c index e57bb31ece..dd4cf1e60a 100644 --- a/usr/src/lib/libc/port/threads/pthr_barrier.c +++ b/usr/src/lib/libc/port/threads/pthr_barrier.c @@ -37,9 +37,8 @@ typedef struct { int pshared; } barrierattr_t; -#pragma weak pthread_barrierattr_init = _pthread_barrierattr_init int -_pthread_barrierattr_init(pthread_barrierattr_t *attr) +pthread_barrierattr_init(pthread_barrierattr_t *attr) { barrierattr_t *ap; @@ -50,9 +49,8 @@ _pthread_barrierattr_init(pthread_barrierattr_t *attr) return (0); } -#pragma weak pthread_barrierattr_destroy = _pthread_barrierattr_destroy int -_pthread_barrierattr_destroy(pthread_barrierattr_t *attr) +pthread_barrierattr_destroy(pthread_barrierattr_t *attr) { if (attr == NULL || attr->__pthread_barrierattrp == NULL) return (EINVAL); @@ -61,9 +59,8 @@ _pthread_barrierattr_destroy(pthread_barrierattr_t *attr) return (0); } -#pragma weak pthread_barrierattr_setpshared = _pthread_barrierattr_setpshared int -_pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared) +pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared) { barrierattr_t *ap; @@ -75,9 +72,8 @@ _pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared) return (0); } -#pragma weak pthread_barrierattr_getpshared = _pthread_barrierattr_getpshared int -_pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, int *pshared) +pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, int *pshared) { barrierattr_t *ap; @@ -88,9 +84,8 @@ _pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, int *pshared) return (0); } -#pragma weak pthread_barrier_init = _pthread_barrier_init int -_pthread_barrier_init(pthread_barrier_t *barrier, +pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, uint_t count) { mutex_t *mp = (mutex_t *)&barrier->__pthread_barrier_lock; @@ -113,20 +108,19 @@ _pthread_barrier_init(pthread_barrier_t *barrier, barrier->__pthread_barrier_current = count; barrier->__pthread_barrier_cycle = 0; barrier->__pthread_barrier_reserved = 0; - (void) __mutex_init(mp, type, NULL); - (void) _cond_init(cvp, type, NULL); + (void) mutex_init(mp, type, NULL); + (void) cond_init(cvp, type, NULL); return (0); } -#pragma weak pthread_barrier_destroy = _pthread_barrier_destroy int -_pthread_barrier_destroy(pthread_barrier_t *barrier) +pthread_barrier_destroy(pthread_barrier_t *barrier) { mutex_t *mp = (mutex_t *)&barrier->__pthread_barrier_lock; cond_t *cvp = (cond_t *)&barrier->__pthread_barrier_cond; - (void) __mutex_destroy(mp); - (void) _cond_destroy(cvp); + (void) mutex_destroy(mp); + (void) cond_destroy(cvp); (void) memset(barrier, -1, sizeof (*barrier)); return (0); } @@ -134,33 +128,32 @@ _pthread_barrier_destroy(pthread_barrier_t *barrier) /* * pthread_barrier_wait() is not a cancellation point; */ -#pragma weak pthread_barrier_wait = _pthread_barrier_wait int -_pthread_barrier_wait(pthread_barrier_t *barrier) +pthread_barrier_wait(pthread_barrier_t *barrier) { mutex_t *mp = (mutex_t *)&barrier->__pthread_barrier_lock; cond_t *cvp = (cond_t *)&barrier->__pthread_barrier_cond; uint64_t cycle; int cancel_state; - (void) __mutex_lock(mp); + (void) mutex_lock(mp); if (--barrier->__pthread_barrier_current == 0) { barrier->__pthread_barrier_cycle++; barrier->__pthread_barrier_current = barrier->__pthread_barrier_count; - (void) __mutex_unlock(mp); - (void) _cond_broadcast(cvp); + (void) mutex_unlock(mp); + (void) cond_broadcast(cvp); return (PTHREAD_BARRIER_SERIAL_THREAD); } - (void) _pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); + (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); cycle = barrier->__pthread_barrier_cycle; do { - (void) _cond_wait(cvp, mp); + (void) cond_wait(cvp, mp); } while (cycle == barrier->__pthread_barrier_cycle); - (void) _pthread_setcancelstate(cancel_state, NULL); + (void) pthread_setcancelstate(cancel_state, NULL); - (void) __mutex_unlock(mp); + (void) mutex_unlock(mp); return (0); } diff --git a/usr/src/lib/libc/port/threads/pthr_cond.c b/usr/src/lib/libc/port/threads/pthr_cond.c index 90e4e3443a..b22bc27cf2 100644 --- a/usr/src/lib/libc/port/threads/pthr_cond.c +++ b/usr/src/lib/libc/port/threads/pthr_cond.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -33,9 +33,9 @@ * pthread_condattr_init: allocates the cond attribute object and * initializes it with the default values. */ -#pragma weak pthread_condattr_init = _pthread_condattr_init +#pragma weak _pthread_condattr_init = pthread_condattr_init int -_pthread_condattr_init(pthread_condattr_t *attr) +pthread_condattr_init(pthread_condattr_t *attr) { cvattr_t *ap; @@ -51,9 +51,8 @@ _pthread_condattr_init(pthread_condattr_t *attr) * pthread_condattr_destroy: frees the cond attribute object and * invalidates it with NULL value. */ -#pragma weak pthread_condattr_destroy = _pthread_condattr_destroy int -_pthread_condattr_destroy(pthread_condattr_t *attr) +pthread_condattr_destroy(pthread_condattr_t *attr) { if (attr == NULL || attr->__pthread_condattrp == NULL) return (EINVAL); @@ -65,9 +64,8 @@ _pthread_condattr_destroy(pthread_condattr_t *attr) /* * pthread_condattr_setclock: sets the clockid attribute. */ -#pragma weak pthread_condattr_setclock = _pthread_condattr_setclock int -_pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id) +pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id) { cvattr_t *ap; @@ -82,9 +80,8 @@ _pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id) /* * pthread_condattr_getclock: gets the shared attr. */ -#pragma weak pthread_condattr_getclock = _pthread_condattr_getclock int -_pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock_id) +pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock_id) { cvattr_t *ap; @@ -101,9 +98,8 @@ _pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock_id) * pthread_condattr_setpshared: sets the shared attr to PRIVATE or SHARED. * This is equivalent to setting USYNC_PROCESS/USYNC_THREAD flag in cond_init(). */ -#pragma weak pthread_condattr_setpshared = _pthread_condattr_setpshared int -_pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared) +pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared) { cvattr_t *ap; @@ -119,9 +115,9 @@ _pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared) /* * pthread_condattr_getpshared: gets the shared attr. */ -#pragma weak pthread_condattr_getpshared = _pthread_condattr_getpshared +#pragma weak _pthread_condattr_getpshared = pthread_condattr_getpshared int -_pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared) +pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared) { cvattr_t *ap; @@ -137,9 +133,9 @@ _pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared) * pthread_cond_init: Initializes the cond object. It copies the * pshared attr into type argument and calls cond_init(). */ -#pragma weak pthread_cond_init = _pthread_cond_init +#pragma weak _pthread_cond_init = pthread_cond_init int -_pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) +pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { cvattr_t *ap; int type; @@ -158,7 +154,7 @@ _pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_HIGHRES) error = EINVAL; - else if ((error = _cond_init((cond_t *)cond, type, NULL)) == 0) + else if ((error = cond_init((cond_t *)cond, type, NULL)) == 0) ((cond_t *)cond)->cond_clockid = (uint8_t)clock_id; return (error); diff --git a/usr/src/lib/libc/port/threads/pthr_mutex.c b/usr/src/lib/libc/port/threads/pthr_mutex.c index d3f54c2c71..2451e5e0e8 100644 --- a/usr/src/lib/libc/port/threads/pthr_mutex.c +++ b/usr/src/lib/libc/port/threads/pthr_mutex.c @@ -34,9 +34,9 @@ * pthread_mutexattr_init: allocates the mutex attribute object and * initializes it with the default values. */ -#pragma weak pthread_mutexattr_init = _pthread_mutexattr_init +#pragma weak _pthread_mutexattr_init = pthread_mutexattr_init int -_pthread_mutexattr_init(pthread_mutexattr_t *attr) +pthread_mutexattr_init(pthread_mutexattr_t *attr) { mattr_t *ap; @@ -54,9 +54,8 @@ _pthread_mutexattr_init(pthread_mutexattr_t *attr) * pthread_mutexattr_destroy: frees the mutex attribute object and * invalidates it with NULL value. */ -#pragma weak pthread_mutexattr_destroy = _pthread_mutexattr_destroy int -_pthread_mutexattr_destroy(pthread_mutexattr_t *attr) +pthread_mutexattr_destroy(pthread_mutexattr_t *attr) { if (attr == NULL || attr->__pthread_mutexattrp == NULL) return (EINVAL); @@ -71,9 +70,8 @@ _pthread_mutexattr_destroy(pthread_mutexattr_t *attr) * This is equivalent to setting the USYNC_THREAD/USYNC_PROCESS * flag in mutex_init(). */ -#pragma weak pthread_mutexattr_setpshared = _pthread_mutexattr_setpshared int -_pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) +pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) { mattr_t *ap; @@ -88,9 +86,9 @@ _pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) /* * pthread_mutexattr_getpshared: gets the shared attribute. */ -#pragma weak pthread_mutexattr_getpshared = _pthread_mutexattr_getpshared +#pragma weak _pthread_mutexattr_getpshared = pthread_mutexattr_getpshared int -_pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared) +pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared) { mattr_t *ap; @@ -104,10 +102,8 @@ _pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared) /* * pthread_mutexattr_setprioceiling: sets the prioceiling attribute. */ -#pragma weak pthread_mutexattr_setprioceiling = \ - _pthread_mutexattr_setprioceiling int -_pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling) +pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling) { const pcclass_t *pccp = get_info_by_policy(SCHED_FIFO); mattr_t *ap; @@ -122,10 +118,10 @@ _pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling) /* * pthread_mutexattr_getprioceiling: gets the prioceiling attribute. */ -#pragma weak pthread_mutexattr_getprioceiling = \ - _pthread_mutexattr_getprioceiling +#pragma weak _pthread_mutexattr_getprioceiling = \ + pthread_mutexattr_getprioceiling int -_pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, int *ceiling) +pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, int *ceiling) { mattr_t *ap; @@ -139,9 +135,8 @@ _pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, int *ceiling) /* * pthread_mutexattr_setprotocol: sets the protocol attribute. */ -#pragma weak pthread_mutexattr_setprotocol = _pthread_mutexattr_setprotocol int -_pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol) +pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol) { mattr_t *ap; @@ -158,9 +153,9 @@ _pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol) /* * pthread_mutexattr_getprotocol: gets the protocol attribute. */ -#pragma weak pthread_mutexattr_getprotocol = _pthread_mutexattr_getprotocol +#pragma weak _pthread_mutexattr_getprotocol = pthread_mutexattr_getprotocol int -_pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *protocol) +pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *protocol) { mattr_t *ap; @@ -175,10 +170,8 @@ _pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *protocol) * pthread_mutexattr_setrobust_np: sets the robustness attribute * to PTHREAD_MUTEX_ROBUST_NP or PTHREAD_MUTEX_STALL_NP. */ -#pragma weak pthread_mutexattr_setrobust_np = \ - _pthread_mutexattr_setrobust_np int -_pthread_mutexattr_setrobust_np(pthread_mutexattr_t *attr, int robust) +pthread_mutexattr_setrobust_np(pthread_mutexattr_t *attr, int robust) { mattr_t *ap; @@ -193,10 +186,8 @@ _pthread_mutexattr_setrobust_np(pthread_mutexattr_t *attr, int robust) /* * pthread_mutexattr_getrobust_np: gets the robustness attribute. */ -#pragma weak pthread_mutexattr_getrobust_np = \ - _pthread_mutexattr_getrobust_np int -_pthread_mutexattr_getrobust_np(const pthread_mutexattr_t *attr, int *robust) +pthread_mutexattr_getrobust_np(const pthread_mutexattr_t *attr, int *robust) { mattr_t *ap; @@ -211,9 +202,10 @@ _pthread_mutexattr_getrobust_np(const pthread_mutexattr_t *attr, int *robust) * pthread_mutex_init: Initializes the mutex object. It copies the * various attributes into one type argument and calls mutex_init(). */ -#pragma weak pthread_mutex_init = _pthread_mutex_init +#pragma weak _pthread_mutex_init = pthread_mutex_init int -_pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) +pthread_mutex_init(pthread_mutex_t *_RESTRICT_KYWD mutex, + const pthread_mutexattr_t *_RESTRICT_KYWD attr) { mattr_t *ap; int type; @@ -245,9 +237,8 @@ _pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) * We pass the MUTEX_NOCEIL flag to mutex_lock_internal() so that * a non-realtime thread can successfully execute this operation. */ -#pragma weak pthread_mutex_setprioceiling = _pthread_mutex_setprioceiling int -_pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int ceil, int *oceil) +pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int ceil, int *oceil) { mutex_t *mp = (mutex_t *)mutex; const pcclass_t *pccp = get_info_by_policy(SCHED_FIFO); @@ -269,9 +260,9 @@ _pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int ceil, int *oceil) /* * pthread_mutex_getprioceiling: gets the prioceiling. */ -#pragma weak pthread_mutex_getprioceiling = _pthread_mutex_getprioceiling +#pragma weak _pthread_mutex_getprioceiling = pthread_mutex_getprioceiling int -_pthread_mutex_getprioceiling(const pthread_mutex_t *mp, int *ceiling) +pthread_mutex_getprioceiling(const pthread_mutex_t *mp, int *ceiling) { *ceiling = ((mutex_t *)mp)->mutex_ceiling; return (0); @@ -281,9 +272,8 @@ _pthread_mutex_getprioceiling(const pthread_mutex_t *mp, int *ceiling) * UNIX98 * pthread_mutexattr_settype: sets the type attribute */ -#pragma weak pthread_mutexattr_settype = _pthread_mutexattr_settype int -_pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) +pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { mattr_t *ap; @@ -310,9 +300,8 @@ _pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) * UNIX98 * pthread_mutexattr_gettype: gets the type attribute. */ -#pragma weak pthread_mutexattr_gettype = _pthread_mutexattr_gettype int -_pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *typep) +pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *typep) { mattr_t *ap; int type; diff --git a/usr/src/lib/libc/port/threads/pthr_rwlock.c b/usr/src/lib/libc/port/threads/pthr_rwlock.c index 35f4c809de..39883d7934 100644 --- a/usr/src/lib/libc/port/threads/pthr_rwlock.c +++ b/usr/src/lib/libc/port/threads/pthr_rwlock.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -34,9 +34,8 @@ * pthread_rwlockattr_init: allocates the mutex attribute object and * initializes it with the default values. */ -#pragma weak pthread_rwlockattr_init = _pthread_rwlockattr_init int -_pthread_rwlockattr_init(pthread_rwlockattr_t *attr) +pthread_rwlockattr_init(pthread_rwlockattr_t *attr) { rwlattr_t *ap; @@ -52,9 +51,8 @@ _pthread_rwlockattr_init(pthread_rwlockattr_t *attr) * pthread_rwlockattr_destroy: frees the rwlock attribute object and * invalidates it with NULL value. */ -#pragma weak pthread_rwlockattr_destroy = _pthread_rwlockattr_destroy int -_pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr) +pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr) { if (attr == NULL || attr->__pthread_rwlockattrp == NULL) return (EINVAL); @@ -67,9 +65,8 @@ _pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr) * UNIX98 * pthread_rwlockattr_setpshared: sets the shared attr to PRIVATE or SHARED. */ -#pragma weak pthread_rwlockattr_setpshared = _pthread_rwlockattr_setpshared int -_pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared) +pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared) { rwlattr_t *ap; @@ -86,9 +83,8 @@ _pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared) * UNIX98 * pthread_rwlockattr_getpshared: gets the shared attr. */ -#pragma weak pthread_rwlockattr_getpshared = _pthread_rwlockattr_getpshared int -_pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, int *pshared) +pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, int *pshared) { rwlattr_t *ap; @@ -105,9 +101,9 @@ _pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, int *pshared) * pthread_rwlock_init: Initializes the rwlock object. It copies the * pshared attr into type argument and calls rwlock_init(). */ -#pragma weak pthread_rwlock_init = _pthread_rwlock_init int -_pthread_rwlock_init(pthread_rwlock_t *rwlock, pthread_rwlockattr_t *attr) +pthread_rwlock_init(pthread_rwlock_t *_RESTRICT_KYWD rwlock, + const pthread_rwlockattr_t *_RESTRICT_KYWD attr) { rwlattr_t *ap; int type; @@ -119,5 +115,5 @@ _pthread_rwlock_init(pthread_rwlock_t *rwlock, pthread_rwlockattr_t *attr) else return (EINVAL); - return (__rwlock_init((rwlock_t *)rwlock, type, NULL)); + return (rwlock_init((rwlock_t *)rwlock, type, NULL)); } diff --git a/usr/src/lib/libc/port/threads/pthread.c b/usr/src/lib/libc/port/threads/pthread.c index 83cc7ec37a..af3ad4b999 100644 --- a/usr/src/lib/libc/port/threads/pthread.c +++ b/usr/src/lib/libc/port/threads/pthread.c @@ -73,7 +73,7 @@ _thr_setparam(pthread_t tid, int policy, int prio) ulwp->ul_rtclassid = cid; ulwp->ul_cid = cid; ulwp->ul_pri = prio; - _membar_producer(); + membar_producer(); ulwp->ul_policy = policy; } ulwp_unlock(ulwp, curthread->ul_uberdata); @@ -85,9 +85,9 @@ _thr_setparam(pthread_t tid, int policy, int prio) * pthread_create: creates a thread in the current process. * calls common _thrp_create() after copying the attributes. */ -#pragma weak pthread_create = _pthread_create +#pragma weak _pthread_create = pthread_create int -_pthread_create(pthread_t *thread, const pthread_attr_t *attr, +pthread_create(pthread_t *thread, const pthread_attr_t *attr, void * (*start_routine)(void *), void *arg) { ulwp_t *self = curthread; @@ -141,7 +141,7 @@ _pthread_create(pthread_t *thread, const pthread_attr_t *attr, } else if (thread) { *thread = tid; } - (void) _thr_continue(tid); + (void) thr_continue(tid); } /* posix version expects EAGAIN for lack of memory */ @@ -154,9 +154,8 @@ _pthread_create(pthread_t *thread, const pthread_attr_t *attr, * pthread_once: calls given function only once. * it synchronizes via mutex in pthread_once_t structure */ -#pragma weak pthread_once = _pthread_once int -_pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) +pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { __once_t *once = (__once_t *)once_control; @@ -169,12 +168,12 @@ _pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) pthread_cleanup_push(mutex_unlock, &once->mlock); (*init_routine)(); pthread_cleanup_pop(0); - _membar_producer(); + membar_producer(); once->once_flag = PTHREAD_ONCE_DONE; } (void) mutex_unlock(&once->mlock); } - _membar_consumer(); + membar_consumer(); return (0); } @@ -182,9 +181,8 @@ _pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) /* * pthread_equal: equates two thread ids. */ -#pragma weak pthread_equal = _pthread_equal int -_pthread_equal(pthread_t t1, pthread_t t2) +pthread_equal(pthread_t t1, pthread_t t2) { return (t1 == t2); } @@ -192,9 +190,9 @@ _pthread_equal(pthread_t t1, pthread_t t2) /* * pthread_getschedparam: get the thread's sched parameters. */ -#pragma weak pthread_getschedparam = _pthread_getschedparam +#pragma weak _pthread_getschedparam = pthread_getschedparam int -_pthread_getschedparam(pthread_t tid, int *policy, struct sched_param *param) +pthread_getschedparam(pthread_t tid, int *policy, struct sched_param *param) { ulwp_t *ulwp; id_t cid; @@ -218,7 +216,7 @@ _pthread_getschedparam(pthread_t tid, int *policy, struct sched_param *param) ulwp->ul_rtclassid = cid; ulwp->ul_cid = cid; ulwp->ul_pri = param->sched_priority; - _membar_producer(); + membar_producer(); ulwp->ul_policy = *policy; } ulwp_unlock(ulwp, curthread->ul_uberdata); @@ -227,15 +225,15 @@ _pthread_getschedparam(pthread_t tid, int *policy, struct sched_param *param) return (error); } -#pragma weak thr_getprio = _thr_getprio +#pragma weak _thr_getprio = thr_getprio int -_thr_getprio(thread_t tid, int *priority) +thr_getprio(thread_t tid, int *priority) { struct sched_param param; int policy; int error; - if ((error = _pthread_getschedparam(tid, &policy, ¶m)) == 0) + if ((error = pthread_getschedparam(tid, &policy, ¶m)) == 0) *priority = param.sched_priority; return (error); } @@ -243,29 +241,26 @@ _thr_getprio(thread_t tid, int *priority) /* * pthread_setschedparam: sets the sched parameters for a thread. */ -#pragma weak pthread_setschedparam = _pthread_setschedparam int -_pthread_setschedparam(pthread_t tid, +pthread_setschedparam(pthread_t tid, int policy, const struct sched_param *param) { return (_thr_setparam(tid, policy, param->sched_priority)); } -#pragma weak thr_setprio = _thr_setprio -#pragma weak pthread_setschedprio = _thr_setprio -#pragma weak _pthread_setschedprio = _thr_setprio +#pragma weak pthread_setschedprio = thr_setprio int -_thr_setprio(thread_t tid, int prio) +thr_setprio(thread_t tid, int prio) { struct sched_param param; int policy; int error; /* - * _pthread_getschedparam() has the side-effect of setting + * pthread_getschedparam() has the side-effect of setting * the target thread's ul_policy, ul_pri and ul_cid correctly. */ - if ((error = _pthread_getschedparam(tid, &policy, ¶m)) != 0) + if ((error = pthread_getschedparam(tid, &policy, ¶m)) != 0) return (error); if (param.sched_priority == prio) /* no change */ return (0); diff --git a/usr/src/lib/libc/port/threads/rwlock.c b/usr/src/lib/libc/port/threads/rwlock.c index 7a8e70b223..582da6b5c4 100644 --- a/usr/src/lib/libc/port/threads/rwlock.c +++ b/usr/src/lib/libc/port/threads/rwlock.c @@ -133,12 +133,10 @@ rwl_free(ulwp_t *ulwp) /* * Check if a reader version of the lock is held by the current thread. - * rw_read_is_held() is private to libc. */ -#pragma weak rw_read_is_held = _rw_read_held -#pragma weak rw_read_held = _rw_read_held +#pragma weak _rw_read_held = rw_read_held int -_rw_read_held(rwlock_t *rwlp) +rw_read_held(rwlock_t *rwlp) { volatile uint32_t *rwstate = (volatile uint32_t *)&rwlp->rwlock_readers; uint32_t readers; @@ -178,12 +176,10 @@ _rw_read_held(rwlock_t *rwlp) /* * Check if a writer version of the lock is held by the current thread. - * rw_write_is_held() is private to libc. */ -#pragma weak rw_write_is_held = _rw_write_held -#pragma weak rw_write_held = _rw_write_held +#pragma weak _rw_write_held = rw_write_held int -_rw_write_held(rwlock_t *rwlp) +rw_write_held(rwlock_t *rwlp) { volatile uint32_t *rwstate = (volatile uint32_t *)&rwlp->rwlock_readers; uint32_t readers; @@ -203,11 +199,10 @@ _rw_write_held(rwlock_t *rwlp) return (rval); } -#pragma weak rwlock_init = __rwlock_init -#pragma weak _rwlock_init = __rwlock_init +#pragma weak _rwlock_init = rwlock_init /* ARGSUSED2 */ int -__rwlock_init(rwlock_t *rwlp, int type, void *arg) +rwlock_init(rwlock_t *rwlp, int type, void *arg) { if (type != USYNC_THREAD && type != USYNC_PROCESS) return (EINVAL); @@ -227,12 +222,10 @@ __rwlock_init(rwlock_t *rwlp, int type, void *arg) return (0); } -#pragma weak rwlock_destroy = __rwlock_destroy -#pragma weak _rwlock_destroy = __rwlock_destroy -#pragma weak pthread_rwlock_destroy = __rwlock_destroy -#pragma weak _pthread_rwlock_destroy = __rwlock_destroy +#pragma weak pthread_rwlock_destroy = rwlock_destroy +#pragma weak _rwlock_destroy = rwlock_destroy int -__rwlock_destroy(rwlock_t *rwlp) +rwlock_destroy(rwlock_t *rwlp) { /* * Once destroyed, we can no longer be holding a read or write lock. @@ -638,7 +631,7 @@ rw_rdlock_impl(rwlock_t *rwlp, timespec_t *tsp) /* * If we hold the writer lock, bail out. */ - if (rw_write_is_held(rwlp)) { + if (rw_write_held(rwlp)) { if (self->ul_error_detection) rwlock_error(rwlp, "rwlock_rdlock", "calling thread owns the writer lock"); @@ -668,12 +661,10 @@ out: return (error); } -#pragma weak rw_rdlock = __rw_rdlock -#pragma weak _rw_rdlock = __rw_rdlock -#pragma weak pthread_rwlock_rdlock = __rw_rdlock -#pragma weak _pthread_rwlock_rdlock = __rw_rdlock +#pragma weak pthread_rwlock_rdlock = rw_rdlock +#pragma weak _rw_rdlock = rw_rdlock int -__rw_rdlock(rwlock_t *rwlp) +rw_rdlock(rwlock_t *rwlp) { ASSERT(!curthread->ul_critical || curthread->ul_bindflags); return (rw_rdlock_impl(rwlp, NULL)); @@ -686,31 +677,30 @@ lrw_rdlock(rwlock_t *rwlp) (void) rw_rdlock_impl(rwlp, NULL); } -#pragma weak pthread_rwlock_reltimedrdlock_np = \ - _pthread_rwlock_reltimedrdlock_np int -_pthread_rwlock_reltimedrdlock_np(rwlock_t *rwlp, const timespec_t *reltime) +pthread_rwlock_reltimedrdlock_np(pthread_rwlock_t *_RESTRICT_KYWD rwlp, + const struct timespec *_RESTRICT_KYWD reltime) { timespec_t tslocal = *reltime; int error; ASSERT(!curthread->ul_critical || curthread->ul_bindflags); - error = rw_rdlock_impl(rwlp, &tslocal); + error = rw_rdlock_impl((rwlock_t *)rwlp, &tslocal); if (error == ETIME) error = ETIMEDOUT; return (error); } -#pragma weak pthread_rwlock_timedrdlock = _pthread_rwlock_timedrdlock int -_pthread_rwlock_timedrdlock(rwlock_t *rwlp, const timespec_t *abstime) +pthread_rwlock_timedrdlock(pthread_rwlock_t *_RESTRICT_KYWD rwlp, + const struct timespec *_RESTRICT_KYWD abstime) { timespec_t tslocal; int error; ASSERT(!curthread->ul_critical || curthread->ul_bindflags); abstime_to_reltime(CLOCK_REALTIME, abstime, &tslocal); - error = rw_rdlock_impl(rwlp, &tslocal); + error = rw_rdlock_impl((rwlock_t *)rwlp, &tslocal); if (error == ETIME) error = ETIMEDOUT; return (error); @@ -727,7 +717,7 @@ rw_wrlock_impl(rwlock_t *rwlp, timespec_t *tsp) /* * If we hold a readers lock on this rwlock, bail out. */ - if (rw_read_is_held(rwlp)) { + if (rw_read_held(rwlp)) { if (self->ul_error_detection) rwlock_error(rwlp, "rwlock_wrlock", "calling thread owns the readers lock"); @@ -738,7 +728,7 @@ rw_wrlock_impl(rwlock_t *rwlp, timespec_t *tsp) /* * If we hold the writer lock, bail out. */ - if (rw_write_is_held(rwlp)) { + if (rw_write_held(rwlp)) { if (self->ul_error_detection) rwlock_error(rwlp, "rwlock_wrlock", "calling thread owns the writer lock"); @@ -769,12 +759,10 @@ out: return (error); } -#pragma weak rw_wrlock = __rw_wrlock -#pragma weak _rw_wrlock = __rw_wrlock -#pragma weak pthread_rwlock_wrlock = __rw_wrlock -#pragma weak _pthread_rwlock_wrlock = __rw_wrlock +#pragma weak pthread_rwlock_wrlock = rw_wrlock +#pragma weak _rw_wrlock = rw_wrlock int -__rw_wrlock(rwlock_t *rwlp) +rw_wrlock(rwlock_t *rwlp) { ASSERT(!curthread->ul_critical || curthread->ul_bindflags); return (rw_wrlock_impl(rwlp, NULL)); @@ -787,42 +775,37 @@ lrw_wrlock(rwlock_t *rwlp) (void) rw_wrlock_impl(rwlp, NULL); } -#pragma weak pthread_rwlock_reltimedwrlock_np = \ - _pthread_rwlock_reltimedwrlock_np int -_pthread_rwlock_reltimedwrlock_np(rwlock_t *rwlp, const timespec_t *reltime) +pthread_rwlock_reltimedwrlock_np(pthread_rwlock_t *_RESTRICT_KYWD rwlp, + const struct timespec *_RESTRICT_KYWD reltime) { timespec_t tslocal = *reltime; int error; ASSERT(!curthread->ul_critical || curthread->ul_bindflags); - error = rw_wrlock_impl(rwlp, &tslocal); + error = rw_wrlock_impl((rwlock_t *)rwlp, &tslocal); if (error == ETIME) error = ETIMEDOUT; return (error); } -#pragma weak pthread_rwlock_timedwrlock = _pthread_rwlock_timedwrlock int -_pthread_rwlock_timedwrlock(rwlock_t *rwlp, const timespec_t *abstime) +pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlp, const timespec_t *abstime) { timespec_t tslocal; int error; ASSERT(!curthread->ul_critical || curthread->ul_bindflags); abstime_to_reltime(CLOCK_REALTIME, abstime, &tslocal); - error = rw_wrlock_impl(rwlp, &tslocal); + error = rw_wrlock_impl((rwlock_t *)rwlp, &tslocal); if (error == ETIME) error = ETIMEDOUT; return (error); } -#pragma weak rw_tryrdlock = __rw_tryrdlock -#pragma weak _rw_tryrdlock = __rw_tryrdlock -#pragma weak pthread_rwlock_tryrdlock = __rw_tryrdlock -#pragma weak _pthread_rwlock_tryrdlock = __rw_tryrdlock +#pragma weak pthread_rwlock_tryrdlock = rw_tryrdlock int -__rw_tryrdlock(rwlock_t *rwlp) +rw_tryrdlock(rwlock_t *rwlp) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -878,12 +861,9 @@ out: return (error); } -#pragma weak rw_trywrlock = __rw_trywrlock -#pragma weak _rw_trywrlock = __rw_trywrlock -#pragma weak pthread_rwlock_trywrlock = __rw_trywrlock -#pragma weak _pthread_rwlock_trywrlock = __rw_trywrlock +#pragma weak pthread_rwlock_trywrlock = rw_trywrlock int -__rw_trywrlock(rwlock_t *rwlp) +rw_trywrlock(rwlock_t *rwlp) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -920,12 +900,10 @@ __rw_trywrlock(rwlock_t *rwlp) return (error); } -#pragma weak rw_unlock = __rw_unlock -#pragma weak _rw_unlock = __rw_unlock -#pragma weak pthread_rwlock_unlock = __rw_unlock -#pragma weak _pthread_rwlock_unlock = __rw_unlock +#pragma weak pthread_rwlock_unlock = rw_unlock +#pragma weak _rw_unlock = rw_unlock int -__rw_unlock(rwlock_t *rwlp) +rw_unlock(rwlock_t *rwlp) { volatile uint32_t *rwstate = (volatile uint32_t *)&rwlp->rwlock_readers; uint32_t readers; @@ -951,7 +929,7 @@ __rw_unlock(rwlock_t *rwlp) * Since the writer lock is held, we'd better be * holding it, else we cannot legitimately be here. */ - if (!rw_write_is_held(rwlp)) { + if (!rw_write_held(rwlp)) { if (self->ul_error_detection) rwlock_error(rwlp, "rwlock_unlock", "writer lock held, " @@ -1041,6 +1019,6 @@ out: void lrw_unlock(rwlock_t *rwlp) { - (void) __rw_unlock(rwlp); + (void) rw_unlock(rwlp); exit_critical(curthread); } diff --git a/usr/src/lib/libc/port/threads/scalls.c b/usr/src/lib/libc/port/threads/scalls.c index ceb227c9d5..c90ab6cbde 100644 --- a/usr/src/lib/libc/port/threads/scalls.c +++ b/usr/src/lib/libc/port/threads/scalls.c @@ -39,6 +39,46 @@ #include <sys/door.h> /* + * These leading-underbar symbols exist because mistakes were made + * in the past that put them into non-SUNWprivate versions of + * the libc mapfiles. They should be eliminated, but oh well... + */ +#pragma weak _fork = fork +#pragma weak _read = read +#pragma weak _write = write +#pragma weak _getmsg = getmsg +#pragma weak _getpmsg = getpmsg +#pragma weak _putmsg = putmsg +#pragma weak _putpmsg = putpmsg +#pragma weak _sleep = sleep +#pragma weak _close = close +#pragma weak _creat = creat +#pragma weak _fcntl = fcntl +#pragma weak _fsync = fsync +#pragma weak _lockf = lockf +#pragma weak _msgrcv = msgrcv +#pragma weak _msgsnd = msgsnd +#pragma weak _msync = msync +#pragma weak _open = open +#pragma weak _openat = openat +#pragma weak _pause = pause +#pragma weak _readv = readv +#pragma weak _sigpause = sigpause +#pragma weak _sigsuspend = sigsuspend +#pragma weak _tcdrain = tcdrain +#pragma weak _waitid = waitid +#pragma weak _writev = writev + +#if !defined(_LP64) +#pragma weak _creat64 = creat64 +#pragma weak _lockf64 = lockf64 +#pragma weak _open64 = open64 +#pragma weak _openat64 = openat64 +#pragma weak _pread64 = pread64 +#pragma weak _pwrite64 = pwrite64 +#endif + +/* * atfork_lock protects the pthread_atfork() data structures. * * fork_lock does double-duty. Not only does it (and atfork_lock) @@ -100,9 +140,8 @@ callout_lock_exit(void) cancel_safe_mutex_unlock(&curthread->ul_uberdata->callout_lock); } -#pragma weak forkx = _forkx pid_t -_forkx(int flags) +forkx(int flags) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -213,22 +252,19 @@ _forkx(int flags) * The forkall() interface exists for applications that require * the semantics of replicating all threads. */ -#pragma weak fork1 = _fork -#pragma weak _fork1 = _fork -#pragma weak fork = _fork +#pragma weak fork1 = fork pid_t -_fork(void) +fork(void) { - return (_forkx(0)); + return (forkx(0)); } /* * Much of the logic here is the same as in forkx(). * See the comments in forkx(), above. */ -#pragma weak forkallx = _forkallx pid_t -_forkallx(int flags) +forkallx(int flags) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -281,11 +317,10 @@ _forkallx(int flags) return (pid); } -#pragma weak forkall = _forkall pid_t -_forkall(void) +forkall(void) { - return (_forkallx(0)); + return (forkallx(0)); } /* @@ -303,7 +338,7 @@ _forkall(void) if (!self->ul_cancel_disabled) { \ self->ul_cancel_async = 1; \ if (self->ul_cancel_pending) \ - _pthread_exit(PTHREAD_CANCELED); \ + pthread_exit(PTHREAD_CANCELED); \ } \ self->ul_sp = stkptr(); \ } else if (self->ul_cancel_pending && \ @@ -374,7 +409,7 @@ _forkall(void) self->ul_sigsuspend = 0;\ restore_signals(self); \ } \ - _pthread_exit(PTHREAD_CANCELED);\ + pthread_exit(PTHREAD_CANCELED); \ } \ } \ self->ul_sp = stkptr(); \ @@ -415,7 +450,7 @@ _cancel_prologue(void) if (!self->ul_cancel_disabled) { self->ul_cancel_async = 1; if (self->ul_cancel_pending) - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); } self->ul_sp = stkptr(); } else if (self->ul_cancel_pending && @@ -452,9 +487,8 @@ lwp_wait(thread_t tid, thread_t *found) return (error); } -#pragma weak read = _read ssize_t -_read(int fd, void *buf, size_t size) +read(int fd, void *buf, size_t size) { extern ssize_t __read(int, void *, size_t); ssize_t rv; @@ -462,9 +496,8 @@ _read(int fd, void *buf, size_t size) PERFORM(__read(fd, buf, size)) } -#pragma weak write = _write ssize_t -_write(int fd, const void *buf, size_t size) +write(int fd, const void *buf, size_t size) { extern ssize_t __write(int, const void *, size_t); ssize_t rv; @@ -472,9 +505,8 @@ _write(int fd, const void *buf, size_t size) PERFORM(__write(fd, buf, size)) } -#pragma weak getmsg = _getmsg int -_getmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, +getmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, int *flagsp) { extern int __getmsg(int, struct strbuf *, struct strbuf *, int *); @@ -483,9 +515,8 @@ _getmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, PERFORM(__getmsg(fd, ctlptr, dataptr, flagsp)) } -#pragma weak getpmsg = _getpmsg int -_getpmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, +getpmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, int *bandp, int *flagsp) { extern int __getpmsg(int, struct strbuf *, struct strbuf *, @@ -495,9 +526,8 @@ _getpmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, PERFORM(__getpmsg(fd, ctlptr, dataptr, bandp, flagsp)) } -#pragma weak putmsg = _putmsg int -_putmsg(int fd, const struct strbuf *ctlptr, +putmsg(int fd, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags) { extern int __putmsg(int, const struct strbuf *, @@ -518,9 +548,8 @@ __xpg4_putmsg(int fd, const struct strbuf *ctlptr, PERFORM(__putmsg(fd, ctlptr, dataptr, flags|MSG_XPG4)) } -#pragma weak putpmsg = _putpmsg int -_putpmsg(int fd, const struct strbuf *ctlptr, +putpmsg(int fd, const struct strbuf *ctlptr, const struct strbuf *dataptr, int band, int flags) { extern int __putpmsg(int, const struct strbuf *, @@ -541,9 +570,8 @@ __xpg4_putpmsg(int fd, const struct strbuf *ctlptr, PERFORM(__putpmsg(fd, ctlptr, dataptr, band, flags|MSG_XPG4)) } -#pragma weak nanosleep = _nanosleep int -_nanosleep(const timespec_t *rqtp, timespec_t *rmtp) +nanosleep(const timespec_t *rqtp, timespec_t *rmtp) { int error; @@ -557,9 +585,8 @@ _nanosleep(const timespec_t *rqtp, timespec_t *rmtp) return (0); } -#pragma weak clock_nanosleep = _clock_nanosleep int -_clock_nanosleep(clockid_t clock_id, int flags, +clock_nanosleep(clockid_t clock_id, int flags, const timespec_t *rqtp, timespec_t *rmtp) { timespec_t reltime; @@ -634,9 +661,8 @@ restart: return (error); } -#pragma weak sleep = _sleep unsigned int -_sleep(unsigned int sec) +sleep(unsigned int sec) { unsigned int rem = 0; timespec_t ts; @@ -644,7 +670,7 @@ _sleep(unsigned int sec) ts.tv_sec = (time_t)sec; ts.tv_nsec = 0; - if (_nanosleep(&ts, &tsr) == -1 && errno == EINTR) { + if (nanosleep(&ts, &tsr) == -1 && errno == EINTR) { rem = (unsigned int)tsr.tv_sec; if (tsr.tv_nsec >= NANOSEC / 2) rem++; @@ -652,21 +678,19 @@ _sleep(unsigned int sec) return (rem); } -#pragma weak usleep = _usleep int -_usleep(useconds_t usec) +usleep(useconds_t usec) { timespec_t ts; ts.tv_sec = usec / MICROSEC; ts.tv_nsec = (long)(usec % MICROSEC) * 1000; - (void) _nanosleep(&ts, NULL); + (void) nanosleep(&ts, NULL); return (0); } -#pragma weak close = _close int -_close(int fildes) +close(int fildes) { extern void _aio_close(int); extern int __close(int); @@ -684,9 +708,8 @@ _close(int fildes) PERFORM(__close(fildes)) } -#pragma weak creat = _creat int -_creat(const char *path, mode_t mode) +creat(const char *path, mode_t mode) { extern int __creat(const char *, mode_t); int rv; @@ -695,9 +718,8 @@ _creat(const char *path, mode_t mode) } #if !defined(_LP64) -#pragma weak creat64 = _creat64 int -_creat64(const char *path, mode_t mode) +creat64(const char *path, mode_t mode) { extern int __creat64(const char *, mode_t); int rv; @@ -706,9 +728,8 @@ _creat64(const char *path, mode_t mode) } #endif /* !_LP64 */ -#pragma weak door_call = _door_call int -_door_call(int d, door_arg_t *params) +door_call(int d, door_arg_t *params) { extern int __door_call(int, door_arg_t *); int rv; @@ -716,9 +737,8 @@ _door_call(int d, door_arg_t *params) PERFORM(__door_call(d, params)) } -#pragma weak fcntl = _fcntl int -_fcntl(int fildes, int cmd, ...) +fcntl(int fildes, int cmd, ...) { extern int __fcntl(int, int, ...); intptr_t arg; @@ -733,9 +753,8 @@ _fcntl(int fildes, int cmd, ...) PERFORM(__fcntl(fildes, cmd, arg)) } -#pragma weak fdatasync = _fdatasync int -_fdatasync(int fildes) +fdatasync(int fildes) { extern int __fdsync(int, int); int rv; @@ -743,9 +762,8 @@ _fdatasync(int fildes) PERFORM(__fdsync(fildes, FDSYNC)) } -#pragma weak fsync = _fsync int -_fsync(int fildes) +fsync(int fildes) { extern int __fdsync(int, int); int rv; @@ -753,9 +771,8 @@ _fsync(int fildes) PERFORM(__fdsync(fildes, FSYNC)) } -#pragma weak lockf = _lockf int -_lockf(int fildes, int function, off_t size) +lockf(int fildes, int function, off_t size) { extern int __lockf(int, int, off_t); int rv; @@ -764,9 +781,8 @@ _lockf(int fildes, int function, off_t size) } #if !defined(_LP64) -#pragma weak lockf64 = _lockf64 int -_lockf64(int fildes, int function, off64_t size) +lockf64(int fildes, int function, off64_t size) { extern int __lockf64(int, int, off64_t); int rv; @@ -775,9 +791,8 @@ _lockf64(int fildes, int function, off64_t size) } #endif /* !_LP64 */ -#pragma weak msgrcv = _msgrcv ssize_t -_msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) +msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) { extern ssize_t __msgrcv(int, void *, size_t, long, int); ssize_t rv; @@ -785,9 +800,8 @@ _msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) PERFORM(__msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)) } -#pragma weak msgsnd = _msgsnd int -_msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) +msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) { extern int __msgsnd(int, const void *, size_t, int); int rv; @@ -795,9 +809,8 @@ _msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) PERFORM(__msgsnd(msqid, msgp, msgsz, msgflg)) } -#pragma weak msync = _msync int -_msync(caddr_t addr, size_t len, int flags) +msync(caddr_t addr, size_t len, int flags) { extern int __msync(caddr_t, size_t, int); int rv; @@ -805,9 +818,8 @@ _msync(caddr_t addr, size_t len, int flags) PERFORM(__msync(addr, len, flags)) } -#pragma weak open = _open int -_open(const char *path, int oflag, ...) +open(const char *path, int oflag, ...) { extern int __open(const char *, int, ...); mode_t mode; @@ -820,9 +832,8 @@ _open(const char *path, int oflag, ...) PERFORM(__open(path, oflag, mode)) } -#pragma weak openat = _openat int -_openat(int fd, const char *path, int oflag, ...) +openat(int fd, const char *path, int oflag, ...) { extern int __openat(int, const char *, int, ...); mode_t mode; @@ -836,9 +847,8 @@ _openat(int fd, const char *path, int oflag, ...) } #if !defined(_LP64) -#pragma weak open64 = _open64 int -_open64(const char *path, int oflag, ...) +open64(const char *path, int oflag, ...) { extern int __open64(const char *, int, ...); mode_t mode; @@ -851,9 +861,8 @@ _open64(const char *path, int oflag, ...) PERFORM(__open64(path, oflag, mode)) } -#pragma weak openat64 = _openat64 int -_openat64(int fd, const char *path, int oflag, ...) +openat64(int fd, const char *path, int oflag, ...) { extern int __openat64(int, const char *, int, ...); mode_t mode; @@ -867,9 +876,8 @@ _openat64(int fd, const char *path, int oflag, ...) } #endif /* !_LP64 */ -#pragma weak pause = _pause int -_pause(void) +pause(void) { extern int __pause(void); int rv; @@ -877,9 +885,8 @@ _pause(void) PERFORM(__pause()) } -#pragma weak pread = _pread ssize_t -_pread(int fildes, void *buf, size_t nbyte, off_t offset) +pread(int fildes, void *buf, size_t nbyte, off_t offset) { extern ssize_t __pread(int, void *, size_t, off_t); ssize_t rv; @@ -888,9 +895,8 @@ _pread(int fildes, void *buf, size_t nbyte, off_t offset) } #if !defined(_LP64) -#pragma weak pread64 = _pread64 ssize_t -_pread64(int fildes, void *buf, size_t nbyte, off64_t offset) +pread64(int fildes, void *buf, size_t nbyte, off64_t offset) { extern ssize_t __pread64(int, void *, size_t, off64_t); ssize_t rv; @@ -899,9 +905,8 @@ _pread64(int fildes, void *buf, size_t nbyte, off64_t offset) } #endif /* !_LP64 */ -#pragma weak pwrite = _pwrite ssize_t -_pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) +pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) { extern ssize_t __pwrite(int, const void *, size_t, off_t); ssize_t rv; @@ -910,9 +915,8 @@ _pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) } #if !defined(_LP64) -#pragma weak pwrite64 = _pwrite64 ssize_t -_pwrite64(int fildes, const void *buf, size_t nbyte, off64_t offset) +pwrite64(int fildes, const void *buf, size_t nbyte, off64_t offset) { extern ssize_t __pwrite64(int, const void *, size_t, off64_t); ssize_t rv; @@ -921,9 +925,8 @@ _pwrite64(int fildes, const void *buf, size_t nbyte, off64_t offset) } #endif /* !_LP64 */ -#pragma weak readv = _readv ssize_t -_readv(int fildes, const struct iovec *iov, int iovcnt) +readv(int fildes, const struct iovec *iov, int iovcnt) { extern ssize_t __readv(int, const struct iovec *, int); ssize_t rv; @@ -931,9 +934,8 @@ _readv(int fildes, const struct iovec *iov, int iovcnt) PERFORM(__readv(fildes, iov, iovcnt)) } -#pragma weak sigpause = _sigpause int -_sigpause(int sig) +sigpause(int sig) { extern int __sigpause(int); int rv; @@ -941,9 +943,8 @@ _sigpause(int sig) PERFORM(__sigpause(sig)) } -#pragma weak sigsuspend = _sigsuspend int -_sigsuspend(const sigset_t *set) +sigsuspend(const sigset_t *set) { extern int __sigsuspend(const sigset_t *); int rv; @@ -968,9 +969,8 @@ _pollsys(struct pollfd *fds, nfds_t nfd, const timespec_t *timeout, return (rv); } -#pragma weak sigtimedwait = _sigtimedwait int -_sigtimedwait(const sigset_t *set, siginfo_t *infop, const timespec_t *timeout) +sigtimedwait(const sigset_t *set, siginfo_t *infop, const timespec_t *timeout) { extern int __sigtimedwait(const sigset_t *, siginfo_t *, const timespec_t *); @@ -996,23 +996,20 @@ _sigtimedwait(const sigset_t *set, siginfo_t *infop, const timespec_t *timeout) return (sig); } -#pragma weak sigwait = _sigwait int -_sigwait(sigset_t *set) +sigwait(sigset_t *set) { - return (_sigtimedwait(set, NULL, NULL)); + return (sigtimedwait(set, NULL, NULL)); } -#pragma weak sigwaitinfo = _sigwaitinfo int -_sigwaitinfo(const sigset_t *set, siginfo_t *info) +sigwaitinfo(const sigset_t *set, siginfo_t *info) { - return (_sigtimedwait(set, info, NULL)); + return (sigtimedwait(set, info, NULL)); } -#pragma weak sigqueue = _sigqueue int -_sigqueue(pid_t pid, int signo, const union sigval value) +sigqueue(pid_t pid, int signo, const union sigval value) { extern int __sigqueue(pid_t pid, int signo, /* const union sigval */ void *value, int si_code, int block); @@ -1095,9 +1092,8 @@ _so_sendto(int sock, const void *buf, size_t len, int flags, PERFORM(__so_sendto(sock, buf, len, flags, addr, addrlen)) } -#pragma weak tcdrain = _tcdrain int -_tcdrain(int fildes) +tcdrain(int fildes) { extern int __tcdrain(int); int rv; @@ -1105,9 +1101,8 @@ _tcdrain(int fildes) PERFORM(__tcdrain(fildes)) } -#pragma weak waitid = _waitid int -_waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) +waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) { extern int __waitid(idtype_t, id_t, siginfo_t *, int); int rv; @@ -1117,9 +1112,8 @@ _waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) PERFORM(__waitid(idtype, id, infop, options)) } -#pragma weak writev = _writev ssize_t -_writev(int fildes, const struct iovec *iov, int iovcnt) +writev(int fildes, const struct iovec *iov, int iovcnt) { extern ssize_t __writev(int, const struct iovec *, int); ssize_t rv; diff --git a/usr/src/lib/libc/port/threads/sema.c b/usr/src/lib/libc/port/threads/sema.c index 4e58123bd7..d0882fe75e 100644 --- a/usr/src/lib/libc/port/threads/sema.c +++ b/usr/src/lib/libc/port/threads/sema.c @@ -34,17 +34,17 @@ static uint32_t _semvaluemax; /* * Check to see if anyone is waiting for this semaphore. */ -#pragma weak sema_held = _sema_held +#pragma weak _sema_held = sema_held int -_sema_held(sema_t *sp) +sema_held(sema_t *sp) { return (sp->count == 0); } -#pragma weak sema_init = _sema_init -/* ARGSUSED2 */ +#pragma weak _sema_init = sema_init +/* ARGSUSED3 */ int -_sema_init(sema_t *sp, unsigned int count, int type, void *arg) +sema_init(sema_t *sp, unsigned int count, int type, void *arg) { if (_semvaluemax == 0) _semvaluemax = (uint32_t)_sysconf(_SC_SEM_VALUE_MAX); @@ -58,9 +58,9 @@ _sema_init(sema_t *sp, unsigned int count, int type, void *arg) return (0); } -#pragma weak sema_destroy = _sema_destroy +#pragma weak _sema_destroy = sema_destroy int -_sema_destroy(sema_t *sp) +sema_destroy(sema_t *sp) { sp->magic = 0; tdb_sync_obj_deregister(sp); @@ -186,17 +186,16 @@ sema_wait_impl(sema_t *sp, timespec_t *tsp) return (error); } -#pragma weak sema_wait = _sema_wait +#pragma weak _sema_wait = sema_wait int -_sema_wait(sema_t *sp) +sema_wait(sema_t *sp) { ASSERT(!curthread->ul_critical || curthread->ul_bindflags); return (sema_wait_impl(sp, NULL)); } -#pragma weak sema_reltimedwait = _sema_reltimedwait int -_sema_reltimedwait(sema_t *sp, timespec_t *reltime) +sema_reltimedwait(sema_t *sp, const timespec_t *reltime) { timespec_t tslocal = *reltime; @@ -204,9 +203,8 @@ _sema_reltimedwait(sema_t *sp, timespec_t *reltime) return (sema_wait_impl(sp, &tslocal)); } -#pragma weak sema_timedwait = _sema_timedwait int -_sema_timedwait(sema_t *sp, timespec_t *abstime) +sema_timedwait(sema_t *sp, const timespec_t *abstime) { timespec_t tslocal; @@ -215,9 +213,9 @@ _sema_timedwait(sema_t *sp, timespec_t *abstime) return (sema_wait_impl(sp, &tslocal)); } -#pragma weak sema_trywait = _sema_trywait +#pragma weak _sema_trywait = sema_trywait int -_sema_trywait(sema_t *sp) +sema_trywait(sema_t *sp) { lwp_sema_t *lsp = (lwp_sema_t *)sp; ulwp_t *self = curthread; @@ -232,7 +230,7 @@ _sema_trywait(sema_t *sp) tdb_incr(ssp->sema_trywait); if (lsp->type == USYNC_PROCESS) { /* kernel-level */ - error = __lwp_sema_trywait(lsp); + error = _lwp_sema_trywait(lsp); } else if (!udp->uberflags.uf_mt) { /* single threaded */ sigoff(self); if (lsp->count == 0) @@ -282,9 +280,9 @@ _sema_trywait(sema_t *sp) return (error); } -#pragma weak sema_post = _sema_post +#pragma weak _sema_post = sema_post int -_sema_post(sema_t *sp) +sema_post(sema_t *sp) { lwp_sema_t *lsp = (lwp_sema_t *)sp; ulwp_t *self = curthread; @@ -299,7 +297,7 @@ _sema_post(sema_t *sp) _semvaluemax = (uint32_t)_sysconf(_SC_SEM_VALUE_MAX); if (lsp->type == USYNC_PROCESS) { /* kernel-level */ - error = __lwp_sema_post(lsp); + error = _lwp_sema_post(lsp); } else if (!udp->uberflags.uf_mt) { /* single threaded */ sigoff(self); if (lsp->count >= _semvaluemax) diff --git a/usr/src/lib/libc/port/threads/sigaction.c b/usr/src/lib/libc/port/threads/sigaction.c index 4eb5ff659d..ccc9203ecd 100644 --- a/usr/src/lib/libc/port/threads/sigaction.c +++ b/usr/src/lib/libc/port/threads/sigaction.c @@ -27,14 +27,21 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include "lint.h" +#include <sys/feature_tests.h> +/* + * setcontext() really can return, if UC_CPU is not specified. + * Make the compiler shut up about it. + */ +#if defined(__NORETURN) +#undef __NORETURN +#endif +#define __NORETURN #include "thr_uberdata.h" #include "asyncio.h" #include <signal.h> #include <siginfo.h> #include <sys/systm.h> -extern int _setcontext(const ucontext_t *); - const sigset_t maskset = {MASKSET0, MASKSET1, 0, 0}; /* maskable signals */ /* @@ -171,10 +178,10 @@ call_user_handler(int sig, siginfo_t *sip, ucontext_t *ucp) * we are an aio worker thread, cancel the aio request. */ if (sig == SIGAIOCANCEL) { - aio_worker_t *aiowp = _pthread_getspecific(_aio_key); + aio_worker_t *aiowp = pthread_getspecific(_aio_key); if (sip != NULL && sip->si_code == SI_LWP && aiowp != NULL) - _siglongjmp(aiowp->work_jmp_buf, 1); + siglongjmp(aiowp->work_jmp_buf, 1); /* SIGLWP is ignored by default */ if (uact.sa_sigaction == SIG_DFL || uact.sa_sigaction == SIG_IGN) @@ -206,8 +213,8 @@ call_user_handler(int sig, siginfo_t *sip, ucontext_t *ucp) #endif /* sparc */ out: - (void) _setcontext(ucp); - thr_panic("call_user_handler(): _setcontext() returned"); + (void) setcontext(ucp); + thr_panic("call_user_handler(): setcontext() returned"); } /* @@ -327,7 +334,7 @@ sigacthandler(int sig, siginfo_t *sip, void *uvp) * Return to the previous context with all signals blocked. * We will restore the signal mask in take_deferred_signal(). * Note that we are calling the system call trap here, not - * the _setcontext() wrapper. We don't want to change the + * the setcontext() wrapper. We don't want to change the * thread's ul_sigmask by this operation. */ ucp->uc_sigmask = maskset; @@ -335,9 +342,9 @@ sigacthandler(int sig, siginfo_t *sip, void *uvp) thr_panic("sigacthandler(): __setcontext() returned"); } -#pragma weak sigaction = _sigaction +#pragma weak _sigaction = sigaction int -_sigaction(int sig, const struct sigaction *nact, struct sigaction *oact) +sigaction(int sig, const struct sigaction *nact, struct sigaction *oact) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -494,9 +501,9 @@ set_setcontext_enforcement(int on) setcontext_enforcement = on; } -#pragma weak setcontext = _setcontext +#pragma weak _setcontext = setcontext int -_setcontext(const ucontext_t *ucp) +setcontext(const ucontext_t *ucp) { ulwp_t *self = curthread; int ret; @@ -507,7 +514,7 @@ _setcontext(const ucontext_t *ucp) * the thread to exit. See setcontext(2) and makecontext(3C). */ if (ucp == NULL) - _thr_exit(NULL); + thr_exit(NULL); (void) memcpy(&uc, ucp, sizeof (uc)); /* @@ -566,11 +573,9 @@ _setcontext(const ucontext_t *ucp) return (ret); } -#pragma weak thr_sigsetmask = _thr_sigsetmask -#pragma weak pthread_sigmask = _thr_sigsetmask -#pragma weak _pthread_sigmask = _thr_sigsetmask +#pragma weak _thr_sigsetmask = thr_sigsetmask int -_thr_sigsetmask(int how, const sigset_t *set, sigset_t *oset) +thr_sigsetmask(int how, const sigset_t *set, sigset_t *oset) { ulwp_t *self = curthread; sigset_t saveset; @@ -620,9 +625,16 @@ _thr_sigsetmask(int how, const sigset_t *set, sigset_t *oset) return (0); } -#pragma weak sigprocmask = _sigprocmask +#pragma weak _pthread_sigmask = pthread_sigmask +int +pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) +{ + return (thr_sigsetmask(how, set, oset)); +} + +#pragma weak _sigprocmask = sigprocmask int -_sigprocmask(int how, const sigset_t *set, sigset_t *oset) +sigprocmask(int how, const sigset_t *set, sigset_t *oset) { int error; @@ -632,7 +644,7 @@ _sigprocmask(int how, const sigset_t *set, sigset_t *oset) if (curthread->ul_vfork) return (__lwp_sigmask(how, set, oset)); - if ((error = _thr_sigsetmask(how, set, oset)) != 0) { + if ((error = thr_sigsetmask(how, set, oset)) != 0) { errno = error; return (-1); } @@ -698,7 +710,7 @@ do_sigcancel(void) !self->ul_cancel_disabled && self->ul_libc_locks == 0 && !self->ul_cancelable) - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); set_cancel_pending_flag(self, 0); } diff --git a/usr/src/lib/libc/port/threads/spawn.c b/usr/src/lib/libc/port/threads/spawn.c index cf28f44b99..8743133b9c 100644 --- a/usr/src/lib/libc/port/threads/spawn.c +++ b/usr/src/lib/libc/port/threads/spawn.c @@ -65,8 +65,6 @@ typedef struct file_attr { int fa_newfiledes; /* new file descriptor for dup2() */ } file_attr_t; -extern pid_t _vforkx(int); -#pragma unknown_control_flow(_vforkx) extern int __lwp_sigmask(int, const sigset_t *, sigset_t *); extern int __sigaction(int, const struct sigaction *, struct sigaction *); @@ -185,13 +183,12 @@ get_error(int *errp) * (with a defunct owner) and we would deadlock ourself if we invoked it. * * Therefore, all of the functions we call here after returning from - * _vforkx() in the child are not and must never be exported from libc + * vforkx() in the child are not and must never be exported from libc * as global symbols. To do so would risk invoking the dynamic linker. */ -#pragma weak posix_spawn = _posix_spawn int -_posix_spawn( +posix_spawn( pid_t *pidp, const char *path, const posix_spawn_file_actions_t *file_actions, @@ -207,7 +204,7 @@ _posix_spawn( if (attrp != NULL && sap == NULL) return (EINVAL); - switch (pid = _vforkx(forkflags(sap))) { + switch (pid = vforkx(forkflags(sap))) { case 0: /* child */ break; case -1: /* parent, failure */ @@ -267,10 +264,9 @@ execat(const char *s1, const char *s2, char *si) return (*s1? ++s1: NULL); } -#pragma weak posix_spawnp = _posix_spawnp /* ARGSUSED */ int -_posix_spawnp( +posix_spawnp( pid_t *pidp, const char *file, const posix_spawn_file_actions_t *file_actions, @@ -309,7 +305,7 @@ _posix_spawnp( continue; newargs = alloca((argc + 2) * sizeof (char *)); - switch (pid = _vforkx(forkflags(sap))) { + switch (pid = vforkx(forkflags(sap))) { case 0: /* child */ break; case -1: /* parent, failure */ @@ -392,20 +388,16 @@ _posix_spawnp( return (0); /* not reached */ } -#pragma weak posix_spawn_file_actions_init = \ - _posix_spawn_file_actions_init int -_posix_spawn_file_actions_init( +posix_spawn_file_actions_init( posix_spawn_file_actions_t *file_actions) { file_actions->__file_attrp = NULL; return (0); } -#pragma weak posix_spawn_file_actions_destroy = \ - _posix_spawn_file_actions_destroy int -_posix_spawn_file_actions_destroy( +posix_spawn_file_actions_destroy( posix_spawn_file_actions_t *file_actions) { file_attr_t *froot = file_actions->__file_attrp; @@ -440,10 +432,8 @@ add_file_attr(posix_spawn_file_actions_t *file_actions, file_attr_t *fap) } } -#pragma weak posix_spawn_file_actions_addopen = \ - _posix_spawn_file_actions_addopen int -_posix_spawn_file_actions_addopen( +posix_spawn_file_actions_addopen( posix_spawn_file_actions_t *file_actions, int filedes, const char *path, @@ -473,10 +463,8 @@ _posix_spawn_file_actions_addopen( return (0); } -#pragma weak posix_spawn_file_actions_addclose = \ - _posix_spawn_file_actions_addclose int -_posix_spawn_file_actions_addclose( +posix_spawn_file_actions_addclose( posix_spawn_file_actions_t *file_actions, int filedes) { @@ -494,10 +482,8 @@ _posix_spawn_file_actions_addclose( return (0); } -#pragma weak posix_spawn_file_actions_adddup2 = \ - _posix_spawn_file_actions_adddup2 int -_posix_spawn_file_actions_adddup2( +posix_spawn_file_actions_adddup2( posix_spawn_file_actions_t *file_actions, int filedes, int newfiledes) @@ -517,10 +503,8 @@ _posix_spawn_file_actions_adddup2( return (0); } -#pragma weak posix_spawnattr_init = \ - _posix_spawnattr_init int -_posix_spawnattr_init( +posix_spawnattr_init( posix_spawnattr_t *attr) { if ((attr->__spawn_attrp = lmalloc(sizeof (posix_spawnattr_t))) == NULL) @@ -531,10 +515,8 @@ _posix_spawnattr_init( return (0); } -#pragma weak posix_spawnattr_destroy = \ - _posix_spawnattr_destroy int -_posix_spawnattr_destroy( +posix_spawnattr_destroy( posix_spawnattr_t *attr) { spawn_attr_t *sap = attr->__spawn_attrp; @@ -550,10 +532,8 @@ _posix_spawnattr_destroy( return (0); } -#pragma weak posix_spawnattr_setflags = \ - _posix_spawnattr_setflags int -_posix_spawnattr_setflags( +posix_spawnattr_setflags( posix_spawnattr_t *attr, short flags) { @@ -567,10 +547,8 @@ _posix_spawnattr_setflags( return (0); } -#pragma weak posix_spawnattr_getflags = \ - _posix_spawnattr_getflags int -_posix_spawnattr_getflags( +posix_spawnattr_getflags( const posix_spawnattr_t *attr, short *flags) { @@ -583,10 +561,8 @@ _posix_spawnattr_getflags( return (0); } -#pragma weak posix_spawnattr_setpgroup = \ - _posix_spawnattr_setpgroup int -_posix_spawnattr_setpgroup( +posix_spawnattr_setpgroup( posix_spawnattr_t *attr, pid_t pgroup) { @@ -599,10 +575,8 @@ _posix_spawnattr_setpgroup( return (0); } -#pragma weak posix_spawnattr_getpgroup = \ - _posix_spawnattr_getpgroup int -_posix_spawnattr_getpgroup( +posix_spawnattr_getpgroup( const posix_spawnattr_t *attr, pid_t *pgroup) { @@ -615,10 +589,8 @@ _posix_spawnattr_getpgroup( return (0); } -#pragma weak posix_spawnattr_setschedparam = \ - _posix_spawnattr_setschedparam int -_posix_spawnattr_setschedparam( +posix_spawnattr_setschedparam( posix_spawnattr_t *attr, const struct sched_param *schedparam) { @@ -634,10 +606,8 @@ _posix_spawnattr_setschedparam( return (0); } -#pragma weak posix_spawnattr_getschedparam = \ - _posix_spawnattr_getschedparam int -_posix_spawnattr_getschedparam( +posix_spawnattr_getschedparam( const posix_spawnattr_t *attr, struct sched_param *schedparam) { @@ -650,10 +620,8 @@ _posix_spawnattr_getschedparam( return (0); } -#pragma weak posix_spawnattr_setschedpolicy = \ - _posix_spawnattr_setschedpolicy int -_posix_spawnattr_setschedpolicy( +posix_spawnattr_setschedpolicy( posix_spawnattr_t *attr, int schedpolicy) { @@ -673,10 +641,8 @@ _posix_spawnattr_setschedpolicy( return (0); } -#pragma weak posix_spawnattr_getschedpolicy = \ - _posix_spawnattr_getschedpolicy int -_posix_spawnattr_getschedpolicy( +posix_spawnattr_getschedpolicy( const posix_spawnattr_t *attr, int *schedpolicy) { @@ -689,10 +655,8 @@ _posix_spawnattr_getschedpolicy( return (0); } -#pragma weak posix_spawnattr_setsigdefault = \ - _posix_spawnattr_setsigdefault int -_posix_spawnattr_setsigdefault( +posix_spawnattr_setsigdefault( posix_spawnattr_t *attr, const sigset_t *sigdefault) { @@ -705,10 +669,8 @@ _posix_spawnattr_setsigdefault( return (0); } -#pragma weak posix_spawnattr_getsigdefault = \ - _posix_spawnattr_getsigdefault int -_posix_spawnattr_getsigdefault( +posix_spawnattr_getsigdefault( const posix_spawnattr_t *attr, sigset_t *sigdefault) { @@ -721,10 +683,8 @@ _posix_spawnattr_getsigdefault( return (0); } -#pragma weak posix_spawnattr_setsigmask = \ - _posix_spawnattr_setsigmask int -_posix_spawnattr_setsigmask( +posix_spawnattr_setsigmask( posix_spawnattr_t *attr, const sigset_t *sigmask) { @@ -737,10 +697,8 @@ _posix_spawnattr_setsigmask( return (0); } -#pragma weak posix_spawnattr_getsigmask = \ - _posix_spawnattr_getsigmask int -_posix_spawnattr_getsigmask( +posix_spawnattr_getsigmask( const posix_spawnattr_t *attr, sigset_t *sigmask) { diff --git a/usr/src/lib/libc/port/threads/synch.c b/usr/src/lib/libc/port/threads/synch.c index 7bc1347e9a..83795070b6 100644 --- a/usr/src/lib/libc/port/threads/synch.c +++ b/usr/src/lib/libc/port/threads/synch.c @@ -26,8 +26,6 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#define atomic_cas_64 _atomic_cas_64 - #include "lint.h" #include "thr_uberdata.h" #include <sys/rtpriocntl.h> @@ -125,11 +123,10 @@ int thread_queue_spin = 10000; * LOCK_PRIO_PROTECT * LOCK_ROBUST */ -#pragma weak mutex_init = __mutex_init -#pragma weak _mutex_init = __mutex_init +#pragma weak _mutex_init = mutex_init /* ARGSUSED2 */ int -__mutex_init(mutex_t *mp, int type, void *arg) +mutex_init(mutex_t *mp, int type, void *arg) { int basetype = (type & ~ALL_ATTRIBUTES); const pcclass_t *pccp; @@ -169,15 +166,14 @@ __mutex_init(mutex_t *mp, int type, void *arg) * atomic_or_16() to set the LOCK_INITED flag so as * not to disturb surrounding bits (LOCK_OWNERDEAD, etc). */ - extern void _atomic_or_16(volatile uint16_t *, uint16_t); if (!(mp->mutex_flag & LOCK_INITED)) { mp->mutex_type = (uint8_t)type; - _atomic_or_16(&mp->mutex_flag, LOCK_INITED); + atomic_or_16(&mp->mutex_flag, LOCK_INITED); mp->mutex_magic = MUTEX_MAGIC; } else if (type != mp->mutex_type || ((type & LOCK_PRIO_PROTECT) && mp->mutex_ceiling != ceil)) { error = EINVAL; - } else if (__mutex_consistent(mp) != 0) { + } else if (mutex_consistent(mp) != 0) { error = EBUSY; } /* register a process robust mutex with the kernel */ @@ -1107,19 +1103,16 @@ setup_schedctl(void) * Interfaces from libsched, incorporated into libc. * libsched.so.1 is now a filter library onto libc. */ -#pragma weak schedctl_lookup = _schedctl_init -#pragma weak _schedctl_lookup = _schedctl_init -#pragma weak schedctl_init = _schedctl_init +#pragma weak schedctl_lookup = schedctl_init schedctl_t * -_schedctl_init(void) +schedctl_init(void) { volatile sc_shared_t *scp = setup_schedctl(); return ((scp == NULL)? NULL : (schedctl_t *)&scp->sc_preemptctl); } -#pragma weak schedctl_exit = _schedctl_exit void -_schedctl_exit(void) +schedctl_exit(void) { } @@ -1820,7 +1813,7 @@ mutex_lock_queue(ulwp_t *self, tdb_mutex_stats_t *msp, mutex_t *mp, static int mutex_recursion(mutex_t *mp, int mtype, int try) { - ASSERT(mutex_is_held(mp)); + ASSERT(mutex_held(mp)); ASSERT(mtype & (LOCK_RECURSIVE|LOCK_ERRORCHECK)); ASSERT(try == MUTEX_TRY || try == MUTEX_LOCK); @@ -1859,12 +1852,12 @@ register_lock(mutex_t *mp) lmutex_lock(&udp->tdb_hash_lock); if ((table = udp->robustlocks) == NULL) { table = lmalloc(LOCKHASHSZ * sizeof (robust_t *)); - _membar_producer(); + membar_producer(); udp->robustlocks = table; } lmutex_unlock(&udp->tdb_hash_lock); } - _membar_consumer(); + membar_consumer(); /* * First search the registered table with no locks held. @@ -1898,7 +1891,7 @@ register_lock(mutex_t *mp) (void) ___lwp_mutex_register(mp); rlp = lmalloc(sizeof (*rlp)); rlp->robust_lock = mp; - _membar_producer(); + membar_producer(); *rlpp = rlp; lmutex_unlock(&udp->tdb_hash_lock); @@ -1956,11 +1949,11 @@ mutex_lock_internal(mutex_t *mp, timespec_t *tsp, int try) if (msp && try == MUTEX_TRY) tdb_incr(msp->mutex_try); - if ((mtype & (LOCK_RECURSIVE|LOCK_ERRORCHECK)) && mutex_is_held(mp)) + if ((mtype & (LOCK_RECURSIVE|LOCK_ERRORCHECK)) && mutex_held(mp)) return (mutex_recursion(mp, mtype, try)); if (self->ul_error_detection && try == MUTEX_LOCK && - tsp == NULL && mutex_is_held(mp)) + tsp == NULL && mutex_held(mp)) lock_error(mp, "mutex_lock", NULL, NULL); if ((mtype & LOCK_PRIO_PROTECT) && noceil == 0) { @@ -2166,53 +2159,48 @@ mutex_lock_impl(mutex_t *mp, timespec_t *tsp) return (mutex_lock_internal(mp, tsp, MUTEX_LOCK)); } -#pragma weak mutex_lock = __mutex_lock -#pragma weak _mutex_lock = __mutex_lock -#pragma weak pthread_mutex_lock = __mutex_lock -#pragma weak _pthread_mutex_lock = __mutex_lock +#pragma weak pthread_mutex_lock = mutex_lock +#pragma weak _mutex_lock = mutex_lock int -__mutex_lock(mutex_t *mp) +mutex_lock(mutex_t *mp) { ASSERT(!curthread->ul_critical || curthread->ul_bindflags); return (mutex_lock_impl(mp, NULL)); } -#pragma weak pthread_mutex_timedlock = _pthread_mutex_timedlock int -_pthread_mutex_timedlock(mutex_t *mp, const timespec_t *abstime) +pthread_mutex_timedlock(pthread_mutex_t *_RESTRICT_KYWD mp, + const struct timespec *_RESTRICT_KYWD abstime) { timespec_t tslocal; int error; ASSERT(!curthread->ul_critical || curthread->ul_bindflags); abstime_to_reltime(CLOCK_REALTIME, abstime, &tslocal); - error = mutex_lock_impl(mp, &tslocal); + error = mutex_lock_impl((mutex_t *)mp, &tslocal); if (error == ETIME) error = ETIMEDOUT; return (error); } -#pragma weak pthread_mutex_reltimedlock_np = _pthread_mutex_reltimedlock_np int -_pthread_mutex_reltimedlock_np(mutex_t *mp, const timespec_t *reltime) +pthread_mutex_reltimedlock_np(pthread_mutex_t *_RESTRICT_KYWD mp, + const struct timespec *_RESTRICT_KYWD reltime) { timespec_t tslocal; int error; ASSERT(!curthread->ul_critical || curthread->ul_bindflags); tslocal = *reltime; - error = mutex_lock_impl(mp, &tslocal); + error = mutex_lock_impl((mutex_t *)mp, &tslocal); if (error == ETIME) error = ETIMEDOUT; return (error); } -#pragma weak mutex_trylock = __mutex_trylock -#pragma weak _mutex_trylock = __mutex_trylock -#pragma weak pthread_mutex_trylock = __mutex_trylock -#pragma weak _pthread_mutex_trylock = __mutex_trylock +#pragma weak pthread_mutex_trylock = mutex_trylock int -__mutex_trylock(mutex_t *mp) +mutex_trylock(mutex_t *mp) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -2283,10 +2271,10 @@ mutex_unlock_internal(mutex_t *mp, int retain_robust_flags) int release_all; lwpid_t lwpid; - if ((mtype & LOCK_ERRORCHECK) && !mutex_is_held(mp)) + if ((mtype & LOCK_ERRORCHECK) && !mutex_held(mp)) return (EPERM); - if (self->ul_error_detection && !mutex_is_held(mp)) + if (self->ul_error_detection && !mutex_held(mp)) lock_error(mp, "mutex_unlock", NULL, NULL); if ((mtype & LOCK_RECURSIVE) && mp->mutex_rcount != 0) { @@ -2333,12 +2321,10 @@ mutex_unlock_internal(mutex_t *mp, int retain_robust_flags) return (error); } -#pragma weak mutex_unlock = __mutex_unlock -#pragma weak _mutex_unlock = __mutex_unlock -#pragma weak pthread_mutex_unlock = __mutex_unlock -#pragma weak _pthread_mutex_unlock = __mutex_unlock +#pragma weak pthread_mutex_unlock = mutex_unlock +#pragma weak _mutex_unlock = mutex_unlock int -__mutex_unlock(mutex_t *mp) +mutex_unlock(mutex_t *mp) { ulwp_t *self = curthread; int mtype = mp->mutex_type; @@ -2435,7 +2421,7 @@ slow_unlock: /* * Internally to the library, almost all mutex lock/unlock actions * go through these lmutex_ functions, to protect critical regions. - * We replicate a bit of code from __mutex_lock() and __mutex_unlock() + * We replicate a bit of code from mutex_lock() and mutex_unlock() * to make these functions faster since we know that the mutex type * of all internal locks is USYNC_THREAD. We also know that internal * locking can never fail, so we panic if it does. @@ -2626,7 +2612,7 @@ cancel_safe_mutex_unlock(mutex_t *mp) !(self->ul_vfork | self->ul_nocancel | self->ul_critical | self->ul_sigdefer) && cancel_active()) - _pthread_exit(PTHREAD_CANCELED); + pthread_exit(PTHREAD_CANCELED); } static int @@ -2652,18 +2638,9 @@ shared_mutex_held(mutex_t *mparg) return (MUTEX_OWNED(mp, self) && mp->mutex_ownerpid == udp->pid); } -/* - * Some crufty old programs define their own version of _mutex_held() - * to be simply return(1). This breaks internal libc logic, so we - * define a private version for exclusive use by libc, mutex_is_held(), - * and also a new public function, __mutex_held(), to be used in new - * code to circumvent these crufty old programs. - */ -#pragma weak mutex_held = mutex_is_held -#pragma weak _mutex_held = mutex_is_held -#pragma weak __mutex_held = mutex_is_held +#pragma weak _mutex_held = mutex_held int -mutex_is_held(mutex_t *mparg) +mutex_held(mutex_t *mparg) { volatile mutex_t *mp = (volatile mutex_t *)mparg; @@ -2672,12 +2649,10 @@ mutex_is_held(mutex_t *mparg) return (MUTEX_OWNED(mp, curthread)); } -#pragma weak mutex_destroy = __mutex_destroy -#pragma weak _mutex_destroy = __mutex_destroy -#pragma weak pthread_mutex_destroy = __mutex_destroy -#pragma weak _pthread_mutex_destroy = __mutex_destroy +#pragma weak pthread_mutex_destroy = mutex_destroy +#pragma weak _mutex_destroy = mutex_destroy int -__mutex_destroy(mutex_t *mp) +mutex_destroy(mutex_t *mp) { if (mp->mutex_type & USYNC_PROCESS) forget_lock(mp); @@ -2686,18 +2661,15 @@ __mutex_destroy(mutex_t *mp) return (0); } -#pragma weak mutex_consistent = __mutex_consistent -#pragma weak _mutex_consistent = __mutex_consistent -#pragma weak pthread_mutex_consistent_np = __mutex_consistent -#pragma weak _pthread_mutex_consistent_np = __mutex_consistent +#pragma weak pthread_mutex_consistent_np = mutex_consistent int -__mutex_consistent(mutex_t *mp) +mutex_consistent(mutex_t *mp) { /* * Do this only for an inconsistent, initialized robust lock * that we hold. For all other cases, return EINVAL. */ - if (mutex_is_held(mp) && + if (mutex_held(mp) && (mp->mutex_type & LOCK_ROBUST) && (mp->mutex_flag & LOCK_INITED) && (mp->mutex_flag & (LOCK_OWNERDEAD | LOCK_UNMAPPED))) { @@ -2713,9 +2685,8 @@ __mutex_consistent(mutex_t *mp) * but we use the same data structure for them. */ -#pragma weak pthread_spin_init = _pthread_spin_init int -_pthread_spin_init(pthread_spinlock_t *lock, int pshared) +pthread_spin_init(pthread_spinlock_t *lock, int pshared) { mutex_t *mp = (mutex_t *)lock; @@ -2729,17 +2700,15 @@ _pthread_spin_init(pthread_spinlock_t *lock, int pshared) return (0); } -#pragma weak pthread_spin_destroy = _pthread_spin_destroy int -_pthread_spin_destroy(pthread_spinlock_t *lock) +pthread_spin_destroy(pthread_spinlock_t *lock) { (void) memset(lock, 0, sizeof (*lock)); return (0); } -#pragma weak pthread_spin_trylock = _pthread_spin_trylock int -_pthread_spin_trylock(pthread_spinlock_t *lock) +pthread_spin_trylock(pthread_spinlock_t *lock) { mutex_t *mp = (mutex_t *)lock; ulwp_t *self = curthread; @@ -2758,9 +2727,8 @@ _pthread_spin_trylock(pthread_spinlock_t *lock) return (error); } -#pragma weak pthread_spin_lock = _pthread_spin_lock int -_pthread_spin_lock(pthread_spinlock_t *lock) +pthread_spin_lock(pthread_spinlock_t *lock) { mutex_t *mp = (mutex_t *)lock; ulwp_t *self = curthread; @@ -2797,9 +2765,8 @@ _pthread_spin_lock(pthread_spinlock_t *lock) return (0); } -#pragma weak pthread_spin_unlock = _pthread_spin_unlock int -_pthread_spin_unlock(pthread_spinlock_t *lock) +pthread_spin_unlock(pthread_spinlock_t *lock) { mutex_t *mp = (mutex_t *)lock; ulwp_t *self = curthread; @@ -2942,7 +2909,7 @@ heldlock_exit(void) * We avoid that case here. */ if ((mp = *lockptr) != NULL && - mutex_is_held(mp) && + mutex_held(mp) && (mp->mutex_type & (LOCK_ROBUST | LOCK_PRIO_INHERIT)) == LOCK_ROBUST) { mp->mutex_rcount = 0; @@ -2955,10 +2922,10 @@ heldlock_exit(void) heldlock_free(self); } -#pragma weak cond_init = _cond_init +#pragma weak _cond_init = cond_init /* ARGSUSED2 */ int -_cond_init(cond_t *cvp, int type, void *arg) +cond_init(cond_t *cvp, int type, void *arg) { if (type != USYNC_THREAD && type != USYNC_PROCESS) return (EINVAL); @@ -3091,7 +3058,7 @@ cond_sleep_queue(cond_t *cvp, mutex_t *mp, timespec_t *tsp) * then perform another cond_signal() to avoid consuming it. */ if (error && signalled) - (void) cond_signal_internal(cvp); + (void) cond_signal(cvp); return (error); } @@ -3213,7 +3180,7 @@ cond_wait_kernel(cond_t *cvp, mutex_t *mp, timespec_t *tsp) } /* - * Common code for _cond_wait() and _cond_timedwait() + * Common code for cond_wait() and cond_timedwait() */ int cond_wait_common(cond_t *cvp, mutex_t *mp, timespec_t *tsp) @@ -3261,7 +3228,7 @@ cond_wait_common(cond_t *cvp, mutex_t *mp, timespec_t *tsp) begin_sleep = gethrtime(); if (self->ul_error_detection) { - if (!mutex_is_held(mp)) + if (!mutex_held(mp)) lock_error(mp, "cond_wait", cvp, NULL); if ((mtype & LOCK_RECURSIVE) && mp->mutex_rcount != 0) lock_error(mp, "recursive mutex in cond_wait", @@ -3309,8 +3276,8 @@ cond_wait_common(cond_t *cvp, mutex_t *mp, timespec_t *tsp) } /* - * cond_wait() and _cond_wait() are cancellation points but __cond_wait() - * is not. Internally, libc calls the non-cancellation version. + * cond_wait() is a cancellation point but __cond_wait() is not. + * Internally, libc calls the non-cancellation version. * Other libraries need to use pthread_setcancelstate(), as appropriate, * since __cond_wait() is not exported from libc. */ @@ -3337,9 +3304,9 @@ __cond_wait(cond_t *cvp, mutex_t *mp) return (cond_wait_common(cvp, mp, NULL)); } -#pragma weak cond_wait = _cond_wait +#pragma weak _cond_wait = cond_wait int -_cond_wait(cond_t *cvp, mutex_t *mp) +cond_wait(cond_t *cvp, mutex_t *mp) { int error; @@ -3355,19 +3322,18 @@ _cond_wait(cond_t *cvp, mutex_t *mp) /* * pthread_cond_wait() is a cancellation point. */ -#pragma weak pthread_cond_wait = _pthread_cond_wait int -_pthread_cond_wait(cond_t *cvp, mutex_t *mp) +pthread_cond_wait(pthread_cond_t *_RESTRICT_KYWD cvp, + pthread_mutex_t *_RESTRICT_KYWD mp) { int error; - error = _cond_wait(cvp, mp); + error = cond_wait((cond_t *)cvp, (mutex_t *)mp); return ((error == EINTR)? 0 : error); } /* - * cond_timedwait() and _cond_timedwait() are cancellation points - * but __cond_timedwait() is not. + * cond_timedwait() is a cancellation point but __cond_timedwait() is not. */ int __cond_timedwait(cond_t *cvp, mutex_t *mp, const timespec_t *abstime) @@ -3394,9 +3360,8 @@ __cond_timedwait(cond_t *cvp, mutex_t *mp, const timespec_t *abstime) return (error); } -#pragma weak cond_timedwait = _cond_timedwait int -_cond_timedwait(cond_t *cvp, mutex_t *mp, const timespec_t *abstime) +cond_timedwait(cond_t *cvp, mutex_t *mp, const timespec_t *abstime) { int error; @@ -3412,13 +3377,14 @@ _cond_timedwait(cond_t *cvp, mutex_t *mp, const timespec_t *abstime) /* * pthread_cond_timedwait() is a cancellation point. */ -#pragma weak pthread_cond_timedwait = _pthread_cond_timedwait int -_pthread_cond_timedwait(cond_t *cvp, mutex_t *mp, const timespec_t *abstime) +pthread_cond_timedwait(pthread_cond_t *_RESTRICT_KYWD cvp, + pthread_mutex_t *_RESTRICT_KYWD mp, + const struct timespec *_RESTRICT_KYWD abstime) { int error; - error = _cond_timedwait(cvp, mp, abstime); + error = cond_timedwait((cond_t *)cvp, (mutex_t *)mp, abstime); if (error == ETIME) error = ETIMEDOUT; else if (error == EINTR) @@ -3427,8 +3393,7 @@ _pthread_cond_timedwait(cond_t *cvp, mutex_t *mp, const timespec_t *abstime) } /* - * cond_reltimedwait() and _cond_reltimedwait() are cancellation points - * but __cond_reltimedwait() is not. + * cond_reltimedwait() is a cancellation point but __cond_reltimedwait() is not. */ int __cond_reltimedwait(cond_t *cvp, mutex_t *mp, const timespec_t *reltime) @@ -3438,9 +3403,8 @@ __cond_reltimedwait(cond_t *cvp, mutex_t *mp, const timespec_t *reltime) return (cond_wait_common(cvp, mp, &tslocal)); } -#pragma weak cond_reltimedwait = _cond_reltimedwait int -_cond_reltimedwait(cond_t *cvp, mutex_t *mp, const timespec_t *reltime) +cond_reltimedwait(cond_t *cvp, mutex_t *mp, const timespec_t *reltime) { int error; @@ -3453,14 +3417,14 @@ _cond_reltimedwait(cond_t *cvp, mutex_t *mp, const timespec_t *reltime) return (error); } -#pragma weak pthread_cond_reltimedwait_np = _pthread_cond_reltimedwait_np int -_pthread_cond_reltimedwait_np(cond_t *cvp, mutex_t *mp, - const timespec_t *reltime) +pthread_cond_reltimedwait_np(pthread_cond_t *_RESTRICT_KYWD cvp, + pthread_mutex_t *_RESTRICT_KYWD mp, + const struct timespec *_RESTRICT_KYWD reltime) { int error; - error = _cond_reltimedwait(cvp, mp, reltime); + error = cond_reltimedwait((cond_t *)cvp, (mutex_t *)mp, reltime); if (error == ETIME) error = ETIMEDOUT; else if (error == EINTR) @@ -3468,12 +3432,10 @@ _pthread_cond_reltimedwait_np(cond_t *cvp, mutex_t *mp, return (error); } -#pragma weak pthread_cond_signal = cond_signal_internal -#pragma weak _pthread_cond_signal = cond_signal_internal -#pragma weak cond_signal = cond_signal_internal -#pragma weak _cond_signal = cond_signal_internal +#pragma weak pthread_cond_signal = cond_signal +#pragma weak _cond_signal = cond_signal int -cond_signal_internal(cond_t *cvp) +cond_signal(cond_t *cvp) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -3492,7 +3454,7 @@ cond_signal_internal(cond_t *cvp) tdb_incr(csp->cond_signal); if (cvp->cond_waiters_kernel) /* someone sleeping in the kernel? */ - error = __lwp_cond_signal(cvp); + error = _lwp_cond_signal(cvp); if (!cvp->cond_waiters_user) /* no one sleeping at user-level */ return (error); @@ -3601,12 +3563,10 @@ alloc_lwpids(lwpid_t *lwpid, int *nlwpid_ptr, int *maxlwps_ptr) return (lwpid); } -#pragma weak pthread_cond_broadcast = cond_broadcast_internal -#pragma weak _pthread_cond_broadcast = cond_broadcast_internal -#pragma weak cond_broadcast = cond_broadcast_internal -#pragma weak _cond_broadcast = cond_broadcast_internal +#pragma weak pthread_cond_broadcast = cond_broadcast +#pragma weak _cond_broadcast = cond_broadcast int -cond_broadcast_internal(cond_t *cvp) +cond_broadcast(cond_t *cvp) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -3627,7 +3587,7 @@ cond_broadcast_internal(cond_t *cvp) tdb_incr(csp->cond_broadcast); if (cvp->cond_waiters_kernel) /* someone sleeping in the kernel? */ - error = __lwp_cond_broadcast(cvp); + error = _lwp_cond_broadcast(cvp); if (!cvp->cond_waiters_user) /* no one sleeping at user-level */ return (error); @@ -3699,11 +3659,9 @@ cond_broadcast_internal(cond_t *cvp) return (error); } -#pragma weak pthread_cond_destroy = _cond_destroy -#pragma weak _pthread_cond_destroy = _cond_destroy -#pragma weak cond_destroy = _cond_destroy +#pragma weak pthread_cond_destroy = cond_destroy int -_cond_destroy(cond_t *cvp) +cond_destroy(cond_t *cvp) { cvp->cond_magic = 0; tdb_sync_obj_deregister(cvp); @@ -3745,9 +3703,6 @@ record_spin_locks(ulwp_t *ulwp) /* * atexit function: dump the queue statistics to stderr. */ -#if !defined(__lint) -#define fprintf _fprintf -#endif #include <stdio.h> void dump_queue_statistics(void) diff --git a/usr/src/lib/libc/port/threads/tdb_agent.c b/usr/src/lib/libc/port/threads/tdb_agent.c index 519fd4e439..919f0473f4 100644 --- a/usr/src/lib/libc/port/threads/tdb_agent.c +++ b/usr/src/lib/libc/port/threads/tdb_agent.c @@ -218,7 +218,7 @@ initialize_sync_hash() tdbp->tdb_register_count = 1; /* assign to tdb_sync_addr_hash only after fully initialized */ - _membar_producer(); + membar_producer(); tdbp->tdb_sync_addr_hash = addr_hash; lmutex_unlock(&udp->tdb_hash_lock); } @@ -269,7 +269,7 @@ tdb_sync_obj_register(void *addr, int *new) goto out; } } - _membar_consumer(); + membar_consumer(); sapp = &tdbp->tdb_sync_addr_hash[tdb_addr_hash(addr)]; if (udp->uberflags.uf_tdb_register_sync == REGISTER_SYNC_ON) { diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c index 17625cb61c..2a23b6bd88 100644 --- a/usr/src/lib/libc/port/threads/thr.c +++ b/usr/src/lib/libc/port/threads/thr.c @@ -34,6 +34,17 @@ #include <ctype.h> #include "libc.h" +/* + * These symbols should not be exported from libc, but + * /lib/libm.so.2 references _thr_main. libm needs to be fixed. + * Also, some older versions of the Studio compiler/debugger + * components reference them. These need to be fixed, too. + */ +#pragma weak _thr_main = thr_main +#pragma weak _thr_create = thr_create +#pragma weak _thr_join = thr_join +#pragma weak _thr_self = thr_self + #undef errno extern int errno; @@ -243,7 +254,7 @@ dead_and_buried(ulwp_t *ulwp) if (ulwp->ul_lwpid == (lwpid_t)(-1)) return (1); if (ulwp->ul_dead && ulwp->ul_detached && - __lwp_kill(ulwp->ul_lwpid, 0) == ESRCH) { + _lwp_kill(ulwp->ul_lwpid, 0) == ESRCH) { ulwp->ul_lwpid = (lwpid_t)(-1); return (1); } @@ -512,7 +523,7 @@ ulwp_broadcast(ulwp_t *ulwp) uberdata_t *udp = self->ul_uberdata; ASSERT(MUTEX_OWNED(ulwp_mutex(ulwp, udp), self)); - (void) cond_broadcast_internal(ulwp_condvar(ulwp, udp)); + (void) cond_broadcast(ulwp_condvar(ulwp, udp)); } /* @@ -591,7 +602,7 @@ _thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, if (flags & THR_DAEMON) lwp_flags |= LWP_DAEMON; - /* creating a thread: enforce mt-correctness in _mutex_lock() */ + /* creating a thread: enforce mt-correctness in mutex_lock() */ self->ul_async_safe = 1; /* per-thread copies of global variables, for speed */ @@ -635,12 +646,12 @@ _thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, _fpinherit(ulwp); /* * Defer signals on the new thread until its TLS constructors - * have been called. _thr_setup() will call sigon() after + * have been called. _thrp_setup() will call sigon() after * it has called tls_setup(). */ ulwp->ul_sigdefer = 1; - if (setup_context(&uc, _thr_setup, ulwp, + if (setup_context(&uc, _thrp_setup, ulwp, (caddr_t)ulwp->ul_stk + ulwp->ul_guardsize, stksize) != 0) error = EAGAIN; @@ -702,9 +713,8 @@ _thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, return (0); } -#pragma weak thr_create = _thr_create int -_thr_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, +thr_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, long flags, thread_t *new_thread) { return (_thrp_create(stk, stksize, func, arg, flags, new_thread, 0)); @@ -714,7 +724,7 @@ _thr_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, * A special cancellation cleanup hook for DCE. * cleanuphndlr, when it is not NULL, will contain a callback * function to be called before a thread is terminated in - * _thr_exit() as a result of being cancelled. + * thr_exit() as a result of being cancelled. */ static void (*cleanuphndlr)(void) = NULL; @@ -887,8 +897,8 @@ collect_queue_statistics() } #endif -void -_thr_exit_common(void *status, int unwind) +static void __NORETURN +_thrp_exit_common(void *status, int unwind) { ulwp_t *self = curthread; int cancelled = (self->ul_cancel_pending && status == PTHREAD_CANCELED); @@ -919,7 +929,7 @@ _thr_exit_common(void *status, int unwind) * bad behavior. Such signals will be lost to the process * when the thread finishes exiting. */ - (void) _thr_sigsetmask(SIG_SETMASK, &maskset, NULL); + (void) thr_sigsetmask(SIG_SETMASK, &maskset, NULL); sigoff(self); self->ul_rval = status; @@ -938,7 +948,10 @@ _thr_exit_common(void *status, int unwind) * It never returns. */ _thrp_unwind(NULL); - thr_panic("_thr_exit_common(): _thrp_unwind() returned"); + thr_panic("_thrp_exit_common(): _thrp_unwind() returned"); + + for (;;) /* to shut the compiler up about __NORETURN */ + continue; } /* @@ -946,18 +959,17 @@ _thr_exit_common(void *status, int unwind) * We are at the top of the stack; no unwinding is necessary. */ void -_thr_terminate(void *status) +_thrp_terminate(void *status) { - _thr_exit_common(status, 0); + _thrp_exit_common(status, 0); } -#pragma weak thr_exit = _thr_exit -#pragma weak pthread_exit = _thr_exit -#pragma weak _pthread_exit = _thr_exit +#pragma weak pthread_exit = thr_exit +#pragma weak _thr_exit = thr_exit void -_thr_exit(void *status) +thr_exit(void *status) { - _thr_exit_common(status, 1); + _thrp_exit_common(status, 1); } int @@ -1047,9 +1059,8 @@ _thrp_join(thread_t tid, thread_t *departed, void **status, int do_cancel) return (0); } -#pragma weak thr_join = _thr_join int -_thr_join(thread_t tid, thread_t *departed, void **status) +thr_join(thread_t tid, thread_t *departed, void **status) { int error = _thrp_join(tid, departed, status, 1); return ((error == EINVAL)? ESRCH : error); @@ -1061,17 +1072,15 @@ _thr_join(thread_t tid, thread_t *departed, void **status) * and hence does not have a "departed" argument. * It returns EINVAL if tid refers to a detached thread. */ -#pragma weak pthread_join = _pthread_join +#pragma weak _pthread_join = pthread_join int -_pthread_join(pthread_t tid, void **status) +pthread_join(pthread_t tid, void **status) { return ((tid == 0)? ESRCH : _thrp_join(tid, NULL, status, 1)); } -#pragma weak pthread_detach = _thr_detach -#pragma weak _pthread_detach = _thr_detach int -_thr_detach(thread_t tid) +pthread_detach(pthread_t tid) { uberdata_t *udp = curthread->ul_uberdata; ulwp_t *ulwp; @@ -1094,20 +1103,6 @@ _thr_detach(thread_t tid) return (error); } -/* - * Static local string compare function to avoid calling strncmp() - * (and hence the dynamic linker) during library initialization. - */ -static int -sncmp(const char *s1, const char *s2, size_t n) -{ - n++; - while (--n != 0 && *s1 == *s2++) - if (*s1++ == '\0') - return (0); - return (n == 0 ? 0 : *(uchar_t *)s1 - *(uchar_t *)--s2); -} - static const char * ematch(const char *ev, const char *match) { @@ -1184,18 +1179,18 @@ etest(const char *ev) static void set_thread_vars() { - extern const char **_environ; + extern const char **environ; const char **pev; const char *ev; char c; - if ((pev = _environ) == NULL) + if ((pev = environ) == NULL) return; while ((ev = *pev++) != NULL) { c = *ev; - if (c == '_' && sncmp(ev, "_THREAD_", 8) == 0) + if (c == '_' && strncmp(ev, "_THREAD_", 8) == 0) etest(ev + 8); - if (c == 'L' && sncmp(ev, "LIBTHREAD_", 10) == 0) + if (c == 'L' && strncmp(ev, "LIBTHREAD_", 10) == 0) etest(ev + 10); } } @@ -1314,7 +1309,7 @@ libc_init(void) self->ul_forw = self->ul_back = self; self->ul_hash = NULL; self->ul_ix = 0; - self->ul_lwpid = 1; /* __lwp_self() */ + self->ul_lwpid = 1; /* _lwp_self() */ self->ul_main = 1; self->ul_self = self; self->ul_policy = -1; /* initialize only when needed */ @@ -1603,7 +1598,7 @@ postfork1_child() __libc_threaded = 0; for (i = 0; i < udp->hash_size; i++) udp->thr_hash_table[i].hash_bucket = NULL; - self->ul_lwpid = __lwp_self(); + self->ul_lwpid = _lwp_self(); hash_in_unlocked(self, TIDHASH(self->ul_lwpid, udp), udp); /* @@ -1611,8 +1606,10 @@ postfork1_child() * while holding udp->callout_lock or udp->ld_lock. * Reinitialize the child's copies. */ - mutex_init(&udp->callout_lock, USYNC_THREAD | LOCK_RECURSIVE, NULL); - mutex_init(&udp->ld_lock, USYNC_THREAD | LOCK_RECURSIVE, NULL); + (void) mutex_init(&udp->callout_lock, + USYNC_THREAD | LOCK_RECURSIVE, NULL); + (void) mutex_init(&udp->ld_lock, + USYNC_THREAD | LOCK_RECURSIVE, NULL); /* no one in the child is on a sleep queue; reinitialize */ if ((qp = udp->queue_head) != NULL) { @@ -1692,19 +1689,16 @@ lwp_self(void) return (curthread->ul_lwpid); } -#pragma weak _ti_thr_self = _thr_self -#pragma weak thr_self = _thr_self -#pragma weak pthread_self = _thr_self -#pragma weak _pthread_self = _thr_self +#pragma weak _ti_thr_self = thr_self +#pragma weak pthread_self = thr_self thread_t -_thr_self() +thr_self() { return (curthread->ul_lwpid); } -#pragma weak thr_main = _thr_main int -_thr_main() +thr_main() { ulwp_t *self = __curthread(); @@ -1726,9 +1720,9 @@ _thrp_stksegment(ulwp_t *ulwp, stack_t *stk) return (0); } -#pragma weak thr_stksegment = _thr_stksegment +#pragma weak _thr_stksegment = thr_stksegment int -_thr_stksegment(stack_t *stk) +thr_stksegment(stack_t *stk) { return (_thrp_stksegment(curthread, stk)); } @@ -1747,7 +1741,7 @@ force_continue(ulwp_t *ulwp) ASSERT(MUTEX_OWNED(ulwp_mutex(ulwp, udp), self)); for (;;) { - error = __lwp_continue(ulwp->ul_lwpid); + error = _lwp_continue(ulwp->ul_lwpid); if (error != 0 && error != EINTR) break; error = 0; @@ -1869,7 +1863,7 @@ top: } } - (void) cond_broadcast_internal(cvp); + (void) cond_broadcast(cvp); lmutex_unlock(mp); return (error); } @@ -2099,36 +2093,32 @@ _thrp_continue(thread_t tid, uchar_t whystopped) return (error); } -#pragma weak thr_suspend = _thr_suspend int -_thr_suspend(thread_t tid) +thr_suspend(thread_t tid) { return (_thrp_suspend(tid, TSTP_REGULAR)); } -#pragma weak thr_continue = _thr_continue int -_thr_continue(thread_t tid) +thr_continue(thread_t tid) { return (_thrp_continue(tid, TSTP_REGULAR)); } -#pragma weak thr_yield = _thr_yield void -_thr_yield() +thr_yield() { yield(); } -#pragma weak thr_kill = _thr_kill -#pragma weak pthread_kill = _thr_kill -#pragma weak _pthread_kill = _thr_kill +#pragma weak pthread_kill = thr_kill +#pragma weak _thr_kill = thr_kill int -_thr_kill(thread_t tid, int sig) +thr_kill(thread_t tid, int sig) { if (sig == SIGCANCEL) return (EINVAL); - return (__lwp_kill(tid, sig)); + return (_lwp_kill(tid, sig)); } /* @@ -2200,7 +2190,7 @@ _ti_bind_guard(int flags) if ((flags & (THR_FLG_NOLOCK | THR_FLG_REENTER)) == THR_FLG_NOLOCK) { ASSERT(self->ul_critical == 0); sigoff(self); /* see no signals while holding ld_lock */ - mutex_lock(&udp->ld_lock); + (void) mutex_lock(&udp->ld_lock); } enter_critical(self); self->ul_save_state = self->ul_cancel_disabled; @@ -2226,7 +2216,7 @@ _ti_bind_clear(int flags) if ((flags & (THR_FLG_NOLOCK | THR_FLG_REENTER)) == THR_FLG_NOLOCK) { ASSERT(self->ul_critical == 0); if (MUTEX_OWNED(&udp->ld_lock, self)) { - mutex_unlock(&udp->ld_lock); + (void) mutex_unlock(&udp->ld_lock); sigon(self); /* reenable signals */ } } @@ -2237,7 +2227,7 @@ _ti_bind_clear(int flags) * sigoff() and sigon() enable cond_wait() to behave (optionally) like * it does in the old libthread (see the comments in cond_wait_queue()). * Also, signals are deferred at thread startup until TLS constructors - * have all been called, at which time _thr_setup() calls sigon(). + * have all been called, at which time _thrp_setup() calls sigon(). * * _sigoff() and _sigon() are external consolidation-private interfaces to * sigoff() and sigon(), respectively, in libc. These are used in libnsl. @@ -2272,23 +2262,20 @@ sigon(ulwp_t *self) } } -#pragma weak thr_getconcurrency = _thr_getconcurrency int -_thr_getconcurrency() +thr_getconcurrency() { return (thr_concurrency); } -#pragma weak pthread_getconcurrency = _pthread_getconcurrency int -_pthread_getconcurrency() +pthread_getconcurrency() { return (pthread_concurrency); } -#pragma weak thr_setconcurrency = _thr_setconcurrency int -_thr_setconcurrency(int new_level) +thr_setconcurrency(int new_level) { uberdata_t *udp = curthread->ul_uberdata; @@ -2303,9 +2290,8 @@ _thr_setconcurrency(int new_level) return (0); } -#pragma weak pthread_setconcurrency = _pthread_setconcurrency int -_pthread_setconcurrency(int new_level) +pthread_setconcurrency(int new_level) { if (new_level < 0) return (EINVAL); @@ -2315,10 +2301,8 @@ _pthread_setconcurrency(int new_level) return (0); } -#pragma weak thr_min_stack = _thr_min_stack -#pragma weak __pthread_min_stack = _thr_min_stack size_t -_thr_min_stack(void) +thr_min_stack(void) { return (MINSTACK); } @@ -2346,9 +2330,9 @@ cond_t mutatorscv = DEFAULTCV; /* where non-mutators sleep. */ * Get the available register state for the target thread. * Return non-volatile registers: TRS_NONVOLATILE */ -#pragma weak thr_getstate = _thr_getstate +#pragma weak _thr_getstate = thr_getstate int -_thr_getstate(thread_t tid, int *flag, lwpid_t *lwp, stack_t *ss, gregset_t rs) +thr_getstate(thread_t tid, int *flag, lwpid_t *lwp, stack_t *ss, gregset_t rs) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -2393,9 +2377,9 @@ _thr_getstate(thread_t tid, int *flag, lwpid_t *lwp, stack_t *ss, gregset_t rs) * Set the appropriate register state for the target thread. * This is not used by java. It exists solely for the MSTC test suite. */ -#pragma weak thr_setstate = _thr_setstate +#pragma weak _thr_setstate = thr_setstate int -_thr_setstate(thread_t tid, int flag, gregset_t rs) +thr_setstate(thread_t tid, int flag, gregset_t rs) { uberdata_t *udp = curthread->ul_uberdata; ulwp_t *ulwp; @@ -2524,9 +2508,9 @@ __gettsp(thread_t tid) * This tells java stack walkers how to find the ucontext * structure passed to signal handlers. */ -#pragma weak thr_sighndlrinfo = _thr_sighndlrinfo +#pragma weak _thr_sighndlrinfo = thr_sighndlrinfo void -_thr_sighndlrinfo(void (**func)(), int *funcsize) +thr_sighndlrinfo(void (**func)(), int *funcsize) { *func = &__sighndlr; *funcsize = (char *)&__sighndlrend - (char *)&__sighndlr; @@ -2536,9 +2520,9 @@ _thr_sighndlrinfo(void (**func)(), int *funcsize) * Mark a thread a mutator or reset a mutator to being a default, * non-mutator thread. */ -#pragma weak thr_setmutator = _thr_setmutator +#pragma weak _thr_setmutator = thr_setmutator int -_thr_setmutator(thread_t tid, int enabled) +thr_setmutator(thread_t tid, int enabled) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -2566,11 +2550,11 @@ top: lmutex_lock(&mutatorslock); if (mutatorsbarrier) { ulwp_unlock(ulwp, udp); - (void) _pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, + (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); while (mutatorsbarrier) - (void) _cond_wait(&mutatorscv, &mutatorslock); - (void) _pthread_setcancelstate(cancel_state, NULL); + (void) cond_wait(&mutatorscv, &mutatorslock); + (void) pthread_setcancelstate(cancel_state, NULL); lmutex_unlock(&mutatorslock); goto top; } @@ -2586,9 +2570,9 @@ top: * Establish a barrier against new mutators. Any non-mutator trying * to become a mutator is suspended until the barrier is removed. */ -#pragma weak thr_mutators_barrier = _thr_mutators_barrier +#pragma weak _thr_mutators_barrier = thr_mutators_barrier void -_thr_mutators_barrier(int enabled) +thr_mutators_barrier(int enabled) { int oldvalue; int cancel_state; @@ -2598,10 +2582,10 @@ _thr_mutators_barrier(int enabled) /* * Wait if trying to set the barrier while it is already set. */ - (void) _pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); + (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); while (mutatorsbarrier && enabled) - (void) _cond_wait(&mutatorscv, &mutatorslock); - (void) _pthread_setcancelstate(cancel_state, NULL); + (void) cond_wait(&mutatorscv, &mutatorslock); + (void) pthread_setcancelstate(cancel_state, NULL); oldvalue = mutatorsbarrier; mutatorsbarrier = enabled; @@ -2609,7 +2593,7 @@ _thr_mutators_barrier(int enabled) * Wakeup any blocked non-mutators when barrier is removed. */ if (oldvalue && !enabled) - (void) cond_broadcast_internal(&mutatorscv); + (void) cond_broadcast(&mutatorscv); lmutex_unlock(&mutatorslock); } @@ -2619,9 +2603,9 @@ _thr_mutators_barrier(int enabled) * in this list are suspended. Actively running non-mutators remain * running. Any other thread is suspended. */ -#pragma weak thr_suspend_allmutators = _thr_suspend_allmutators +#pragma weak _thr_suspend_allmutators = thr_suspend_allmutators int -_thr_suspend_allmutators(void) +thr_suspend_allmutators(void) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -2678,9 +2662,9 @@ top: * suspended mutator, whether suspended by thr_suspend_mutator(), or by * thr_suspend_allmutators(), can be resumed by thr_continue_mutator(). */ -#pragma weak thr_suspend_mutator = _thr_suspend_mutator +#pragma weak _thr_suspend_mutator = thr_suspend_mutator int -_thr_suspend_mutator(thread_t tid) +thr_suspend_mutator(thread_t tid) { if (tid == 0) tid = curthread->ul_lwpid; @@ -2690,9 +2674,9 @@ _thr_suspend_mutator(thread_t tid) /* * Resume the set of all suspended mutators. */ -#pragma weak thr_continue_allmutators = _thr_continue_allmutators +#pragma weak _thr_continue_allmutators = thr_continue_allmutators int -_thr_continue_allmutators() +thr_continue_allmutators() { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -2731,26 +2715,26 @@ _thr_continue_allmutators() /* * Resume a suspended mutator. */ -#pragma weak thr_continue_mutator = _thr_continue_mutator +#pragma weak _thr_continue_mutator = thr_continue_mutator int -_thr_continue_mutator(thread_t tid) +thr_continue_mutator(thread_t tid) { return (_thrp_continue(tid, TSTP_MUTATOR)); } -#pragma weak thr_wait_mutator = _thr_wait_mutator +#pragma weak _thr_wait_mutator = thr_wait_mutator int -_thr_wait_mutator(thread_t tid, int dontwait) +thr_wait_mutator(thread_t tid, int dontwait) { uberdata_t *udp = curthread->ul_uberdata; ulwp_t *ulwp; int cancel_state; int error = 0; - (void) _pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); + (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); top: if ((ulwp = find_lwp(tid)) == NULL) { - (void) _pthread_setcancelstate(cancel_state, NULL); + (void) pthread_setcancelstate(cancel_state, NULL); return (ESRCH); } @@ -2763,13 +2747,13 @@ top: cond_t *cvp = ulwp_condvar(ulwp, udp); mutex_t *mp = ulwp_mutex(ulwp, udp); - (void) _cond_wait(cvp, mp); + (void) cond_wait(cvp, mp); (void) lmutex_unlock(mp); goto top; } ulwp_unlock(ulwp, udp); - (void) _pthread_setcancelstate(cancel_state, NULL); + (void) pthread_setcancelstate(cancel_state, NULL); return (error); } diff --git a/usr/src/lib/libc/port/threads/tls.c b/usr/src/lib/libc/port/threads/tls.c index 5225f11205..12704cdc4f 100644 --- a/usr/src/lib/libc/port/threads/tls.c +++ b/usr/src/lib/libc/port/threads/tls.c @@ -312,7 +312,7 @@ __tls_get_addr(TLS_index *tls_index) #endif /* TLS_GET_ADDR_IS_WRITTEN_IN_ASSEMBLER */ /* - * This is called by _thr_setup() to initialize the thread's static TLS. + * This is called by _thrp_setup() to initialize the thread's static TLS. * Constructors for initially allocated static TLS are called here. */ void diff --git a/usr/src/lib/libc/port/threads/tsd.c b/usr/src/lib/libc/port/threads/tsd.c index bd11c43a7f..290aa22352 100644 --- a/usr/src/lib/libc/port/threads/tsd.c +++ b/usr/src/lib/libc/port/threads/tsd.c @@ -31,17 +31,24 @@ #include <stddef.h> /* + * These symbols should not be exported from libc, but + * /lib/libm.so.2 references them. libm needs to be fixed. + * Also, some older versions of the Studio compiler/debugger + * components reference them. These need to be fixed, too. + */ +#pragma weak _thr_getspecific = thr_getspecific +#pragma weak _thr_keycreate = thr_keycreate +#pragma weak _thr_setspecific = thr_setspecific + +/* * 128 million keys should be enough for anyone. * This allocates half a gigabyte of memory for the keys themselves and * half a gigabyte of memory for each thread that uses the largest key. */ #define MAX_KEYS 0x08000000U -#pragma weak thr_keycreate = _thr_keycreate -#pragma weak pthread_key_create = _thr_keycreate -#pragma weak _pthread_key_create = _thr_keycreate int -_thr_keycreate(thread_key_t *pkey, void (*destructor)(void *)) +thr_keycreate(thread_key_t *pkey, void (*destructor)(void *)) { tsd_metadata_t *tsdm = &curthread->ul_uberdata->tsd_metadata; void (**old_data)(void *) = NULL; @@ -128,8 +135,15 @@ _thr_keycreate(thread_key_t *pkey, void (*destructor)(void *)) return (0); } +#pragma weak _pthread_key_create = pthread_key_create +int +pthread_key_create(pthread_key_t *pkey, void (*destructor)(void *)) +{ + return (thr_keycreate(pkey, destructor)); +} + /* - * Same as _thr_keycreate(), above, except that the key creation + * Same as thr_keycreate(), above, except that the key creation * is performed only once. This relies upon the fact that a key * value of THR_ONCE_KEY is invalid, and requires that the key be * allocated with a value of THR_ONCE_KEY before calling here. @@ -141,11 +155,9 @@ _thr_keycreate(thread_key_t *pkey, void (*destructor)(void *)) * ... * pthread_key_create_once_np(&key, destructor); */ -#pragma weak pthread_key_create_once_np = _thr_keycreate_once -#pragma weak _pthread_key_create_once_np = _thr_keycreate_once -#pragma weak thr_keycreate_once = _thr_keycreate_once +#pragma weak pthread_key_create_once_np = thr_keycreate_once int -_thr_keycreate_once(thread_key_t *keyp, void (*destructor)(void *)) +thr_keycreate_once(thread_key_t *keyp, void (*destructor)(void *)) { static mutex_t key_lock = DEFAULTMUTEX; thread_key_t key; @@ -154,25 +166,23 @@ _thr_keycreate_once(thread_key_t *keyp, void (*destructor)(void *)) if (*keyp == THR_ONCE_KEY) { lmutex_lock(&key_lock); if (*keyp == THR_ONCE_KEY) { - error = _thr_keycreate(&key, destructor); + error = thr_keycreate(&key, destructor); if (error) { lmutex_unlock(&key_lock); return (error); } - _membar_producer(); + membar_producer(); *keyp = key; } lmutex_unlock(&key_lock); } - _membar_consumer(); + membar_consumer(); return (0); } -#pragma weak pthread_key_delete = _thr_key_delete -#pragma weak _pthread_key_delete = _thr_key_delete int -_thr_key_delete(thread_key_t key) +pthread_key_delete(pthread_key_t key) { tsd_metadata_t *tsdm = &curthread->ul_uberdata->tsd_metadata; @@ -200,9 +210,8 @@ _thr_key_delete(thread_key_t key) * incurred by thr_getspecific(). Every once in a while, the Standards * get it right -- but usually by accident. */ -#pragma weak pthread_getspecific = _pthread_getspecific void * -_pthread_getspecific(pthread_key_t key) +pthread_getspecific(pthread_key_t key) { tsd_t *stsd; @@ -223,9 +232,8 @@ _pthread_getspecific(pthread_key_t key) return (NULL); } -#pragma weak thr_getspecific = _thr_getspecific int -_thr_getspecific(thread_key_t key, void **valuep) +thr_getspecific(thread_key_t key, void **valuep) { tsd_t *stsd; @@ -250,13 +258,13 @@ _thr_getspecific(thread_key_t key, void **valuep) } /* - * We call _thr_setspecific_slow() when the key specified + * We call thr_setspecific_slow() when the key specified * is beyond the current thread's currently allocated range. * This case is in a separate function because we want * the compiler to optimize for the common case. */ static int -_thr_setspecific_slow(thread_key_t key, void *value) +thr_setspecific_slow(thread_key_t key, void *value) { ulwp_t *self = curthread; tsd_metadata_t *tsdm = &self->ul_uberdata->tsd_metadata; @@ -310,18 +318,15 @@ _thr_setspecific_slow(thread_key_t key, void *value) return (0); } -#pragma weak thr_setspecific = _thr_setspecific -#pragma weak pthread_setspecific = _thr_setspecific -#pragma weak _pthread_setspecific = _thr_setspecific int -_thr_setspecific(thread_key_t key, void *value) +thr_setspecific(thread_key_t key, void *value) { tsd_t *stsd; int ret; ulwp_t *self = curthread; /* - * See the comment in _thr_getspecific(), above. + * See the comment in thr_getspecific(), above. */ if (key == 0) return (EINVAL); @@ -341,11 +346,17 @@ _thr_setspecific(thread_key_t key, void *value) * allocation and free. Similar protection required in tsd_free(). */ enter_critical(self); - ret = _thr_setspecific_slow(key, value); + ret = thr_setspecific_slow(key, value); exit_critical(self); return (ret); } +int +pthread_setspecific(pthread_key_t key, const void *value) +{ + return (thr_setspecific(key, (void *)value)); +} + /* * Contract-private interface for java. See PSARC/2003/159 * |
