]>
git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/sources/socket.c
4 #include <sys/socket.h>
6 static_assert((SOCK_DGRAM
& ~SOCK_NONBLOCK
& ~SOCK_CLOEXEC
) == SOCK_DGRAM
,
7 "Socket type flags clash");
8 static_assert((SOCK_STREAM
& ~SOCK_NONBLOCK
& ~SOCK_CLOEXEC
) == SOCK_STREAM
,
9 "Socket type flags clash");
11 static int socketcall(int domain
, int type
, int protocol
) {
12 // FIXME: Implement socket by looking up pre-opened network sockets.
17 int socket(int domain
, int type
, int protocol
)
19 int s
= socketcall(domain
, type
& ~SOCK_CLOEXEC
& ~SOCK_NONBLOCK
, protocol
);
21 if (type
& SOCK_CLOEXEC
) fcntl(s
, F_SETFD
, FD_CLOEXEC
);
22 if (type
& SOCK_NONBLOCK
) fcntl(s
, F_SETFL
, O_NONBLOCK
);