Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2004-03-26 23:02:01 +0300
committerChristopher Faylor <me@cgf.cx>2004-03-26 23:02:01 +0300
commit11a9a1cfbd9eb8f1c3670a253c561915af168407 (patch)
tree08916a8b1bfe902f704f2bff5ab2bac93bdecd45 /winsup/cygwin/thread.cc
parent6b0d86c56d6082cdc5c403d063530a1114b9bda1 (diff)
* path.cc (path_conv::check): Use 'strchr' rather than 'strrchr' to find end of
string, for efficiency. * include/cygwin/_types.h: New file. * include/sys/lock.h: Ditto. * include/sys/stdio.h: Ditto. * thread.cc: Include sys/lock.h (__cygwin_lock_init): New function. (__cygwin_lock_init_recursive): Ditto. (__cygwin_lock_fini): Ditto. (__cygwin_lock_lock): Ditto. (__cygwin_lock_trylock): Ditto. (__cygwin_lock_unlock): Ditto. (pthread::atforkprepare): Lock file pointer before fork. (pthread::atforkparent): Unlock file pointer after fork. (pthread::atforkchild): Ditto.
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 9f06c8e3b..11a9d0629 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -44,6 +44,10 @@ details. */
#include <sys/timeb.h>
#include <exceptions.h>
#include <sys/fcntl.h>
+#include <sys/lock.h>
+
+extern "C" void __fp_lock_all ();
+extern "C" void __fp_unlock_all ();
extern int threadsafe;
@@ -54,6 +58,43 @@ __getreent ()
return &_my_tls.local_clib;
}
+extern "C" void
+__cygwin_lock_init (_LOCK_T *lock)
+{
+ *lock = _LOCK_T_INITIALIZER;
+}
+
+extern "C" void
+__cygwin_lock_init_recursive (_LOCK_T *lock)
+{
+ *lock = _LOCK_T_RECURSIVE_INITIALIZER;
+}
+
+extern "C" void
+__cygwin_lock_fini (_LOCK_T *lock)
+{
+ pthread_mutex_destroy ((pthread_mutex_t*) lock);
+}
+
+extern "C" void
+__cygwin_lock_lock (_LOCK_T *lock)
+{
+ pthread_mutex_lock ((pthread_mutex_t*) lock);
+}
+
+extern "C" void
+__cygwin_lock_trylock (_LOCK_T *lock)
+{
+ pthread_mutex_trylock ((pthread_mutex_t*) lock);
+}
+
+
+extern "C" void
+__cygwin_lock_unlock (_LOCK_T *lock)
+{
+ pthread_mutex_unlock ((pthread_mutex_t*) lock);
+}
+
inline LPCRITICAL_SECTION
ResourceLocks::Lock (int _resid)
{
@@ -1908,11 +1949,15 @@ pthread::atforkprepare (void)
cb->cb ();
cb = cb->next;
}
+
+ __fp_lock_all ();
}
void
pthread::atforkparent (void)
{
+ __fp_unlock_all ();
+
callback *cb = MT_INTERFACE->pthread_parent;
while (cb)
{
@@ -1926,6 +1971,8 @@ pthread::atforkchild (void)
{
MT_INTERFACE->fixup_after_fork ();
+ __fp_unlock_all ();
+
callback *cb = MT_INTERFACE->pthread_child;
while (cb)
{