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: [PATCH] Avoid more problems with type clashes


Ok, I see now.

I would prefer a cleaner solution that doesn't do this via the _COMPILING_NEWLIB
flag in stdio.h.  I also would like it to be a generic solution so other platforms can
use it, if desired/needed.

What I am thinking of is to add the wrapper functions that take the external type and
call the correct function underneath.  For example, we change the current fgetpos
routine to be called _fgetpos() which takes _fpos_t and we also add to fgetpos.c,
an fgetpos() wrapper routine that takes fpos_t.  The wrapper function calls _fgetpos()
or fgetpos64 based on a compiler flag.  Prototypes for _fgetpos() etc..
could be hidden in stdio/local.h.  The wrapper function would be #ifdef'd
out if the flag isn't set and instead, we redefine _fgetpos to be fgetpos.

Currently you are using __CYGWIN_USE_BIG_TYPES__, but if this were renamed to
be something more generic (e.g. __LARGE64_DEFAULTED__), then any platform
could use it if desired.

I can implement the patch if you would like.

-- Jeff J.


Corinna Vinschen wrote:
On Wed, Mar 12, 2003 at 07:08:49PM -0500, J. Johnston wrote:

I hadn't forgotten.  I do not understand why you are
avoiding the fpos_t type.  It is supposed to be defined by stdio.h.

Could you provide a little more detail the actual problem you are seeing
that this patch fixes?


fpos_t != _fpos_t.

_fpos_t as well as _fpos64_t are the definitions internally to newlib. So it should be used by internal functions to avoid type clashes with
the type fpos_t which could change.


See stdio.h:

  #ifdef __CYGWIN__
  #ifdef __CYGWIN_USE_BIG_TYPES__
  typedef _fpos64_t fpos_t;
  #else
  typedef _fpos_t fpos_t;
  #endif
  #else
  typedef _fpos_t fpos_t;
  #ifdef __LARGE64_FILES
  typedef _fpos64_t fpos64_t;
  #endif
  #endif /* !__CYGWIN__ */

Cygwin up to the recent 1.3.21 doesn't define __CYGWIN_USE_BIG_TYPES__
so fpos_t == _fpos_t == 32bit.  The next version of Cygwin will define
__CYGWIN_USE_BIG_TYPES__ and then the types fpos_t and off_t are 64bit
types.  This shall work without any user intervention, no extra functions
for 64bit file access needed.

A newly compiled program will further use "fgetpos" but it will actually
call "fgetpos64" while applications built with Cygwin up to 1.3.21 will
still call the old entry points.  But since newlib itself uses fpos_t
internally so far, the 32bit entry points are either wrong compiled or
the compiler complains at compile time as soon as __CYGWIN_USE_BIG_TYPES__
is defined.


Corinna





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