summaryrefslogtreecommitdiff
path: root/newlib/libc/reent/readr.c
diff options
context:
space:
mode:
authorChristopher Faylor <me+cygwin@cgf.cx>2000-02-17 19:39:46 +0000
committerChristopher Faylor <me+cygwin@cgf.cx>2000-02-17 19:39:46 +0000
commit43b55bace5fad27af5da7a99784667363b92c45d (patch)
tree17fe82f6ba0d93b76d10dd73d4945ab81b69db40 /newlib/libc/reent/readr.c
parent8dabd7496a9eeaca2a7180c0a176059ba9229bb2 (diff)
downloadgdb-43b55bace5fad27af5da7a99784667363b92c45d.tar.gz
import newlib-2000-02-17 snapshotnewlib-2000-02-17SNAPSHOT
Diffstat (limited to 'newlib/libc/reent/readr.c')
-rw-r--r--newlib/libc/reent/readr.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/newlib/libc/reent/readr.c b/newlib/libc/reent/readr.c
new file mode 100644
index 00000000000..e3deca9a718
--- /dev/null
+++ b/newlib/libc/reent/readr.c
@@ -0,0 +1,63 @@
+/* Reentrant versions of read system call. */
+
+#include <reent.h>
+#include <unistd.h>
+#include <_syslist.h>
+
+/* Some targets provides their own versions of this 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
+ <<_read_r>>---Reentrant version of read
+
+INDEX
+ _read_r
+
+ANSI_SYNOPSIS
+ #include <reent.h>
+ long _read_r(struct _reent *<[ptr]>,
+ int <[fd]>, void *<[buf]>, size_t <[cnt]>);
+
+TRAD_SYNOPSIS
+ #include <reent.h>
+ long _read_r(<[ptr]>, <[fd]>, <[buf]>, <[cnt]>)
+ struct _reent *<[ptr]>;
+ int <[fd]>;
+ char *<[buf]>;
+ size_t <[cnt]>;
+
+DESCRIPTION
+ This is a reentrant version of <<read>>. It
+ takes a pointer to the global data block, which holds
+ <<errno>>.
+*/
+
+long
+_read_r (ptr, fd, buf, cnt)
+ struct _reent *ptr;
+ int fd;
+ _PTR buf;
+ size_t cnt;
+{
+ long ret;
+
+ errno = 0;
+ if ((ret = _read (fd, buf, cnt)) == -1 && errno != 0)
+ ptr->_errno = errno;
+ return ret;
+}
+
+#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */