Source file posix_types_generated_constants.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
[@@@warning "-9-27"]
include Ctypes
let lift x = x
open Ctypes_static
let rec field : type t a. t typ -> string -> a typ -> (a, t) field =
fun s fname ftype -> match s, fname with
| View { ty; _ }, _ ->
let { ftype; foffset; fname } = field ty fname ftype in
{ ftype; foffset; fname }
| _ -> failwith ("Unexpected field "^ fname)
let rec seal : type a. a typ -> unit = function
| Struct { tag; spec = Complete _; _ } ->
raise (ModifyingSealedType tag)
| Union { utag; uspec = Some _; _ } ->
raise (ModifyingSealedType utag)
| View { ty; _ } -> seal ty
| _ ->
raise (Unsupported "Sealing a non-structured type")
type 'a const = 'a
let constant (type t) name (t : t typ) : t = match t, name with
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_RWLOCKATTR_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_RWLOCK_T_SIZE" ->
56
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_ONCE_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_MUTEXATTR_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_MUTEX_T_SIZE" ->
40
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_KEY_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_CONDATTR_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_COND_T_SIZE" ->
48
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_ATTR_T_SIZE" ->
56
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_T_ALIGNMENT" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_RWLOCKATTR_T_ALIGNMENT" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_RWLOCK_T_ALIGNMENT" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_ONCE_T_ALIGNMENT" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_MUTEXATTR_T_ALIGNMENT" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_MUTEX_T_ALIGNMENT" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_KEY_T_ALIGNMENT" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_CONDATTR_T_ALIGNMENT" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_COND_T_ALIGNMENT" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PTHREAD_ATTR_T_ALIGNMENT" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "USECONDS_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "UID_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Bool, "IS_TIME_T_FLOAT" ->
((0) <> 0)
| Ctypes_static.Primitive Cstubs_internals.Int, "TIME_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "SUSECONDS_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "SSIZE_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "SIZE_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "PID_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "OFF_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "NLINK_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "MODE_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Bool, "IS_KEY_T_FLOAT" ->
((0) <> 0)
| Ctypes_static.Primitive Cstubs_internals.Int, "KEY_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "INO_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "ID_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "GID_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "FSFILCNT_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "FSBLKCNT_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "DEV_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Bool, "IS_CLOCK_T_FLOAT" ->
((0) <> 0)
| Ctypes_static.Primitive Cstubs_internals.Int, "CLOCKID_T_SIZE" ->
4
| Ctypes_static.Primitive Cstubs_internals.Int, "CLOCK_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "BLKSIZE_T_SIZE" ->
8
| Ctypes_static.Primitive Cstubs_internals.Int, "BLKCNT_T_SIZE" ->
8
| _, s -> failwith ("unmatched constant: "^ s)
let enum (type a) name ?typedef ?unexpected (alist : (a * int64) list) =
match name with
| s ->
failwith ("unmatched enum: "^ s)