This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] SPU use a 16 byte fpos_t
- From: Jeff Johnston <jjohnstn at redhat dot com>
- To: Patrick Mansfield <patmans at us dot ibm dot com>
- Cc: newlib at sourceware dot org
- Date: Thu, 06 Sep 2007 17:20:59 -0400
- Subject: Re: [PATCH] SPU use a 16 byte fpos_t
- References: <20070905162606.GA6098@us.ibm.com>
Patrick Mansfield wrote:
fpos_t is 12 bytes for 32 bit ppc glibc, and 16 bytes for 64 bit.
Currently SPU newlib uses 4 bytes for fpos_t. This is always a problem
with 64 bit ppc, since the fgetpos() assist call writes 8 bytes back for
the offset, and is a potential problem with 32 bit ppc.
So for SPU always use 16 bytes for fpos_t and also make currently unused
(in SPU) _fpos64_t 16 bytes.
Patrick,
This needs to be cleaned up. Not your fault, but I don't want cpu
checks in sys/reent.h and I don't think that _fpos_t should be magically
defined in sys/reent.h. The following proposal makes this change and
others easy for you to do. It is pretty straightforward.
So, this is what I propose:
1. copy machine/_types.h to machine/_default_types.h
2. make machine/_types.h simply include machine/_default_types.h
3. have sys/_types.h include machine/_types.h
4. have sys/_types.h look for flags before defining _ types. For
example, #ifndef _OFF_T_DEFINED). You need to add
_fpos_t and _fpos64_t default defs which weren't there previously
5. create an machine/spu/machine/_types.h which defines all of these
to your liking...also set the flags on so sys/_types.h won't try
and define them
6. remove _fpos_t and _fpos64_t defs from sys/reent.h
This will be clean and allow other platforms to do tweaking as
desired without cluttering up the common headers.
Comments?
-- Jeff J.
newlib ChangeLog:
2007-09-05 Patrick Mansfield <patmans@us.ibm.com>
* libc/include/sys/reent.h: For SPU use a _fpos_t and _fpos64_t with
sizes of 16 bytes.
Index: src/newlib/libc/include/sys/reent.h
===================================================================
--- src.orig/newlib/libc/include/sys/reent.h
+++ src/newlib/libc/include/sys/reent.h
@@ -112,6 +112,19 @@ struct __sbuf {
* so we use _fpos_t instead.
*/
+#ifdef __SPU__
+/*
+ * Requires that the size be large enough to store a 64 bit ppc glibc
+ * fpos_t of 16 bytes.
+ */
+typedef struct {
+ char __pos[16];
+} _fpos_t;
+#ifdef __LARGE64_FILES
+typedef _fpos_t _fpos64_t;
+#endif
+
+#else
typedef long _fpos_t; /* XXX must match off_t in <sys/types.h> */
/* (and must be `long' for now) */
@@ -119,6 +132,8 @@ typedef long _fpos_t; /* XXX must match
typedef _off64_t _fpos64_t;
#endif
+#endif
+
/*
* Stdio state variables.
*