Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lib/libsigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ sigs = {
__syscall_connect__sig: 'iipiiii',
__syscall_dup__sig: 'ii',
__syscall_dup3__sig: 'iiii',
__syscall_epoll_create1__sig: 'ii',
__syscall_epoll_ctl__sig: 'iiiip',
__syscall_epoll_pwait__sig: 'iipiipp',
__syscall_faccessat__sig: 'iipii',
__syscall_fallocate__sig: 'iiijj',
__syscall_fchdir__sig: 'ii',
Expand Down
7 changes: 7 additions & 0 deletions src/lib/libsyscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,13 @@ var SyscallsLibrary = {
__syscall_poll_nonblocking: (fds, nfds) => {
return doPoll(fds, nfds, 0, undefined);
},
// epoll is not yet implemented in the legacy (non-WASMFS) JS syscall layer.
__syscall_epoll_create1__nothrow: true,
__syscall_epoll_create1: (flags) => -{{{ cDefs.ENOSYS }}},
__syscall_epoll_ctl__nothrow: true,
__syscall_epoll_ctl: (epfd, op, fd, ev) => -{{{ cDefs.ENOSYS }}},
__syscall_epoll_pwait__nothrow: true,
__syscall_epoll_pwait: (epfd, ev, maxevents, timeout, sigmask, sigsetsize) => -{{{ cDefs.ENOSYS }}},
__syscall_getcwd__deps: ['$lengthBytesUTF8', '$stringToUTF8'],
__syscall_getcwd: (buf, size) => {
if (size === 0) return -{{{ cDefs.EINVAL }}};
Expand Down
4 changes: 4 additions & 0 deletions system/include/emscripten/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <poll.h>
#include <stdint.h>
#include <sys/epoll.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -120,6 +121,9 @@ int __syscall_sendmsg(int sockfd, const struct msghdr *msg, int flags, int unuse
int __syscall_recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen);
int __syscall_recvmsg(int sockfd, struct msghdr *msg, int flags, int unused1, int unused2, int unused3);
int __syscall_shutdown(int sockfd, int how, int unused1, int unused2, int unused3, int unused4);
int __syscall_epoll_create1(int flags);
int __syscall_epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev);
int __syscall_epoll_pwait(int epfd, struct epoll_event *ev, int maxevents, int timeout, const sigset_t *sigmask, size_t sigsetsize);

#ifdef __cplusplus
}
Expand Down
3 changes: 3 additions & 0 deletions system/lib/libc/musl/arch/emscripten/bits/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@
#define SYS_recvfrom __syscall_recvfrom
#define SYS_recvmsg __syscall_recvmsg
#define SYS_shutdown __syscall_shutdown
#define SYS_epoll_create1 __syscall_epoll_create1
#define SYS_epoll_ctl __syscall_epoll_ctl
#define SYS_epoll_pwait __syscall_epoll_pwait
81 changes: 81 additions & 0 deletions system/lib/libc/musl/include/sys/epoll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#ifndef _SYS_EPOLL_H
#define _SYS_EPOLL_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>

#define __NEED_sigset_t

#include <bits/alltypes.h>

#define EPOLL_CLOEXEC O_CLOEXEC
#define EPOLL_NONBLOCK O_NONBLOCK

enum EPOLL_EVENTS { __EPOLL_DUMMY };
#define EPOLLIN 0x001
#define EPOLLPRI 0x002
#define EPOLLOUT 0x004
#define EPOLLRDNORM 0x040
#define EPOLLNVAL 0x020
#define EPOLLRDBAND 0x080
#define EPOLLWRNORM 0x100
#define EPOLLWRBAND 0x200
#define EPOLLMSG 0x400
#define EPOLLERR 0x008
#define EPOLLHUP 0x010
#define EPOLLRDHUP 0x2000
#define EPOLLEXCLUSIVE (1U<<28)
#define EPOLLWAKEUP (1U<<29)
#define EPOLLONESHOT (1U<<30)
#define EPOLLET (1U<<31)

#define EPOLL_CTL_ADD 1
#define EPOLL_CTL_DEL 2
#define EPOLL_CTL_MOD 3

typedef union epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;

struct epoll_event {
uint32_t events;
epoll_data_t data;
}
#ifdef __x86_64__
__attribute__ ((__packed__))
#endif
;

