Skip to content

Commit

Permalink
Support OCaml 5 names for Unix symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed May 26, 2022
1 parent 654952b commit 58437ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 0 additions & 3 deletions src/unix/unix_c/unix_get_network_information_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ char *s_strdup(const char *s)
}
#endif

CAMLexport value alloc_inet_addr(struct in_addr *inaddr);
CAMLexport value alloc_inet6_addr(struct in6_addr *inaddr);

static value alloc_one_addr(char const *a)
{
struct in_addr addr;
Expand Down
10 changes: 6 additions & 4 deletions src/unix/unix_c/unix_getaddrinfo_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ static value convert_addrinfo(struct addrinfo *a)
vcanonname =
caml_copy_string(a->ai_canonname == NULL ? "" : a->ai_canonname);
vres = caml_alloc_small(5, 0);
Field(vres, 0) = cst_to_constr(a->ai_family, socket_domain_table, 3, 0);
Field(vres, 1) = cst_to_constr(a->ai_socktype, socket_type_table, 4, 0);
Field(vres, 0) =
cst_to_constr(a->ai_family, unix_socket_domain_table, 3, 0);
Field(vres, 1) =
cst_to_constr(a->ai_socktype, unix_socket_type_table, 4, 0);
Field(vres, 2) = Val_int(a->ai_protocol);
Field(vres, 3) = vaddr;
Field(vres, 4) = vcanonname;
Expand Down Expand Up @@ -97,11 +99,11 @@ CAMLprim value lwt_unix_getaddrinfo_job(value node, value service, value hints)
if (Is_block(v)) switch (Tag_val(v)) {
case 0: /* AI_FAMILY of socket_domain */
job->hints.ai_family =
socket_domain_table[Int_val(Field(v, 0))];
unix_socket_domain_table[Int_val(Field(v, 0))];
break;
case 1: /* AI_SOCKTYPE of socket_type */
job->hints.ai_socktype =
socket_type_table[Int_val(Field(v, 0))];
unix_socket_type_table[Int_val(Field(v, 0))];
break;
case 2: /* AI_PROTOCOL of int */
job->hints.ai_protocol = Int_val(Field(v, 0));
Expand Down
10 changes: 8 additions & 2 deletions src/unix/unix_c/unix_recv_send_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@

#include <caml/mlvalues.h>
#include <caml/socketaddr.h>
#include <caml/version.h>
#include <sys/socket.h>
#include <sys/uio.h>

#if OCAML_VERSION_MAJOR < 5
#define unix_socket_domain_table socket_domain_table
#define unix_socket_type_table socket_type_table
#endif

extern int msg_flag_table[];
extern int socket_domain_table[];
extern int socket_type_table[];
extern int unix_socket_domain_table[];
extern int unix_socket_type_table[];
extern void get_sockaddr(value mladdr, union sock_addr_union *addr /*out*/,
socklen_t *addr_len /*out*/);
value wrapper_recv_msg(int fd, int n_iovs, struct iovec *iovs);
Expand Down

0 comments on commit 58437ae

Please sign in to comment.