From f09b0dbd56f530b3ac21c153469c44378367cb5c Mon Sep 17 00:00:00 2001 From: Hokila <1647434+Hokila@users.noreply.github.com> Date: Sun, 30 Aug 2026 14:19:03 +0800 Subject: [PATCH] Fix WASIp1 socket level constants --- libc-bottom-half/headers/public/__header_sys_socket.h | 2 ++ test/CMakeLists.txt | 2 ++ test/src/socket-levels.c | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 test/src/socket-levels.c diff --git a/libc-bottom-half/headers/public/__header_sys_socket.h b/libc-bottom-half/headers/public/__header_sys_socket.h index a7ee66e08..99a66933d 100644 --- a/libc-bottom-half/headers/public/__header_sys_socket.h +++ b/libc-bottom-half/headers/public/__header_sys_socket.h @@ -16,6 +16,8 @@ #define MSG_PEEK __WASI_RIFLAGS_RECV_PEEK #define MSG_WAITALL __WASI_RIFLAGS_RECV_WAITALL #define MSG_TRUNC __WASI_ROFLAGS_RECV_DATA_TRUNCATED +#define SOL_TCP 6 +#define SOL_UDP 17 #elif defined(__wasip2__) || defined(__wasip3__) #define MSG_DONTWAIT 0x0040 #define MSG_NOSIGNAL 0x4000 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9eb102d2c..7a56f683c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -746,6 +746,8 @@ add_external_entrypoint_test(external_entrypoint_pthread_tls.c) # ========= sockets-related tests =============================== +add_wasilibc_test(socket-levels.c) + if (NOT (WASI STREQUAL "p1")) add_wasilibc_test(poll-connect.c NETWORK) add_wasilibc_test(poll-badfd.c) diff --git a/test/src/socket-levels.c b/test/src/socket-levels.c new file mode 100644 index 000000000..167fc3a4e --- /dev/null +++ b/test/src/socket-levels.c @@ -0,0 +1,6 @@ +#include + +_Static_assert(SOL_TCP == 6, "SOL_TCP must match the socket API value"); +_Static_assert(SOL_UDP == 17, "SOL_UDP must match the socket API value"); + +int main(void) { return 0; }