From 2a512ece34674639eb80c4e67d74d2b5c265f506 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 4 Aug 2021 20:42:45 -0700 Subject: musl: fix missing . Issue peported by Ethan Hawk. Our socket.c module is using struct timeval without including , which breaks on musl. * configure: in the select test, let's include , and if the test passes, let's set have_sys_time, so that HAVE_SELECT implies HAVE_SYS_TIME. This way code wrapped with HAVE_SELECT doesn't separately have to test for HAVE_SYS_TIME. * socket.c: If HAVE_SYS_TIME is true, then we include , independently of HAVE_SELECT. (sock_timeout, sock_load_init): Like the select-based code, code using SO_SNDTIMEO or SO_RCVTIMO also uses timeval, so needs to be wrapped with HAVE_SYS_TIME. --- configure | 2 ++ socket.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ead8bccc..63f1ec5c 100755 --- a/configure +++ b/configure @@ -3480,6 +3480,7 @@ if [ $have_sockets ] ; then cat > conftest.c < +#include int main(int argc, char **argv) { @@ -3494,6 +3495,7 @@ int main(int argc, char **argv) if conftest; then printf "yes\n" printf "#define HAVE_SELECT 1\n" >> config.h + have_sys_time=y else printf "no\n" fi diff --git a/socket.c b/socket.c index f8222b03..c4745241 100644 --- a/socket.c +++ b/socket.c @@ -45,6 +45,9 @@ #elif HAVE_SELECT #include #endif +#if HAVE_SYS_TIME +#include +#endif #include #include "lib.h" #include "stream.h" @@ -1045,7 +1048,7 @@ static val sock_shutdown(val sock, val how) return t; } -#if defined SO_SNDTIMEO && defined SO_RCVTIMEO +#if HAVE_SYS_TIME && defined SO_SNDTIMEO && defined SO_RCVTIMEO static val sock_timeout(val sock, val usec, val name, int which, val self) { cnum fd = c_num(stream_fd(sock), self); @@ -1180,7 +1183,7 @@ void sock_load_init(void) reg_fun(intern(lit("sock-shutdown"), user_package), func_n2o(sock_shutdown, 1)); reg_fun(intern(lit("open-socket"), user_package), func_n3o(open_socket, 2)); reg_fun(intern(lit("open-socket-pair"), user_package), func_n3o(socketpair_wrap, 2)); -#if defined SO_SNDTIMEO && defined SO_RCVTIMEO +#if HAVE_SYS_TIME && defined SO_SNDTIMEO && defined SO_RCVTIMEO reg_fun(intern(lit("sock-send-timeout"), user_package), func_n2(sock_send_timeout)); reg_fun(intern(lit("sock-recv-timeout"), user_package), func_n2(sock_recv_timeout)); #endif -- cgit v1.2.3