]>
Commit | Line | Data |
---|---|---|
320054e8 DG |
1 | // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ |
2 | // | |
3 | // SPDX-License-Identifier: BSD-2-Clause | |
4 | ||
5 | #include <assert.h> | |
446cb3f1 | 6 | #include <wasi/api.h> |
320054e8 DG |
7 | #include <errno.h> |
8 | #include <unistd.h> | |
9 | ||
10 | static_assert(SEEK_CUR == __WASI_WHENCE_CUR, "Value mismatch"); | |
11 | static_assert(SEEK_END == __WASI_WHENCE_END, "Value mismatch"); | |
12 | static_assert(SEEK_SET == __WASI_WHENCE_SET, "Value mismatch"); | |
13 | ||
79a9b408 | 14 | off_t __lseek(int fildes, off_t offset, int whence) { |
320054e8 DG |
15 | __wasi_filesize_t new_offset; |
16 | __wasi_errno_t error = | |
17 | __wasi_fd_seek(fildes, offset, whence, &new_offset); | |
18 | if (error != 0) { | |
19 | errno = error == ENOTCAPABLE ? ESPIPE : error; | |
20 | return -1; | |
21 | } | |
22 | return new_offset; | |
23 | } | |
79a9b408 | 24 | |
79a9b408 | 25 | extern __typeof(__lseek) lseek __attribute__((weak, alias("__lseek"))); |