1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/**************************************************************************/
/* */
/* OCaml */
/* */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* */
/* Copyright 1995 Institut National de Recherche en Informatique et */
/* en Automatique. */
/* */
/* All rights reserved. This file is distributed under the terms of */
/* the GNU Lesser General Public License version 2.1, with the */
/* special exception on linking described in the file LICENSE. */
/* */
/**************************************************************************/
#include <signal.h>
#define CAML_INTERNALS
#include "caml/mlvalues.h"
#include "caml/memory.h"
#include "caml/callback.h"
#include "caml/signals.h"
value mycallback1(value fun, value arg)
{
value res;
res = caml_callback(fun, arg);
return res;
}
value mycallback2(value fun, value arg1, value arg2)
{
value res;
res = caml_callback2(fun, arg1, arg2);
return res;
}
value mycallback3(value fun, value arg1, value arg2, value arg3)
{
value res;
res = caml_callback3(fun, arg1, arg2, arg3);
return res;
}
value mycallback4(value fun, value arg1, value arg2, value arg3, value arg4)
{
value args[4];
value res;
args[0] = arg1;
args[1] = arg2;
args[2] = arg3;
args[3] = arg4;
res = caml_callbackN(fun, 4, args);
return res;
}
value mypushroot(value v, value fun, value arg)
{
CAMLparam1(v);
caml_callback(fun, arg);
CAMLreturn(v);
}
value mycamlparam (value v, value fun, value arg)
{
CAMLparam3 (v, fun, arg);
CAMLlocal2 (x, y);
x = v;
y = caml_callback (fun, arg);
v = x;
CAMLreturn (v);
}
value mykill(value pid, value signal)
{
int sig;
sig = caml_convert_signal_number(Int_val(signal));
kill(Int_val(pid), sig);
return Val_unit;
}
|