* 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-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
#endif /* !_REENT_ONLY */
+#define _GLOBAL_REENT _impure_ptr
+
#ifdef __cplusplus
}
#endif
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);
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);
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))
int
fcloseall (void)
{
- return _fcloseall_r (_REENT);
+ return _fcloseall_r (_GLOBAL_REENT);
}
#endif
register unsigned char *p;
register int n, t;
-
-
-
if (fp == NULL)
- return _fwalk (_REENT, fflush);
+ return _fwalk (_GLOBAL_REENT, fflush);
_flockfile(fp);
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>
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
#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)
{
_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 */
ptr->_write = __swrite;
ptr->_seek = __sseek;
ptr->_close = __sclose;
- ptr->_data = data;
#ifndef __SINGLE_THREAD__
__lock_init_recursive (*(_LOCK_RECURSIVE_T *)&ptr->_lock);
#endif
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)
fp->_ub._size = 0;
fp->_lb._base = NULL; /* no line buffer */
fp->_lb._size = 0;
- fp->_data = d;
return fp;
}
void
_cleanup ()
{
- _cleanup_r (_REENT);
+ _cleanup_r (_GLOBAL_REENT);
}
#endif
#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
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;
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))
#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
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>
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
*/
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)
{
_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 */
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>
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
*/
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;
/* 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. */
_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 */
#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;
_off_t offset;
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 */
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>
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
#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 */
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>
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
#include "local.h"
long
-_DEFUN (ftell, (fp),
+_DEFUN (_ftell_r, (ptr, fp),
+ struct _reent *ptr _AND
register FILE * fp)
{
_fpos_t pos;
if (fp->_seek == NULL)
{
- fp->_data->_errno = ESPIPE;
+ ptr->_errno = ESPIPE;
_funlockfile(fp);
return -1L;
}
_funlockfile(fp);
return pos;
}
+
+#ifndef _REENT_ONLY
+
+long
+_DEFUN (ftell, (fp),
+ register FILE * fp)
+{
+ return _ftell_r (_REENT, fp);
+}
+
+#endif /* !_REENT_ONLY */
#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 */
{ /* 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;
#include "local.h"
-#ifndef _REENT_ONLY
-
#ifdef _HAVE_STDC
-
#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#ifndef _REENT_ONLY
+
+#ifdef _HAVE_STDC
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
#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)
#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! */
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;
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;
}
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;
#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 */
*/
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 */
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
#include <stdio.h>
void
-_DEFUN (rewind, (fp),
+_DEFUN (_rewind_r, (ptr, fp),
+ struct _reent * ptr _AND
register FILE * fp)
{
- (void) fseek(fp, 0L, SEEK_SET);
+ (void) _fseek_r (ptr, fp, 0L, SEEK_SET);
clearerr(fp);
}
+
+#ifndef _REENT_ONLY
+
+void
+_DEFUN (rewind, (fp),
+ register FILE * fp)
+{
+ (void) _fseek_r (_REENT, fp, 0L, SEEK_SET);
+}
+
+#endif /* !_REENT_ONLY */
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)
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;
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
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;
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;
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);
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);
f._read = eofread;
f._ub._base = NULL;
f._lb._base = NULL;
- f._data = _REENT;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
f._read = eofread;
f._ub._base = NULL;
f._lb._base = NULL;
- f._data = _REENT;
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
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)
#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
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)
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
{
FILE *fp = (FILE *) cookie;
- return _close_r (fp->_data, fp->_file);
+ return _close_r (_REENT, fp->_file);
}
#ifdef __SCLE
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;
}
/*
* 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;
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);
#include <varargs.h>
#endif
+#ifndef _REENT_ONLY
+
int
_DEFUN (vasprintf, (strp, fmt, ap),
char **strp _AND
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
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;
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;
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 */
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;
}
( 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 \
*/
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--;
/* 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;
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 == '%')
va_list ap)
{
CHECK_INIT(fp);
- return __svfscanf_r (fp->_data, fp, fmt, ap);
+ return __svfscanf_r (_REENT, fp, fmt, ap);
}
int
#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
#include <varargs.h>
#endif
+#ifndef _REENT_ONLY
+
int
_DEFUN (vsnprintf, (str, size, fmt, ap),
char *str _AND
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
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;
#include <varargs.h>
#endif
+#ifndef _REENT_ONLY
+
int
_DEFUN (vsprintf, (str, fmt, ap),
char *str _AND
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
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;
f._read = eofread1;
f._ub._base = NULL;
f._lb._base = NULL;
- f._data = ptr;
return __svfscanf_r (ptr, &f, fmt, ap);
}
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>
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
#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)
{
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 */
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;
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))
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>
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
#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)
{
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 */
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>
_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
*/
_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;
/* 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. */
{
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;
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 */
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>
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
#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 */
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
#ifdef __LARGE64_FILES
_off64_t
-_DEFUN (ftello64, (fp),
+_DEFUN (_ftello64_r, (ptr, fp),
+ struct _reent *ptr _AND
register FILE * fp)
{
_fpos64_t pos;
if (fp->_seek64 == NULL)
{
- fp->_data->_errno = ESPIPE;
+ ptr->_errno = ESPIPE;
_funlockfile(fp);
return -1L;
}
return pos;
}
+#ifndef _REENT_ONLY
+
+_off64_t
+_DEFUN (ftello64, (fp),
+ register FILE * fp)
+{
+ return _ftello64_r (_REENT, fp);
+}
+
+#endif /* !_REENT_ONLY */
+
#endif /* __LARGE64_FILES */
#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
#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;
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
}
_READ_WRITE_RETURN_TYPE
-__swrite64 (cookie, buf, n)
+__swrite64_r (ptr, cookie, buf, n)
+ struct _reent *ptr;
_PTR cookie;
char _CONST *buf;
int 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
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)
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 */