Skip to content

Commit b1fa89f

Browse files
committed
Remove support for sendmsg/recvmsg, simplify send/recv.
1 parent b0a0c7d commit b1fa89f

14 files changed

Lines changed: 47 additions & 328 deletions

File tree

expected/wasm32-wasi/defined-symbols.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
CMSG_FIRSTHDR
2-
CMSG_NXTHDR
31
FD_CLR
42
FD_COPY
53
FD_ISSET
@@ -832,7 +830,6 @@ readlinkat
832830
readv
833831
realloc
834832
recv
835-
recvmsg
836833
regcomp
837834
regerror
838835
regexec
@@ -874,7 +871,6 @@ seed48
874871
seekdir
875872
select
876873
send
877-
sendmsg
878874
setbuf
879875
setbuffer
880876
setenv

expected/wasm32-wasi/include-all.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <__header_unistd.h>
1616
#include <__macro_FD_SETSIZE.h>
1717
#include <__macro_PAGESIZE.h>
18-
#include <__struct_cmsghdr.h>
1918
#include <__struct_dirent.h>
2019
#include <__struct_in6_addr.h>
2120
#include <__struct_in_addr.h>

expected/wasm32-wasi/predefined-macros.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@
244244
#define CMPLX(x,y) __CMPLX(x, y, double)
245245
#define CMPLXF(x,y) __CMPLX(x, y, float)
246246
#define CMPLXL(x,y) __CMPLX(x, y, long double)
247-
#define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
248-
#define CMSG_FIRSTHDR CMSG_FIRSTHDR
249-
#define CMSG_LEN(len) (__builtin_offsetof(struct cmsghdr, __cmsg_data[(len)]))
250-
#define CMSG_NXTHDR CMSG_NXTHDR
251-
#define CMSG_SPACE(len) ((CMSG_LEN((len)) + (_Alignof(struct cmsghdr) - 1)) & (_Alignof(struct cmsghdr) - 1))
252247
#define CMSPAR 010000000000
253248
#define CODESET 14
254249
#define COLL_WEIGHTS_MAX 2
@@ -1457,7 +1452,6 @@
14571452
#define MOREDATA 2
14581453
#define MSG_ANY 0x02
14591454
#define MSG_BAND 0x04
1460-
#define MSG_CTRUNC __WASI_SOCK_RECV_FDS_TRUNCATED
14611455
#define MSG_HIPRI 0x01
14621456
#define MSG_PEEK __WASI_SOCK_RECV_PEEK
14631457
#define MSG_TRUNC __WASI_SOCK_RECV_DATA_TRUNCATED
@@ -1941,7 +1935,6 @@
19411935
#define SCHED_OTHER 0
19421936
#define SCHED_RESET_ON_FORK 0x40000000
19431937
#define SCHED_RR 2
1944-
#define SCM_RIGHTS 1
19451938
#define SCNd16 "hd"
19461939
#define SCNd32 "d"
19471940
#define SCNd64 __PRI64 "d"
@@ -3596,8 +3589,7 @@
35963589
#define __WASI_SIGWINCH (UINT8_C(27))
35973590
#define __WASI_SIGXCPU (UINT8_C(23))
35983591
#define __WASI_SIGXFSZ (UINT8_C(24))
3599-
#define __WASI_SOCK_RECV_DATA_TRUNCATED (UINT16_C(0x0002))
3600-
#define __WASI_SOCK_RECV_FDS_TRUNCATED (UINT16_C(0x0001))
3592+
#define __WASI_SOCK_RECV_DATA_TRUNCATED (UINT16_C(0x0001))
36013593
#define __WASI_SOCK_RECV_PEEK (UINT16_C(0x0001))
36023594
#define __WASI_SOCK_RECV_WAITALL (UINT16_C(0x0002))
36033595
#define __WASI_SUBSCRIPTION_CLOCK_ABSTIME (UINT16_C(0x0001))
@@ -3651,7 +3643,6 @@
36513643
#define __wasilibc___header_time_h
36523644
#define __wasilibc___header_unistd_h
36533645
#define __wasilibc___macro_FD_SETSIZE_h
3654-
#define __wasilibc___struct_cmsghdr_h
36553646
#define __wasilibc___struct_dirent_h
36563647
#define __wasilibc___struct_in6_addr_h
36573648
#define __wasilibc___struct_in_addr_h

libc-bottom-half/cloudlibc/src/libc/sys/socket/CMSG_FIRSTHDR.c

Lines changed: 0 additions & 11 deletions
This file was deleted.

libc-bottom-half/cloudlibc/src/libc/sys/socket/CMSG_NXTHDR.c

Lines changed: 0 additions & 32 deletions
This file was deleted.

libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,37 @@ ssize_t recv(int socket, void *restrict buffer, size_t length, int flags) {
2323

2424
// Prepare input parameters.
2525
__wasi_iovec_t iov = {.buf = buffer, .buf_len = length};
26+
#ifdef __wasilibc_unmodified_upstream // send/recv
2627
__wasi_recv_in_t ri = {
2728
.ri_data = &iov,
2829
.ri_data_len = 1,
2930
.ri_flags = flags,
3031
};
32+
#else
33+
__wasi_iovec_t *ri_data = &iov;
34+
size_t ri_data_len = 1;
35+
__wasi_riflags_t ri_flags = flags;
36+
#endif
3137

3238
// Perform system call.
39+
#ifdef __wasilibc_unmodified_upstream // send/recv
3340
__wasi_recv_out_t ro;
3441
__wasi_errno_t error = __wasi_sock_recv(socket, &ri, &ro);
42+
#else
43+
size_t ro_datalen;
44+
__wasi_roflags_t ro_flags;
45+
__wasi_errno_t error = __wasi_sock_recv(socket,
46+
ri_data, ri_data_len, ri_flags,
47+
&ro_datalen,
48+
&ro_flags);
49+
#endif
3550
if (error != 0) {
3651
errno = errno_fixup_socket(socket, error);
3752
return -1;
3853
}
54+
#ifdef __wasilibc_unmodified_upstream // send/recv
3955
return ro.ro_datalen;
56+
#else
57+
return ro_datalen;
58+
#endif
4059
}

libc-bottom-half/cloudlibc/src/libc/sys/socket/recvmsg.c

Lines changed: 0 additions & 67 deletions
This file was deleted.

libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,32 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags) {
1919

2020
// Prepare input parameters.
2121
__wasi_ciovec_t iov = {.buf = buffer, .buf_len = length};
22+
#ifdef __wasilibc_unmodified_upstream // send/recv
2223
__wasi_send_in_t si = {
2324
.si_data = &iov,
2425
.si_data_len = 1,
2526
};
27+
#else
28+
__wasi_ciovec_t *si_data = &iov;
29+
size_t si_data_len = 1;
30+
__wasi_siflags_t si_flags = 0;
31+
#endif
2632

2733
// Perform system call.
34+
#ifdef __wasilibc_unmodified_upstream // send/recv
2835
__wasi_send_out_t so;
2936
__wasi_errno_t error = __wasi_sock_send(socket, &si, &so);
37+
#else
38+
size_t so_datalen;
39+
__wasi_errno_t error = __wasi_sock_send(socket, si_data, si_data_len, si_flags, &so_datalen);
40+
#endif
3041
if (error != 0) {
3142
errno = errno_fixup_socket(socket, error);
3243
return -1;
3344
}
45+
#ifdef __wasilibc_unmodified_upstream // send/recv
3446
return so.so_datalen;
47+
#else
48+
return so_datalen;
49+
#endif
3550
}

libc-bottom-half/cloudlibc/src/libc/sys/socket/sendmsg.c

Lines changed: 0 additions & 59 deletions
This file was deleted.

libc-bottom-half/headers/public/__header_sys_socket.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define __wasilibc___header_sys_socket_h
33

44
#include <__struct_msghdr.h>
5-
#include <__struct_cmsghdr.h>
65
#include <__struct_sockaddr.h>
76
#include <__struct_sockaddr_storage.h>
87

@@ -14,10 +13,7 @@
1413

1514
#define MSG_PEEK __WASI_SOCK_RECV_PEEK
1615
#define MSG_WAITALL __WASI_SOCK_RECV_WAITALL
17-
#define MSG_CTRUNC __WASI_SOCK_RECV_FDS_TRUNCATED
1816
#define MSG_TRUNC __WASI_SOCK_RECV_DATA_TRUNCATED
19-
#define MSG_PEEK __WASI_SOCK_RECV_PEEK
20-
#define MSG_WAITALL __WASI_SOCK_RECV_WAITALL
2117

2218
#define SOCK_DGRAM __WASI_FILETYPE_SOCKET_DGRAM
2319
#define SOCK_STREAM __WASI_FILETYPE_SOCKET_STREAM
@@ -29,15 +25,6 @@
2925

3026
#define SO_TYPE 3
3127

32-
#define SCM_RIGHTS 1
33-
34-
#define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
35-
#define CMSG_NXTHDR CMSG_NXTHDR
36-
#define CMSG_FIRSTHDR CMSG_FIRSTHDR
37-
#define CMSG_LEN(len) (__builtin_offsetof(struct cmsghdr, __cmsg_data[(len)]))
38-
#define CMSG_SPACE(len) ((CMSG_LEN((len)) + (_Alignof(struct cmsghdr) - 1)) & \
39-
(_Alignof(struct cmsghdr) - 1))
40-
4128
#define AF_UNSPEC 0
4229
#define AF_INET 1
4330
#define AF_INET6 2
@@ -47,9 +34,6 @@
4734
extern "C" {
4835
#endif
4936

50-
struct cmsghdr *CMSG_FIRSTHDR(const struct msghdr *);
51-
struct cmsghdr *CMSG_NXTHDR(const struct msghdr *, const struct cmsghdr *);
52-
5337
#ifdef __cplusplus
5438
}
5539
#endif

0 commit comments

Comments
 (0)