Skip to content

Commit

Permalink
Warn on use of undefined macros
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA committed Nov 6, 2023
1 parent 3d76183 commit 44d2127
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
2 changes: 1 addition & 1 deletion configure

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

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ AS_CASE([$ocaml_cv_cc_vendor],
[outputobj='-o '
warn_error_flag='-Werror'
cc_warnings="-Wall -Wint-conversion -Wstrict-prototypes \
-Wold-style-definition"])
-Wold-style-definition -Wundef"])

# Use -Wold-style-declaration if supported
AX_CHECK_COMPILE_FLAG([-Wold-style-declaration],
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/unix/getcwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <caml/osdeps.h>
#include "unixsupport.h"

#if !defined (_WIN32) && !macintosh
#if !defined(_WIN32)
#include <sys/param.h>
#endif

Expand Down
43 changes: 19 additions & 24 deletions otherlibs/unix/gethost.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@

#define NETDB_BUFFER_SIZE 10000

#ifdef _WIN32
#define GETHOSTBYADDR_IS_REENTRANT 1
#define GETHOSTBYNAME_IS_REENTRANT 1
#endif

static value alloc_one_addr_4(char const *a)
{
return caml_alloc_initialized_string(4, a);
Expand Down Expand Up @@ -101,7 +96,15 @@ CAMLprim value caml_unix_gethostbyaddr(value a)
#if HAS_IPV6
}
#endif
#if HAS_GETHOSTBYADDR_R == 7
#if !defined(HAS_GETHOSTBYADDR_R)
#ifdef _WIN32
caml_enter_blocking_section();
#endif
hp = gethostbyaddr(adr, addr_len, addr_type);
#ifdef _WIN32
caml_leave_blocking_section();
#endif
#elif HAS_GETHOSTBYADDR_R == 7
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int h_errnop;
Expand All @@ -118,14 +121,6 @@ CAMLprim value caml_unix_gethostbyaddr(value a)
&h, buffer, sizeof(buffer), &hp, &h_errnop);
caml_leave_blocking_section();
if (rc != 0) hp = NULL;
#else
#ifdef GETHOSTBYADDR_IS_REENTRANT
caml_enter_blocking_section();
#endif
hp = gethostbyaddr(adr, addr_len, addr_type);
#ifdef GETHOSTBYADDR_IS_REENTRANT
caml_leave_blocking_section();
#endif
#endif
if (hp == (struct hostent *) NULL) caml_raise_not_found();
return alloc_host_entry(hp);
Expand All @@ -135,7 +130,7 @@ CAMLprim value caml_unix_gethostbyname(value name)
{
struct hostent * hp;
char * hostname;
#if HAS_GETHOSTBYNAME_R
#ifdef HAS_GETHOSTBYNAME_R
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int err;
Expand All @@ -145,7 +140,15 @@ CAMLprim value caml_unix_gethostbyname(value name)

hostname = caml_stat_strdup(String_val(name));

#if HAS_GETHOSTBYNAME_R == 5
#if !defined(HAS_GETHOSTBYNAME_R)
#ifdef _WIN32
caml_enter_blocking_section();
#endif
hp = gethostbyname(hostname);
#ifdef _WIN32
caml_leave_blocking_section();
#endif
#elif HAS_GETHOSTBYNAME_R == 5
{
caml_enter_blocking_section();
hp = gethostbyname_r(hostname, &h, buffer, sizeof(buffer), &err);
Expand All @@ -159,14 +162,6 @@ CAMLprim value caml_unix_gethostbyname(value name)
caml_leave_blocking_section();
if (rc != 0) hp = NULL;
}
#else
#ifdef GETHOSTBYNAME_IS_REENTRANT
caml_enter_blocking_section();
#endif
hp = gethostbyname(hostname);
#ifdef GETHOSTBYNAME_IS_REENTRANT
caml_leave_blocking_section();
#endif
#endif

caml_stat_free(hostname);
Expand Down
2 changes: 1 addition & 1 deletion runtime/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define CAML_INTERNALS

#if _MSC_VER >= 1400 && _MSC_VER < 1700
#if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1700
/* Microsoft introduced a regression in Visual Studio 2005 (technically it's
not present in the Windows Server 2003 SDK which has a pre-release version)
and the abort function ceased to be declared __declspec(noreturn). This was
Expand Down
2 changes: 1 addition & 1 deletion runtime/startup_byt.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static void do_print_config(void)
"false");
#endif
printf("windows_unicode: %s\n",
#if WINDOWS_UNICODE
#if defined(WINDOWS_UNICODE) && WINDOWS_UNICODE != 0
"true");
#else
"false");
Expand Down

0 comments on commit 44d2127

Please sign in to comment.