* libc/stdio64/fdopen64.c: New file.

* libc/stdio64/Makefile.am (LIB_OBJS): Add fdopen64.o
* libc/stdio64/Makefile.in: Regenerate.
* libc/include/stdio.h (fdopen64): Define.
* libc/include/stdio.h (_fdopen64_r): Ditto.
This commit is contained in:
Christopher Faylor 2003-07-25 16:06:01 +00:00
parent 206ac17473
commit 035367578f
6 changed files with 137 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2003-07-24 Christopher Faylor <cgf@redhat.com>
* libc/stdio64/fdopen64.c: New file.
* libc/stdio64/Makefile.am (LIB_OBJS): Add fdopen64.o
* libc/stdio64/Makefile.in: Regenerate.
* libc/include/stdio.h (fdopen64): Define.
* libc/include/stdio.h (_fdopen64_r): Ditto.
2003-07-10 Alexandre Oliva <aoliva@redhat.com>
2000-04-27 Alexandre Oliva <aoliva@cygnus.com>

View File

@ -434,7 +434,9 @@ esac
case "${host}" in
*-*-cygwin*)
newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED"
test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
export cygwin_srcdir
newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED -I${cygwin_srcdir}/include"
syscall_dir=syscalls
;;
# RTEMS supplies its own versions of some routines:

View File

@ -309,6 +309,7 @@ ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
#ifdef __LARGE64_FILES
#ifndef __CYGWIN__
FILE * _EXFUN(fdopen64, (int, const char *));
FILE * _EXFUN(fopen64, (const char *, const char *));
_off64_t _EXFUN(ftello64, (FILE *));
_off64_t _EXFUN(fseeko64, (FILE *, _off64_t, int));
@ -316,6 +317,7 @@ int _EXFUN(fgetpos64, (FILE *, _fpos64_t *));
int _EXFUN(fsetpos64, (FILE *, const _fpos64_t *));
FILE * _EXFUN(tmpfile64, (void));
FILE * _EXFUN(_fdopen64_r, (struct _reent *, int, const char *));
FILE * _EXFUN(_fopen64_r, (struct _reent *,const char *, const char *));
_off64_t _EXFUN(_ftello64_r, (struct _reent *, FILE *));
_off64_t _EXFUN(_fseeko64_r, (struct _reent *, FILE *, _off64_t, int));

View File

@ -12,6 +12,7 @@ if ELIX_LEVEL_1
LIB_OBJS =
else
LIB_OBJS = \
fdopen64.$(oext) \
fgetpos64.$(oext) \
fopen64.$(oext) \
freopen64.$(oext) \

View File

@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -114,6 +114,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = dummy.c local64.h
@ELIX_LEVEL_1_TRUE@LIB_OBJS =
@ELIX_LEVEL_1_FALSE@LIB_OBJS = @ELIX_LEVEL_1_FALSE@\
@ELIX_LEVEL_1_FALSE@ fdopen64.$(oext) \
@ELIX_LEVEL_1_FALSE@ fgetpos64.$(oext) \
@ELIX_LEVEL_1_FALSE@ fopen64.$(oext) \
@ELIX_LEVEL_1_FALSE@ freopen64.$(oext) \

View File

@ -0,0 +1,120 @@
/*
FUNCTION
<<fdopen64>>---turn open file into a stream
INDEX
fdopen64
INDEX
_fdopen64_r
SYNOPSIS
#include <stdio.h>
FILE *fdopen64(int <[fd]>, const char *<[mode]>);
FILE *_fdopen64_r(void *<[reent]>,
int <[fd]>, const char *<[mode]>);
DESCRIPTION
<<fdopen64>> produces a file descriptor of type <<FILE *>>, from a
descriptor for an already-open file (returned, for example, by the
system subroutine <<open>> rather than by <<fopen>>).
The <[mode]> argument has the same meanings as in <<fopen>>.
RETURNS
File pointer or <<NULL>>, as for <<fopen>>.
*/
#include <sys/types.h>
#include <sys/fcntl.h>
#include <stdio.h>
#include <errno.h>
#include "local64.h"
#include <_syslist.h>
extern int __sflags ();
FILE *
_DEFUN (_fdopen64_r, (ptr, fd, mode),
struct _reent *ptr _AND
int fd _AND
_CONST char *mode)
{
register FILE *fp;
int flags, oflags;
#ifdef HAVE_FCNTL
int fdflags, fdmode;
#endif
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
return 0;
/* make sure the mode the user wants is a subset of the actual mode */
#ifdef HAVE_FCNTL
if ((fdflags = _fcntl_r (ptr, fd, F_GETFL, 0)) < 0)
return 0;
fdmode = fdflags & O_ACCMODE;
if (fdmode != O_RDWR && (fdmode != (oflags & O_ACCMODE)))
{
ptr->_errno = EBADF;
return 0;
}
#endif
if ((fp = __sfp (ptr)) == 0)
return 0;
fp->_flags = flags;
/*
* If opened for appending, but underlying descriptor
* does not have O_APPEND bit set, assert __SAPP so that
* __swrite() will lseek to end before each write.
*/
if ((oflags & O_APPEND)
#ifdef HAVE_FCNTL
&& !(fdflags & O_APPEND)
#endif
)
fp->_flags |= __SAPP;
fp->_file = fd;
fp->_cookie = (_PTR) fp;
#undef _read
#undef _write
#undef _seek
#undef _close
fp->_read = __sread;
fp->_write = __swrite64;
fp->_seek = __sseek;
fp->_seek64 = __sseek64;
fp->_close = __sclose;
#ifdef __SCLE
/* Explicit given mode results in explicit setting mode on fd */
if (oflags & O_BINARY)
setmode(fp->_file, O_BINARY);
else if (oflags & O_TEXT)
setmode(fp->_file, O_TEXT);
if (__stextmode(fp->_file))
fp->_flags |= __SCLE;
#endif
#ifndef __SINGLE_THREAD__
__lock_init_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock);
#endif
fp->_flags |= __SL64;
return fp;
}
#ifndef _REENT_ONLY
FILE *
_DEFUN (fdopen64, (fd, mode),
int fd _AND
_CONST char *mode)
{
return _fdopen64_r (_REENT, fd, mode);
}
#endif