aboutsummaryrefslogtreecommitdiff
path: root/tls/compat/pread.c
diff options
context:
space:
mode:
authorkinichiro <kinichiro.inoguchi@gmail.com>2018-02-25 01:59:39 +0900
committerkinichiro <kinichiro.inoguchi@gmail.com>2018-02-25 21:56:05 +0900
commit3681d02253d29229e265720984ce81a35206de4c (patch)
tree95590bed234fb09e40e14feb5cdb6c0120f07334 /tls/compat/pread.c
parent47781e69e2946011ea7bd0723e98a2fedff88980 (diff)
downloadportable-3681d02253d29229e265720984ce81a35206de4c.tar.gz
portable-3681d02253d29229e265720984ce81a35206de4c.tar.bz2
portable-3681d02253d29229e265720984ce81a35206de4c.zip
Add compat bits for libtls on Windows
Diffstat (limited to 'tls/compat/pread.c')
-rw-r--r--tls/compat/pread.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tls/compat/pread.c b/tls/compat/pread.c
new file mode 100644
index 0000000..f0c9a2f
--- /dev/null
+++ b/tls/compat/pread.c
@@ -0,0 +1,23 @@
1/*
2 * Public domain
3 *
4 * Kinichiro Inoguchi <inoguchi@openbsd.org>
5 */
6
7#include <unistd.h>
8
9ssize_t
10pread(int d, void *buf, size_t nbytes, off_t offset)
11{
12 off_t cpos, opos, rpos;
13 ssize_t bytes;
14 if((cpos = lseek(d, 0, SEEK_CUR)) == -1)
15 return -1;
16 if((opos = lseek(d, offset, SEEK_SET)) == -1)
17 return -1;
18 if((bytes = read(d, buf, nbytes)) == -1)
19 return -1;
20 if((rpos = lseek(d, cpos, SEEK_SET)) == -1)
21 return -1;
22 return bytes;
23}