-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtraction_ffi.v
34 lines (24 loc) · 999 Bytes
/
Extraction_ffi.v
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
(* @eladrion's example for issue #18212 *)
From Stdlib Require Extraction.
(* Define an axiomatic function. *)
Axiom ax_fun : nat -> nat.
(* Define a fully specified function*)
Definition exact_fun (a : nat) := (ax_fun a) + 1.
(* Define duplicate of the fully specified function*)
Definition exact_fun2 (a : nat) := (ax_fun a) + 1.
(* before we give the directive axioms produce failwith "axiom to be realized" *)
Extraction ax_fun.
(* ax_fun shall be a FFI call to the C function my_c_fun *)
Extract Foreign Constant ax_fun => "my_c_fun".
Extraction ax_fun.
(* Extract exact_fun *)
Extraction exact_fun.
(* exact_fun shall now be a FFI call to the C function my_c_fun *)
Extract Foreign Constant exact_fun => "my_exact_c_fun".
Extraction exact_fun.
(* Now, exact_fun is an entry point exposed to C *)
Extract Callback "call_exact_fun" exact_fun2.
Extraction exact_fun2.
(* Now we make sure that a callback registration can be reverted *)
Reset Extraction Callback.
Extraction exact_fun2.