Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap caml_convert_flag_list in lwt_convert_flag_list for compat #1030

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/unix/lwt_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
#include <caml/socketaddr.h>
#include <string.h>

// The following macro is for backwards compatibility.
// It is given an `lwt_` prefix to avoid name collisions for code which
// include both this file and alloc.h.
#if OCAML_VERSION < 50000
raphael-proust marked this conversation as resolved.
Show resolved Hide resolved
#define caml_convert_flag_list(flags, table) \
#define lwt_convert_flag_list(flags, table) \
caml_convert_flag_list((flags), (int *)(table))
#else
#define lwt_convert_flag_list caml_convert_flag_list
#endif

/* The macro to get the file-descriptor from a value. */
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_bytes_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ value lwt_unix_bytes_recv(value fd, value buf, value ofs, value len,
int ret;
ret =
recv(Int_val(fd), (char *)Caml_ba_array_val(buf)->data + Long_val(ofs),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table));
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table));
if (ret == -1) uerror("recv", Nothing);
return Val_int(ret);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_bytes_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ value lwt_unix_bytes_recvfrom(value fd, value buf, value ofs, value len,
socklen_t addr_len;
addr_len = sizeof(addr);
ret = recvfrom(Int_val(fd), (char *)Caml_ba_data_val(buf) + Long_val(ofs),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table),
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table),
&addr.s_gen, &addr_len);
if (ret == -1) uerror("recvfrom", Nothing);
address = alloc_sockaddr(&addr, addr_len, -1);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_bytes_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ value lwt_unix_bytes_send(value fd, value buf, value ofs, value len,
int ret;
ret =
send(Int_val(fd), (char *)Caml_ba_array_val(buf)->data + Long_val(ofs),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table));
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table));
if (ret == -1) uerror("send", Nothing);
return Val_int(ret);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_bytes_sendto.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ value lwt_unix_bytes_sendto(value fd, value buf, value ofs, value len,
int ret;
get_sockaddr(dest, &addr, &addr_len);
ret = sendto(Int_val(fd), (char *)Caml_ba_data_val(buf) + Long_val(ofs),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table),
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table),
&addr.s_gen, addr_len);
if (ret == -1) uerror("send", Nothing);
return Val_int(ret);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_getnameinfo_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CAMLprim value lwt_unix_getnameinfo_job(value sockaddr, value opts)
{
LWT_UNIX_INIT_JOB(job, getnameinfo, 0);
get_sockaddr(sockaddr, &job->addr, &job->addr_len);
job->opts = caml_convert_flag_list(opts, getnameinfo_flag_table);
job->opts = lwt_convert_flag_list(opts, getnameinfo_flag_table);
return lwt_unix_alloc_job(&job->job);
}
#endif
4 changes: 2 additions & 2 deletions src/unix/unix_c/unix_open_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ static value result_open(struct job_open *job)
CAMLprim value lwt_unix_open_job(value name, value flags, value perms)
{
LWT_UNIX_INIT_JOB_STRING(job, open, 0, name);
job->fd = caml_convert_flag_list(flags, open_cloexec_table);
job->flags = caml_convert_flag_list(flags, open_flag_table);
job->fd = lwt_convert_flag_list(flags, open_cloexec_table);
job->flags = lwt_convert_flag_list(flags, open_flag_table);
job->perms = Int_val(perms);
return lwt_unix_alloc_job(&(job->job));
}
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ value lwt_unix_recv(value fd, value buf, value ofs, value len, value flags)
{
int ret;
ret = recv(Int_val(fd), &Byte(String_val(buf), Long_val(ofs)),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table));
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table));
if (ret == -1) uerror("recv", Nothing);
return Val_int(ret);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ value lwt_unix_recvfrom(value fd, value buf, value ofs, value len, value flags)
socklen_t addr_len;
addr_len = sizeof(addr);
ret = recvfrom(Int_val(fd), &Byte(String_val(buf), Long_val(ofs)),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table),
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table),
&addr.s_gen, &addr_len);
if (ret == -1) uerror("recvfrom", Nothing);
address = alloc_sockaddr(&addr, addr_len, -1);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ value lwt_unix_send(value fd, value buf, value ofs, value len, value flags)
{
int ret;
ret = send(Int_val(fd), &Byte(String_val(buf), Long_val(ofs)),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table));
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table));
if (ret == -1) uerror("send", Nothing);
return Val_int(ret);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_sendto.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ value lwt_unix_sendto(value fd, value buf, value ofs, value len, value flags,
int ret;
get_sockaddr(dest, &addr, &addr_len);
ret = sendto(Int_val(fd), &Byte(String_val(buf), Long_val(ofs)),
Long_val(len), caml_convert_flag_list(flags, msg_flag_table),
Long_val(len), lwt_convert_flag_list(flags, msg_flag_table),
&addr.s_gen, addr_len);
if (ret == -1) uerror("send", Nothing);
return Val_int(ret);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/unix_c/unix_wait4.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ value lwt_unix_wait4(value flags, value pid_req)
CAMLlocal2(times, res);

int pid, status, cv_flags;
cv_flags = caml_convert_flag_list(flags, wait_flag_table);
cv_flags = lwt_convert_flag_list(flags, wait_flag_table);

struct rusage ru;

Expand Down