Skip to content

Commit d9038f7

Browse files
authored
flambda-backend: Revert unixsupport_unix.c to the upstream version (#2110)
Revert unixsupport_unix.c to the upstream version when using runtime5
1 parent a998ddf commit d9038f7

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

otherlibs/unix/unixsupport_unix.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include <caml/callback.h>
2121
#include <caml/memory.h>
2222
#include <caml/fail.h>
23-
/* BACKPORT
23+
#ifdef CAML_RUNTIME_5
2424
#include <caml/platform.h>
25-
*/
25+
#endif
2626
#include "unixsupport.h"
2727
#include "cst2constr.h"
2828
#include <errno.h>
@@ -291,6 +291,37 @@ int caml_unix_code_of_unix_error (value error)
291291

292292
static const value * _Atomic caml_unix_error_exn = NULL;
293293

294+
#ifdef CAML_RUNTIME_5
295+
296+
void caml_unix_error(int errcode, const char *cmdname, value cmdarg)
297+
{
298+
CAMLparam0();
299+
CAMLlocal3(name, err, arg);
300+
value res;
301+
const value * exn;
302+
303+
exn = atomic_load_acquire(&caml_unix_error_exn);
304+
if (exn == NULL) {
305+
exn = caml_named_value("Unix.Unix_error");
306+
if (exn == NULL)
307+
caml_invalid_argument("Exception Unix.Unix_error not initialized,"
308+
" please link unix.cma");
309+
atomic_store(&caml_unix_error_exn, exn);
310+
}
311+
arg = cmdarg == Nothing ? caml_copy_string("") : cmdarg;
312+
name = caml_copy_string(cmdname);
313+
err = caml_unix_error_of_code (errcode);
314+
res = caml_alloc_small(4, 0);
315+
Field(res, 0) = *exn;
316+
Field(res, 1) = err;
317+
Field(res, 2) = name;
318+
Field(res, 3) = arg;
319+
caml_raise(res);
320+
CAMLnoreturn;
321+
}
322+
323+
#else
324+
294325
void caml_unix_error(int errcode, const char *cmdname, value cmdarg)
295326
{
296327
CAMLparam0();
@@ -326,6 +357,8 @@ void caml_unix_error(int errcode, const char *cmdname, value cmdarg)
326357
CAMLnoreturn;
327358
}
328359

360+
#endif
361+
329362
void caml_uerror(const char *cmdname, value cmdarg)
330363
{
331364
caml_unix_error(errno, cmdname, cmdarg);

runtime/caml/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef CAML_CONFIG_H
1717
#define CAML_CONFIG_H
1818

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

2122
/* CAML_NAME_SPACE was introduced in OCaml 3.08 to declare compatibility with

0 commit comments

Comments
 (0)