summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/globals.cc7
-rw-r--r--winsup/cygwin/miscfuncs.cc3
3 files changed, 16 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 34d7242f8..fd3212332 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
2013-05-21 Corinna Vinschen <corinna@vinschen.de>
+ * globals.cc (__isthreaded): New global variable. Explain what it's
+ used for.
+ * miscfuncs.cc (thread_wrapper): Set __isthreaded to 1 here.
+
+2013-05-21 Corinna Vinschen <corinna@vinschen.de>
+
* fhandler.h (class fhandler_dev_random): Change type of pseudo to
uint32_t to make sure it's 32 bit on all supported platforms.
diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index 887326156..9462c7a0c 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -75,6 +75,13 @@ bool detect_bloda = false;
bool NO_COPY in_forkee;
+/* Taken from BSD libc:
+ This variable is zero until a process has created a pthread. It is used
+ to avoid calling locking functions in libc when they are not required.
+ Note that this is moderately dangerous. Do not rely on it if the public
+ API is also used from a non-pthread thread like the signal thread. */
+int NO_COPY __isthreaded = 0;
+
int __argc_safe;
int __argc;
char **__argv;
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index 409392760..6a204a01e 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -473,6 +473,9 @@ thread_wrapper (PVOID arg)
if (!arg)
return ERROR_INVALID_PARAMETER;
+ /* The process is now threaded. Note the fact for later usage. */
+ __isthreaded = 1;
+
/* Fetch thread wrapper info and free from cygheap. */
thread_wrapper_arg wrapper_arg = *(thread_wrapper_arg *) arg;
cfree (arg);