Skip to content

Commit

Permalink
Deprecate socklen_param_type for socklen_t
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA committed Dec 11, 2024
1 parent 1958669 commit d57dae2
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 41 deletions.
10 changes: 7 additions & 3 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ws2tcpip.h>])],
[AC_CHECK_TYPE([socklen_t], [AC_DEFINE([HAS_SOCKLEN_T], [1])], [],
[#include <sys/socket.h>])])
[AC_CHECK_TYPES([socklen_t], [], [], [#include <ws2tcpip.h>])],
[AC_CHECK_TYPES([socklen_t], [], [], [#include <sys/socket.h>])])

AC_CHECK_FUNC([inet_aton], [AC_DEFINE([HAS_INET_ATON], [1])])

Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/accept_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/accept_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/bind_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/bind_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions otherlibs/unix/caml/socketaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/channels_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/connect_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/connect_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/getnameinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/getpeername_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/getpeername_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/getsockname_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/getsockname_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/unix/sendrecv_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/unix/sendrecv_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/unix/socketaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/socketpair_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/unix/sockopt_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/unix/sockopt_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions runtime/caml/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
#define HAS_UNISTD 1
#endif

#ifdef HAVE_SOCKLEN_T
#define HAS_SOCKLEN_T 1
#endif

#endif /* CAML_COMPATIBILITY_H */
5 changes: 2 additions & 3 deletions runtime/caml/s.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d57dae2

Please sign in to comment.