[patch] inline __getreent in newlib

Brian Dessent brian@dessent.net
Fri Sep 7 00:49:00 GMT 2007

CC'd to newlib: I've checked in the attached change to
libc/reent/getreent.c as obvious, please let me know if it breaks

Christopher Faylor wrote:

> So, I guess I'll come down on the side of speed over clarity.  I'm sure
> that Jeff won't mind your checking in the undef in newlib.  So, please
> check in everything but, again, document heavily what you're doing with
> the reent macro.

Done.  I added the following comment to config.h to hopefully clarify
the situation:

/* The following provides an inline version of __getreent() for newlib,
   which will be used throughout the library whereever there is a _r
   version of a function that takes _REENT.  This saves the overhead
   of a function call for what amounts to a simple computation.
   The definition below is essentially equivalent to the one in cygtls.h
   (&_my_tls.local_clib) however it uses a fixed precomputed
   offset rather than dereferencing a field of a structure.
   Including tlsoffets.h here in order to get this constant offset
   tls_local_clib is a bit of a hack, but the alternative would require
   dragging the entire definition of struct _cygtls (a large and complex
   Cygwin internal data structure) into newlib.  The machinery to
   compute these offsets already exists for the sake of gendef so
   we might as well just use it here.  */

-------------- next part --------------
2007-09-06  Brian Dessent  <brian@dessent.net>

	* libc/reent/getreent.c: Allow for case where __getreent is
	defined as a macro.

Index: libc/reent/getreent.c
RCS file: /cvs/src/src/newlib/libc/reent/getreent.c,v
retrieving revision 1.1
diff -u -p -r1.1 getreent.c
--- libc/reent/getreent.c	17 May 2002 23:39:37 -0000	1.1
+++ libc/reent/getreent.c	6 Sep 2007 23:13:10 -0000
@@ -3,6 +3,10 @@
 #include <_ansi.h>
 #include <reent.h>
+#ifdef __getreent
+#undef __getreent
 struct _reent *

More information about the Cygwin-patches mailing list