Skip to content

Commit 48abed7

Browse files
authored
Merge pull request #1022 from MisterDA/modern-c
Modern C and compatibility fixes
2 parents 266f173 + 0da9177 commit 48abed7

38 files changed

+84
-43
lines changed

src/unix/config/discover.ml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ sig
165165
val add_link_flags : string list -> unit
166166
end =
167167
struct
168-
let c_flags = ref []
168+
let c_flags = ref ["-Wall"; "-fdiagnostics-color=always"]
169169
let link_flags = ref []
170170

171171
let extend c_flags' link_flags' =
@@ -424,7 +424,7 @@ struct
424424
let code = {|
425425
#include <ev.h>
426426

427-
int main()
427+
int main(void)
428428
{
429429
ev_default_loop(0);
430430
return 0;
@@ -452,7 +452,7 @@ struct
452452
let code = {|
453453
#include <pthread.h>
454454

455-
int main()
455+
int main(void)
456456
{
457457
pthread_create(0, 0, 0, 0);
458458
return 0;
@@ -494,7 +494,7 @@ struct
494494
compiles context {|
495495
#include <sys/eventfd.h>
496496

497-
int main()
497+
int main(void)
498498
{
499499
eventfd(0, 0);
500500
return 0;
@@ -511,7 +511,7 @@ struct
511511
#include <sys/types.h>
512512
#include <sys/socket.h>
513513

514-
int main()
514+
int main(void)
515515
{
516516
struct msghdr msg;
517517
msg.msg_controllen = 0;
@@ -531,7 +531,7 @@ struct
531531
#define _GNU_SOURCE
532532
#include <sched.h>
533533

534-
int main()
534+
int main(void)
535535
{
536536
sched_getcpu();
537537
return 0;
@@ -549,7 +549,7 @@ struct
549549
#define _GNU_SOURCE
550550
#include <sched.h>
551551

552-
int main()
552+
int main(void)
553553
{
554554
sched_getaffinity(0, 0, 0);
555555
return 0;
@@ -562,7 +562,7 @@ struct
562562
#include <sys/types.h>
563563
#include <sys/socket.h>
564564

565-
int main()
565+
int main(void)
566566
{
567567
struct |} ^ struct_name ^ {| cred;
568568
socklen_t cred_len = sizeof(cred);
@@ -612,7 +612,7 @@ struct
612612
#include <sys/types.h>
613613
#include <unistd.h>
614614

615-
int main()
615+
int main(void)
616616
{
617617
uid_t euid;
618618
gid_t egid;
@@ -630,7 +630,7 @@ struct
630630
compiles context {|
631631
#include <unistd.h>
632632

633-
int main()
633+
int main(void)
634634
{
635635
int (*fdatasyncp)(int) = fdatasync;
636636
fdatasyncp(0);
@@ -650,7 +650,7 @@ struct
650650
#include <netdb.h>
651651
#include <stddef.h>
652652
653-
int main()
653+
int main(void)
654654
{
655655
int x;
656656
x =
@@ -733,7 +733,7 @@ struct
733733
#define NON_R_GETHOSTBYNAME 1
734734
#endif
735735

736-
int main()
736+
int main(void)
737737
{
738738
#if defined(NON_R_GETHOSTBYNAME) || defined(NON_R_GETHOSTBYNAME)
739739
#error "not available"
@@ -750,7 +750,7 @@ struct
750750
#include <sys/stat.h>
751751
#include <unistd.h>
752752

753-
int main() {
753+
int main(void) {
754754
struct stat *buf;
755755
double a, m, c;
756756
a = (double)buf->st_a|} ^ projection ^ {|;
@@ -790,9 +790,9 @@ struct
790790
#include <unistd.h>
791791
#include <sys/mman.h>
792792

793-
int main()
793+
int main(void)
794794
{
795-
int (*mincore_ptr)(void*, size_t, unsigned char*) = mincore;
795+
int (*mincore_ptr)(const void*, size_t, char*) = mincore;
796796
return (int)(mincore_ptr == NULL);
797797
}
798798
|}
@@ -808,7 +808,7 @@ struct
808808
#include <sys/socket.h>
809809
#include <stddef.h>
810810

811-
int main()
811+
int main(void)
812812
{
813813
accept4(0, NULL, 0, 0);
814814
return 0;

src/unix/lwt_libev_stubs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/* Stubs for libev */
77

88
#include "lwt_config.h"
9-
#include "lwt_unix.h"
109

1110
#if defined(HAVE_LIBEV)
1211

@@ -21,6 +20,8 @@
2120
#include <caml/signals.h>
2221
#include <ev.h>
2322

23+
#include "lwt_unix.h"
24+
2425
/* +-----------------------------------------------------------------+
2526
| Backend types |
2627
+-----------------------------------------------------------------+ */
@@ -221,6 +222,8 @@ CAMLprim value lwt_libev_timer_stop(value loop, value val_watcher) {
221222

222223
#else
223224

225+
#include "lwt_unix.h"
226+
224227
LWT_NOT_AVAILABLE1(libev_init)
225228
LWT_NOT_AVAILABLE1(libev_stop)
226229
LWT_NOT_AVAILABLE2(libev_loop)

src/unix/lwt_process_stubs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#if defined(LWT_ON_WINDOWS)
99

10-
#include <lwt_unix.h>
10+
#include "lwt_unix.h"
1111

1212
#if OCAML_VERSION < 41300
1313
#define CAML_INTERNALS

src/unix/lwt_unix.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
#include <caml/socketaddr.h>
1515
#include <string.h>
1616

17+
#if OCAML_VERSION < 50000
18+
#define caml_convert_flag_list(flags, table) \
19+
caml_convert_flag_list((flags), (int *)(table))
20+
#endif
21+
1722
/* The macro to get the file-descriptor from a value. */
1823
#if defined(LWT_ON_WINDOWS)
1924
#define FD_val(value) win_CRT_fd_of_filedescr(value)

src/unix/unix_c/unix_access_job.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
*/
1717

1818
/* Caml headers. */
19-
#include <lwt_unix.h>
19+
#include "lwt_config.h"
2020
#include <caml/memory.h>
2121
#include <caml/alloc.h>
2222
#include <caml/fail.h>
2323
#include <caml/signals.h>
24+
#include "lwt_unix.h"
2425

2526
#if !defined(LWT_ON_WINDOWS)
2627

src/unix/unix_c/unix_bytes_recv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <sys/types.h>
1515
#include <sys/socket.h>
1616

17+
#include "lwt_unix.h"
1718
#include "unix_recv_send_utils.h"
1819

1920
value lwt_unix_bytes_recv(value fd, value buf, value ofs, value len,

src/unix/unix_c/unix_bytes_recvfrom.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <sys/types.h>
1717
#include <sys/socket.h>
1818

19+
#include "lwt_unix.h"
1920
#include "unix_recv_send_utils.h"
2021

2122
value lwt_unix_bytes_recvfrom(value fd, value buf, value ofs, value len,

src/unix/unix_c/unix_bytes_send.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <sys/types.h>
1515
#include <sys/socket.h>
1616

17+
#include "lwt_unix.h"
1718
#include "unix_recv_send_utils.h"
1819

1920
value lwt_unix_bytes_send(value fd, value buf, value ofs, value len,

src/unix/unix_c/unix_bytes_sendto.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <sys/types.h>
1616
#include <sys/socket.h>
1717

18+
#include "lwt_unix.h"
1819
#include "unix_recv_send_utils.h"
1920

2021
value lwt_unix_bytes_sendto(value fd, value buf, value ofs, value len,

src/unix/unix_c/unix_chdir_job.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
*/
1717

1818
/* Caml headers. */
19-
#include <lwt_unix.h>
19+
#include "lwt_config.h"
2020
#include <caml/memory.h>
2121
#include <caml/alloc.h>
2222
#include <caml/fail.h>
2323
#include <caml/signals.h>
24+
#include "lwt_unix.h"
2425

2526
#if !defined(LWT_ON_WINDOWS)
2627

0 commit comments

Comments
 (0)