[PATCH] Avoid more problems with type clashes
J. Johnston
jjohnstn@redhat.com
Thu Mar 13 00:08:00 GMT 2003
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?
-- Jeff J.
Corinna Vinschen wrote:
> On Mon, Mar 10, 2003 at 12:06:26PM +0100, Corinna Vinschen wrote:
>
>>Hi,
>>
>>the following patch avoids more problems with fpos_t and off_t problems,
>>this time especially inside of newlib. All these problems are just
>>visible due to the switch of Cygwin to 64bit file offsets. Basically
>>all fpos_t are changed to _fpos_t and off_t to _off_t.
>>
>>Ok to commit?
>
>
> Ping?
>
> Corinna
>
>
>>2003-03-10 Corinna Vinschen <corinna@vinschen.de>
>>
>> * libc/include/stdio.h: Declare fgetpos, fsetpos, fseeko and ftello
>> with internal (_fpos_t and _off_t) datatypes when compiling newlib.
>> * libc/include/sys/unistd.h: Declare _lseek using _off_t.
>> * libc/reent/lseekr.c (_lseek_r): Use _off_t instead of off_t.
>> * libc/stdio/fseeko.c (fseeko): Ditto.
>> * libc/stdio/ftello.c (ftello): Ditto.
>> * libc/stdio/stdio.c (__swrite): Ditto.
>> (__sseek): Ditto.
>> * libc/stdio/fgetpos.c (fgetpos): Use _fpos_t instead of fpos_t.
>> * libc/stdio/fseek.c (fseek): Ditto.
>> * libc/stdio/fsetpos.c (fsetpos): Ditto.
>> * libc/stdio/ftell.c (ftell): Ditto.
>> * libc/stdio/local.h: Declare __sseek using _off_t.
>>
>>Index: libc/include/stdio.h
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
>>retrieving revision 1.20
>>diff -p -u -r1.20 stdio.h
>>--- libc/include/stdio.h 7 Mar 2003 20:41:49 -0000 1.20
>>+++ libc/include/stdio.h 10 Mar 2003 10:44:33 -0000
>>@@ -195,9 +195,17 @@ int _EXFUN(puts, (const char *));
>> int _EXFUN(ungetc, (int, FILE *));
>> size_t _EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *));
>> size_t _EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *));
>>+#ifdef _COMPILING_NEWLIB
>>+int _EXFUN(fgetpos, (FILE *, _fpos_t *));
>>+#else
>> int _EXFUN(fgetpos, (FILE *, fpos_t *));
>>+#endif
>> int _EXFUN(fseek, (FILE *, long, int));
>>+#ifdef _COMPILING_NEWLIB
>>+int _EXFUN(fsetpos, (FILE *, const _fpos_t *));
>>+#else
>> int _EXFUN(fsetpos, (FILE *, const fpos_t *));
>>+#endif
>> long _EXFUN(ftell, ( FILE *));
>> void _EXFUN(rewind, (FILE *));
>> void _EXFUN(clearerr, (FILE *));
>>@@ -212,8 +220,13 @@ int _EXFUN(rename, (const char *, const
>> #endif
>> #ifndef __STRICT_ANSI__
>> int _EXFUN(asprintf, (char **, const char *, ...));
>>+#ifdef _COMPILING_NEWLIB
>>+int _EXFUN(fseeko, (FILE *, _off_t, int));
>>+_off_t _EXFUN(ftello, ( FILE *));
>>+#else
>> int _EXFUN(fseeko, (FILE *, off_t, int));
>> off_t _EXFUN(ftello, ( FILE *));
>>+#endif
>> int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST));
>> int _EXFUN(iprintf, (const char *, ...));
>> int _EXFUN(fiprintf, (FILE *, const char *, ...));
>>Index: libc/include/sys/unistd.h
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/include/sys/unistd.h,v
>>retrieving revision 1.41
>>diff -p -u -r1.41 unistd.h
>>--- libc/include/sys/unistd.h 9 Mar 2003 21:08:51 -0000 1.41
>>+++ libc/include/sys/unistd.h 10 Mar 2003 10:44:33 -0000
>>@@ -165,7 +165,7 @@ int _EXFUN(_close, (int __fildes ));
>> pid_t _EXFUN(_fork, (void ));
>> pid_t _EXFUN(_getpid, (void ));
>> int _EXFUN(_link, (const char *__path1, const char *__path2 ));
>>-off_t _EXFUN(_lseek, (int __fildes, off_t __offset, int __whence ));
>>+_off_t _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence ));
>> _READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte ));
>> void * _EXFUN(_sbrk, (ptrdiff_t __incr));
>> int _EXFUN(_unlink, (const char *__path ));
>>Index: libc/reent/lseekr.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/reent/lseekr.c,v
>>retrieving revision 1.2
>>diff -p -u -r1.2 lseekr.c
>>--- libc/reent/lseekr.c 9 Mar 2003 22:10:14 -0000 1.2
>>+++ libc/reent/lseekr.c 10 Mar 2003 10:44:33 -0000
>>@@ -52,10 +52,10 @@ _lseek_r (ptr, fd, pos, whence)
>> _off_t pos;
>> int whence;
>> {
>>- off_t ret;
>>+ _off_t ret;
>>
>> errno = 0;
>>- if ((ret = _lseek (fd, pos, whence)) == (off_t) -1 && errno != 0)
>>+ if ((ret = _lseek (fd, pos, whence)) == (_off_t) -1 && errno != 0)
>> ptr->_errno = errno;
>> return ret;
>> }
>>Index: libc/stdio/fgetpos.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/fgetpos.c,v
>>retrieving revision 1.2
>>diff -p -u -r1.2 fgetpos.c
>>--- libc/stdio/fgetpos.c 8 May 2002 00:12:48 -0000 1.2
>>+++ libc/stdio/fgetpos.c 10 Mar 2003 10:44:33 -0000
>>@@ -51,7 +51,7 @@ No supporting OS subroutines are require
>> int
>> _DEFUN (fgetpos, (fp, pos),
>> FILE * fp _AND
>>- fpos_t * pos)
>>+ _fpos_t * pos)
>> {
>> _flockfile(fp);
>> *pos = ftell (fp);
>>Index: libc/stdio/fseek.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/fseek.c,v
>>retrieving revision 1.5
>>diff -p -u -r1.5 fseek.c
>>--- libc/stdio/fseek.c 4 Jul 2002 19:33:54 -0000 1.5
>>+++ libc/stdio/fseek.c 10 Mar 2003 10:44:33 -0000
>>@@ -86,7 +86,7 @@ Supporting OS subroutines required: <<cl
>> #include <sys/stat.h>
>> #include "local.h"
>>
>>-#define POS_ERR (-(fpos_t)1)
>>+#define POS_ERR (-(_fpos_t)1)
>>
>> /*
>> * Seek the given file to the given offset.
>>@@ -100,8 +100,8 @@ fseek (fp, offset, whence)
>> int whence;
>> {
>> struct _reent *ptr;
>>- fpos_t _EXFUN ((*seekfn), (void *, fpos_t, int));
>>- fpos_t target, curoff;
>>+ _fpos_t _EXFUN ((*seekfn), (void *, _fpos_t, int));
>>+ _fpos_t target, curoff;
>> size_t n;
>> struct stat st;
>> int havepos;
>>@@ -149,7 +149,7 @@ fseek (fp, offset, whence)
>> curoff = fp->_offset;
>> else
>> {
>>- curoff = (*seekfn) (fp->_cookie, (fpos_t) 0, SEEK_CUR);
>>+ curoff = (*seekfn) (fp->_cookie, (_fpos_t) 0, SEEK_CUR);
>> if (curoff == -1L)
>> {
>> _funlockfile(fp);
>>Index: libc/stdio/fseeko.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/fseeko.c,v
>>retrieving revision 1.1
>>diff -p -u -r1.1 fseeko.c
>>--- libc/stdio/fseeko.c 4 Jul 2002 19:33:54 -0000 1.1
>>+++ libc/stdio/fseeko.c 10 Mar 2003 10:44:33 -0000
>>@@ -20,7 +20,7 @@
>> int
>> fseeko (fp, offset, whence)
>> register FILE *fp;
>>- off_t offset;
>>+ _off_t offset;
>> int whence;
>> {
>> /* for now we simply cast since off_t should be long */
>>Index: libc/stdio/fsetpos.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/fsetpos.c,v
>>retrieving revision 1.1.1.1
>>diff -p -u -r1.1.1.1 fsetpos.c
>>--- libc/stdio/fsetpos.c 17 Feb 2000 19:39:47 -0000 1.1.1.1
>>+++ libc/stdio/fsetpos.c 10 Mar 2003 10:44:33 -0000
>>@@ -44,7 +44,7 @@ Supporting OS subroutines required: <<cl
>> int
>> _DEFUN (fsetpos, (iop, pos),
>> FILE * iop _AND
>>- _CONST fpos_t * pos)
>>+ _CONST _fpos_t * pos)
>> {
>> int x = fseek (iop, *pos, SEEK_SET);
>>
>>Index: libc/stdio/ftell.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/ftell.c,v
>>retrieving revision 1.4
>>diff -p -u -r1.4 ftell.c
>>--- libc/stdio/ftell.c 16 Jul 2002 15:30:32 -0000 1.4
>>+++ libc/stdio/ftell.c 10 Mar 2003 10:44:33 -0000
>>@@ -87,7 +87,7 @@ long
>> _DEFUN (ftell, (fp),
>> register FILE * fp)
>> {
>>- fpos_t pos;
>>+ _fpos_t pos;
>>
>> _flockfile(fp);
>>
>>@@ -109,7 +109,7 @@ _DEFUN (ftell, (fp),
>> pos = fp->_offset;
>> else
>> {
>>- pos = (*fp->_seek) (fp->_cookie, (fpos_t) 0, SEEK_CUR);
>>+ pos = (*fp->_seek) (fp->_cookie, (_fpos_t) 0, SEEK_CUR);
>> if (pos == -1L)
>> {
>> _funlockfile(fp);
>>Index: libc/stdio/ftello.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/ftello.c,v
>>retrieving revision 1.1
>>diff -p -u -r1.1 ftello.c
>>--- libc/stdio/ftello.c 4 Jul 2002 19:33:54 -0000 1.1
>>+++ libc/stdio/ftello.c 10 Mar 2003 10:44:33 -0000
>>@@ -17,10 +17,10 @@
>>
>> #include <stdio.h>
>>
>>-off_t
>>+_off_t
>> _DEFUN (ftello, (fp),
>> register FILE * fp)
>> {
>> /* for now we simply cast since off_t should be long */
>>- return (off_t)ftell (fp);
>>+ return (_off_t)ftell (fp);
>> }
>>Index: libc/stdio/local.h
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/local.h,v
>>retrieving revision 1.6
>>diff -p -u -r1.6 local.h
>>--- libc/stdio/local.h 1 Oct 2001 18:05:11 -0000 1.6
>>+++ libc/stdio/local.h 10 Mar 2003 10:44:33 -0000
>>@@ -33,7 +33,7 @@ extern int _EXFUN(__sflags,(struct _r
>> extern int _EXFUN(__srefill,(FILE *));
>> extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(void *, char *, int));
>> extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(void *, char const *, int));
>>-extern fpos_t _EXFUN(__sseek,(void *, fpos_t, int));
>>+extern _fpos_t _EXFUN(__sseek,(void *, _fpos_t, int));
>> extern int _EXFUN(__sclose,(void *));
>> extern int _EXFUN(__stextmode,(int));
>> extern void _EXFUN(__sinit,(struct _reent *));
>>Index: libc/stdio/stdio.c
>>===================================================================
>>RCS file: /cvs/src/src/newlib/libc/stdio/stdio.c,v
>>retrieving revision 1.4
>>diff -p -u -r1.4 stdio.c
>>--- libc/stdio/stdio.c 6 Mar 2001 01:04:43 -0000 1.4
>>+++ libc/stdio/stdio.c 10 Mar 2003 10:44:33 -0000
>>@@ -72,7 +72,7 @@ __swrite (cookie, buf, n)
>> #endif
>>
>> if (fp->_flags & __SAPP)
>>- (void) _lseek_r (fp->_data, fp->_file, (off_t) 0, SEEK_END);
>>+ (void) _lseek_r (fp->_data, fp->_file, (_off_t) 0, SEEK_END);
>> fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */
>>
>> #ifdef __SCLE
>>@@ -90,16 +90,16 @@ __swrite (cookie, buf, n)
>> return w;
>> }
>>
>>-fpos_t
>>+_fpos_t
>> __sseek (cookie, offset, whence)
>> _PTR cookie;
>>- fpos_t offset;
>>+ _fpos_t offset;
>> int whence;
>> {
>> register FILE *fp = (FILE *) cookie;
>>- register off_t ret;
>>+ register _off_t ret;
>>
>>- ret = _lseek_r (fp->_data, fp->_file, (off_t) offset, whence);
>>+ ret = _lseek_r (fp->_data, fp->_file, (_off_t) offset, whence);
>> if (ret == -1L)
>> fp->_flags &= ~__SOFF;
>> else
>>
>>--
>>Corinna Vinschen
>>Cygwin Developer
>>Red Hat, Inc.
>>mailto:vinschen@redhat.com
>
>
More information about the Newlib
mailing list