summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2002-04-27 03:02:01 +0000
committerwtc%netscape.com <devnull@localhost>2002-04-27 03:02:01 +0000
commiteb6b1b65ead38de36e0d00bec64a7613f25d2d76 (patch)
treec1d8778fbf0d26538b5d207ec6c9916d024bec03
parented0e11f2689ecccd2d9a4d2dabff9179848bc8ca (diff)
downloadnspr-hg-eb6b1b65ead38de36e0d00bec64a7613f25d2d76.tar.gz
Backed out the fix for bug 121975 on the MOZILLA_1_0_0_BRANCH. It doesn't
work on Windows 95. Modified files: configure configure.in WIN32.mk _win95.h w95dllmain.c w95thred.c
-rw-r--r--config/WIN32.mk10
-rwxr-xr-xconfigure49
-rw-r--r--configure.in4
-rw-r--r--pr/include/md/_win95.h60
-rw-r--r--pr/src/md/windows/w95dllmain.c19
-rw-r--r--pr/src/md/windows/w95thred.c24
6 files changed, 74 insertions, 92 deletions
diff --git a/config/WIN32.mk b/config/WIN32.mk
index 2d914e6f..f002c074 100644
--- a/config/WIN32.mk
+++ b/config/WIN32.mk
@@ -116,6 +116,16 @@ endif
DEFINES += -DWIN32
#
+# On Win95, we use the TlsXXX() interface by default because that
+# allows us to load the NSPR DLL dynamically at run time.
+# If you want to use static thread-local storage (TLS) for better
+# performance, build the NSPR library with USE_STATIC_TLS=1.
+#
+ifeq ($(USE_STATIC_TLS),1)
+DEFINES += -D_PR_USE_STATIC_TLS
+endif
+
+#
# NSPR uses both fibers and static thread-local storage
# (i.e., __declspec(thread) variables) on NT. We need the -GT
# flag to turn off certain compiler optimizations so that fibers
diff --git a/configure b/configure
index d2fb9bc2..bbd9de53 100755
--- a/configure
+++ b/configure
@@ -3796,6 +3796,13 @@ EOF
fi
fi # GNU_CC
+ if test -n "$USE_STATIC_TLS"; then
+ cat >> confdefs.h <<\EOF
+#define _PR_USE_STATIC_TLS 1
+EOF
+
+ fi
+
if test "$OS_TARGET" = "WINNT"; then
cat >> confdefs.h <<\EOF
#define WINNT 1
@@ -4152,17 +4159,17 @@ EOF
ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4156: checking for machine/builtins.h" >&5
+echo "configure:4163: checking for machine/builtins.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4161 "configure"
+#line 4168 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4166: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4173: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -4677,12 +4684,12 @@ esac
if test -z "$SKIP_LIBRARY_CHECKS"; then
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:4681: checking for dlopen" >&5
+echo "configure:4688: checking for dlopen" >&5
if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4686 "configure"
+#line 4693 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@@ -4705,7 +4712,7 @@ dlopen();
; return 0; }
EOF
-if { (eval echo configure:4709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_dlopen=yes"
else
@@ -4724,7 +4731,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4728: checking for dlopen in -ldl" >&5
+echo "configure:4735: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -4732,7 +4739,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4736 "configure"
+#line 4743 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -4743,7 +4750,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:4747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4754: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -4771,13 +4778,13 @@ fi
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:4775: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:4782: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 4781 "configure"
+#line 4788 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -4795,7 +4802,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 4799 "configure"
+#line 4806 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -4819,12 +4826,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4823: checking for $ac_func" >&5
+echo "configure:4830: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4828 "configure"
+#line 4835 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -4847,7 +4854,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:4851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -4885,7 +4892,7 @@ fi
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:4889: checking for pthread_create in -lpthreads" >&5
+echo "configure:4896: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -4907,7 +4914,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:4911: checking for pthread_create in -lpthread" >&5
+echo "configure:4918: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -4929,7 +4936,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:4933: checking for pthread_create in -lc_r" >&5
+echo "configure:4940: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -4951,7 +4958,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:4955: checking for pthread_create in -lc" >&5
+echo "configure:4962: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -5101,7 +5108,7 @@ if test -n "$USE_PTHREADS"; then
rm -f conftest*
ac_cv_have_dash_pthread=no
echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:5105: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5112: checking whether ${CC-cc} accepts -pthread" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@@ -5124,7 +5131,7 @@ echo "configure:5105: checking whether ${CC-cc} accepts -pthread" >&5
ac_cv_have_dash_pthreads=no
if test "$ac_cv_have_dash_pthread" = "no"; then
echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:5128: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5135: checking whether ${CC-cc} accepts -pthreads" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
diff --git a/configure.in b/configure.in
index 007d355d..47772bbd 100644
--- a/configure.in
+++ b/configure.in
@@ -1247,6 +1247,10 @@ case "$target" in
fi
fi # GNU_CC
+ if test -n "$USE_STATIC_TLS"; then
+ AC_DEFINE(_PR_USE_STATIC_TLS)
+ fi
+
if test "$OS_TARGET" = "WINNT"; then
AC_DEFINE(WINNT)
else
diff --git a/pr/include/md/_win95.h b/pr/include/md/_win95.h
index a94abbd6..86b39d5d 100644
--- a/pr/include/md/_win95.h
+++ b/pr/include/md/_win95.h
@@ -409,55 +409,31 @@ extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
extern struct PRThread * _MD_CURRENT_THREAD(void);
-extern BOOL _pr_use_static_tls;
-
+#ifdef _PR_USE_STATIC_TLS
extern __declspec(thread) struct PRThread *_pr_currentThread;
-extern DWORD _pr_currentThreadIndex;
-
-#define _MD_GET_ATTACHED_THREAD() \
- (_pr_use_static_tls ? _pr_currentThread \
- : (PRThread *) TlsGetValue(_pr_currentThreadIndex))
-
-#define _MD_SET_CURRENT_THREAD(_thread) \
- PR_BEGIN_MACRO \
- if (_pr_use_static_tls) { \
- _pr_currentThread = (_thread); \
- } else { \
- TlsSetValue(_pr_currentThreadIndex, (_thread)); \
- } \
- PR_END_MACRO
+#define _MD_GET_ATTACHED_THREAD() _pr_currentThread
+#define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
extern __declspec(thread) struct PRThread *_pr_thread_last_run;
-extern DWORD _pr_lastThreadIndex;
+#define _MD_LAST_THREAD() _pr_thread_last_run
+#define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0)
-#define _MD_LAST_THREAD() \
- (_pr_use_static_tls ? _pr_thread_last_run \
- : (PRThread *) TlsGetValue(_pr_lastThreadIndex))
+extern __declspec(thread) struct _PRCPU *_pr_currentCPU;
+#define _MD_CURRENT_CPU() _pr_currentCPU
+#define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0)
+#else /* _PR_USE_STATIC_TLS */
+extern DWORD _pr_currentThreadIndex;
+#define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex))
+#define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread))
-#define _MD_SET_LAST_THREAD(_thread) \
- PR_BEGIN_MACRO \
- if (_pr_use_static_tls) { \
- _pr_thread_last_run = 0; \
- } else { \
- TlsSetValue(_pr_lastThreadIndex, 0); \
- } \
- PR_END_MACRO
+extern DWORD _pr_lastThreadIndex;
+#define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex))
+#define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0)
-extern __declspec(thread) struct _PRCPU *_pr_currentCPU;
extern DWORD _pr_currentCPUIndex;
-
-#define _MD_CURRENT_CPU() \
- (_pr_use_static_tls ? _pr_currentCPU \
- : (struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))
-
-#define _MD_SET_CURRENT_CPU(_cpu) \
- PR_BEGIN_MACRO \
- if (_pr_use_static_tls) { \
- _pr_currentCPU = 0; \
- } else { \
- TlsSetValue(_pr_currentCPUIndex, 0); \
- } \
- PR_END_MACRO
+#define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))
+#define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0)
+#endif /* _PR_USE_STATIC_TLS */
/* --- Scheduler stuff --- */
#define LOCK_SCHEDULER() 0
diff --git a/pr/src/md/windows/w95dllmain.c b/pr/src/md/windows/w95dllmain.c
index f5c1bca9..f6e8d59c 100644
--- a/pr/src/md/windows/w95dllmain.c
+++ b/pr/src/md/windows/w95dllmain.c
@@ -36,20 +36,12 @@
* The DLL entry point (DllMain) for NSPR.
*
* This is used to detach threads that were automatically attached by
- * nspr and to find out whether the NSPR DLL is statically or
- * dynamically loaded. When dynamically loaded, we cannot use static
- * thread-local storage. However, static TLS is faster than the
- * TlsXXX() functions. So we want to use static TLS whenever we can.
- * A global variable _pr_use_static_tls is set in DllMain() during
- * process attachment to indicate whether it is safe to use static
- * TLS or not.
+ * nspr.
*/
#include <windows.h>
#include <primpl.h>
-extern BOOL _pr_use_static_tls; /* defined in w95thred.c */
-
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
@@ -59,15 +51,6 @@ PRThread *me;
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
- /*
- * If lpvReserved is NULL, we are dynamically loaded
- * and therefore can't use static thread-local storage.
- */
- if (lpvReserved == NULL) {
- _pr_use_static_tls = FALSE;
- } else {
- _pr_use_static_tls = TRUE;
- }
break;
case DLL_THREAD_ATTACH:
break;
diff --git a/pr/src/md/windows/w95thred.c b/pr/src/md/windows/w95thred.c
index 918db7b4..f8a70043 100644
--- a/pr/src/md/windows/w95thred.c
+++ b/pr/src/md/windows/w95thred.c
@@ -38,13 +38,15 @@
extern void _PR_Win32InitTimeZone(void); /* defined in ntmisc.c */
/* --- globals ------------------------------------------------ */
-BOOL _pr_use_static_tls = TRUE;
+#ifdef _PR_USE_STATIC_TLS
__declspec(thread) struct PRThread *_pr_thread_last_run;
__declspec(thread) struct PRThread *_pr_currentThread;
__declspec(thread) struct _PRCPU *_pr_currentCPU;
+#else
DWORD _pr_currentThreadIndex;
DWORD _pr_lastThreadIndex;
DWORD _pr_currentCPUIndex;
+#endif
int _pr_intsOff = 0;
_PRInterruptTable _pr_interruptTable[] = { { 0 } };
@@ -53,11 +55,11 @@ _PR_MD_EARLY_INIT()
{
_PR_Win32InitTimeZone();
- if (!_pr_use_static_tls) {
- _pr_currentThreadIndex = TlsAlloc();
- _pr_lastThreadIndex = TlsAlloc();
- _pr_currentCPUIndex = TlsAlloc();
- }
+#ifndef _PR_USE_STATIC_TLS
+ _pr_currentThreadIndex = TlsAlloc();
+ _pr_lastThreadIndex = TlsAlloc();
+ _pr_currentCPUIndex = TlsAlloc();
+#endif
}
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
@@ -66,11 +68,11 @@ void _PR_MD_CLEANUP_BEFORE_EXIT(void)
WSACleanup();
- if (!_pr_use_static_tls) {
- TlsFree(_pr_currentThreadIndex);
- TlsFree(_pr_lastThreadIndex);
- TlsFree(_pr_currentCPUIndex);
- }
+#ifndef _PR_USE_STATIC_TLS
+ TlsFree(_pr_currentThreadIndex);
+ TlsFree(_pr_lastThreadIndex);
+ TlsFree(_pr_currentCPUIndex);
+#endif
}
PRStatus