From 2a940c1a22765411b70679bf886714930aeaf79f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 14 Mar 2003 18:39:05 +0000 Subject: [PATCH] * 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. --- newlib/ChangeLog | 16 ++++++++++++++++ newlib/libc/include/stdio.h | 13 +++++++++++++ newlib/libc/include/sys/unistd.h | 2 +- newlib/libc/reent/lseekr.c | 4 ++-- newlib/libc/stdio/fgetpos.c | 2 +- newlib/libc/stdio/fseek.c | 8 ++++---- newlib/libc/stdio/fseeko.c | 2 +- newlib/libc/stdio/fsetpos.c | 2 +- newlib/libc/stdio/ftell.c | 4 ++-- newlib/libc/stdio/ftello.c | 4 ++-- newlib/libc/stdio/local.h | 2 +- newlib/libc/stdio/stdio.c | 10 +++++----- 12 files changed, 49 insertions(+), 20 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 001b5d8f6..53f13844e 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,19 @@ +2003-03-10 Corinna Vinschen + + * 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. + 2003-03-09 Corinna Vinschen * libc/reent/lseekr.c (lseek_r): Use _off_t instead of off_t. diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h index 3e1162cab..3531c981e 100644 --- a/newlib/libc/include/stdio.h +++ b/newlib/libc/include/stdio.h @@ -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 char *)); #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 *, ...)); diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h index 49d2a592d..8678a3c9b 100644 --- a/newlib/libc/include/sys/unistd.h +++ b/newlib/libc/include/sys/unistd.h @@ -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 )); diff --git a/newlib/libc/reent/lseekr.c b/newlib/libc/reent/lseekr.c index 45a340a3d..817d52a26 100644 --- a/newlib/libc/reent/lseekr.c +++ b/newlib/libc/reent/lseekr.c @@ -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; } diff --git a/newlib/libc/stdio/fgetpos.c b/newlib/libc/stdio/fgetpos.c index ed6f5cfd3..787f8007a 100644 --- a/newlib/libc/stdio/fgetpos.c +++ b/newlib/libc/stdio/fgetpos.c @@ -51,7 +51,7 @@ No supporting OS subroutines are required. int _DEFUN (fgetpos, (fp, pos), FILE * fp _AND - fpos_t * pos) + _fpos_t * pos) { _flockfile(fp); *pos = ftell (fp); diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 8912dd60c..069457854 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -86,7 +86,7 @@ Supporting OS subroutines required: <>, <>, <>, #include #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); diff --git a/newlib/libc/stdio/fseeko.c b/newlib/libc/stdio/fseeko.c index 0697a5fc7..b3e85596f 100644 --- a/newlib/libc/stdio/fseeko.c +++ b/newlib/libc/stdio/fseeko.c @@ -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 */ diff --git a/newlib/libc/stdio/fsetpos.c b/newlib/libc/stdio/fsetpos.c index 28cd69ead..3748b665c 100644 --- a/newlib/libc/stdio/fsetpos.c +++ b/newlib/libc/stdio/fsetpos.c @@ -44,7 +44,7 @@ Supporting OS subroutines required: <>, <>, <>, int _DEFUN (fsetpos, (iop, pos), FILE * iop _AND - _CONST fpos_t * pos) + _CONST _fpos_t * pos) { int x = fseek (iop, *pos, SEEK_SET); diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index 5cd3987c0..c20ba81a8 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -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); diff --git a/newlib/libc/stdio/ftello.c b/newlib/libc/stdio/ftello.c index 474c78834..f4c28b4d1 100644 --- a/newlib/libc/stdio/ftello.c +++ b/newlib/libc/stdio/ftello.c @@ -17,10 +17,10 @@ #include -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); } diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 8b55503c8..089320b30 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -33,7 +33,7 @@ extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*)); 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 *)); diff --git a/newlib/libc/stdio/stdio.c b/newlib/libc/stdio/stdio.c index b0c759fdb..478e95cdb 100644 --- a/newlib/libc/stdio/stdio.c +++ b/newlib/libc/stdio/stdio.c @@ -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