2003-08-22 Jeff Johnston <jjohnstn@redhat.com>

* libc/include/sys/reent.h: Add _GLOBAL_REENT macro.
	* libc/stdio: Globally remove/replace all references to fp->_data.
	Replace with _REENT or _GLOBAL_REENT where appropriate.
	* libc/stdio/asprintf.c: Ditto.
	* libc/stdio/fclose.c: Ditto.
	* libc/stdio/fvwrite.c: Ditto.
	* libc/stdio/makebuf.c: Ditto.
	* libc/stdio/refill.c: Ditto.
	* libc/stdio/local.h: Ditto.
	* libc/stdio/setvbuf.c: Ditto.
	* libc/stdio/sscanf.c: Ditto.
	* libc/stdio/stdio.c: Ditto.
	* libc/stdio/ungetc.c: Ditto.
	* libc/stdio/vfscanf.c: Ditto.
	* libc/stdio/vsscanf.c: Ditto.
	* libc/stdio/fopen.c: Ditto.  Also use _fseek_r in _fopen_r.
	* libc/stdio/vasprintf.c: Ditto.  Also call _vfprintf_r directly.
	* libc/stdio/vsnprintf.c: Ditto.
	* libc/stdio/vsprintf.c: Ditto.
	* libc/stdio/fcloseall.c(fcloseall): Use _GLOBAL_REENT macro
	instead of _REENT to walk file list.
	* libc/stdio/fflush.c: Ditto.
	* libc/stdio/fgetpos.c: Add reentrant version and have regular
	version call reentrant version with _REENT argument.
	* libc/stdio/fsetpos.c: Ditto.
	* libc/stdio/fseek.c: Ditto.
	* libc/stdio/fseeko.c: Ditto.
	* libc/stdio/ftell.c: Ditto.
	* libc/stdio/ftello.c: Ditto.
	* libc/stdio/freopen.c: Ditto.
	* libc/stdio/findfp.c: Use _GLOBAL_REENT pointer when adding
	new files to chain.  Also use _GLOBAL_REENT pointer for
	cleaning up.
	* libc/stdio/fiprintf.c: Reformatted to minimize duplicate code.
	* libc/stdio/siprintf.c: Ditto.
	* libc/stdio/iprintf.c: Ditto.
	* libc/stdio/fprintf.c: Ditto.
	* libc/stdio/printf.c: Ditto.
	* libc/stdio/snprintf.c: Call _vfprintf_r directly.
	* libc/stdio/sprintf.c: Ditto.
	* libc/stdio/vprintf.c: Ditto.  Also add _REENT_ONLY check.
	* libc/stdio/rewind.c: Call _fseek_r directly.
	* libc/stdio/tmpfile.c: Call _fopen_r and _remove_r directly.
	* libc/stdio/vfprintf.c (_VFPRINTF_R): Change _r routines to use
	data pointer.
	(get_arg): Add extra struct _reent pointer argument.
	* libc/stdio64/fgetpos64.c: Add _r versions, remove any reference
	to fp->_data.
	* libc/stdio64/fopen64.c: Ditto.
	* libc/stdio64/freopen64.c: Ditto.
	* libc/stdio64/fsetpos64.c: Ditto.
	* libc/stdio64/ftello64.c: Ditto.
	* libc/stdio64/local64.h: Ditto.
	* libc/stdio64/stdio64.c: Ditto.
	* libc/stdio64/fseeko64.c: Ditto plus use _fstat_r instead of
	_fstat64_r for the meantime.
This commit is contained in:
Jeff Johnston 2003-08-22 18:52:25 +00:00
parent c5a12ca3b9
commit 9fc9e1c916
47 changed files with 522 additions and 225 deletions

View File

@ -1,3 +1,62 @@
2003-08-22 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/reent.h: Add _GLOBAL_REENT macro.
* libc/stdio: Globally remove/replace all references to fp->_data.
Replace with _REENT or _GLOBAL_REENT where appropriate.
* libc/stdio/asprintf.c: Ditto.
* libc/stdio/fclose.c: Ditto.
* libc/stdio/fvwrite.c: Ditto.
* libc/stdio/makebuf.c: Ditto.
* libc/stdio/refill.c: Ditto.
* libc/stdio/local.h: Ditto.
* libc/stdio/setvbuf.c: Ditto.
* libc/stdio/sscanf.c: Ditto.
* libc/stdio/stdio.c: Ditto.
* libc/stdio/ungetc.c: Ditto.
* libc/stdio/vfscanf.c: Ditto.
* libc/stdio/vsscanf.c: Ditto.
* libc/stdio/fopen.c: Ditto. Also use _fseek_r in _fopen_r.
* libc/stdio/vasprintf.c: Ditto. Also call _vfprintf_r directly.
* libc/stdio/vsnprintf.c: Ditto.
* libc/stdio/vsprintf.c: Ditto.
* libc/stdio/fcloseall.c(fcloseall): Use _GLOBAL_REENT macro
instead of _REENT to walk file list.
* libc/stdio/fflush.c: Ditto.
* libc/stdio/fgetpos.c: Add reentrant version and have regular
version call reentrant version with _REENT argument.
* libc/stdio/fsetpos.c: Ditto.
* libc/stdio/fseek.c: Ditto.
* libc/stdio/fseeko.c: Ditto.
* libc/stdio/ftell.c: Ditto.
* libc/stdio/ftello.c: Ditto.
* libc/stdio/freopen.c: Ditto.
* libc/stdio/findfp.c: Use _GLOBAL_REENT pointer when adding
new files to chain. Also use _GLOBAL_REENT pointer for
cleaning up.
* libc/stdio/fiprintf.c: Reformatted to minimize duplicate code.
* libc/stdio/siprintf.c: Ditto.
* libc/stdio/iprintf.c: Ditto.
* libc/stdio/fprintf.c: Ditto.
* libc/stdio/printf.c: Ditto.
* libc/stdio/snprintf.c: Call _vfprintf_r directly.
* libc/stdio/sprintf.c: Ditto.
* libc/stdio/vprintf.c: Ditto. Also add _REENT_ONLY check.
* libc/stdio/rewind.c: Call _fseek_r directly.
* libc/stdio/tmpfile.c: Call _fopen_r and _remove_r directly.
* libc/stdio/vfprintf.c (_VFPRINTF_R): Change _r routines to use
data pointer.
(get_arg): Add extra struct _reent pointer argument.
* libc/stdio64/fgetpos64.c: Add _r versions, remove any reference
to fp->_data.
* libc/stdio64/fopen64.c: Ditto.
* libc/stdio64/freopen64.c: Ditto.
* libc/stdio64/fsetpos64.c: Ditto.
* libc/stdio64/ftello64.c: Ditto.
* libc/stdio64/local64.h: Ditto.
* libc/stdio64/stdio64.c: Ditto.
* libc/stdio64/fseeko64.c: Ditto plus use _fstat_r instead of
_fstat64_r for the meantime.
2003-08-19 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/mallocr.c (mALLOc, rEALLOc, mEMEALIGn): Enhance

