Skip to content

Commit 8af2292

Browse files
committed
Update for the recent WASI function renamings.
1 parent fa4134e commit 8af2292

36 files changed

Lines changed: 261 additions & 164 deletions

expected/wasm32-wasi/predefined-macros.txt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3518,42 +3518,42 @@
35183518
#define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
35193519
#define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
35203520
#define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
3521-
#define __WASI_FILE_STAT_SET_ATIM (UINT16_C(0x0001))
3522-
#define __WASI_FILE_STAT_SET_ATIM_NOW (UINT16_C(0x0002))
3523-
#define __WASI_FILE_STAT_SET_MTIM (UINT16_C(0x0004))
3524-
#define __WASI_FILE_STAT_SET_MTIM_NOW (UINT16_C(0x0008))
35253521
#define __WASI_LOOKUP_SYMLINK_FOLLOW (UINT32_C(0x00000001))
35263522
#define __WASI_O_CREAT (UINT16_C(0x0001))
35273523
#define __WASI_O_DIRECTORY (UINT16_C(0x0002))
35283524
#define __WASI_O_EXCL (UINT16_C(0x0004))
35293525
#define __WASI_O_TRUNC (UINT16_C(0x0008))
3526+
#define __WASI_PATH_FILESTAT_SET_ATIM (UINT16_C(0x0001))
3527+
#define __WASI_PATH_FILESTAT_SET_ATIM_NOW (UINT16_C(0x0002))
3528+
#define __WASI_PATH_FILESTAT_SET_MTIM (UINT16_C(0x0004))
3529+
#define __WASI_PATH_FILESTAT_SET_MTIM_NOW (UINT16_C(0x0008))
3530+
#define __WASI_RIGHT_FD_ADVISE (UINT64_C(0x0000000000000080))
3531+
#define __WASI_RIGHT_FD_ALLOCATE (UINT64_C(0x0000000000000100))
35303532
#define __WASI_RIGHT_FD_DATASYNC (UINT64_C(0x0000000000000001))
3533+
#define __WASI_RIGHT_FD_FDSTAT_SET_FLAGS (UINT64_C(0x0000000000000008))
3534+
#define __WASI_RIGHT_FD_FILESTAT_GET (UINT64_C(0x0000000000200000))
3535+
#define __WASI_RIGHT_FD_FILESTAT_SET_SIZE (UINT64_C(0x0000000000400000))
3536+
#define __WASI_RIGHT_FD_FILESTAT_SET_TIMES (UINT64_C(0x0000000000800000))
35313537
#define __WASI_RIGHT_FD_READ (UINT64_C(0x0000000000000002))
3538+
#define __WASI_RIGHT_FD_READDIR (UINT64_C(0x0000000000004000))
35323539
#define __WASI_RIGHT_FD_SEEK (UINT64_C(0x0000000000000004))
3533-
#define __WASI_RIGHT_FD_STAT_SET_FLAGS (UINT64_C(0x0000000000000008))
35343540
#define __WASI_RIGHT_FD_SYNC (UINT64_C(0x0000000000000010))
35353541
#define __WASI_RIGHT_FD_TELL (UINT64_C(0x0000000000000020))
35363542
#define __WASI_RIGHT_FD_WRITE (UINT64_C(0x0000000000000040))
3537-
#define __WASI_RIGHT_FILE_ADVISE (UINT64_C(0x0000000000000080))
3538-
#define __WASI_RIGHT_FILE_ALLOCATE (UINT64_C(0x0000000000000100))
3539-
#define __WASI_RIGHT_FILE_CREATE_DIRECTORY (UINT64_C(0x0000000000000200))
3540-
#define __WASI_RIGHT_FILE_CREATE_FILE (UINT64_C(0x0000000000000400))
3541-
#define __WASI_RIGHT_FILE_FSTAT_GET (UINT64_C(0x0000000000200000))
3542-
#define __WASI_RIGHT_FILE_FSTAT_SET_SIZE (UINT64_C(0x0000000000400000))
3543-
#define __WASI_RIGHT_FILE_FSTAT_SET_TIMES (UINT64_C(0x0000000000800000))
3544-
#define __WASI_RIGHT_FILE_LINK_SOURCE (UINT64_C(0x0000000000000800))
3545-
#define __WASI_RIGHT_FILE_LINK_TARGET (UINT64_C(0x0000000000001000))
3546-
#define __WASI_RIGHT_FILE_OPEN (UINT64_C(0x0000000000002000))
3547-
#define __WASI_RIGHT_FILE_READDIR (UINT64_C(0x0000000000004000))
3548-
#define __WASI_RIGHT_FILE_READLINK (UINT64_C(0x0000000000008000))
3549-
#define __WASI_RIGHT_FILE_RENAME_SOURCE (UINT64_C(0x0000000000010000))
3550-
#define __WASI_RIGHT_FILE_RENAME_TARGET (UINT64_C(0x0000000000020000))
3551-
#define __WASI_RIGHT_FILE_STAT_GET (UINT64_C(0x0000000000040000))
3552-
#define __WASI_RIGHT_FILE_STAT_SET_SIZE (UINT64_C(0x0000000000080000))
3553-
#define __WASI_RIGHT_FILE_STAT_SET_TIMES (UINT64_C(0x0000000000100000))
3554-
#define __WASI_RIGHT_FILE_SYMLINK (UINT64_C(0x0000000001000000))
3555-
#define __WASI_RIGHT_FILE_UNLINK_DIRECTORY (UINT64_C(0x0000000004000000))
3556-
#define __WASI_RIGHT_FILE_UNLINK_FILE (UINT64_C(0x0000000002000000))
3543+
#define __WASI_RIGHT_PATH_CREATE_DIRECTORY (UINT64_C(0x0000000000000200))
3544+
#define __WASI_RIGHT_PATH_CREATE_FILE (UINT64_C(0x0000000000000400))
3545+
#define __WASI_RIGHT_PATH_FILESTAT_GET (UINT64_C(0x0000000000040000))
3546+
#define __WASI_RIGHT_PATH_FILESTAT_SET_SIZE (UINT64_C(0x0000000000080000))
3547+
#define __WASI_RIGHT_PATH_FILESTAT_SET_TIMES (UINT64_C(0x0000000000100000))
3548+
#define __WASI_RIGHT_PATH_LINK_SOURCE (UINT64_C(0x0000000000000800))
3549+
#define __WASI_RIGHT_PATH_LINK_TARGET (UINT64_C(0x0000000000001000))
3550+
#define __WASI_RIGHT_PATH_OPEN (UINT64_C(0x0000000000002000))
3551+
#define __WASI_RIGHT_PATH_READLINK (UINT64_C(0x0000000000008000))
3552+
#define __WASI_RIGHT_PATH_RENAME_SOURCE (UINT64_C(0x0000000000010000))
3553+
#define __WASI_RIGHT_PATH_RENAME_TARGET (UINT64_C(0x0000000000020000))
3554+
#define __WASI_RIGHT_PATH_SYMLINK (UINT64_C(0x0000000001000000))
3555+
#define __WASI_RIGHT_PATH_UNLINK_DIRECTORY (UINT64_C(0x0000000002000000))
3556+
#define __WASI_RIGHT_PATH_UNLINK_FILE (UINT64_C(0x0000000004000000))
35573557
#define __WASI_RIGHT_POLL_FD_READWRITE (UINT64_C(0x0000000008000000))
35583558
#define __WASI_RIGHT_SOCK_SHUTDOWN (UINT64_C(0x0000000010000000))
35593559
#define __WASI_SHUT_RD (UINT8_C(0x01))

