This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Adjust _REENT_SMALL to be binary compatible with normal layout.


Hi,

Attached is a patch to adjust _REENT_SMALL to be binary compatible
with normal layout.

Specifically, this patch makes the first few members identical between
the _REENT_SMALL and !_REENT_SMALL versions of _reent.  This way,
source code compiled with the _REENT_SMALL headers can be linked
against the !_REENT_SMALL version of libc, and vice versa.  Note that
members like _stdin, _stdout, and _stderr "leak" into the users'
object code because stdin, for example, is expanded to:

  _impure_ptr->_stdin

Tested on arm-none-eabi.  OK to apply?

Kazu Hirata

2010-06-02  Paul Brook  <paul@codesourcery.com>

	* libc/include/sys/reent.h (_reent): Adjust _REENT_SMALL to be
	binary compatible with normal layout.
	(_REENT_INIT): Adjust to match struct layout.

Index: newlib/libc/include/sys/reent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/reent.h,v
retrieving revision 1.48
diff -u -d -p -r1.48 reent.h
--- newlib/libc/include/sys/reent.h	17 Dec 2009 19:43:43 -0000	1.48
+++ newlib/libc/include/sys/reent.h	2 Jun 2010 02:03:53 -0000
@@ -357,14 +357,15 @@ struct _misc_reent
  * ports with 16-bit int's but 32-bit pointers, align nicely.  */
 struct _reent
 {
+  /* As an exception to the above put _errno first for binary
+     compatibility with non _REENT_SMALL targets.  */
+  int _errno;			/* local copy of errno */
 
   /* FILE is a big struct and may change over time.  To try to achieve binary
      compatibility with future versions, put stdin,stdout,stderr here.
      These are pointers into member __sf defined below.  */
   __FILE *_stdin, *_stdout, *_stderr;	/* XXX */
 
-  int _errno;			/* local copy of errno */
-
   int  _inc;			/* used by tmpnam */
 
   char *_emergency;
@@ -405,12 +406,12 @@ extern const struct __sFILE_fake __sf_fa
 extern const struct __sFILE_fake __sf_fake_stdout;
 extern const struct __sFILE_fake __sf_fake_stderr;
 
-#define _REENT_INIT(var) \
-  { (__FILE *)&__sf_fake_stdin, \
+# define _REENT_INIT(var) \
+  { 0, \
+    (__FILE *)&__sf_fake_stdin, \
     (__FILE *)&__sf_fake_stdout, \
     (__FILE *)&__sf_fake_stderr, \
     0, \
-    0, \
     _NULL, \
     0, \
     0, \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]