diff --git a/common b/common index c8e64b3ff..30d3e9213 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit c8e64b3ff0870871905b0ece60aebf512777948a +Subproject commit 30d3e921307ddf687fc6666aca99354a8daee27e diff --git a/lib/guestfs-internal-all.h b/lib/guestfs-internal-all.h index e1ac29a78..df0b04a0b 100644 --- a/lib/guestfs-internal-all.h +++ b/lib/guestfs-internal-all.h @@ -164,4 +164,9 @@ extern int accept4 (int sockfd, struct sockaddr *__restrict__ addr, extern int pipe2 (int pipefd[2], int flags); #endif +#ifndef HAVE_CAML_UNIX_ERROR +/* For backwards compatibility with OCaml < 5.0 */ +#define caml_unix_error unix_error +#endif + #endif /* GUESTFS_INTERNAL_ALL_H_ */ diff --git a/m4/guestfs-ocaml.m4 b/m4/guestfs-ocaml.m4 index 10d443408..200d27f3a 100644 --- a/m4/guestfs-ocaml.m4 +++ b/m4/guestfs-ocaml.m4 @@ -191,3 +191,19 @@ if test "x$INSTALL_OCAMLLIB" = "x"; then INSTALL_OCAMLLIB=$OCAMLLIB fi AC_SUBST([INSTALL_OCAMLLIB]) + +dnl Check if OCaml has caml_unix_error (added 2022, OCaml 5.0). +AC_MSG_CHECKING([for caml_unix_error]) +cat >conftest.c <<'EOF' +#include +#include +int main () { char *p = (void *) caml_unix_error; return 0; } +EOF +AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_CAML_UNIX_ERROR],[1], + [caml_unix_error found at compile time.]) +],[ + AC_MSG_RESULT([no]) +]) +rm -f conftest.c conftest.o