Re: [PATCH v2 00/11] Decouple global file object list from _GLOBAL_REENT

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On May 12 21:14, Corinna Vinschen wrote:
> Hi Matt,
> 
> On May 12 14:11, Matthew Joyce wrote:
> > From: Matt Joyce <[email protected]>
> > 
> > Hello Corinna,
> > 
> > Per your comments, please see version 2.
> > 
> > 1) stdio_atexit is now called stdio_exit_handler
> > 2) declarations for stdio_exit_handler() and _fwalk_sglue() are moved
> >    to sys/reent.h
> 
> Please see my comments in terms of patch 11, which needs an additional
> tweak.  With this change, the patchset is GTG.

Btw., it looks like Cygwin can switch to _REENT_GLOBAL_STDIO_STREAMS
with only minor changes.  I'll test this a bit more before pushing,
but it's quite neat so far...

diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
index c8352adf9f25..0fd5509d2306 100644
--- a/winsup/cygwin/cygtls.cc
+++ b/winsup/cygwin/cygtls.cc
@@ -55,16 +55,8 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *))
       _REENT_INIT_PTR (&local_clib);
       stackptr = stack;
       altstack.ss_flags = SS_DISABLE;
-      if (_GLOBAL_REENT)
-	{
-	  local_clib._stdin = _GLOBAL_REENT->_stdin;
-	  local_clib._stdout = _GLOBAL_REENT->_stdout;
-	  local_clib._stderr = _GLOBAL_REENT->_stderr;
-	  if (_GLOBAL_REENT->__cleanup)
-	    local_clib.__cleanup = _cygtls::cleanup_early;
-	  local_clib.__sglue._niobs = 3;
-	  local_clib.__sglue._iobs = &_GLOBAL_REENT->__sf[0];
-	}
+      if (_GLOBAL_REENT && _GLOBAL_REENT->__cleanup)
+	local_clib.__cleanup = _cygtls::cleanup_early;
     }
 
   thread_id = GetCurrentThreadId ();
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 5f460d8a5c78..6b816763e002 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -757,9 +757,7 @@ dll_crt0_0 ()
 
   lock_process::init ();
   _impure_ptr = _GLOBAL_REENT;
-  _impure_ptr->_stdin = &_impure_ptr->__sf[0];
-  _impure_ptr->_stdout = &_impure_ptr->__sf[1];
-  _impure_ptr->_stderr = &_impure_ptr->__sf[2];
+  _REENT_INIT_PTR_ZEROED (_GLOBAL_REENT);
   user_data->impure_ptr = _impure_ptr;
   user_data->impure_ptr_ptr = &_impure_ptr;
 
diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h
index 71a216fbd16d..56fc326bd43e 100644
--- a/winsup/cygwin/include/cygwin/config.h
+++ b/winsup/cygwin/include/cygwin/config.h
@@ -66,6 +66,7 @@ extern inline struct _reent *__getreent (void)
 /* The following block of macros is required to build newlib correctly for
    Cygwin.  Changing them in applications has no or not the desired effect.
    Just leave them alone. */
+#define _REENT_GLOBAL_STDIO_STREAMS 1
 #define _READ_WRITE_RETURN_TYPE _ssize_t
 #define _READ_WRITE_BUFSIZE_TYPE size_t
 #define __LARGE64_FILES 1
diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h
[...skipped, just autogenerated data...]
diff --git a/winsup/cygwin/tlsoffsets64.h b/winsup/cygwin/tlsoffsets64.h
[...skipped, just autogenerated data...]


Corinna
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.