m4/guestfs-ocaml.m4: Check for caml_unix_error

In OCaml 5.0, unix_error was renamed caml_unix_error.

If it's not available, define as unix_error, the old symbol name.
This commit is contained in:
Richard W.M. Jones
2026-03-17 16:05:45 +00:00
parent 3bff5a6f79
commit 48607d9d15
3 changed files with 22 additions and 1 deletions

2
common

Submodule common updated: c8e64b3ff0...30d3e92130

View File

@@ -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_ */

View File

@@ -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 <caml/mlvalues.h>
#include <caml/unixsupport.h>
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