Source file posix_unistd_generated_stubs_unlocked.ml

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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
module CI = Cstubs_internals

external posix_unistd_unlocked_1_read : int -> _ CI.fatptr -> int -> int
  = "posix_unistd_unlocked_1_read" 

external posix_unistd_unlocked_2_write : int -> _ CI.fatptr -> int -> int
  = "posix_unistd_unlocked_2_write" 

external posix_unistd_unlocked_3_pread
  : int -> _ CI.fatptr -> int -> int -> int = "posix_unistd_unlocked_3_pread" 

external posix_unistd_unlocked_4_pwrite
  : int -> _ CI.fatptr -> int -> int -> int
  = "posix_unistd_unlocked_4_pwrite" 

external posix_unistd_unlocked_5_readlink
  : _ CI.fatptr -> _ CI.fatptr -> int -> int
  = "posix_unistd_unlocked_5_readlink" 

external posix_unistd_unlocked_6_lseek : int -> int -> int -> int
  = "posix_unistd_unlocked_6_lseek" 

external posix_unistd_unlocked_7_fork : unit -> int
  = "posix_unistd_unlocked_7_fork" 

external posix_unistd_unlocked_8_nice : int -> int
  = "posix_unistd_unlocked_8_nice" 

external posix_unistd_unlocked_9_sleep : int -> int
  = "posix_unistd_unlocked_9_sleep" 

external posix_unistd_unlocked_10_usleep : int -> int
  = "posix_unistd_unlocked_10_usleep" 

external posix_unistd_unlocked_11_pause : unit -> int
  = "posix_unistd_unlocked_11_pause" 

external posix_unistd_unlocked_12_alarm : int -> int
  = "posix_unistd_unlocked_12_alarm" 

external posix_unistd_unlocked_13_execv : _ CI.fatptr -> _ CI.fatptr -> int
  = "posix_unistd_unlocked_13_execv" 

external posix_unistd_unlocked_14_execve
  : _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> int
  = "posix_unistd_unlocked_14_execve" 

external posix_unistd_unlocked_15_execvp : _ CI.fatptr -> _ CI.fatptr -> int
  = "posix_unistd_unlocked_15_execvp" 

external posix_unistd_unlocked_16__exit : int -> unit
  = "posix_unistd_unlocked_16__exit" 

type 'a result = 'a
type 'a return = 'a
type 'a fn =
 | Returns  : 'a CI.typ   -> 'a return fn
 | Function : 'a CI.typ * 'b fn  -> ('a -> 'b) fn
let map_result f x = f x
let returning t = Returns t
let (@->) f p = Function (f, p)
let foreign : type a b. string -> (a -> b) fn -> (a -> b) =
  fun name t -> match t, name with
| Function (CI.Primitive CI.Int, Returns CI.Void), "_exit" ->
  posix_unistd_unlocked_16__exit
| Function
    (CI.View {CI.ty = CI.Pointer _; write = x3; _},
     Function
       (CI.View {CI.ty = CI.Pointer _; write = x7; _},
        Returns (CI.Primitive CI.Int))),
  "execvp" ->
  (fun x2 x6 ->
    let CI.CPointer x9 = x7 x6 in
    let CI.CPointer x5 = x3 x2 in
    let x4 = x5 in let x8 = x9 in posix_unistd_unlocked_15_execvp x4 x8)
| Function
    (CI.View {CI.ty = CI.Pointer _; write = x11; _},
     Function
       (CI.View {CI.ty = CI.Pointer _; write = x15; _},
        Function
          (CI.View {CI.ty = CI.Pointer _; write = x19; _},
           Returns (CI.Primitive CI.Int)))),
  "execve" ->
  (fun x10 x14 x18 ->
    let CI.CPointer x21 = x19 x18 in
    let CI.CPointer x17 = x15 x14 in
    let CI.CPointer x13 = x11 x10 in
    let x12 = x13 in
    let x16 = x17 in
    let x20 = x21 in posix_unistd_unlocked_14_execve x12 x16 x20)
| Function
    (CI.View {CI.ty = CI.Pointer _; write = x23; _},
     Function
       (CI.View {CI.ty = CI.Pointer _; write = x27; _},
        Returns (CI.Primitive CI.Int))),
  "execv" ->
  (fun x22 x26 ->
    let CI.CPointer x29 = x27 x26 in
    let CI.CPointer x25 = x23 x22 in
    let x24 = x25 in let x28 = x29 in posix_unistd_unlocked_13_execv x24 x28)
| Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)), "alarm" ->
  posix_unistd_unlocked_12_alarm
| Function (CI.Void, Returns (CI.Primitive CI.Int)), "pause" ->
  posix_unistd_unlocked_11_pause
| Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)), "usleep" ->
  posix_unistd_unlocked_10_usleep
| Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)), "sleep" ->
  posix_unistd_unlocked_9_sleep
| Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)), "nice" ->
  posix_unistd_unlocked_8_nice
| Function (CI.Void, Returns (CI.Primitive CI.Int)), "fork" ->
  posix_unistd_unlocked_7_fork
| Function
    (CI.Primitive CI.Int,
     Function
       (CI.Primitive CI.Int,
        Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)))),
  "lseek" -> posix_unistd_unlocked_6_lseek
| Function
    (CI.View {CI.ty = CI.Pointer _; write = x40; _},
     Function
       (CI.Pointer _,
        Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)))),
  "readlink" ->
  (fun x39 x43 x45 ->
    let CI.CPointer x44 = x43 in
    let CI.CPointer x42 = x40 x39 in
    let x41 = x42 in posix_unistd_unlocked_5_readlink x41 x44 x45)
| Function
    (CI.Primitive CI.Int,
     Function
       (CI.Pointer _,
        Function
          (CI.Primitive CI.Int,
           Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int))))),
  "pwrite" ->
  (fun x46 x47 x49 x50 ->
    let CI.CPointer x48 = x47 in
    posix_unistd_unlocked_4_pwrite x46 x48 x49 x50)
| Function
    (CI.Primitive CI.Int,
     Function
       (CI.Pointer _,
        Function
          (CI.Primitive CI.Int,
           Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int))))),
  "pread" ->
  (fun x51 x52 x54 x55 ->
    let CI.CPointer x53 = x52 in
    posix_unistd_unlocked_3_pread x51 x53 x54 x55)
| Function
    (CI.Primitive CI.Int,
     Function
       (CI.Pointer _,
        Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)))),
  "write" ->
  (fun x56 x57 x59 ->
    let CI.CPointer x58 = x57 in posix_unistd_unlocked_2_write x56 x58 x59)
| Function
    (CI.Primitive CI.Int,
     Function
       (CI.Pointer _,
        Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int)))),
  "read" ->
  (fun x60 x61 x63 ->
    let CI.CPointer x62 = x61 in posix_unistd_unlocked_1_read x60 x62 x63)
| _, s ->  Printf.ksprintf failwith "No match for %s" s


let foreign_value : type a. string -> a Ctypes.typ -> a Ctypes.ptr =
  fun name t -> match t, name with
| _, s ->  Printf.ksprintf failwith "No match for %s" s