From 3a8fc0e4f13f940839c1e25818eac3f7860d3fe8 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 21 Feb 2001 23:11:06 +0000 Subject: [PATCH] 2001-02-21 Jeff Johnston * libc/stdio/fdopen.c (fdopen): Protect calls to _fcntl() with HAVE_FCNTL flag check. * configure.host: Define HAVE_FCNTL for Cygwin, go32, RTEMS, sparc64, powerpcle, x86 netware, x86 sco, x86 Linux and Vxworks. --- newlib/ChangeLog | 7 +++++++ newlib/configure.host | 18 +++++++++--------- newlib/libc/stdio/fdopen.c | 6 +++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index dc820c8a4..8e6cdbe28 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,10 @@ +2001-02-21 Jeff Johnston + + * libc/stdio/fdopen.c (fdopen): Protect calls to _fcntl() with + HAVE_FCNTL flag check. + * configure.host: Define HAVE_FCNTL for Cygwin, go32, RTEMS, sparc64, + powerpcle, x86 netware, x86 sco, x86 Linux and Vxworks. + Thu Feb 15 01:39:51 2001 Christopher Faylor * libc/include/sys/signal.h: Always include sys/types.h under Cygwin. diff --git a/newlib/configure.host b/newlib/configure.host index 1df620199..7a1e2918d 100644 --- a/newlib/configure.host +++ b/newlib/configure.host @@ -252,7 +252,7 @@ case "${host}" in #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD newlib_cflags="${newlib_cflags} -Wall" newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS" - newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES" + newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL" # --- Required when building a shared library ------------------------ newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION" # --- The three lines below are optional ------------------------------ @@ -326,7 +326,7 @@ 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" + newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL" syscall_dir=syscalls ;; # RTEMS supplies its own versions of some routines: @@ -337,12 +337,12 @@ case "${host}" in # # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that. *-*-rtems*) - newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DWANT_PRINTF_LONG_LONG" + newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DWANT_PRINTF_LONG_LONG -DHAVE_FCNTL" ;; # VxWorks supplies its own version of malloc, and the newlib one # doesn't work because VxWorks does not have sbrk. *-wrs-vxworks*) - newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES" + newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL" ;; # UDI doesn't have exec, so system() should fail the right way a29k-amd-udi) @@ -393,13 +393,13 @@ case "${host}" in newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY" ;; i[3456]86-*-sco*) - newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED" + newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL" ;; i[3456]86-*-netware*) - newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED" + newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL" ;; i[3456]86-*-go32) - newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC" + newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DHAVE_FCNTL" ;; m32r-*-*) # Pass -msdata=sdata so _impure_ptr goes in .sdata. @@ -425,7 +425,7 @@ case "${host}" in newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES" ;; powerpcle-*-pe) - newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME" + newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL" syscall_dir=syscalls ;; sh*-*-*) @@ -436,7 +436,7 @@ case "${host}" in newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED" ;; sparc64-*-*) - newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY" + newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL" # This either belongs elsewhere or nowhere. But I need *something*, # so for now it's here ... case "${host_os}" in diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index 410a5248a..bd4018b69 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -55,7 +55,7 @@ _DEFUN (_fdopen_r, (ptr, fd, mode), { register FILE *fp; int flags, oflags; -#ifdef F_GETFL +#ifdef HAVE_FCNTL int fdflags, fdmode; #endif @@ -63,7 +63,7 @@ _DEFUN (_fdopen_r, (ptr, fd, mode), return 0; /* make sure the mode the user wants is a subset of the actual mode */ -#ifdef F_GETFL +#ifdef HAVE_FCNTL if ((fdflags = _fcntl (fd, F_GETFL, 0)) < 0) return 0; fdmode = fdflags & O_ACCMODE; @@ -83,7 +83,7 @@ _DEFUN (_fdopen_r, (ptr, fd, mode), * __swrite() will lseek to end before each write. */ if ((oflags & O_APPEND) -#ifdef F_GETFL +#ifdef HAVE_FCNTL && !(fdflags & O_APPEND) #endif )