This is the mail archive of the newlib@sources.redhat.com 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]

Re: Compiling newlib natively [PATCH]


Shaun Jackman wrote:
Hmm, this was bound to happen with newlib using a combination of our headers and
external headers.

I get a problem because my Red Hat linux/time.h brings in linux/types.h.  This
causes the following:

[clip]


to define a number of types.  When newlib's sys/types.h gets included, there is
a conflict among a number of the types.


It seems my linux/time.h has a Debian specific patch. If __KERNEL__ is
not defined it includes <time.h> (i.e. /usr/include/time.h) instead.
If __KERNEL__ is defined, my linux/time.h does bring in linux/types.h
as your does.

newlib's sys/types.h brings in linux/types.h explicitly. How about
including newlib's sys/types.h (which seems to work) before including
linux/time.h, so that linux/types.h is already included in a "safe"
manner.


This worked for me on my base system. I will try it out on an FC3 system tomorrow and check it in if all goes well and it works for you. I have attached the new patch for /libc/sys/linux/sys/stat.h



On all of my Red Hat Linux boxes (both old and new), the
/usr/include/linux/stat.h does not include linux/time.h so I don't run into that
particular problem with mktime.


My linux/stat.h defines struct kstat, which has a struct timespec
member, so it includes <linux/time.h> immediately before defining
struct timespec.


I can only assume your linux/time.h isn't
dragging in linux/types.h or doesn't have the clause above being invoked.  Can
you attach a copy of your linux/time.h and linux/stat.h so I can try and come up
with some compromise (a.k.a kludge) that works for both.  My first instinct is
to try defining/undefining __KERNEL_STRICT_NAMES around the include but it would
be good to see what your include files are.


It looks like defining/undefining __KERNEL_STRICT_NAMES would work for
me as well, though I haven't tested it. I've attached linux/time.h and
linux/stat.h, as well as linux/types.h.

I've noticed that my Linux kernel headers are provided by Debian and
are different than the kernel I'm running (2.6.8.1).
linux-kernel-headers 2.5.999-test7-bk-16


The experiment of using __KERNEL_STRICT_NAMES failed. Anyway, hopefully the solution above works for you as well.


-- Jeff J.
Index: stat.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/linux/sys/stat.h,v
retrieving revision 1.3
diff -u -p -r1.3 stat.h
--- stat.h	26 Jul 2002 21:44:34 -0000	1.3
+++ stat.h	2 Dec 2004 00:08:42 -0000
@@ -7,14 +7,15 @@
 #define _SYS_STAT_H
 
 #include <asm/stat.h>
+#include <_ansi.h>
+#include <sys/types.h>
+#include <linux/time.h>
 #define __KERNEL__
 #include <linux/stat.h>
 #undef __KERNEL__
 
 /* --- redundant stuff below --- */
 
-#include <_ansi.h>
-#include <sys/types.h>
 
 int     _EXFUN(fstat,( int __fd, struct stat *__sbuf ));
 int     _EXFUN(mkdir,( const char *_path, mode_t __mode ));

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