expected/wasm32-wasi/undefined-symbols.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,33 @@ __trunctfsf2
2525
__unordtf2
2626
__wasi_clock_res_get
2727
__wasi_clock_time_get
28+
__wasi_fd_advise
29+
__wasi_fd_allocate
2830
__wasi_fd_close
2931
__wasi_fd_datasync
32+
__wasi_fd_fdstat_get
33+
__wasi_fd_fdstat_set_flags
34+
__wasi_fd_filestat_get
35+
__wasi_fd_filestat_set_size
36+
__wasi_fd_filestat_set_times
3037
__wasi_fd_pread
3138
__wasi_fd_pwrite
3239
__wasi_fd_read
40+
__wasi_fd_readdir
3341
__wasi_fd_renumber
3442
__wasi_fd_seek
35-
__wasi_fd_stat_get
36-
__wasi_fd_stat_set_flags
3743
__wasi_fd_sync
3844
__wasi_fd_write
39-
__wasi_file_advise
40-
__wasi_file_allocate
41-
__wasi_file_create_directory
42-
__wasi_file_fstat_get
43-
__wasi_file_fstat_set_size
44-
__wasi_file_fstat_set_times
45-
__wasi_file_link
46-
__wasi_file_open
47-
__wasi_file_readdir
48-
__wasi_file_readlink
49-
__wasi_file_rename
50-
__wasi_file_stat_get
51-
__wasi_file_stat_set_times
52-
__wasi_file_symlink
53-
__wasi_file_unlink_directory
54-
__wasi_file_unlink_file
45+
__wasi_path_create_directory
46+
__wasi_path_filestat_get
47+
__wasi_path_filestat_set_times
48+
__wasi_path_link
49+
__wasi_path_open
50+
__wasi_path_readlink
51+
__wasi_path_rename
52+
__wasi_path_symlink
53+
__wasi_path_unlink_directory
54+
__wasi_path_unlink_file
5555
__wasi_poll_oneoff
5656
__wasi_proc_exit
5757
__wasi_random_get

libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ DIR *fdopendir(int fd) {
2525
// Ensure that this is really a directory by already loading the first
2626
// chunk of data.
2727
__wasi_errno_t error =
28+
#ifdef __wasilibc_unmodified_upstream
2829
__wasi_file_readdir(fd, dirp->buffer, DIRENT_DEFAULT_BUFFER_SIZE,
30+
#else
31+
__wasi_fd_readdir(fd, dirp->buffer, DIRENT_DEFAULT_BUFFER_SIZE,
32+
#endif
2933
__WASI_DIRCOOKIE_START, &dirp->buffer_used);
3034
if (error != 0) {
3135
free(dirp->buffer);

libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ struct dirent *readdir(DIR *dirp) {
9191

9292
// Load more directory entries and continue.
9393
__wasi_errno_t error =
94+
#ifdef __wasilibc_unmodified_upstream
9495
__wasi_file_readdir(dirp->fd, dirp->buffer, dirp->buffer_size,
96+
#else
97+
__wasi_fd_readdir(dirp->fd, dirp->buffer, dirp->buffer_size,
98+
#endif
9599
dirp->cookie, &dirp->buffer_used);
96100
if (error != 0) {
97101
errno = error;

libc-bottom-half/cloudlibc/src/libc/dirent/scandirat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ int scandirat(int dirfd, const char *dir, struct dirent ***namelist,
114114

115115
read_entries:;
116116
// Load more directory entries and continue.
117+
#ifdef __wasilibc_unmodified_upstream
117118
__wasi_errno_t error = __wasi_file_readdir(fd, buffer, buffer_size,
119+
#else
120+
__wasi_errno_t error = __wasi_fd_readdir(fd, buffer, buffer_size,
121+
#endif
118122
cookie, &buffer_used);
119123
if (error != 0) {
120124
errno = error;

libc-bottom-half/cloudlibc/src/libc/fcntl/fcntl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ int fcntl(int fildes, int cmd, ...) {
1818
case F_GETFL: {
1919
// Obtain the flags and the rights of the descriptor.
2020
__wasi_fdstat_t fds;
21+
#ifdef __wasilibc_unmodified_upstream
2122
__wasi_errno_t error = __wasi_fd_stat_get(fildes, &fds);
23+
#else
24+
__wasi_errno_t error = __wasi_fd_fdstat_get(fildes, &fds);
25+
#endif
2226
if (error != 0) {
2327
errno = error;
2428
return -1;
@@ -27,7 +31,11 @@ int fcntl(int fildes, int cmd, ...) {
2731
// Roughly approximate the access mode by converting the rights.
2832
int oflags = fds.fs_flags;
2933
if ((fds.fs_rights_base &
34+
#ifdef __wasilibc_unmodified_upstream
3035
(__WASI_RIGHT_FD_READ | __WASI_RIGHT_FILE_READDIR)) != 0) {
36+
#else
37+
(__WASI_RIGHT_FD_READ | __WASI_RIGHT_FD_READDIR)) != 0) {
38+
#endif
3139
if ((fds.fs_rights_base & __WASI_RIGHT_FD_WRITE) != 0)
3240
oflags |= O_RDWR;
3341
else
@@ -57,7 +65,7 @@ int fcntl(int fildes, int cmd, ...) {
5765
#else
5866
__wasi_fdflags_t fs_flags = flags & 0xfff;
5967
__wasi_errno_t error =
60-
__wasi_fd_stat_set_flags(fildes, fs_flags);
68+
__wasi_fd_fdstat_set_flags(fildes, fs_flags);
6169
#endif
6270
if (error != 0) {
6371
errno = error;

libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ int openat(int fd, const char *path, int oflag, ...) {
2828
__wasi_rights_t min = 0;
2929
__wasi_rights_t max =
3030
~(__WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_READ |
31-
__WASI_RIGHT_FD_WRITE | __WASI_RIGHT_FILE_ALLOCATE |
3231
#ifdef __wasilibc_unmodified_upstream // fstat
32+
__WASI_RIGHT_FD_WRITE | __WASI_RIGHT_FILE_ALLOCATE |
3333
__WASI_RIGHT_FILE_READDIR | __WASI_RIGHT_FILE_STAT_FPUT_SIZE |
3434
#else
35-
__WASI_RIGHT_FILE_READDIR | __WASI_RIGHT_FILE_FSTAT_SET_SIZE |
35+
__WASI_RIGHT_FD_WRITE | __WASI_RIGHT_FD_ALLOCATE |
36+
__WASI_RIGHT_FD_READDIR | __WASI_RIGHT_FD_FILESTAT_SET_SIZE |
3637
#endif
3738
#ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
3839
__WASI_RIGHT_MEM_MAP_EXEC);
@@ -44,25 +45,28 @@ int openat(int fd, const char *path, int oflag, ...) {
4445
case O_RDWR:
4546
case O_WRONLY:
4647
if ((oflag & O_RDONLY) != 0) {
48+
#ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
4749
min |= (oflag & O_DIRECTORY) == 0 ? __WASI_RIGHT_FD_READ
4850
: __WASI_RIGHT_FILE_READDIR;
4951
max |= __WASI_RIGHT_FD_READ | __WASI_RIGHT_FILE_READDIR |
50-
#ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
5152
__WASI_RIGHT_MEM_MAP_EXEC;
5253
#else
53-
0;
54+
min |= (oflag & O_DIRECTORY) == 0 ? __WASI_RIGHT_FD_READ
55+
: __WASI_RIGHT_FD_READDIR;
56+
max |= __WASI_RIGHT_FD_READ | __WASI_RIGHT_FD_READDIR;
5457
#endif
5558
}
5659
if ((oflag & O_WRONLY) != 0) {
5760
min |= __WASI_RIGHT_FD_WRITE;
5861
if ((oflag & O_APPEND) == 0)
5962
min |= __WASI_RIGHT_FD_SEEK;
6063
max |= __WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_WRITE |
61-
__WASI_RIGHT_FILE_ALLOCATE |
6264
#ifdef __wasilibc_unmodified_upstream // fstat
65+
__WASI_RIGHT_FILE_ALLOCATE |
6366
__WASI_RIGHT_FILE_STAT_FPUT_SIZE;
6467
#else
65-
__WASI_RIGHT_FILE_FSTAT_SET_SIZE;
68+
__WASI_RIGHT_FD_ALLOCATE |
69+
__WASI_RIGHT_FD_FILESTAT_SET_SIZE;
6670
#endif
6771
}
6872
break;
@@ -82,7 +86,11 @@ int openat(int fd, const char *path, int oflag, ...) {
8286

8387
// Ensure that we can actually obtain the minimal rights needed.
8488
__wasi_fdstat_t fsb_cur;
89+
#ifdef __wasilibc_unmodified_upstream
8590
__wasi_errno_t error = __wasi_fd_stat_get(fd, &fsb_cur);
91+
#else
92+
__wasi_errno_t error = __wasi_fd_fdstat_get(fd, &fsb_cur);
93+
#endif
8694
if (error != 0) {
8795
errno = error;
8896
return -1;
@@ -124,7 +132,7 @@ int openat(int fd, const char *path, int oflag, ...) {
124132
__wasi_rights_t fs_rights_base = max & fsb_cur.fs_rights_inheriting;
125133
__wasi_rights_t fs_rights_inheriting = fsb_cur.fs_rights_inheriting;
126134
__wasi_fd_t newfd;
127-
error = __wasi_file_open(fd, lookup_flags, path, strlen(path),
135+
error = __wasi_path_open(fd, lookup_flags, path, strlen(path),
128136
(oflag >> 12) & 0xfff,
129137
fs_rights_base, fs_rights_inheriting, fs_flags,
130138
&newfd);

libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fadvise.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ static_assert(POSIX_FADV_WILLNEED == __WASI_ADVICE_WILLNEED,
2020
int posix_fadvise(int fd, off_t offset, off_t len, int advice) {
2121
if (offset < 0 || len < 0)
2222
return EINVAL;
23+
#ifdef __wasilibc_unmodified_upstream
2324
return __wasi_file_advise(fd, offset, len, advice);
25+
#else
26+
return __wasi_fd_advise(fd, offset, len, advice);
27+
#endif
2428
}

libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fallocate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99
int posix_fallocate(int fd, off_t offset, off_t len) {
1010
if (offset < 0 || len < 0)
1111
return EINVAL;
12+
#ifdef __wasilibc_unmodified_upstream
1213
return __wasi_file_allocate(fd, offset, len);
14+
#else
15+
return __wasi_fd_allocate(fd, offset, len);
16+
#endif
1317
}

libc-bottom-half/cloudlibc/src/libc/poll/poll.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) {
7373
// Execute poll().
7474
__wasi_event_t events[nevents];
7575
__wasi_errno_t error =
76+
#ifdef __wasilibc_unmodified_upstream
77+
__wasi_poll(subscriptions, events, nevents, &nevents);
78+
#else
7679
__wasi_poll_oneoff(subscriptions, events, nevents, &nevents);
80+
#endif
7781
if (error != 0) {
7882
errno = error;
7983
return -1;

0 commit comments

Comments
 (0)