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

Modern C and compatibility fixes #1022

Merged
merged 6 commits into from
Jul 27, 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
32 changes: 16 additions & 16 deletions src/unix/config/discover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ sig
val add_link_flags : string list -> unit
end =
struct
let c_flags = ref []
let c_flags = ref ["-Wall"; "-fdiagnostics-color=always"]
let link_flags = ref []

let extend c_flags' link_flags' =
Expand Down Expand Up @@ -424,7 +424,7 @@ struct
let code = {|
#include <ev.h>

int main()
int main(void)
{
ev_default_loop(0);
return 0;
Expand Down Expand Up @@ -452,7 +452,7 @@ struct
let code = {|
#include <pthread.h>

int main()
int main(void)
{
pthread_create(0, 0, 0, 0);
return 0;
Expand Down Expand Up @@ -494,7 +494,7 @@ struct
compiles context {|
#include <sys/eventfd.h>

int main()
int main(void)
{
eventfd(0, 0);
return 0;
Expand All @@ -511,7 +511,7 @@ struct
#include <sys/types.h>
#include <sys/socket.h>

int main()
int main(void)
{
struct msghdr msg;
msg.msg_controllen = 0;
Expand All @@ -531,7 +531,7 @@ struct
#define _GNU_SOURCE
#include <sched.h>

int main()
int main(void)
{
sched_getcpu();
return 0;
Expand All @@ -549,7 +549,7 @@ struct
#define _GNU_SOURCE
#include <sched.h>

int main()
int main(void)
{
sched_getaffinity(0, 0, 0);
return 0;
Expand All @@ -562,7 +562,7 @@ struct
#include <sys/types.h>
#include <sys/socket.h>

int main()
int main(void)
{
struct |} ^ struct_name ^ {| cred;
socklen_t cred_len = sizeof(cred);
Expand Down Expand Up @@ -612,7 +612,7 @@ struct
#include <sys/types.h>
#include <unistd.h>

int main()
int main(void)
{
uid_t euid;
gid_t egid;
Expand All @@ -630,7 +630,7 @@ struct
compiles context {|
#include <unistd.h>

int main()
int main(void)
{
int (*fdatasyncp)(int) = fdatasync;
fdatasyncp(0);
Expand All @@ -650,7 +650,7 @@ struct
#include <netdb.h>
#include <stddef.h>

int main()
int main(void)
{
int x;
x =
Expand Down Expand Up @@ -733,7 +733,7 @@ struct
#define NON_R_GETHOSTBYNAME 1
#endif

int main()
int main(void)
{
#if defined(NON_R_GETHOSTBYNAME) || defined(NON_R_GETHOSTBYNAME)
#error "not available"
Expand All @@ -750,7 +750,7 @@ struct
#include <sys/stat.h>
#include <unistd.h>

int main() {
int main(void) {
struct stat *buf;
double a, m, c;
a = (double)buf->st_a|} ^ projection ^ {|;
Expand Down Expand Up @@ -790,9 +790,9 @@ struct
#include <unistd.h>
#include <sys/mman.h>

int main()
int main(void)
{
int (*mincore_ptr)(void*, size_t, unsigned char*) = mincore;
int (*mincore_ptr)(const void*, size_t, char*) = mincore;
return (int)(mincore_ptr == NULL);
}
|}
Expand All @@ -808,7 +808,7 @@ struct
#include <sys/socket.h>
#include <stddef.h>

int main()
int main(void)
{
accept4(0, NULL, 0, 0);
return 0;
Expand Down
5 changes: 4 additions & 1 deletion src/unix/lwt_libev_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/* Stubs for libev */

#include "lwt_config.h"
#include "lwt_unix.h"

#if defined(HAVE_LIBEV)

Expand All @@ -21,6 +20,8 @@
#include <caml/signals.h>
#include <ev.h>

#include "lwt_unix.h"

/* +-----------------------------------------------------------------+
| Backend types |
+-----------------------------------------------------------------+ */
Expand Down Expand Up @@ -221,6 +222,8 @@ CAMLprim value lwt_libev_timer_stop(value loop, value val_watcher) {

#else

#include "lwt_unix.h"

LWT_NOT_AVAILABLE1(libev_init)
LWT_NOT_AVAILABLE1(libev_stop)
LWT_NOT_AVAILABLE2(libev_loop)
Expand Down
2 changes: 1 addition & 1 deletion src/unix/lwt_process_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#if defined(LWT_ON_WINDOWS)

#include <lwt_unix.h>
#include "lwt_unix.h"

#if OCAML_VERSION < 41300
#define CAML_INTERNALS
Expand Down
5 changes: 5 additions & 0 deletions src/unix/lwt_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#include <caml/socketaddr.h>
#include <string.h>

#if OCAML_VERSION < 50000
#define caml_convert_flag_list(flags, table) \
caml_convert_flag_list((flags), (int *)(table))
#endif

/* The macro to get the file-descriptor from a value. */
#if defined(LWT_ON_WINDOWS)
#define FD_val(value) win_CRT_fd_of_filedescr(value)
Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_access_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
1 change: 1 addition & 0 deletions src/unix/unix_c/unix_bytes_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/socket.h>

#include "lwt_unix.h"
#include "unix_recv_send_utils.h"

value lwt_unix_bytes_recv(value fd, value buf, value ofs, value len,
Expand Down
1 change: 1 addition & 0 deletions src/unix/unix_c/unix_bytes_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sys/types.h>
#include <sys/socket.h>

#include "lwt_unix.h"
#include "unix_recv_send_utils.h"

value lwt_unix_bytes_recvfrom(value fd, value buf, value ofs, value len,
Expand Down
1 change: 1 addition & 0 deletions src/unix/unix_c/unix_bytes_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/socket.h>

#include "lwt_unix.h"
#include "unix_recv_send_utils.h"

value lwt_unix_bytes_send(value fd, value buf, value ofs, value len,
Expand Down
1 change: 1 addition & 0 deletions src/unix/unix_c/unix_bytes_sendto.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sys/types.h>
#include <sys/socket.h>

#include "lwt_unix.h"
#include "unix_recv_send_utils.h"

value lwt_unix_bytes_sendto(value fd, value buf, value ofs, value len,
Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_chdir_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_chmod_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_chown_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_chroot_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_close_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_fchmod_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_fchown_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_fdatasync_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS) && defined(HAVE_FDATASYNC)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_fsync_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_ftruncate_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_link_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
3 changes: 2 additions & 1 deletion src/unix/unix_c/unix_lseek_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

/* Caml headers. */
#include <lwt_unix.h>
#include "lwt_config.h"
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include "lwt_unix.h"

#if !defined(LWT_ON_WINDOWS)

Expand Down
Loading