diff --git a/configure b/configure index caaf1a490b77..8760f1c9988a 100755 --- a/configure +++ b/configure @@ -18431,13 +18431,15 @@ fi ## socklen_t -case $host in #( +case $target in #( *-*-mingw32*|*-pc-windows) : ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include " if test "x$ac_cv_type_socklen_t" = xyes then : - printf "%s\n" "#define HAS_SOCKLEN_T 1" >>confdefs.h + +printf "%s\n" "#define HAVE_SOCKLEN_T 1" >>confdefs.h + fi ;; #( @@ -18446,7 +18448,9 @@ fi " if test "x$ac_cv_type_socklen_t" = xyes then : - printf "%s\n" "#define HAS_SOCKLEN_T 1" >>confdefs.h + +printf "%s\n" "#define HAVE_SOCKLEN_T 1" >>confdefs.h + fi ;; diff --git a/configure.ac b/configure.ac index 7201a8eb2c94..26af082473ed 100644 --- a/configure.ac +++ b/configure.ac @@ -1969,12 +1969,10 @@ AS_IF([$sockets], [AC_DEFINE([HAS_SOCKETS], [1])]) ## socklen_t -AS_CASE([$host], +AS_CASE([$target], [*-*-mingw32*|*-pc-windows], - [AC_CHECK_TYPE([socklen_t], [AC_DEFINE([HAS_SOCKLEN_T], [1])], [], - [#include ])], - [AC_CHECK_TYPE([socklen_t], [AC_DEFINE([HAS_SOCKLEN_T], [1])], [], - [#include ])]) + [AC_CHECK_TYPES([socklen_t], [], [], [#include ])], + [AC_CHECK_TYPES([socklen_t], [], [], [#include ])]) AC_CHECK_FUNC([inet_aton], [AC_DEFINE([HAS_INET_ATON], [1])]) diff --git a/otherlibs/unix/accept_unix.c b/otherlibs/unix/accept_unix.c index 482142354e79..f2724ee1feb3 100644 --- a/otherlibs/unix/accept_unix.c +++ b/otherlibs/unix/accept_unix.c @@ -32,7 +32,7 @@ CAMLprim value caml_unix_accept(value cloexec, value sock) int retcode; value res; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; int clo = caml_unix_cloexec_p(cloexec); addr_len = sizeof(addr); diff --git a/otherlibs/unix/accept_win32.c b/otherlibs/unix/accept_win32.c index 8d747c57d1dd..569eb43d300b 100644 --- a/otherlibs/unix/accept_win32.c +++ b/otherlibs/unix/accept_win32.c @@ -28,7 +28,7 @@ CAMLprim value caml_unix_accept(value cloexec, value sock) SOCKET snew; value res; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; DWORD err = 0; addr_len = sizeof(addr); diff --git a/otherlibs/unix/bind_unix.c b/otherlibs/unix/bind_unix.c index 9ea36c9e7250..620f286f95a2 100644 --- a/otherlibs/unix/bind_unix.c +++ b/otherlibs/unix/bind_unix.c @@ -25,7 +25,7 @@ CAMLprim value caml_unix_bind(value socket, value address) { int ret; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; caml_unix_get_sockaddr(address, &addr, &addr_len); ret = bind(Int_val(socket), (struct sockaddr *) &addr, addr_len); diff --git a/otherlibs/unix/bind_win32.c b/otherlibs/unix/bind_win32.c index 71e5b7a0255d..eba4325619f3 100644 --- a/otherlibs/unix/bind_win32.c +++ b/otherlibs/unix/bind_win32.c @@ -21,7 +21,7 @@ CAMLprim value caml_unix_bind(value socket, value address) { int ret; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; caml_unix_get_sockaddr(address, &addr, &addr_len); ret = bind(Socket_val(socket), (struct sockaddr *) &addr, addr_len); diff --git a/otherlibs/unix/caml/socketaddr.h b/otherlibs/unix/caml/socketaddr.h index 62e739b630f7..051e8046b294 100644 --- a/otherlibs/unix/caml/socketaddr.h +++ b/otherlibs/unix/caml/socketaddr.h @@ -55,11 +55,11 @@ union sock_addr_union { #endif }; -#ifdef HAS_SOCKLEN_T -typedef socklen_t socklen_param_type; -#else -typedef int socklen_param_type; +#ifndef HAVE_SOCKLEN_T +typedef int socklen_t; #endif +/* Deprecated: use socklen_t */ +CAMLdeprecated_typedef(socklen_param_type, socklen_t); #ifdef __cplusplus extern "C" { @@ -74,9 +74,9 @@ extern "C" { extern void caml_unix_get_sockaddr (value vaddr, struct sockaddr_storage * addr /*out*/, - socklen_param_type * addr_len /*out*/); + socklen_t * addr_len /*out*/); extern value caml_unix_alloc_sockaddr (struct sockaddr_storage * addr /*in*/, - socklen_param_type addr_len, + socklen_t addr_len, int close_on_error); extern value caml_unix_alloc_inet_addr (struct in_addr * inaddr); #define GET_INET_ADDR(v) (*((struct in_addr *) (v))) diff --git a/otherlibs/unix/channels_unix.c b/otherlibs/unix/channels_unix.c index 152ba6ac6b95..2921dcd6a394 100644 --- a/otherlibs/unix/channels_unix.c +++ b/otherlibs/unix/channels_unix.c @@ -46,7 +46,7 @@ static int caml_unix_check_stream_semantics(int fd) #ifdef HAS_SOCKETS case S_IFSOCK: { int so_type; - socklen_param_type so_type_len = sizeof(so_type); + socklen_t so_type_len = sizeof(so_type); if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &so_type, &so_type_len) == -1) return errno; switch (so_type) { diff --git a/otherlibs/unix/connect_unix.c b/otherlibs/unix/connect_unix.c index 0058268b9318..745d055943a7 100644 --- a/otherlibs/unix/connect_unix.c +++ b/otherlibs/unix/connect_unix.c @@ -26,7 +26,7 @@ CAMLprim value caml_unix_connect(value socket, value address) { int retcode; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; caml_unix_get_sockaddr(address, &addr, &addr_len); caml_enter_blocking_section(); diff --git a/otherlibs/unix/connect_win32.c b/otherlibs/unix/connect_win32.c index 21ebdae79784..a4393a4609b4 100644 --- a/otherlibs/unix/connect_win32.c +++ b/otherlibs/unix/connect_win32.c @@ -22,7 +22,7 @@ CAMLprim value caml_unix_connect(value socket, value address) { SOCKET s = Socket_val(socket); struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; DWORD err = 0; caml_unix_get_sockaddr(address, &addr, &addr_len); diff --git a/otherlibs/unix/getaddrinfo.c b/otherlibs/unix/getaddrinfo.c index f3a6bcbf8485..4313e1ca3d5e 100644 --- a/otherlibs/unix/getaddrinfo.c +++ b/otherlibs/unix/getaddrinfo.c @@ -39,7 +39,7 @@ static value convert_addrinfo(const struct addrinfo * a) CAMLparam0(); CAMLlocal3(vres,vaddr,vcanonname); struct sockaddr_storage addr; - socklen_param_type len; + socklen_t len; len = a->ai_addrlen; if (len > sizeof(addr)) len = sizeof(addr); diff --git a/otherlibs/unix/getnameinfo.c b/otherlibs/unix/getnameinfo.c index 418484bcdcae..ec9ceb63d047 100644 --- a/otherlibs/unix/getnameinfo.c +++ b/otherlibs/unix/getnameinfo.c @@ -38,7 +38,7 @@ CAMLprim value caml_unix_getnameinfo(value vaddr, value vopts) CAMLparam0(); CAMLlocal3(vhost, vserv, vres); struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; char host[4096]; char serv[1024]; int opts, retcode; diff --git a/otherlibs/unix/getpeername_unix.c b/otherlibs/unix/getpeername_unix.c index 51d3c3fd6ac9..85e7662d42fa 100644 --- a/otherlibs/unix/getpeername_unix.c +++ b/otherlibs/unix/getpeername_unix.c @@ -25,7 +25,7 @@ CAMLprim value caml_unix_getpeername(value sock) { int retcode; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; addr_len = sizeof(addr); retcode = getpeername(Int_val(sock), (struct sockaddr *) &addr, &addr_len); diff --git a/otherlibs/unix/getpeername_win32.c b/otherlibs/unix/getpeername_win32.c index 01c659ae9c52..3ad2846e69ff 100644 --- a/otherlibs/unix/getpeername_win32.c +++ b/otherlibs/unix/getpeername_win32.c @@ -21,7 +21,7 @@ CAMLprim value caml_unix_getpeername(value sock) { int retcode; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; addr_len = sizeof(addr); retcode = getpeername(Socket_val(sock), (struct sockaddr *) &addr, &addr_len); diff --git a/otherlibs/unix/getsockname_unix.c b/otherlibs/unix/getsockname_unix.c index d1743f808381..b1073c62242d 100644 --- a/otherlibs/unix/getsockname_unix.c +++ b/otherlibs/unix/getsockname_unix.c @@ -25,7 +25,7 @@ CAMLprim value caml_unix_getsockname(value sock) { int retcode; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; addr_len = sizeof(addr); retcode = getsockname(Int_val(sock), (struct sockaddr *) &addr, &addr_len); diff --git a/otherlibs/unix/getsockname_win32.c b/otherlibs/unix/getsockname_win32.c index 19a2d6f8d2b6..a8619be8fcad 100644 --- a/otherlibs/unix/getsockname_win32.c +++ b/otherlibs/unix/getsockname_win32.c @@ -21,7 +21,7 @@ CAMLprim value caml_unix_getsockname(value sock) { int retcode; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; addr_len = sizeof(addr); retcode = getsockname(Socket_val(sock), (struct sockaddr *) &addr, &addr_len); diff --git a/otherlibs/unix/sendrecv_unix.c b/otherlibs/unix/sendrecv_unix.c index c1335d5d4ffa..0cca66e6748a 100644 --- a/otherlibs/unix/sendrecv_unix.c +++ b/otherlibs/unix/sendrecv_unix.c @@ -57,7 +57,7 @@ CAMLprim value caml_unix_recvfrom(value sock, value buff, value ofs, value len, char iobuf[UNIX_BUFFER_SIZE]; value res; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; cv_flags = caml_convert_flag_list(flags, msg_flag_table); numbytes = Long_val(len); @@ -101,7 +101,7 @@ CAMLprim value caml_unix_sendto_native(value sock, value buff, value ofs, long numbytes; char iobuf[UNIX_BUFFER_SIZE]; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; cv_flags = caml_convert_flag_list(flags, msg_flag_table); caml_unix_get_sockaddr(dest, &addr, &addr_len); diff --git a/otherlibs/unix/sendrecv_win32.c b/otherlibs/unix/sendrecv_win32.c index 1b409d5e6934..8c21ea2286ca 100644 --- a/otherlibs/unix/sendrecv_win32.c +++ b/otherlibs/unix/sendrecv_win32.c @@ -61,7 +61,7 @@ CAMLprim value caml_unix_recvfrom(value sock, value buff, value ofs, value len, char iobuf[UNIX_BUFFER_SIZE]; value res; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; DWORD err = 0; numbytes = Long_val(len); @@ -117,7 +117,7 @@ value caml_unix_sendto_native(value sock, value buff, value ofs, value len, intnat numbytes; char iobuf[UNIX_BUFFER_SIZE]; struct sockaddr_storage addr; - socklen_param_type addr_len; + socklen_t addr_len; DWORD err = 0; caml_unix_get_sockaddr(dest, &addr, &addr_len); diff --git a/otherlibs/unix/socketaddr.c b/otherlibs/unix/socketaddr.c index d3028bfe7376..3fd4ef393aa5 100644 --- a/otherlibs/unix/socketaddr.c +++ b/otherlibs/unix/socketaddr.c @@ -51,7 +51,7 @@ CAMLexport value caml_unix_alloc_inet6_addr(struct in6_addr * a) void caml_unix_get_sockaddr(value vaddr, struct sockaddr_storage * addr /*out*/, - socklen_param_type * addr_len /*out*/) + socklen_t * addr_len /*out*/) { switch(Tag_val(vaddr)) { case 0: /* ADDR_UNIX */ @@ -109,7 +109,7 @@ static value alloc_unix_sockaddr(value path) { } value caml_unix_alloc_sockaddr(struct sockaddr_storage * addr /*in*/, - socklen_param_type addr_len, int close_on_error) + socklen_t addr_len, int close_on_error) { CAMLparam0(); CAMLlocal1(a); diff --git a/otherlibs/unix/socketpair_win32.c b/otherlibs/unix/socketpair_win32.c index acb4cb74dde4..e2c775e1e869 100644 --- a/otherlibs/unix/socketpair_win32.c +++ b/otherlibs/unix/socketpair_win32.c @@ -40,7 +40,7 @@ static int socketpair(int domain, int type, int protocol, { wchar_t dirname[MAX_PATH + 1], path[MAX_PATH + 1]; struct sockaddr_un addr; - socklen_param_type socklen; + socklen_t socklen; /* POSIX states that in case of error, the contents of socket_vector shall be unmodified. */ diff --git a/otherlibs/unix/sockopt_unix.c b/otherlibs/unix/sockopt_unix.c index a826de86ba05..29011acfc9fe 100644 --- a/otherlibs/unix/sockopt_unix.c +++ b/otherlibs/unix/sockopt_unix.c @@ -180,7 +180,7 @@ CAMLexport value caml_unix_getsockopt_aux(const char * name, CAMLlocal1(err); value res; union option_value optval; - socklen_param_type optsize; + socklen_t optsize; switch (ty) { @@ -235,7 +235,7 @@ CAMLexport value caml_unix_setsockopt_aux(const char * name, value socket, value val) { union option_value optval; - socklen_param_type optsize; + socklen_t optsize; double f; switch (ty) { diff --git a/otherlibs/unix/sockopt_win32.c b/otherlibs/unix/sockopt_win32.c index 64d17b08f370..06e2fd945e25 100644 --- a/otherlibs/unix/sockopt_win32.c +++ b/otherlibs/unix/sockopt_win32.c @@ -117,7 +117,7 @@ CAMLexport value caml_unix_getsockopt_aux(const char * name, CAMLparam0(); CAMLlocal1(err); union option_value optval; - socklen_param_type optsize; + socklen_t optsize; value res; switch (ty) { @@ -173,7 +173,7 @@ CAMLexport value caml_unix_setsockopt_aux(const char * name, value socket, value val) { union option_value optval; - socklen_param_type optsize; + socklen_t optsize; double f; switch (ty) { diff --git a/runtime/caml/compatibility.h b/runtime/caml/compatibility.h index 103170f13345..3baa978df00c 100644 --- a/runtime/caml/compatibility.h +++ b/runtime/caml/compatibility.h @@ -33,4 +33,8 @@ #define HAS_UNISTD 1 #endif +#ifdef HAVE_SOCKLEN_T +#define HAS_SOCKLEN_T 1 +#endif + #endif /* CAML_COMPATIBILITY_H */ diff --git a/runtime/caml/s.h.in b/runtime/caml/s.h.in index ca5c510c5070..70bbc6d7a7ea 100644 --- a/runtime/caml/s.h.in +++ b/runtime/caml/s.h.in @@ -93,10 +93,9 @@ /* Define HAS_SOCKETPAIR if you have the socketpair function. Only relevant on Windows. */ -#undef HAS_SOCKLEN_T +#undef HAVE_SOCKLEN_T -/* Define HAS_SOCKLEN_T if the type socklen_t is defined in - /usr/include/sys/socket.h. */ +/* Define HAVE_SOCKLEN_T if the type socklen_t is defined. */ #undef HAS_AFUNIX_H