summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorraf <none@none>2006-03-23 17:06:26 -0800
committerraf <none@none>2006-03-23 17:06:26 -0800
commit1d2738a5bf9233cca445b538dd8072428a953b17 (patch)
tree0fcb3e304cbe6bdbced14e02fe40812b9baf32a5 /usr/src
parent19485c10c3945da20fb22366880d733c45bd9c57 (diff)
downloadillumos-gate-1d2738a5bf9233cca445b538dd8072428a953b17.tar.gz
6402763 __threaded escaped from the reservation, abused by Forte6.1
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/sgs/libelf/common/data.c25
-rw-r--r--usr/src/lib/libc/inc/mtlib.h11
-rw-r--r--usr/src/lib/libc/port/stdio/flush.c30
-rw-r--r--usr/src/lib/libc/port/threads/thr.c23
-rw-r--r--usr/src/lib/libc/spec/privatedata.spec11
5 files changed, 57 insertions, 43 deletions
diff --git a/usr/src/cmd/sgs/libelf/common/data.c b/usr/src/cmd/sgs/libelf/common/data.c
index fb943115af..2d3b108cd6 100644
--- a/usr/src/cmd/sgs/libelf/common/data.c
+++ b/usr/src/cmd/sgs/libelf/common/data.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,12 +18,13 @@
*
* CDDL HEADER END
*/
+
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
- * Copyright (c) 1998 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
@@ -51,12 +51,15 @@
*/
/*
- * __threaded is a private symbol exported on Solaris2.5 systems and
- * later. It is used to tell if we are running in a threaded world or
- * not.
+ * __libc_threaded is a private symbol exported from libc in Solaris 10.
+ * It is used to tell if we are running in a threaded world or not.
+ * Between Solaris 2.5 and Solaris 9, this was named __threaded.
+ * The name had to be changed because the Sun Workshop 6 update 1
+ * compilation system used it to mean "we are linked with libthread"
+ * rather than its true meaning in Solaris 10, "more than one thread exists".
*/
-#pragma weak __threaded
-extern int __threaded;
+#pragma weak __libc_threaded
+extern int __libc_threaded;
int _elf_byte = 0;
const Elf32_Ehdr _elf32_ehdr_init = { 0 };
@@ -68,4 +71,4 @@ const Dnode _elf_dnode_init = { 0 };
unsigned _elf_work = EV_NONE;
mutex_t _elf_globals_mutex = DEFAULTMUTEX;
-int * _elf_libc_threaded = &__threaded;
+int *_elf_libc_threaded = &__libc_threaded;
diff --git a/usr/src/lib/libc/inc/mtlib.h b/usr/src/lib/libc/inc/mtlib.h
index 9397d58f14..89c2376949 100644
--- a/usr/src/lib/libc/inc/mtlib.h
+++ b/usr/src/lib/libc/inc/mtlib.h
@@ -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.
@@ -115,16 +114,16 @@ extern void assert_no_libc_locks_held(void);
/*
* Cheap check to tell if stdio needs to lock for MT progs.
* Referenced directly in port/stdio/flush.c and FLOCKFILE and
- * FUNLOCKFILE macros. __threaded gets set to 1 when the first
+ * FUNLOCKFILE macros. __libc_threaded gets set to 1 when the first
* thread (beyond the main thread) is created in _thrp_create().
*/
-extern int __threaded;
+extern int __libc_threaded;
#define FILELOCKING(iop) (GET_IONOLOCK(iop) == 0)
#define FLOCKFILE(lk, iop) \
{ \
- if (__threaded && FILELOCKING(iop)) \
+ if (__libc_threaded && FILELOCKING(iop)) \
lk = _flockget((iop)); \
else \
lk = NULL; \
diff --git a/usr/src/lib/libc/port/stdio/flush.c b/usr/src/lib/libc/port/stdio/flush.c
index 9a60be8745..e0bdb699cd 100644
--- a/usr/src/lib/libc/port/stdio/flush.c
+++ b/usr/src/lib/libc/port/stdio/flush.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 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -141,8 +141,8 @@ static int _fflush_u_iops(void);
static FILE *getiop(FILE *, rmutex_t *, mbstate_t *);
#define GETIOP(fp, lk, mb) {FILE *ret; \
- if ((ret = getiop((fp), __threaded ? (lk) : NULL, (mb))) != NULL) { \
- if (__threaded) \
+ if ((ret = getiop((fp), __libc_threaded? (lk): NULL, (mb))) != NULL) { \
+ if (__libc_threaded) \
(void) __rw_unlock(&_first_link_lock); \
return (ret); \
}; \
@@ -186,7 +186,7 @@ _flushlbf(void) /* fflush() all line-buffered streams */
int i;
struct _link_ *lp;
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_rdlock(&_first_link_lock);
lp = &__first_link;
@@ -199,7 +199,7 @@ _flushlbf(void) /* fflush() all line-buffered streams */
}
} while ((lp = lp->next) != NULL);
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_unlock(&_first_link_lock);
}
@@ -233,7 +233,7 @@ _findiop(void)
FPDECL(fp);
int i;
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_wrlock(&_first_link_lock);
if (lastlink == NULL) {
@@ -288,7 +288,7 @@ rescan:
* Need to allocate another and put it in the linked list.
*/
if ((pkgp = malloc(sizeof (Pkg))) == NULL) {
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_unlock(&_first_link_lock);
return (NULL);
}
@@ -355,7 +355,7 @@ rescan:
fp->_ptr = 0;
fp->_base = 0;
fp->_flag = 0377; /* claim the fp by setting low 8 bits */
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_unlock(&_first_link_lock);
return (fp);
@@ -562,7 +562,7 @@ _fflush_u_iops(void) /* flush all buffers */
struct _link_ *lp;
int res = 0;
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_rdlock(&_first_link_lock);
lp = &__first_link;
@@ -596,7 +596,7 @@ _fflush_u_iops(void) /* flush all buffers */
}
}
} while ((lp = lp->next) != NULL);
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_unlock(&_first_link_lock);
return (res);
}
@@ -658,10 +658,10 @@ fclose(FILE *iop)
iop->_flag = 0; /* marks it as available */
FUNLOCKFILE(lk);
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_wrlock(&_first_link_lock);
fcloses++;
- if (__threaded)
+ if (__libc_threaded)
(void) __rw_unlock(&_first_link_lock);
return (res);
diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c
index a87689aae5..30b5695eb2 100644
--- a/usr/src/lib/libc/port/threads/thr.c
+++ b/usr/src/lib/libc/port/threads/thr.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.
@@ -21,7 +20,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -36,7 +35,17 @@
#undef errno
extern int errno;
-int __threaded = 0; /* zero until first thr_create() */
+/*
+ * Between Solaris 2.5 and Solaris 9, __threaded was used to indicate
+ * "we are linked with libthread". The Sun Workshop 6 update 1 compilation
+ * system used it illegally (it is a consolidation private symbol).
+ * To accommodate this and possibly other abusers of the symbol,
+ * we make it always equal to 1 now that libthread has been folded
+ * into libc. The new __libc_threaded symbol is used to indicate
+ * the new meaning, "more than one thread exists".
+ */
+int __threaded = 1; /* always equal to 1 */
+int __libc_threaded = 0; /* zero until first thr_create() */
/*
* thr_concurrency and pthread_concurrency are not used by the library.
@@ -712,7 +721,7 @@ _thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg,
udp->ndaemons++;
if (flags & THR_NEW_LWP)
thr_concurrency++;
- __threaded = 1; /* inform stdio */
+ __libc_threaded = 1; /* inform stdio */
lmutex_unlock(&udp->link_lock);
if (__td_event_report(self, TD_CREATE, udp)) {
@@ -1600,7 +1609,7 @@ _postfork1_child()
udp->nthreads = 1;
udp->ndaemons = 0;
udp->uberflags.uf_mt = 0;
- __threaded = 0;
+ __libc_threaded = 0;
for (i = 0; i < udp->hash_size; i++)
udp->thr_hash_table[i].hash_bucket = NULL;
self->ul_lwpid = __lwp_self();
diff --git a/usr/src/lib/libc/spec/privatedata.spec b/usr/src/lib/libc/spec/privatedata.spec
index f2fddd0334..3fc9b1687f 100644
--- a/usr/src/lib/libc/spec/privatedata.spec
+++ b/usr/src/lib/libc/spec/privatedata.spec
@@ -1,13 +1,12 @@
#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# 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.
@@ -83,6 +82,10 @@ data __lc_time
version SUNWprivate_1.1
end
+data __libc_threaded
+version SUNWprivate_1.1
+end
+
data __lyday_to_month
arch sparc sparcv9
version sparc=SUNWprivate_1.1 sparcv9=SUNWprivate_1.1