summaryrefslogtreecommitdiff
path: root/libc/reent/readr.c
diff options
context:
space:
mode:
authorProjectRevoTPP <projectrevotpp@hotmail.com>2017-12-20 16:34:35 -0500
committerProjectRevoTPP <projectrevotpp@hotmail.com>2017-12-20 16:34:35 -0500
commit48ef7704c03e7e554c05de01bf8d1d70c16cb6f4 (patch)
tree34d52513de6c903b4f52ef87d885c73472daf469 /libc/reent/readr.c
parentf49e7cbb33e6e27b0ce5eb35244d7241c800a7c1 (diff)
add libc building to agbcc.
Diffstat (limited to 'libc/reent/readr.c')
-rw-r--r--libc/reent/readr.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/libc/reent/readr.c b/libc/reent/readr.c
new file mode 100644
index 0000000..e3deca9
--- /dev/null
+++ b/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) */