Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-07-25 20:06:01 +0400
committerChristopher Faylor <me@cgf.cx>2003-07-25 20:06:01 +0400
commit035367578f7afc08160014c1ab11eeb627a88f31 (patch)
treec502865e201051b5b9b6900196111aad9c0bd0fd
parent206ac174730f7f3495ce271aaff4bd912ca396a5 (diff)
* 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.
-rw-r--r--newlib/ChangeLog8
-rw-r--r--newlib/configure.host4
-rw-r--r--newlib/libc/include/stdio.h2
-rw-r--r--newlib/libc/stdio64/Makefile.am1
-rw-r--r--newlib/libc/stdio64/Makefile.in5
-rw-r--r--newlib/libc/stdio64/fdopen64.c120
6 files changed, 137 insertions, 3 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index e2abf4200..d7557c21a 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -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>
diff --git a/newlib/configure.host b/newlib/configure.host
index edcfef911..cb387e431 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -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:
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index a82cd7639..5f22dfc1b 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -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));
diff --git a/newlib/libc/stdio64/Makefile.am b/newlib/libc/stdio64/Makefile.am
index 422d64909..f31614ae3 100644
--- a/newlib/libc/stdio64/Makefile.am
+++ b/newlib/libc/stdio64/Makefile.am
@@ -12,6 +12,7 @@ if ELIX_LEVEL_1
LIB_OBJS =
else
LIB_OBJS = \
+ fdopen64.$(oext) \
fgetpos64.$(oext) \
fopen64.$(oext) \
freopen64.$(oext) \
diff --git a/newlib/libc/stdio64/Makefile.in b/newlib/libc/stdio64/Makefile.in
index 09b0bf580..69e99f914 100644
--- a/newlib/libc/stdio64/Makefile.in
+++ b/newlib/libc/stdio64/Makefile.in
@@ -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) \
diff --git a/newlib/libc/stdio64/fdopen64.c b/newlib/libc/stdio64/fdopen64.c
new file mode 100644
index 000000000..96c76411f
--- /dev/null
+++ b/newlib/libc/stdio64/fdopen64.c
@@ -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