diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2002-09-19 21:28:52 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2002-09-19 21:28:52 +0000 |
commit | 50558bf3bdb5e2fc2454f38316af1f06f82f9a5d (patch) | |
tree | 06876f77aa28773abc0dfae1f21adf94fa5f3d26 /newlib | |
parent | 0688e43db7cdf256bd7f38c9b0524cf71032ecf9 (diff) | |
download | newlib-50558bf3bdb5e2fc2454f38316af1f06f82f9a5d.zip newlib-50558bf3bdb5e2fc2454f38316af1f06f82f9a5d.tar.gz newlib-50558bf3bdb5e2fc2454f38316af1f06f82f9a5d.tar.bz2 |
2002-09-19 Jeff Johnston <jjohnstn@redhat.com>
* libc/posix/opendir.c (opendir): Change code to check
for HAVE_FCNTL before calling fcntl.
* libc/search/hash.c (hash_open): Ditto.
* libc/search/hash_page.c (open_tmp): Ditto.
* libc/reent/Makefile.am: Add fcntlr.c.
* libc/reent/Makefile.in: Regenerated.
* libc/reent/fcntlr.c: New file.
* libc/stdio/fdopen.c (_fdopen_r): Change to call _fcntl_r
instead of _fcntl when HAVE_FCNTL flag is set.
* libc/syscalls/sysfcntl.c (fcntl): Check for HAVE_FCNTL flag
to see if _fcntl or _fcntl_r should be called. If flag is not
set, default to ENOSYS stub.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 15 | ||||
-rw-r--r-- | newlib/libc/posix/opendir.c | 6 | ||||
-rw-r--r-- | newlib/libc/reent/Makefile.am | 2 | ||||
-rw-r--r-- | newlib/libc/reent/Makefile.in | 18 | ||||
-rw-r--r-- | newlib/libc/reent/fcntlr.c | 65 | ||||
-rw-r--r-- | newlib/libc/search/hash.c | 2 | ||||
-rw-r--r-- | newlib/libc/search/hash_page.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/fdopen.c | 2 | ||||
-rw-r--r-- | newlib/libc/syscalls/sysfcntl.c | 12 |
9 files changed, 111 insertions, 13 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 8fed9e5..df30d24 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,18 @@ +2002-09-19 Jeff Johnston <jjohnstn@redhat.com> + + * libc/posix/opendir.c (opendir): Change code to check + for HAVE_FCNTL before calling fcntl. + * libc/search/hash.c (hash_open): Ditto. + * libc/search/hash_page.c (open_tmp): Ditto. + * libc/reent/Makefile.am: Add fcntlr.c. + * libc/reent/Makefile.in: Regenerated. + * libc/reent/fcntlr.c: New file. + * libc/stdio/fdopen.c (_fdopen_r): Change to call _fcntl_r + instead of _fcntl when HAVE_FCNTL flag is set. + * libc/syscalls/sysfcntl.c (fcntl): Check for HAVE_FCNTL flag + to see if _fcntl or _fcntl_r should be called. If flag is not + set, default to ENOSYS stub. + 2002-09-16 Jeff Johnston <jjohnstn@redhat.com> * libc/include/wchar.h (mbstate_t): Change protective flag to diff --git a/newlib/libc/posix/opendir.c b/newlib/libc/posix/opendir.c index de14edc..ce59cf4 100644 --- a/newlib/libc/posix/opendir.c +++ b/newlib/libc/posix/opendir.c @@ -52,10 +52,14 @@ opendir(name) { register DIR *dirp; register int fd; + int rc = 0; if ((fd = open(name, 0)) == -1) return NULL; - if (fcntl(fd, F_SETFD, 1) == -1 || +#ifdef HAVE_FCNTL + rc = fcntl(fd, F_SETFD, 1); +#endif + if (rc == -1 || (dirp = (DIR *)malloc(sizeof(DIR))) == NULL) { close (fd); return NULL; diff --git a/newlib/libc/reent/Makefile.am b/newlib/libc/reent/Makefile.am index a94be9b..dd396c3 100644 --- a/newlib/libc/reent/Makefile.am +++ b/newlib/libc/reent/Makefile.am @@ -33,6 +33,7 @@ GENERAL_SOURCES = \ closer.c \ reent.c \ impure.c \ + fcntlr.c \ fstatr.c \ getreent.c \ linkr.c \ @@ -69,6 +70,7 @@ CHEWOUT_FILES = \ closer.def \ reent.def \ execr.def \ + fcntlr.def \ fstatr.def \ linkr.def \ lseekr.def \ diff --git a/newlib/libc/reent/Makefile.in b/newlib/libc/reent/Makefile.in index 8333eaf..07f237c 100644 --- a/newlib/libc/reent/Makefile.in +++ b/newlib/libc/reent/Makefile.in @@ -130,6 +130,7 @@ GENERAL_SOURCES = \ closer.c \ reent.c \ impure.c \ + fcntlr.c \ fstatr.c \ getreent.c \ linkr.c \ @@ -162,6 +163,7 @@ CHEWOUT_FILES = \ closer.def \ reent.def \ execr.def \ + fcntlr.def \ fstatr.def \ linkr.def \ lseekr.def \ @@ -192,17 +194,17 @@ DEFS = @DEFS@ -I. -I$(srcdir) CPPFLAGS = @CPPFLAGS@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@lib_a_OBJECTS = closer.$(OBJEXT) reent.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@impure.$(OBJEXT) fstatr.$(OBJEXT) getreent.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@linkr.$(OBJEXT) lseekr.$(OBJEXT) openr.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@readr.$(OBJEXT) signalr.$(OBJEXT) signgam.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sbrkr.$(OBJEXT) statr.$(OBJEXT) timer.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@unlinkr.$(OBJEXT) writer.$(OBJEXT) +@USE_LIBTOOL_FALSE@impure.$(OBJEXT) fcntlr.$(OBJEXT) fstatr.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getreent.$(OBJEXT) linkr.$(OBJEXT) lseekr.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@openr.$(OBJEXT) readr.$(OBJEXT) signalr.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@signgam.$(OBJEXT) sbrkr.$(OBJEXT) statr.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@timer.$(OBJEXT) unlinkr.$(OBJEXT) writer.$(OBJEXT) LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@libreent_la_OBJECTS = closer.lo reent.lo impure.lo \ -@USE_LIBTOOL_TRUE@fstatr.lo getreent.lo linkr.lo lseekr.lo openr.lo \ -@USE_LIBTOOL_TRUE@readr.lo signalr.lo signgam.lo sbrkr.lo statr.lo \ -@USE_LIBTOOL_TRUE@timer.lo unlinkr.lo writer.lo +@USE_LIBTOOL_TRUE@fcntlr.lo fstatr.lo getreent.lo linkr.lo lseekr.lo \ +@USE_LIBTOOL_TRUE@openr.lo readr.lo signalr.lo signgam.lo sbrkr.lo \ +@USE_LIBTOOL_TRUE@statr.lo timer.lo unlinkr.lo writer.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/newlib/libc/reent/fcntlr.c b/newlib/libc/reent/fcntlr.c new file mode 100644 index 0000000..e64dfe2 --- /dev/null +++ b/newlib/libc/reent/fcntlr.c @@ -0,0 +1,65 @@ +/* Reentrant versions of fcntl system call. This implementation just + calls the fcntl system call. */ + +#include <reent.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <_syslist.h> + +/* Some targets provides their own versions of these functions. Those + targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ + +#ifdef _REENT_ONLY +#ifndef REENTRANT_SYSCALLS_PROVIDED +#define REENTRANT_SYSCALLS_PROVIDED +#endif +#endif + +#ifndef REENTRANT_SYSCALLS_PROVIDED + +/* We use the errno variable used by the system dependent layer. */ +#undef errno +extern int errno; + +/* +FUNCTION + <<_fcntl_r>>---Reentrant version of fcntl + +INDEX + _fcntl_r + +ANSI_SYNOPSIS + #include <reent.h> + int _fcntl_r(struct _reent *<[ptr]>, + int <[fd]>, int <[cmd]>, <[arg]>); + +TRAD_SYNOPSIS + #include <reent.h> + int _fcntl_r(<[ptr]>, <[fd]>, <[cmd]>, <[arg]>) + struct _reent *<[ptr]>; + int <[fd]>; + int <[cmd]>; + int <[arg]>; + +DESCRIPTION + This is a reentrant version of <<fcntl>>. It + takes a pointer to the global data block, which holds + <<errno>>. +*/ + +int +_fcntl_r (ptr, fd, cmd, arg) + struct _reent *ptr; + int fd; + int cmd; + int arg; +{ + int ret; + + errno = 0; + if ((ret = _fcntl (fd, cmd, arg)) == -1 && errno != 0) + ptr->_errno = errno; + return ret; +} + +#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ diff --git a/newlib/libc/search/hash.c b/newlib/libc/search/hash.c index 3aa3eb7..10b4ded 100644 --- a/newlib/libc/search/hash.c +++ b/newlib/libc/search/hash.c @@ -143,7 +143,9 @@ __hash_open(file, flags, mode, info, dflags) fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) new_table = 1; +#ifdef HAVE_FCNTL (void)fcntl(hashp->fp, F_SETFD, 1); +#endif } if (new_table) { if (!(hashp = init_hash(hashp, file, (HASHINFO *)info))) diff --git a/newlib/libc/search/hash_page.c b/newlib/libc/search/hash_page.c index cffb20a..68ab9db 100644 --- a/newlib/libc/search/hash_page.c +++ b/newlib/libc/search/hash_page.c @@ -869,7 +869,9 @@ open_temp(hashp) (void)sigprocmask(SIG_BLOCK, &set, &oset); if ((hashp->fp = mkstemp(namestr)) != -1) { (void)unlink(namestr); +#ifdef HAVE_FCNTL (void)fcntl(hashp->fp, F_SETFD, 1); +#endif } (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); return (hashp->fp != -1 ? 0 : -1); diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index bd4018b..0db6062 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -64,7 +64,7 @@ _DEFUN (_fdopen_r, (ptr, fd, mode), /* make sure the mode the user wants is a subset of the actual mode */ #ifdef HAVE_FCNTL - if ((fdflags = _fcntl (fd, F_GETFL, 0)) < 0) + if ((fdflags = _fcntl_r (ptr, fd, F_GETFL, 0)) < 0) return 0; fdmode = fdflags & O_ACCMODE; if (fdmode != O_RDWR && (fdmode != (oflags & O_ACCMODE))) diff --git a/newlib/libc/syscalls/sysfcntl.c b/newlib/libc/syscalls/sysfcntl.c index 23e1d83..4d1c57c 100644 --- a/newlib/libc/syscalls/sysfcntl.c +++ b/newlib/libc/syscalls/sysfcntl.c @@ -2,6 +2,7 @@ /* only called from stdio/fdopen.c, so arg can be int. */ #include <reent.h> +#include <errno.h> int fcntl (fd, flag, arg) @@ -9,9 +10,14 @@ fcntl (fd, flag, arg) int flag; int arg; { -#ifdef REENTRANT_SYSCALLS_PROVIDED +#ifdef HAVE_FCNTL +# ifdef REENTRANT_SYSCALLS_PROVIDED return _fcntl_r (_REENT, fd, flag, arg); -#else +# else return _fcntl (fd, flag, arg); -#endif +# endif +#else /* !HAVE_FCNTL */ + errno = ENOSYS; + return -1; +#endif /& !HAVE_FCNTL */ } |