Index: cygerrno.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/cygerrno.h,v retrieving revision 1.7 diff -u -r1.7 cygerrno.h --- cygerrno.h 22 Oct 2001 21:09:41 -0000 1.7 +++ cygerrno.h 15 May 2003 19:46:23 -0000 @@ -8,6 +8,8 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ +#include + void __stdcall seterrno_from_win_error (const char *file, int line, DWORD code) __attribute__ ((regparm(3))); void __stdcall seterrno (const char *, int line) __attribute__ ((regparm(2))); int __stdcall geterrno_from_win_error (DWORD code, int deferrno) __attribute__ ((regparm(2))); @@ -16,12 +18,12 @@ #define __seterrno_from_win_error(val) seterrno_from_win_error (__FILE__, __LINE__, val) #ifndef DEBUGGING -#define set_errno(val) (_impure_ptr->_errno = (val)) +#define set_errno(val) (errno = (val)) #else int __stdcall __set_errno (const char *ln, int ln, int val) __attribute ((regparm(3))); #define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val)) #endif -#define get_errno() (_impure_ptr->_errno) +#define get_errno() (errno) extern "C" void __stdcall set_sig_errno (int e); class save_errno Index: cygwin.din =================================================================== RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v retrieving revision 1.87 diff -u -r1.87 cygwin.din --- cygwin.din 9 May 2003 22:11:25 -0000 1.87 +++ cygwin.din 15 May 2003 19:46:25 -0000 @@ -26,6 +26,7 @@ __errno __fpclassifyd __fpclassifyf +__getreent __infinity __main __signbitd Index: debug.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/debug.cc,v retrieving revision 1.40 diff -u -r1.40 debug.cc --- debug.cc 21 Oct 2002 01:00:56 -0000 1.40 +++ debug.cc 15 May 2003 19:46:26 -0000 @@ -222,6 +222,6 @@ __set_errno (const char *func, int ln, int val) { debug_printf ("%s:%d val %d", func, ln, val); - return _impure_ptr->_errno = val; + return errno = val; } #endif /*DEBUGGING*/ Index: errno.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/errno.cc,v retrieving revision 1.36 diff -u -r1.36 errno.cc --- errno.cc 11 May 2003 00:10:10 -0000 1.36 +++ errno.cc 15 May 2003 19:46:30 -0000 @@ -12,7 +12,6 @@ #define sys_nerr FOOsys_nerr #define _sys_errlist FOO_sys_errlist #include "winsup.h" -#define _REENT_ONLY #include #include #include "cygerrno.h" Index: signal.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/signal.cc,v retrieving revision 1.43 diff -u -r1.43 signal.cc --- signal.cc 6 May 2003 19:39:10 -0000 1.43 +++ signal.cc 15 May 2003 19:46:31 -0000 @@ -297,8 +297,8 @@ be flushed. However this is the way FreeBSD does it, and it is much easier to do things this way, so... */ - if (_reent_clib ()->__cleanup) - _reent_clib ()->__cleanup (_reent_clib ()); + if (_REENT->__cleanup) + _REENT->__cleanup (_REENT); /* Ensure that SIGABRT can be caught regardless of blockage. */ sigset_t sig_mask; Index: thread.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/thread.cc,v retrieving revision 1.125 diff -u -r1.125 thread.cc --- thread.cc 15 May 2003 19:42:51 -0000 1.125 +++ thread.cc 15 May 2003 19:46:39 -0000 @@ -45,16 +45,21 @@ extern int threadsafe; -struct _reent * -_reent_clib () +extern "C" struct _reent * +__getreent () { struct __reent_t *_r = (struct __reent_t *) MT_INTERFACE->reent_key.get (); -#ifdef _CYG_THREAD_FAILSAFE if (_r == 0) - system_printf ("local thread storage not inited"); + { +#ifdef _CYG_THREAD_FAILSAFE + system_printf ("local thread storage not inited"); #endif + /* Return _impure_ptr as long as MTinterface is not initialized */ + return _impure_ptr; + } + return _r->_clib; } @@ -64,10 +69,14 @@ struct __reent_t *_r = (struct __reent_t *) MT_INTERFACE->reent_key.get (); -#ifdef _CYG_THREAD_FAILSAFE if (_r == 0) - system_printf ("local thread storage not inited"); + { +#ifdef _CYG_THREAD_FAILSAFE + system_printf ("local thread storage not inited"); #endif + return NULL; + } + return _r->_winsup; } @@ -211,6 +220,20 @@ MTinterface::fixup_after_fork (void) { pthread_key::fixup_after_fork (); + +#ifndef __SIGNALS_ARE_MULTITHREADED__ + /* As long as the signal handling not multithreaded + switch reents storage back to _impure_ptr for the mainthread + to support fork from threads other than the mainthread */ + struct _reent *reent_old = __getreent (); + + if (reent_old && _impure_ptr != reent_old) + *_impure_ptr = *reent_old; + reents._clib = _impure_ptr; + reents._winsup = &winsup_reent; + winsup_reent._process_logmask = LOG_UPTO (LOG_DEBUG); + reent_key.set (&reents); +#endif threadcount = 1; pthread::init_mainthread (); Index: thread.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/thread.h,v retrieving revision 1.69 diff -u -r1.69 thread.h --- thread.h 15 May 2003 19:42:51 -0000 1.69 +++ thread.h 15 May 2003 19:46:40 -0000 @@ -110,7 +110,6 @@ struct _winsup_t *_winsup; }; -_reent *_reent_clib (); _winsup_t *_reent_winsup (); void SetResourceLock (int, int, const char *) __attribute__ ((regparm (3))); void ReleaseResourceLock (int, int, const char *) Index: include/cygwin/config.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/config.h,v retrieving revision 1.2 diff -u -r1.2 config.h --- include/cygwin/config.h 13 May 2003 09:26:17 -0000 1.2 +++ include/cygwin/config.h 15 May 2003 19:46:40 -0000 @@ -19,6 +19,7 @@ #endif #define _CYGWIN_CONFIG_H +#define __DYNAMIC_REENT__ #define __FILENAME_MAX__ (260 - 1 /* NUL */) #define _READ_WRITE_RETURN_TYPE _ssize_t #define __LARGE64_FILES 1 Index: include/cygwin/version.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v retrieving revision 1.117 diff -u -r1.117 version.h --- include/cygwin/version.h 9 May 2003 22:11:25 -0000 1.117 +++ include/cygwin/version.h 15 May 2003 19:46:41 -0000 @@ -205,12 +205,13 @@ underscore. No problems with backward compatibility since no official release has been made so far. This change removes exported symbols like fopen64, which might confuse configure. + 86: Export __getreent */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 85 +#define CYGWIN_VERSION_API_MINOR 86 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible