* 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.
This commit is contained in:
Corinna Vinschen
2003-03-14 18:39:05 +00:00
parent 2359084b5b
commit 2a940c1a22
12 changed files with 49 additions and 20 deletions

View File

@ -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);

View File

@ -86,7 +86,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#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);

View File

@ -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 */

View File

@ -44,7 +44,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
int
_DEFUN (fsetpos, (iop, pos),
FILE * iop _AND
_CONST fpos_t * pos)
_CONST _fpos_t * pos)
{
int x = fseek (iop, *pos, SEEK_SET);

View File

@ -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);

View File

@ -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);
}

View File

@ -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 *));

View File

@ -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