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

Revert unixsupport_unix.c to the upstream version #2110

Merged
merged 1 commit into from
Dec 4, 2023
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
37 changes: 35 additions & 2 deletions ocaml/otherlibs/unix/unixsupport_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <caml/callback.h>
#include <caml/memory.h>
#include <caml/fail.h>
/* BACKPORT
#ifdef CAML_RUNTIME_5
#include <caml/platform.h>
*/
#endif
#include "unixsupport.h"
#include "cst2constr.h"
#include <errno.h>
Expand Down Expand Up @@ -291,6 +291,37 @@ int caml_unix_code_of_unix_error (value error)

static const value * _Atomic caml_unix_error_exn = NULL;

#ifdef CAML_RUNTIME_5

void caml_unix_error(int errcode, const char *cmdname, value cmdarg)
{
CAMLparam0();
CAMLlocal3(name, err, arg);
value res;
const value * exn;

exn = atomic_load_acquire(&caml_unix_error_exn);
if (exn == NULL) {
exn = caml_named_value("Unix.Unix_error");
if (exn == NULL)
caml_invalid_argument("Exception Unix.Unix_error not initialized,"
" please link unix.cma");
atomic_store(&caml_unix_error_exn, exn);
}
arg = cmdarg == Nothing ? caml_copy_string("") : cmdarg;
name = caml_copy_string(cmdname);
err = caml_unix_error_of_code (errcode);
res = caml_alloc_small(4, 0);
Field(res, 0) = *exn;
Field(res, 1) = err;
Field(res, 2) = name;
Field(res, 3) = arg;
caml_raise(res);
CAMLnoreturn;
}

#else

void caml_unix_error(int errcode, const char *cmdname, value cmdarg)
{
CAMLparam0();
Expand Down Expand Up @@ -326,6 +357,8 @@ void caml_unix_error(int errcode, const char *cmdname, value cmdarg)
CAMLnoreturn;
}

#endif

void caml_uerror(const char *cmdname, value cmdarg)
{
caml_unix_error(errno, cmdname, cmdarg);
Expand Down
1 change: 1 addition & 0 deletions ocaml/runtime/caml/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef CAML_CONFIG_H
#define CAML_CONFIG_H

/* CR ocaml 5 all-runtime5: remove this and all uses of it */
#define CAML_RUNTIME_5

/* CAML_NAME_SPACE was introduced in OCaml 3.08 to declare compatibility with
Expand Down
Loading