diff options
Diffstat (limited to 'newlib/libc/reent')
-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 |
3 files changed, 77 insertions, 8 deletions
diff --git a/newlib/libc/reent/Makefile.am b/newlib/libc/reent/Makefile.am index a94be9b5e..dd396c33c 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 8333eafe5..07f237c7a 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 000000000..e64dfe28a --- /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) */ |