View File

@ -744,6 +744,8 @@ void _reclaim_reent _PARAMS ((struct _reent *));
#endif /* !_REENT_ONLY */
#define _GLOBAL_REENT _impure_ptr
#ifdef __cplusplus
}
#endif

View File

@ -46,7 +46,6 @@ _asprintf_r (ptr, strp, fmt, va_alist)
f._flags = __SWR | __SSTR | __SMBF;
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._data = ptr;
f._file = -1; /* No file. */
#ifdef _HAVE_STDC
va_start (ap, fmt);
@ -80,7 +79,6 @@ asprintf (strp, fmt, va_alist)
f._flags = __SWR | __SSTR | __SMBF;
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._data = _REENT;
f._file = -1; /* No file. */
#ifdef _HAVE_STDC
va_start (ap, fmt);

View File

@ -77,7 +77,7 @@ _DEFUN (fclose, (fp),
if (fp->_close != NULL && (*fp->_close) (fp->_cookie) < 0)
r = EOF;
if (fp->_flags & __SMBF)
_free_r (fp->_data, (char *) fp->_bf._base);
_free_r (_REENT, (char *) fp->_bf._base);
if (HASUB (fp))
FREEUB (fp);
if (HASLB (fp))

View File

@ -82,7 +82,7 @@ _fcloseall_r (ptr)
int
fcloseall (void)
{
return _fcloseall_r (_REENT);
return _fcloseall_r (_GLOBAL_REENT);
}
#endif

View File

@ -63,11 +63,8 @@ _DEFUN (fflush, (fp),
register unsigned char *p;
register int n, t;
if (fp == NULL)
return _fwalk (_REENT, fflush);
return _fwalk (_GLOBAL_REENT, fflush);
_flockfile(fp);

View File

@ -4,10 +4,13 @@ FUNCTION
INDEX
fgetpos
INDEX
_fgetpos_r
ANSI_SYNOPSIS
#include <stdio.h>
int fgetpos(FILE *<[fp]>, fpos_t *<[pos]>);
int _fgetpos_r(struct _reent *<[ptr]>, FILE *<[fp]>, fpos_t *<[pos]>);
TRAD_SYNOPSIS
#include <stdio.h>
@ -15,6 +18,11 @@ TRAD_SYNOPSIS
FILE *<[fp]>;
fpos_t *<[pos]>;
int _fgetpos_r(<[ptr]>, <[fp]>, <[pos]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
fpos_t *<[pos]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -49,12 +57,13 @@ No supporting OS subroutines are required.
#include <stdio.h>
int
_DEFUN (fgetpos, (fp, pos),
_DEFUN (_fgetpos_r, (ptr, fp, pos),
struct _reent * ptr _AND
FILE * fp _AND
_fpos_t * pos)
{
_flockfile(fp);
*pos = ftell (fp);
*pos = _ftell_r (ptr, fp);
if (*pos != -1)
{
@ -64,3 +73,15 @@ _DEFUN (fgetpos, (fp, pos),
_funlockfile(fp);
return 1;
}
#ifndef _REENT_ONLY
int
_DEFUN (fgetpos, (fp, pos),
FILE * fp _AND
_fpos_t * pos)
{
return _fgetpos_r (_REENT, fp, pos);
}
#endif /* !_REENT_ONLY */

View File

@ -45,7 +45,6 @@ std (ptr, flags, file, data)
ptr->_write = __swrite;
ptr->_seek = __sseek;
ptr->_close = __sclose;
ptr->_data = data;
#ifndef __SINGLE_THREAD__
__lock_init_recursive (*(_LOCK_RECURSIVE_T *)&ptr->_lock);
#endif
@ -87,9 +86,9 @@ __sfp (d)
int n;
struct _glue *g;
if (!d->__sdidinit)
__sinit (d);
for (g = &d->__sglue;; g = g->_next)
if (!_GLOBAL_REENT->__sdidinit)
__sinit (_GLOBAL_REENT);
for (g = &_GLOBAL_REENT->__sglue;; g = g->_next)
{
for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++)
if (fp->_flags == 0)
@ -115,7 +114,6 @@ found:
fp->_ub._size = 0;
fp->_lb._base = NULL; /* no line buffer */
fp->_lb._size = 0;
fp->_data = d;
return fp;
}
@ -139,7 +137,7 @@ _cleanup_r (ptr)
void
_cleanup ()
{
_cleanup_r (_REENT);
_cleanup_r (_GLOBAL_REENT);
}
#endif

View File

@ -40,38 +40,31 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <stdio.h>
#ifdef _HAVE_STDC
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#ifdef _HAVE_STDC
int
fiprintf (FILE * fp, const char *fmt,...)
{
int ret;
va_list ap;
va_start (ap, fmt);
ret = vfiprintf (fp, fmt, ap);
va_end (ap);
return ret;
}
#else
#include <varargs.h>
int
fiprintf (fp, fmt, va_alist)
FILE *fp;
char *fmt;
va_dcl
#endif
{
int ret;
va_list ap;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = vfiprintf (fp, fmt, ap);
va_end (ap);
return ret;
}
#endif

View File

@ -136,7 +136,7 @@ _DEFUN (_fopen_r, (ptr, file, mode),
if ((fp = __sfp (ptr)) == NULL)
return NULL;
if ((f = _open_r (fp->_data, file, oflags, 0666)) < 0)
if ((f = _open_r (ptr, file, oflags, 0666)) < 0)
{
fp->_flags = 0; /* release */
return NULL;
@ -151,7 +151,7 @@ _DEFUN (_fopen_r, (ptr, file, mode),
fp->_close = __sclose;
if (fp->_flags & __SAPP)
fseek (fp, 0, SEEK_END);
_fseek_r (ptr, fp, 0, SEEK_END);
#ifdef __SCLE
if (__stextmode (fp->_file))

View File

@ -19,38 +19,31 @@
#include <stdio.h>
#ifdef _HAVE_STDC
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#ifdef _HAVE_STDC
int
fprintf (FILE * fp, const char *fmt,...)
{
int ret;
va_list ap;
va_start (ap, fmt);
ret = vfprintf (fp, fmt, ap);
va_end (ap);
return ret;
}
#else
#include <varargs.h>
int
fprintf (fp, fmt, va_alist)
FILE *fp;
char *fmt;
va_dcl
#endif
{
int ret;
va_list ap;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = vfprintf (fp, fmt, ap);
va_end (ap);
return ret;
}
#endif

View File

@ -21,11 +21,15 @@ FUNCTION
INDEX
freopen
INDEX
_freopen_r
ANSI_SYNOPSIS
#include <stdio.h>
FILE *freopen(const char *<[file]>, const char *<[mode]>,
FILE *<[fp]>);
FILE *_freopen_r(struct _reent *<[ptr]>, const char *<[file]>,
const char *<[mode]>, FILE *<[fp]>);
TRAD_SYNOPSIS
#include <stdio.h>
@ -34,6 +38,12 @@ TRAD_SYNOPSIS
char *<[mode]>;
FILE *<[fp]>;
FILE *_freopen_r(<[ptr]>, <[file]>, <[mode]>, <[fp]>)
struct _reent *<[ptr]>;
char *<[file]>;
char *<[mode]>;
FILE *<[fp]>;
DESCRIPTION
Use this variant of <<fopen>> if you wish to specify a particular file
descriptor <[fp]> (notably <<stdin>>, <<stdout>>, or <<stderr>>) for
@ -67,19 +77,18 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
*/
FILE *
_DEFUN (freopen, (file, mode, fp),
_DEFUN (_freopen_r, (ptr, file, mode, fp),
struct _reent *ptr _AND
_CONST char *file _AND
_CONST char *mode _AND
register FILE *fp)
{
register int f;
int flags, oflags, e;
struct _reent *ptr;
_flockfile(fp);
CHECK_INIT (fp);
ptr = fp->_data;
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
{
@ -160,3 +169,16 @@ _DEFUN (freopen, (file, mode, fp),
_funlockfile(fp);
return fp;
}
#ifndef _REENT_ONLY
FILE *
_DEFUN (freopen, (file, mode, fp),
_CONST char *file _AND
_CONST char *mode _AND
register FILE *fp)
{
return _freopen_r (_REENT, file, mode, fp);
}
#endif /*!_REENT_ONLY */

View File

@ -23,11 +23,19 @@ INDEX
fseek
INDEX
fseeko
INDEX
_fseek_r
INDEX
_fseeko_r
ANSI_SYNOPSIS
#include <stdio.h>
int fseek(FILE *<[fp]>, long <[offset]>, int <[whence]>)
int fseeko(FILE *<[fp]>, off_t <[offset]>, int <[whence]>)
int _fseek_r(struct _reent *<[ptr]>, FILE *<[fp]>,
long <[offset]>, int <[whence]>)
int _fseeko_r(struct _reent *<[ptr]>, FILE *<[fp]>,
off_t <[offset]>, int <[whence]>)
TRAD_SYNOPSIS
#include <stdio.h>
@ -41,6 +49,18 @@ TRAD_SYNOPSIS
off_t <[offset]>;
int <[whence]>;
int _fseek_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
long <[offset]>;
int <[whence]>;
int _fseeko_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
off_t <[offset]>;
int <[whence]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -94,12 +114,12 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
*/
int
fseek (fp, offset, whence)
register FILE *fp;
long offset;
int whence;
_DEFUN (_fseek_r, (ptr, fp, offset, whence),
struct _reent *ptr _AND
register FILE *fp _AND
long offset _AND
int whence)
{
struct _reent *ptr;
_fpos_t _EXFUN ((*seekfn), (void *, _fpos_t, int));
_fpos_t target, curoff;
size_t n;
@ -111,7 +131,6 @@ fseek (fp, offset, whence)
/* Make sure stdio is set up. */
CHECK_INIT (fp);
ptr = fp->_data;
/* If we've been doing some writing, and we're in append mode
then we don't really know where the filepos is. */
@ -340,3 +359,16 @@ dumb:
_funlockfile(fp);
return 0;
}
#ifndef _REENT_ONLY
int
_DEFUN (fseek, (fp, offset, whence),
register FILE *fp _AND
long offset _AND
int whence)
{
return _fseek_r (_REENT, fp, offset, whence);
}
#endif /* !_REENT_ONLY */

View File

@ -17,6 +17,18 @@
#include <stdio.h>
int
_DEFUN (_fseeko_r, (ptr, fp, offset, whence),
struct _reent *ptr _AND
register FILE *fp _AND
_off_t offset _AND
int whence)
{
return _fseek_r (ptr, fp, (long)offset, whence);
}
#ifndef _REENT_ONLY
int
fseeko (fp, offset, whence)
register FILE *fp;
@ -24,5 +36,7 @@ fseeko (fp, offset, whence)
int whence;
{
/* for now we simply cast since off_t should be long */
return fseek (fp, (long)offset, whence);
return _fseek_r (_REENT, fp, (long)offset, whence);
}
#endif /* !_REENT_ONLY */

View File

@ -4,10 +4,14 @@ FUNCTION
INDEX
fsetpos
INDEX
_fsetpos_r
ANSI_SYNOPSIS
#include <stdio.h>
int fsetpos(FILE *<[fp]>, const fpos_t *<[pos]>);
int _fsetpos_r(struct _reent *<[ptr]>, FILE *<[fp]>, l
const fpos_t *<[pos]>);
TRAD_SYNOPSIS
#include <stdio.h>
@ -15,6 +19,11 @@ TRAD_SYNOPSIS
FILE *<[fp]>;
fpos_t *<[pos]>;
int _fsetpos_r(<[ptr]>, <[fp]>, <[pos]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
fpos_t *<[pos]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -42,13 +51,26 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <stdio.h>
int
_DEFUN (fsetpos, (iop, pos),
_DEFUN (_fsetpos_r, (ptr, iop, pos),
struct _reent * ptr _AND
FILE * iop _AND
_CONST _fpos_t * pos)
{
int x = fseek (iop, *pos, SEEK_SET);
int x = _fseek_r (ptr, iop, *pos, SEEK_SET);
if (x != 0)
return 1;
return 0;
}
#ifndef _REENT_ONLY
int
_DEFUN (fsetpos, (iop, pos),
FILE * iop _AND
_CONST _fpos_t * pos)
{
return _fsetpos_r (_REENT, iop, pos);
}
#endif /* !_REENT_ONLY */

View File

@ -23,11 +23,17 @@ INDEX
ftell
INDEX
ftello
INDEX
_ftell_r
INDEX
_ftello_r
ANSI_SYNOPSIS
#include <stdio.h>
long ftell(FILE *<[fp]>);
off_t ftello(FILE *<[fp]>);
long _ftell_r(struct _reent *<[ptr]>, FILE *<[fp]>);
off_t _ftello_r(struct _reent *<[ptr]>, FILE *<[fp]>);
TRAD_SYNOPSIS
#include <stdio.h>
@ -37,6 +43,14 @@ TRAD_SYNOPSIS
off_t ftello(<[fp]>)
FILE *<[fp]>;
long _ftell_r(<[ptr]>, <[fp]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
off_t _ftello_r(<[ptr]>, <[fp]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -84,7 +98,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include "local.h"
long
_DEFUN (ftell, (fp),
_DEFUN (_ftell_r, (ptr, fp),
struct _reent *ptr _AND
register FILE * fp)
{
_fpos_t pos;
@ -97,7 +112,7 @@ _DEFUN (ftell, (fp),
if (fp->_seek == NULL)
{
fp->_data->_errno = ESPIPE;
ptr->_errno = ESPIPE;
_funlockfile(fp);
return -1L;
}
@ -140,3 +155,14 @@ _DEFUN (ftell, (fp),
_funlockfile(fp);
return pos;
}
#ifndef _REENT_ONLY
long
_DEFUN (ftell, (fp),
register FILE * fp)
{
return _ftell_r (_REENT, fp);
}
#endif /* !_REENT_ONLY */

View File

@ -18,9 +18,21 @@
#include <stdio.h>
_off_t
_DEFUN (ftello, (fp),
_DEFUN (_ftello_r, (ptr, fp),
struct _reent * ptr _AND
register FILE * fp)
{
/* for now we simply cast since off_t should be long */
return (_off_t)ftell (fp);
return (_off_t)_ftell_r (ptr, fp);
}
#ifndef _REENT_ONLY
_off_t
_DEFUN (ftello, (fp),
register FILE * fp)
{
return (_off_t)_ftell_r (_REENT, fp);
}
#endif /* !_REENT_ONLY */

View File

@ -125,7 +125,8 @@ __sfvwrite (fp, uio)
{ /* must be asprintf family */
unsigned char *ptr;
int curpos = (fp->_p - fp->_bf._base);
ptr = (unsigned char *)_realloc_r (fp->_data, fp->_bf._base,
ptr = (unsigned char *)_realloc_r (_REENT,
fp->_bf._base,
curpos + len);
if (!ptr)
goto err;

View File

@ -40,85 +40,61 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include "local.h"
#ifdef _HAVE_STDC
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#ifndef _REENT_ONLY
#ifdef _HAVE_STDC
#include <stdarg.h>
int
iprintf (const char *fmt,...)
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
va_start (ap, fmt);
_stdout_r (_REENT)->_data = _REENT;
ret = vfiprintf (stdout, fmt, ap);
va_end (ap);
return ret;
}
#else
#include <varargs.h>
int
iprintf (fmt, va_alist)
char *fmt;
va_dcl
#endif
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
_stdout_r (_REENT)->_data = _REENT;
#endif
ret = vfiprintf (stdout, fmt, ap);
va_end (ap);
return ret;
}
#endif /* ! _HAVE_STDC */
#endif /* ! _REENT_ONLY */
#ifdef _HAVE_STDC
#include <stdarg.h>
int
_iprintf_r (struct _reent *ptr, const char *fmt, ...)
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
va_start (ap, fmt);
ret = vfiprintf (_stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
}
#else
#include <varargs.h>
int
_iprintf_r (data, fmt, va_alist)
char *data;
char *fmt;
va_dcl
#endif
{
int ret;
struct _reent *ptr = data;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = vfiprintf (_stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
}
#endif

View File

@ -48,10 +48,8 @@ extern int _EXFUN(__srefill,(FILE *fp));
#define CHECK_INIT(fp) \
do \
{ \
if ((fp)->_data == 0) \
(fp)->_data = _REENT; \
if (!(fp)->_data->__sdidinit) \
__sinit ((fp)->_data); \
if (!_REENT->__sdidinit) \
__sinit (_REENT); \
} \
while (0)
@ -67,14 +65,14 @@ extern int _EXFUN(__srefill,(FILE *fp));
#define HASUB(fp) ((fp)->_ub._base != NULL)
#define FREEUB(fp) { \
if ((fp)->_ub._base != (fp)->_ubuf) \
_free_r(fp->_data, (char *)(fp)->_ub._base); \
_free_r(_REENT, (char *)(fp)->_ub._base); \
(fp)->_ub._base = NULL; \
}
/* Test for an fgetline() buffer. */
#define HASLB(fp) ((fp)->_lb._base != NULL)
#define FREELB(fp) { _free_r(fp->_data,(char *)(fp)->_lb._base); (fp)->_lb._base = NULL; }
#define FREELB(fp) { _free_r(_REENT,(char *)(fp)->_lb._base); (fp)->_lb._base = NULL; }
/* WARNING: _dcvt is defined in the stdlib directory, not here! */

View File

@ -48,9 +48,9 @@ __smakebuf (fp)
return;
}
#ifdef __USE_INTERNAL_STAT64
if (fp->_file < 0 || _fstat64_r (fp->_data, fp->_file, &st) < 0)
if (fp->_file < 0 || _fstat64_r (_REENT, fp->_file, &st) < 0)
#else
if (fp->_file < 0 || _fstat_r (fp->_data, fp->_file, &st) < 0)
if (fp->_file < 0 || _fstat_r (_REENT, fp->_file, &st) < 0)
#endif
{
couldbetty = 0;
@ -82,7 +82,7 @@ __smakebuf (fp)
else
fp->_flags |= __SNPT;
}
if ((p = _malloc_r (fp->_data, size)) == NULL)
if ((p = _malloc_r (_REENT, size)) == NULL)
{
fp->_flags |= __SNBF;
fp->_bf._base = fp->_p = fp->_nbuf;
@ -90,7 +90,7 @@ __smakebuf (fp)
}
else
{
fp->_data->__cleanup = _cleanup_r;
_REENT->__cleanup = _cleanup_r;
fp->_flags |= __SMBF;
fp->_bf._base = fp->_p = (unsigned char *) p;
fp->_bf._size = size;

View File

@ -5,85 +5,60 @@
#include "local.h"
#ifdef _HAVE_STDC
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#ifdef _HAVE_STDC
int
_printf_r (struct _reent *ptr, const char *fmt, ...)
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
va_start (ap, fmt);
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
}
#else
#include <varargs.h>
int
_printf_r (ptr, fmt, va_alist)
struct _reent *ptr;
char *fmt;
va_dcl
#endif
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
}
#endif
#ifndef _REENT_ONLY
#ifdef _HAVE_STDC
#include <stdarg.h>
int
printf (const char *fmt, ...)
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
va_start (ap, fmt);
_stdout_r (_REENT)->_data = _REENT;
ret = vfprintf (_stdout_r (_REENT), fmt, ap);
va_end (ap);
return ret;
}
#else
#include <varargs.h>
int
printf (fmt, va_alist)
char *fmt;
va_dcl
#endif
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
_stdout_r (_REENT)->_data = _REENT;
#endif
ret = vfprintf (_stdout_r (_REENT), fmt, ap);
va_end (ap);
return ret;
}
#endif /* ! _HAVE_STDC */
#endif /* ! _REENT_ONLY */

View File

@ -94,7 +94,7 @@ _DEFUN (__srefill, (fp),
*/
if (fp->_flags & (__SLBF | __SNBF))
(void) _fwalk (fp->_data, lflush);
(void) _fwalk (_GLOBAL_REENT, lflush);
fp->_p = fp->_bf._base;
fp->_r = (*fp->_read) (fp->_cookie, (char *) fp->_p, fp->_bf._size);
fp->_flags &= ~__SMOD; /* buffer contents are again pristine */

View File

@ -21,16 +21,23 @@ FUNCTION
INDEX
rewind
INDEX
_rewind_r
ANSI_SYNOPSIS
#include <stdio.h>
void rewind(FILE *<[fp]>);
void _rewind_r(struct _reent *<[ptr]>, FILE *<[fp]>);
TRAD_SYNOPSIS
#include <stdio.h>
void rewind(<[fp]>)
FILE *<[fp]>;
void _rewind_r(<[ptr]>, <[fp]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
DESCRIPTION
<<rewind>> returns the file position indicator (if any) for the file
or stream identified by <[fp]> to the beginning of the file. It also
@ -51,10 +58,22 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <stdio.h>
void
_DEFUN (_rewind_r, (ptr, fp),
struct _reent * ptr _AND
register FILE * fp)
{
(void) _fseek_r (ptr, fp, 0L, SEEK_SET);
clearerr(fp);
}
#ifndef _REENT_ONLY
void
_DEFUN (rewind, (fp),
register FILE * fp)
{
(void) fseek(fp, 0L, SEEK_SET);
clearerr(fp);
(void) _fseek_r (_REENT, fp, 0L, SEEK_SET);
}
#endif /* !_REENT_ONLY */

View File

@ -130,7 +130,7 @@ _DEFUN (setvbuf, (fp, buf, mode, size),
fp->_r = 0;
fp->_lbfsize = 0;
if (fp->_flags & __SMBF)
_free_r (fp->_data, (void *) fp->_bf._base);
_free_r (_REENT, (void *) fp->_bf._base);
fp->_flags &= ~(__SLBF | __SNBF | __SMBF);
if (mode == _IONBF)
@ -180,7 +180,7 @@ nbf:
case _IOFBF:
/* no flag */
fp->_data->__cleanup = _cleanup_r;
_REENT->__cleanup = _cleanup_r;
fp->_bf._base = fp->_p = (unsigned char *) buf;
fp->_bf._size = size;
break;

View File

@ -57,7 +57,6 @@ siprintf (str, fmt, va_alist)
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = INT_MAX;
f._data = _REENT;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else

View File

@ -48,13 +48,12 @@ _snprintf_r (ptr, str, size, fmt, va_alist)
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = (size > 0 ? size - 1 : 0);
f._data = ptr;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = vfprintf (&f, fmt, ap);
ret = _vfprintf_r (ptr, &f, fmt, ap);
va_end (ap);
if (size > 0)
*f._p = 0;
@ -81,13 +80,12 @@ snprintf (str, size, fmt, va_alist)
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = (size > 0 ? size - 1 : 0);
f._data = _REENT;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = vfprintf (&f, fmt, ap);
ret = _vfprintf_r (_REENT, &f, fmt, ap);
va_end (ap);
if (size > 0)
*f._p = 0;

View File

@ -324,14 +324,13 @@ _sprintf_r (ptr, str, fmt, va_alist)
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = INT_MAX;
f._data = ptr;
f._file = -1; /* No file. */
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = vfprintf (&f, fmt, ap);
ret = _vfprintf_r (ptr, &f, fmt, ap);
va_end (ap);
*f._p = 0;
return (ret);
@ -356,14 +355,13 @@ sprintf (str, fmt, va_alist)
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = INT_MAX;
f._data = _REENT;
f._file = -1; /* No file. */
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
va_start (ap);
#endif
ret = vfprintf (&f, fmt, ap);
ret = _vfprintf_r (_REENT, &f, fmt, ap);
va_end (ap);
*f._p = 0;
return (ret);

View File

@ -408,7 +408,6 @@ sscanf (str, fmt, va_alist)
f._read = eofread;
f._ub._base = NULL;
f._lb._base = NULL;
f._data = _REENT;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
@ -443,7 +442,6 @@ _sscanf_r (ptr, str, fmt, va_alist)
f._read = eofread;
f._ub._base = NULL;
f._lb._base = NULL;
f._data = _REENT;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else

View File

@ -43,7 +43,7 @@ __sread (cookie, buf, n)
oldmode = setmode(fp->_file, O_BINARY);
#endif
ret = _read_r (fp->_data, fp->_file, buf, n);
ret = _read_r (_REENT, fp->_file, buf, n);
#ifdef __SCLE
if (oldmode)
@ -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 (_REENT, fp->_file, (_off_t) 0, SEEK_END);
fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */
#ifdef __SCLE
@ -80,7 +80,7 @@ __swrite (cookie, buf, n)
oldmode = setmode(fp->_file, O_BINARY);
#endif
w = _write_r (fp->_data, fp->_file, buf, n);
w = _write_r (_REENT, fp->_file, buf, n);
#ifdef __SCLE
if (oldmode)
@ -99,7 +99,7 @@ __sseek (cookie, offset, whence)
register FILE *fp = (FILE *) cookie;
register _off_t ret;
ret = _lseek_r (fp->_data, fp->_file, (_off_t) offset, whence);
ret = _lseek_r (_REENT, fp->_file, (_off_t) offset, whence);
if (ret == -1L)
fp->_flags &= ~__SOFF;
else
@ -116,7 +116,7 @@ __sclose (cookie)
{
FILE *fp = (FILE *) cookie;
return _close_r (fp->_data, fp->_file);
return _close_r (_REENT, fp->_file);
}
#ifdef __SCLE

View File

@ -59,9 +59,9 @@ _DEFUN (_tmpfile_r, (ptr),
if ((f = _tmpnam_r (ptr, buf)) == NULL)
return NULL;
fp = fopen (f, "wb+");
fp = _fopen_r (ptr, f, "wb+");
e = ptr->_errno;
_CAST_VOID remove (f);
_CAST_VOID _remove_r (ptr, f);
ptr->_errno = e;
return fp;
}

View File

@ -44,7 +44,7 @@ __submore (fp)
/*
* Get a new buffer (rather than expanding the old one).
*/
if ((p = (unsigned char *) _malloc_r (fp->_data, (size_t) BUFSIZ)) == NULL)
if ((p = (unsigned char *) _malloc_r (_REENT, (size_t) BUFSIZ)) == NULL)
return EOF;
fp->_ub._base = p;
fp->_ub._size = BUFSIZ;
@ -55,7 +55,7 @@ __submore (fp)
return 0;
}
i = fp->_ub._size;
p = (unsigned char *) _realloc_r (fp->_data, (_PTR) (fp->_ub._base), i << 1);
p = (unsigned char *) _realloc_r (_REENT, (_PTR) (fp->_ub._base), i << 1);
if (p == NULL)
return EOF;
(void) memcpy ((void *) (p + i), (void *) p, (size_t) i);

View File

@ -33,6 +33,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <varargs.h>
#endif
#ifndef _REENT_ONLY
int
_DEFUN (vasprintf, (strp, fmt, ap),
char **strp _AND
@ -45,14 +47,15 @@ _DEFUN (vasprintf, (strp, fmt, ap),
f._flags = __SWR | __SSTR | __SMBF;
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._data = _REENT;
f._file = -1; /* No file. */
ret = vfprintf (&f, fmt, ap);
ret = _vfprintf_r (_REENT, &f, fmt, ap);
*f._p = 0;
*strp = f._bf._base;
return ret;
}
#endif /* !_REENT_ONLY */
int
_DEFUN (_vasprintf_r, (ptr, strp, fmt, ap),
struct _reent *ptr _AND
@ -66,7 +69,6 @@ _DEFUN (_vasprintf_r, (ptr, strp, fmt, ap),
f._flags = __SWR | __SSTR | __SMBF ;
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._data = ptr;
f._file = -1; /* No file. */
ret = _vfprintf_r (ptr, &f, fmt, ap);
*f._p = 0;

View File

@ -242,7 +242,6 @@ __sbprintf(fp, fmt, ap)
unsigned char buf[BUFSIZ];
/* copy the important variables */
fake._data = fp->_data;
fake._flags = fp->_flags & ~__SNBF;
fake._file = fp->_file;
fake._cookie = fp->_cookie;
@ -323,7 +322,8 @@ union arg_val
u_quad_t val_u_quad_t;
};
static union arg_val *get_arg (int n, char *fmt, va_list *ap, int *numargs, union arg_val *args,
static union arg_val *get_arg (struct _reent *data, int n, char *fmt,
va_list *ap, int *numargs, union arg_val *args,
int *arg_type, char **last_fmt);
#endif /* !_NO_POS_ARGS */
@ -364,7 +364,7 @@ _DEFUN (VFPRINTF, (fp, fmt0, ap),
int result;
_flockfile(fp);
CHECK_INIT (fp);
result = _VFPRINTF_R (fp->_data, fp, fmt0, ap);
result = _VFPRINTF_R (_REENT, fp, fmt0, ap);
_funlockfile(fp);
return result;
}
@ -478,7 +478,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
( is_pos_arg \
? n < numargs \
? args[n].val_##type \
: get_arg (n, fmt_anchor, &ap, &numargs, args, arg_type, &saved_fmt)->val_##type \
: get_arg (data, n, fmt_anchor, &ap, &numargs, args, arg_type, &saved_fmt)->val_##type \
: arg_index++ < numargs \
? args[n].val_##type \
: numargs < MAX_POS_ARGS \
@ -542,7 +542,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
*/
for (;;) {
cp = fmt;
while ((n = _mbtowc_r(_REENT, &wc, fmt, MB_CUR_MAX, &state)) > 0) {
while ((n = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &state)) > 0) {
fmt += n;
if (wc == '%') {
fmt--;
@ -1360,8 +1360,9 @@ const static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = {
/* function to get positional parameter N where n = N - 1 */
static union arg_val *
get_arg (int n, char *fmt, va_list *ap, int *numargs_p, union arg_val *args,
int *arg_type, char **last_fmt)
get_arg (struct _reent *data, int n, char *fmt, va_list *ap,
int *numargs_p, union arg_val *args,
int *arg_type, char **last_fmt)
{
int ch;
wchar_t wc;
@ -1386,7 +1387,7 @@ get_arg (int n, char *fmt, va_list *ap, int *numargs_p, union arg_val *args,
read the desired parameter from the vararg list. */
while (*fmt && n >= numargs)
{
while ((nbytes = _mbtowc_r(_REENT, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0)
while ((nbytes = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0)
{
fmt += nbytes;
if (wc == '%')

View File

@ -210,7 +210,7 @@ _DEFUN (vfscanf, (fp, fmt, ap),
va_list ap)
{
CHECK_INIT(fp);
return __svfscanf_r (fp->_data, fp, fmt, ap);
return __svfscanf_r (_REENT, fp, fmt, ap);
}
int

View File

@ -28,15 +28,19 @@
#include "local.h"
#ifndef _REENT_ONLY
int
_DEFUN (vprintf, (fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
return vfprintf (_stdout_r (_REENT), fmt, ap);
return _vfprintf_r (_REENT, _stdout_r (_REENT), fmt, ap);
}
#endif /* !_REENT_ONLY */
int
_DEFUN (_vprintf_r, (ptr, fmt, ap),
struct _reent *ptr _AND

View File

@ -33,6 +33,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <varargs.h>
#endif
#ifndef _REENT_ONLY
int
_DEFUN (vsnprintf, (str, size, fmt, ap),
char *str _AND
@ -46,13 +48,14 @@ _DEFUN (vsnprintf, (str, size, fmt, ap),
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = (size > 0 ? size - 1 : 0);
f._data = _REENT;
ret = vfprintf (&f, fmt, ap);
ret = _vfprintf_r (_REENT, &f, fmt, ap);
if (size > 0)
*f._p = 0;
return ret;
}
#endif /* !_REENT_ONLY */
int
_DEFUN (_vsnprintf_r, (ptr, str, size, fmt, ap),
struct _reent *ptr _AND
@ -67,7 +70,6 @@ _DEFUN (_vsnprintf_r, (ptr, str, size, fmt, ap),
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = (size > 0 ? size - 1 : 0);
f._data = ptr;
ret = _vfprintf_r (ptr, &f, fmt, ap);
if (size > 0)
*f._p = 0;

View File

@ -31,6 +31,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <varargs.h>
#endif
#ifndef _REENT_ONLY
int
_DEFUN (vsprintf, (str, fmt, ap),
char *str _AND
@ -43,13 +45,14 @@ _DEFUN (vsprintf, (str, fmt, ap),
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = INT_MAX;
f._data = _REENT;
f._file = -1; /* No file. */
ret = vfprintf (&f, fmt, ap);
ret = _vfprintf_r (_REENT, &f, fmt, ap);
*f._p = 0;
return ret;
}
#endif /* !_REENT_ONLY */
int
_DEFUN (_vsprintf_r, (ptr, str, fmt, ap),
struct _reent *ptr _AND
@ -63,7 +66,6 @@ _DEFUN (_vsprintf_r, (ptr, str, fmt, ap),
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = INT_MAX;
f._data = ptr;
f._file = -1; /* No file. */
ret = _vfprintf_r (ptr, &f, fmt, ap);
*f._p = 0;

View File

@ -70,7 +70,6 @@ _DEFUN (_vsscanf_r, (ptr, str, fmt, ap),
f._read = eofread1;
f._ub._base = NULL;
f._lb._base = NULL;
f._data = ptr;
return __svfscanf_r (ptr, &f, fmt, ap);
}

View File

@ -4,10 +4,14 @@ FUNCTION
INDEX
fgetpos64
INDEX
_fgetpos64_r
ANSI_SYNOPSIS
#include <stdio.h>
int fgetpos64(FILE *<[fp]>, _fpos64_t *<[pos]>);
int _fgetpos64_r(struct _reent *<[ptr]>, FILE *<[fp]>,
_fpos64_t *<[pos]>);
TRAD_SYNOPSIS
#include <stdio.h>
@ -15,6 +19,10 @@ TRAD_SYNOPSIS
FILE *<[fp]>;
_fpos64_t *<[pos]>;
int _fgetpos64_r(<[ptr]>, <[fp]>, <[pos]>)
FILE *<[fp]>;
_fpos64_t *<[pos]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -47,12 +55,13 @@ No supporting OS subroutines are required.
#ifdef __LARGE64_FILES
int
_DEFUN (fgetpos64, (fp, pos),
_DEFUN (_fgetpos64_r, (ptr, fp, pos),
struct _reent * ptr _AND
FILE * fp _AND
_fpos64_t * pos)
{
_flockfile(fp);
*pos = (_fpos64_t)ftello64 (fp);
*pos = (_fpos64_t)_ftello64_r (ptr, fp);
if (*pos != -1)
{
@ -63,4 +72,16 @@ _DEFUN (fgetpos64, (fp, pos),
return 1;
}
#ifndef _REENT_ONLY
int
_DEFUN (fgetpos64, (fp, pos),
FILE * fp _AND
_fpos64_t * pos)
{
return _fgetpos64_r (_REENT, fp, pos);
}
#endif /* !_REENT_ONLY */
#endif /* __LARGE64_FILES */

View File

@ -89,7 +89,7 @@ _DEFUN (_fopen64_r, (ptr, file, mode),
if ((fp = __sfp (ptr)) == NULL)
return NULL;
if ((f = _open64_r (fp->_data, file, oflags, 0666)) < 0)
if ((f = _open64_r (ptr, file, oflags, 0666)) < 0)
{
fp->_flags = 0; /* release */
return NULL;
@ -105,7 +105,7 @@ _DEFUN (_fopen64_r, (ptr, file, mode),
fp->_close = __sclose;
if (fp->_flags & __SAPP)
fseeko64 (fp, 0, SEEK_END);
_fseeko64_r (ptr, fp, 0, SEEK_END);
#ifdef __SCLE
if (__stextmode (fp->_file))

View File

@ -21,11 +21,15 @@ FUNCTION
INDEX
freopen64
INDEX
_freopen64_r
ANSI_SYNOPSIS
#include <stdio.h>
FILE *freopen64(const char *<[file]>, const char *<[mode]>,
FILE *<[fp]>);
FILE *_freopen64_r(struct _reent *<[ptr]>, const char *<[file]>,
const char *<[mode]>, FILE *<[fp]>);
TRAD_SYNOPSIS
#include <stdio.h>
@ -34,6 +38,12 @@ TRAD_SYNOPSIS
char *<[mode]>;
FILE *<[fp]>;
FILE *_freopen64_r(<[ptr]>, <[file]>, <[mode]>, <[fp]>)
struct _reent *<[ptr]>;
char *<[file]>;
char *<[mode]>;
FILE *<[fp]>;
DESCRIPTION
Use this variant of <<fopen64>> if you wish to specify a particular file
descriptor <[fp]> (notably <<stdin>>, <<stdout>>, or <<stderr>>) for
@ -69,19 +79,18 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#ifdef __LARGE64_FILES
FILE *
_DEFUN (freopen64, (file, mode, fp),
_DEFUN (_freopen64_r, (ptr, file, mode, fp),
struct _reent *ptr _AND
_CONST char *file _AND
_CONST char *mode _AND
register FILE *fp)
{
register int f;
int flags, oflags, e;
struct _reent *ptr;
_flockfile(fp);
CHECK_INIT (fp);
ptr = fp->_data;
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
{
@ -166,4 +175,17 @@ _DEFUN (freopen64, (file, mode, fp),
return fp;
}
#ifndef _REENT_ONLY
FILE *
_DEFUN (freopen64, (file, mode, fp),
_CONST char *file _AND
_CONST char *mode _AND
register FILE *fp)
{
return _freopen64_r (_REENT, file, mode, fp);
}
#endif /* !_REENT_ONLY */
#endif /* __LARGE64_FILES */

View File

@ -21,11 +21,14 @@ FUNCTION
INDEX
fseeko64
INDEX
_fseeko64_r
ANSI_SYNOPSIS
#include <stdio.h>
int fseeko64(FILE *<[fp]>, _off64_t <[offset]>, int <[whence]>)
int _fseeko64_r (struct _reent *<[ptr]>, FILE *<[fp]>,
_off64_t <[offset]>, int <[whence]>)
TRAD_SYNOPSIS
#include <stdio.h>
@ -34,6 +37,12 @@ TRAD_SYNOPSIS
_off64_t <[offset]>;
int <[whence]>;
int _fseeko64_r (<[ptr]>, <[fp]>, <[offset]>, <[whence]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
_off64_t <[offset]>;
int <[whence]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -89,15 +98,17 @@ Supporting OS subroutines required: <<close>>, <<fstat64>>, <<isatty>>,
*/
_off64_t
fseeko64 (fp, offset, whence)
register FILE *fp;
_off64_t offset;
int whence;
_DEFUN (_fseeko64_r, (ptr, fp, offset, whence),
struct _reent *ptr _AND
register FILE *fp _AND
_off64_t offset _AND
int whence)
{
struct _reent *ptr;
_fpos64_t _EXFUN ((*seekfn), (void *, _fpos64_t, int));
_fpos64_t target, curoff;
size_t n;
/* FIXME: this should be stat64. */
struct stat st;
int havepos;
@ -106,7 +117,8 @@ fseeko64 (fp, offset, whence)
/* Make sure stdio is set up. */
CHECK_INIT (fp);
ptr = fp->_data;
curoff = fp->_offset;
/* If we've been doing some writing, and we're in append mode
then we don't really know where the filepos is. */
@ -193,7 +205,7 @@ fseeko64 (fp, offset, whence)
{
if (seekfn != __sseek64
|| fp->_file < 0
|| _fstat64_r (ptr, fp->_file, &st)
|| _fstat_r (ptr, fp->_file, &st)
|| (st.st_mode & S_IFMT) != S_IFREG)
{
fp->_flags |= __SNPT;
@ -328,4 +340,17 @@ dumb:
return 0;
}
#ifndef _REENT_ONLY
_off64_t
_DEFUN (fseeko64_r, (fp, offset, whence),
register FILE *fp _AND
_off64_t offset _AND
int whence)
{
return _fseeko64_r (_REENT, fp, offset, whence);
}
#endif /* !_REENT_ONLY */
#endif /* __LARGE64_FILES */

View File

@ -4,10 +4,14 @@ FUNCTION
INDEX
fsetpos64
INDEX
_fsetpos64_r
ANSI_SYNOPSIS
#include <stdio.h>
int fsetpos64(FILE *<[fp]>, const _fpos64_t *<[pos]>);
int _fsetpos64_r(struct _reent *<[ptr]>, FILE *<[fp]>,
const _fpos64_t *<[pos]>);
TRAD_SYNOPSIS
#include <stdio.h>
@ -15,6 +19,11 @@ TRAD_SYNOPSIS
FILE *<[fp]>;
_fpos64_t *<[pos]>;
int _fsetpos64_r(<[ptr]>, <[fp]>, <[pos]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
_fpos64_t *<[pos]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -43,15 +52,28 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#ifdef __LARGE64_FILES
int
_DEFUN (fsetpos64, (iop, pos),
_DEFUN (_fsetpos64_r, (ptr, iop, pos),
struct _reent *ptr _AND
FILE * iop _AND
_CONST _fpos64_t * pos)
{
int x = fseeko64 (iop, (_off64_t)(*pos), SEEK_SET);
int x = _fseeko64_r (ptr, iop, (_off64_t)(*pos), SEEK_SET);
if (x != 0)
return 1;
return 0;
}
#ifndef _REENT_ONLY
int
_DEFUN (fsetpos64, (iop, pos),
FILE * iop _AND
_CONST _fpos64_t * pos)
{
return _fsetpos64_r (_REENT, iop, pos);
}
#endif /* !_REENT_ONLY */
#endif /* __LARGE64_FILES */

View File

@ -21,16 +21,23 @@ FUNCTION
INDEX
ftello64
INDEX
_ftello64_r
ANSI_SYNOPSIS
#include <stdio.h>
_off64_t ftello64(FILE *<[fp]>);
_off64_t _ftello64_r(struct _reent *<[ptr]>, FILE *<[fp]>);
TRAD_SYNOPSIS
#include <stdio.h>
_off64_t ftello64(<[fp]>)
FILE *<[fp]>;
_off64_t _ftello64_r(<[ptr]>, <[fp]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
DESCRIPTION
Objects of type <<FILE>> can have a ``position'' that records how much
of the file your program has already read. Many of the <<stdio>> functions
@ -78,7 +85,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#ifdef __LARGE64_FILES
_off64_t
_DEFUN (ftello64, (fp),
_DEFUN (_ftello64_r, (ptr, fp),
struct _reent *ptr _AND
register FILE * fp)
{
_fpos64_t pos;
@ -91,7 +99,7 @@ _DEFUN (ftello64, (fp),
if (fp->_seek64 == NULL)
{
fp->_data->_errno = ESPIPE;
ptr->_errno = ESPIPE;
_funlockfile(fp);
return -1L;
}
@ -135,4 +143,15 @@ _DEFUN (ftello64, (fp),
return pos;
}
#ifndef _REENT_ONLY
_off64_t
_DEFUN (ftello64, (fp),
register FILE * fp)
{
return _ftello64_r (_REENT, fp);
}
#endif /* !_REENT_ONLY */
#endif /* __LARGE64_FILES */

View File

@ -7,7 +7,10 @@
#ifdef __LARGE64_FILES
extern _fpos64_t _EXFUN(__sseek64,(void *, _fpos64_t, int));
extern _fpos64_t _EXFUN(__sseek64_r,(struct _reent *, void *, _fpos64_t, int));
extern _fpos64_t _EXFUN(__sseek64_error,(void *, _fpos64_t, int));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(void *, char const *, int));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64_r,(struct _reent *, void *,
char const *, int));
#endif

View File

@ -26,7 +26,8 @@
#ifdef __LARGE64_FILES
_fpos64_t
__sseek64 (cookie, offset, whence)
__sseek64_r (ptr, cookie, offset, whence)
struct _reent *ptr;
_PTR cookie;
_fpos64_t offset;
int whence;
@ -34,7 +35,7 @@ __sseek64 (cookie, offset, whence)
register FILE *fp = (FILE *) cookie;
register _off64_t ret;
ret = _lseek64_r (fp->_data, fp->_file, (_off64_t) offset, whence);
ret = _lseek64_r (ptr, fp->_file, (_off64_t) offset, whence);
if (ret == (_fpos64_t)-1L)
fp->_flags &= ~__SOFF;
else
@ -46,7 +47,8 @@ __sseek64 (cookie, offset, whence)
}
_READ_WRITE_RETURN_TYPE
__swrite64 (cookie, buf, n)
__swrite64_r (ptr, cookie, buf, n)
struct _reent *ptr;
_PTR cookie;
char _CONST *buf;
int n;
@ -58,7 +60,7 @@ __swrite64 (cookie, buf, n)
#endif
if (fp->_flags & __SAPP)
(void) _lseek64_r (fp->_data, fp->_file, (_off64_t)0, SEEK_END);
(void) _lseek64_r (ptr, fp->_file, (_off64_t)0, SEEK_END);
fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */
#ifdef __SCLE
@ -66,7 +68,7 @@ __swrite64 (cookie, buf, n)
oldmode = setmode(fp->_file, O_BINARY);
#endif
w = _write_r (fp->_data, fp->_file, buf, n);
w = _write_r (ptr, fp->_file, buf, n);
#ifdef __SCLE
if (oldmode)
@ -75,5 +77,27 @@ __swrite64 (cookie, buf, n)
return w;
}
#ifndef _REENT_ONLY
_fpos64_t
__sseek64 (cookie, offset, whence)
_PTR cookie;
_fpos64_t offset;
int whence;
{
return __sseek64_r (_REENT, cookie, offset, whence);
}
_READ_WRITE_RETURN_TYPE
__swrite64 (cookie, buf, n)
_PTR cookie;
char _CONST *buf;
int n;
{
return __swrite64_r (_REENT, cookie, buf, n);
}
#endif /* !_REENT_ONLY */
#endif /* __LARGE64_FILES */