struct epoll_params {
uint32_t busy_poll_usecs;
uint16_t busy_poll_budget;
uint8_t prefer_busy_poll;

uint8_t __pad;
};

#define EPOLL_IOC_TYPE 0x8A
#define EPIOCSPARAMS _IOW(EPOLL_IOC_TYPE, 0x01, struct epoll_params)
#define EPIOCGPARAMS _IOR(EPOLL_IOC_TYPE, 0x02, struct epoll_params)

int epoll_create(int);
int epoll_create1(int);
int epoll_ctl(int, int, int, struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *);


#ifdef __cplusplus
}
#endif

#endif /* sys/epoll.h */
1 change: 0 additions & 1 deletion system/lib/update_musl.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
'aio.h',
'auxv.h',
'cachectl.h',
'epoll.h',
'eventfd.h',
'fanotify.h',
'fsuid.h',
Expand Down
16 changes: 16 additions & 0 deletions system/lib/wasmfs/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1846,4 +1846,20 @@ int __syscall_fadvise64(int fd, off_t offset, off_t len, int advice) {
return 0;
}

// epoll is implemented in the legacy (non-WASMFS) JS syscall layer only.
int __syscall_epoll_create1(int flags) { return -ENOSYS; }

int __syscall_epoll_ctl(int epfd, int op, int fd, struct epoll_event* ev) {
return -ENOSYS;
}

int __syscall_epoll_pwait(int epfd,
struct epoll_event* ev,
int maxevents,
int timeout,
const sigset_t* sigmask,
size_t sigsetsize) {
return -ENOSYS;
}

} // extern "C"
22 changes: 19 additions & 3 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 268445,
"a.out.nodebug.wasm": 587520,
"total": 855965,
"a.out.js": 268603,
"a.out.nodebug.wasm": 587900,
"total": 856503,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down Expand Up @@ -222,6 +222,9 @@
"__syscall_connect",
"__syscall_dup",
"__syscall_dup3",
"__syscall_epoll_create1",
"__syscall_epoll_ctl",
"__syscall_epoll_pwait",
"__syscall_faccessat",
"__syscall_fallocate",
"__syscall_fchdir",
Expand Down Expand Up @@ -1744,6 +1747,9 @@
"env.__syscall_connect",
"env.__syscall_dup",
"env.__syscall_dup3",
"env.__syscall_epoll_create1",
"env.__syscall_epoll_ctl",
"env.__syscall_epoll_pwait",
"env.__syscall_faccessat",
"env.__syscall_fallocate",
"env.__syscall_fchdir",
Expand Down Expand Up @@ -2596,6 +2602,11 @@
"endpwent",
"endservent",
"environ",
"epoll_create",
"epoll_create1",
"epoll_ctl",
"epoll_pwait",
"epoll_wait",
"erand48",
"erf",
"erfc",
Expand Down Expand Up @@ -4460,6 +4471,11 @@
"$emutls_key_destructor",
"$encrypt",
"$endmntent",
"$epoll_create",
"$epoll_create1",
"$epoll_ctl",
"$epoll_pwait",
"$epoll_wait",
"$erand48",
"$erf",
"$erfc",
Expand Down
5 changes: 5 additions & 0 deletions tools/native_sigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@
'__syscall_chdir': '_p',
'__syscall_chmod': '_p_',
'__syscall_connect': '__p____',
'__syscall_epoll_ctl': '____p',
'__syscall_epoll_pwait': '__p__pp',
'__syscall_faccessat': '__p__',
'__syscall_fchmodat2': '__p__',
'__syscall_fchownat': '__p___',
Expand Down Expand Up @@ -872,6 +874,9 @@
'emscripten_wget': '_pp',
'encrypt': '_p_',
'endmntent': '_p',
'epoll_ctl': '____p',
'epoll_pwait': '__p__p',
'epoll_wait': '__p__',
'erand48': '_p',
'erfcl': '_p__',
'erfl': '_p__',
Expand Down
2 changes: 1 addition & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ def get_files(self):

libc_files += files_in_path(
path='system/lib/libc/musl/src/linux',
filenames=['getdents.c', 'gettid.c', 'utimes.c', 'statx.c', 'wait4.c', 'wait3.c'])
filenames=['getdents.c', 'gettid.c', 'utimes.c', 'statx.c', 'wait4.c', 'wait3.c', 'epoll.c'])

libc_files += files_in_path(
path='system/lib/libc/musl/src/malloc',
Expand Down