Skip to content

Commit 649ad92

Browse files
committed
Fix build failures
1 parent 51421f2 commit 649ad92

File tree

5 files changed

+33
-30
lines changed

5 files changed

+33
-30
lines changed

system/lib/libc/emscripten_mmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int __syscall_msync(void *addr, size_t len, int flags) {
102102
return _msync_js(addr, len, map->prot, map->flags, map->fd, map->offset);
103103
}
104104

105-
void *__syscall_mmap2(void *addr, size_t len, int prot, int flags, int fd, off_t offset) {
105+
intptr_t __syscall_mmap2(void *addr, size_t len, int prot, int flags, int fd, off_t offset) {
106106
if (addr != 0) {
107107
// We don't currently support location hints for the address of the mapping
108108
return -EINVAL;
@@ -147,5 +147,5 @@ void *__syscall_mmap2(void *addr, size_t len, int prot, int flags, int fd, off_t
147147
mappings = new_map;
148148
UNLOCK(lock);
149149

150-
return new_map->addr;
150+
return (intptr_t)new_map->addr;
151151
}

system/lib/libc/emscripten_syscall_stubs.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ weak mode_t __syscall_umask(mode_t mask) {
119119
return old;
120120
}
121121

122-
weak int __syscall_getrusage(int who, struct rusage *usage) {
122+
weak int __syscall_getrusage(int who, void *usage) {
123123
REPORT(getrusage);
124-
memset(usage, 0, sizeof(*usage));
125-
usage->ru_utime.tv_sec = 1;
126-
usage->ru_utime.tv_usec = 2;
127-
usage->ru_stime.tv_sec = 3;
128-
usage->ru_stime.tv_usec = 4;
124+
struct rusage *u = (struct rusage *)usage;
125+
memset(u, 0, sizeof(*u));
126+
u->ru_utime.tv_sec = 1;
127+
u->ru_utime.tv_usec = 2;
128+
u->ru_stime.tv_sec = 3;
129+
u->ru_stime.tv_usec = 4;
129130
return 0;
130131
}
131132

@@ -247,10 +248,10 @@ weak int __syscall_setsockopt(int sockfd, int level, int optname, const void *op
247248
UNIMPLEMENTED(acct, (const char *filename))
248249
UNIMPLEMENTED(mincore, (void *addr, size_t length, unsigned char *vec))
249250
UNIMPLEMENTED(pipe2, (int pipefd[2], int flags))
250-
UNIMPLEMENTED(pselect6, (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timespec *ts, const void *mask))
251+
UNIMPLEMENTED(pselect6, (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, const void *ts, const void *mask))
251252
UNIMPLEMENTED(recvmmsg, (int sockfd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout))
252253
UNIMPLEMENTED(sendmmsg, (int sockfd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags))
253254
UNIMPLEMENTED(shutdown, (int sockfd, int how, ...))
254255
UNIMPLEMENTED(socketpair, (int domain, int type, int protocol, int fd[2], ...))
255256
UNIMPLEMENTED(socketcall, (int call, long args[6]))
256-
UNIMPLEMENTED(wait4, (pid_t pid, int *wstatus, int options, struct rusage *rusage))
257+
UNIMPLEMENTED(wait4, (pid_t pid, int *wstatus, int options, void *rusage))

system/lib/libc/musl/arch/emscripten/syscall_arch.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ mode_t __syscall_umask(mode_t mask);
3737
pid_t __syscall_getppid(void);
3838
pid_t __syscall_getpgrp(void);
3939
pid_t __syscall_setsid(void);
40-
int __syscall_getrusage(int who, struct rusage *usage);
40+
int __syscall_getrusage(int who, void *usage);
4141
int __syscall_munmap(void *addr, size_t len);
4242
int __syscall_fchmod(int fd, mode_t mode);
4343
int __syscall_getpriority(int which, id_t who);
4444
int __syscall_setpriority(int which, id_t who, int prio);
4545
int __syscall_socketcall(int call, long args[6]);
46-
pid_t __syscall_wait4(pid_t pid, int *wstatus, int options, struct rusage *rusage);
46+
pid_t __syscall_wait4(pid_t pid, int *wstatus, int options, void *rusage);
4747
int __syscall_setdomainname(const char *name, size_t len);
4848
int __syscall_uname(struct utsname *buf);
4949
int __syscall_mprotect(size_t start, size_t len, int prot);
5050
pid_t __syscall_getpgid(pid_t pid);
5151
int __syscall_fchdir(int fd);
52-
int __syscall__newselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
52+
int __syscall__newselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, void *timeout);
5353
int __syscall_msync(void *addr, size_t len, int flags);
5454
pid_t __syscall_getsid(pid_t pid);
5555
int __syscall_fdatasync(int fd);
@@ -60,7 +60,7 @@ int __syscall_munlockall(void);
6060
int __syscall_mremap(void *old_addr, size_t old_size, size_t new_size, int flags, void *new_addr);
6161
int __syscall_poll(struct pollfd *fds, nfds_t nfds, int timeout);
6262
int __syscall_getcwd(char *buf, size_t size);
63-
void *__syscall_mmap2(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
63+
intptr_t __syscall_mmap2(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
6464
int __syscall_truncate64(const char *path, off_t length);
6565
int __syscall_ftruncate64(int fd, off_t length);
6666
int __syscall_stat64(const char *path, struct stat *buf);
@@ -82,7 +82,7 @@ int __syscall_setuid32(uid_t uid);
8282
int __syscall_setgid32(gid_t gid);
8383
int __syscall_mincore(void *addr, size_t length, unsigned char *vec);
8484
int __syscall_madvise(void *addr, size_t length, int advice);
85-
int __syscall_getdents64(int fd, struct dirent *dirp, size_t count);
85+
int __syscall_getdents64(int fd, void *dirp, size_t count);
8686
int __syscall_fcntl64(int fd, int cmd, ...);
8787
int __syscall_statfs64(const char *path, size_t size, struct statfs *buf);
8888
int __syscall_fstatfs64(int fd, size_t size, struct statfs *buf);
@@ -99,7 +99,7 @@ int __syscall_symlinkat(const char *target, int newdirfd, const char *linkpath);
9999
int __syscall_readlinkat(int dirfd, const char *path, char *buf, size_t bufsize);
100100
int __syscall_fchmodat2(int dirfd, const char *path, mode_t mode, int flags);
101101
int __syscall_faccessat(int dirfd, const char *path, int amode, int flags);
102-
int __syscall_pselect6(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timespec *ts, const void *mask);
102+
int __syscall_pselect6(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, const void *ts, const void *mask);
103103
int __syscall_utimensat(int dirfd, const char *path, const struct timespec times[2], int flags);
104104
int __syscall_fallocate(int fd, int mode, off_t offset, off_t len);
105105
int __syscall_dup3(int oldfd, int newfd, int flags);

system/lib/wasmfs/js_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ int _wasmfs_ftruncate(int fd, off_t length) {
237237
int _wasmfs_close(int fd) { return __wasi_fd_close(fd); }
238238

239239
void* _wasmfs_mmap(size_t length, int prot, int flags, int fd, off_t offset) {
240-
return __syscall_mmap2(0, length, prot, flags, fd, offset);
240+
return (void*)__syscall_mmap2(0, length, prot, flags, fd, offset);
241241
}
242242

243243
int _wasmfs_msync(void* addr, size_t length, int flags) {

system/lib/wasmfs/syscalls.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ int wasmfs_unmount(const char* path) {
900900
return lockedParent.removeChild(childName);
901901
}
902902

903-
int __syscall_getdents64(int fd, struct dirent* dirp, size_t count) {
903+
int __syscall_getdents64(int fd, void* dirp, size_t count) {
904+
dirent* result = (dirent*)dirp;
905+
904906
// Check if the result buffer is too small.
905907
if (count / sizeof(dirent) == 0) {
906908
return -EINVAL;
@@ -933,29 +935,29 @@ int __syscall_getdents64(int fd, struct dirent* dirp, size_t count) {
933935
for (; index < dirents.size() && bytesRead + sizeof(dirent) <= count;
934936
index++) {
935937
const auto& entry = dirents[index];
936-
dirp->d_ino = entry.ino;
937-
dirp->d_off = index + 1;
938-
dirp->d_reclen = sizeof(dirent);
938+
result->d_ino = entry.ino;
939+
result->d_off = index + 1;
940+
result->d_reclen = sizeof(dirent);
939941
switch (entry.kind) {
940942
case File::UnknownKind:
941-
dirp->d_type = DT_UNKNOWN;
943+
result->d_type = DT_UNKNOWN;
942944
break;
943945
case File::DataFileKind:
944-
dirp->d_type = DT_REG;
946+
result->d_type = DT_REG;
945947
break;
946948
case File::DirectoryKind:
947-
dirp->d_type = DT_DIR;
949+
result->d_type = DT_DIR;
948950
break;
949951
case File::SymlinkKind:
950-
dirp->d_type = DT_LNK;
952+
result->d_type = DT_LNK;
951953
break;
952954
default:
953-
dirp->d_type = DT_UNKNOWN;
955+
result->d_type = DT_UNKNOWN;
954956
break;
955957
}
956-
assert(entry.name.size() + 1 <= sizeof(dirp->d_name));
957-
strcpy(dirp->d_name, entry.name.c_str());
958-
++dirp;
958+
assert(entry.name.size() + 1 <= sizeof(result->d_name));
959+
strcpy(result->d_name, entry.name.c_str());
960+
++result;
959961
bytesRead += sizeof(dirent);
960962
}
961963

@@ -1772,7 +1774,7 @@ int __syscall__newselect(int nfds,
17721774
fd_set* readfds_,
17731775
fd_set* writefds_,
17741776
fd_set* exceptfds_,
1775-
struct timeval* timeout_) {
1777+
void* timeout_) {
17761778
// TODO: Implement this syscall. For now, we return an error code,
17771779
// specifically ENOMEM which is valid per the docs:
17781780
// ENOMEM Unable to allocate memory for internal tables

0 commit comments

Comments
 (0)