Backport from sid to buster
[hcoop/debian/mlton.git] / mlton / atoms / c-function.sig
1 (* Copyright (C) 2009,2015 Matthew Fluet.
2 * Copyright (C) 2004-2006 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9 signature C_FUNCTION_STRUCTS =
10 sig
11 structure CType: C_TYPE
12 end
13
14 signature C_FUNCTION =
15 sig
16 include C_FUNCTION_STRUCTS
17
18 structure Convention:
19 sig
20 datatype t = Cdecl | Stdcall
21
22 val layout: t -> Layout.t
23 val toString: t -> string
24 end
25
26 structure Kind:
27 sig
28 datatype t =
29 Impure
30 | Pure
31 | Runtime of {(* bytesNeeded = SOME i means that the i'th
32 * argument to the function is a word that
33 * specifies the number of bytes that must be
34 * free in order for the C function to succeed.
35 * Limit check insertion is responsible for
36 * making sure that the bytesNeeded is available.
37 *)
38 bytesNeeded: int option,
39 ensuresBytesFree: bool,
40 mayGC: bool,
41 maySwitchThreads: bool,
42 modifiesFrontier: bool,
43 readsStackTop: bool,
44 writesStackTop: bool}
45
46 val impure: t
47 val pure: t
48 val reentrant: t
49 val runtimeDefault: t
50
51 val layout: t -> Layout.t
52 val toString: t -> string
53
54 val bytesNeeded: t -> int option
55 val ensuresBytesFree: t -> bool
56 val mayGC: t -> bool
57 val maySwitchThreads: t -> bool
58 val modifiesFrontier: t -> bool
59 val readsStackTop: t -> bool
60 val writesStackTop: t -> bool
61 end
62
63 structure SymbolScope:
64 sig
65 datatype t = External | Private | Public
66
67 val layout: t -> Layout.t
68 val toString: t -> string
69 end
70
71 structure Target:
72 sig
73 datatype t = Direct of string | Indirect
74
75 val layout: t -> Layout.t
76 val toString: t -> string
77 end
78
79 datatype 'a t = T of {args: 'a vector,
80 convention: Convention.t,
81 kind: Kind.t,
82 prototype: CType.t vector * CType.t option,
83 return: 'a,
84 symbolScope: SymbolScope.t,
85 (* target = Indirect means that the 0'th
86 * argument to the function is a word
87 * that specifies the target.
88 *)
89 target: Target.t}
90
91 val args: 'a t -> 'a vector
92 val bytesNeeded: 'a t -> int option
93 val convention: 'a t -> Convention.t
94 val ensuresBytesFree: 'a t -> bool
95 val equals: 'a t * 'a t -> bool
96 val cPointerType: 'a t -> string
97 val cPrototype: 'a t -> string
98 val isOk: 'a t * {isUnit: 'a -> bool} -> bool
99 val layout: 'a t * ('a -> Layout.t) -> Layout.t
100 val map: 'a t * ('a -> 'b) -> 'b t
101 val mayGC: 'a t -> bool
102 val maySwitchThreads: 'a t -> bool
103 val modifiesFrontier: 'a t -> bool
104 val prototype: 'a t -> CType.t vector * CType.t option
105 val readsStackTop: 'a t -> bool
106 val return: 'a t -> 'a
107 val symbolScope: 'a t -> SymbolScope.t
108 val target: 'a t -> Target.t
109 val writesStackTop: 'a t -> bool
110 val vanilla: {args: 'a vector,
111 name: string,
112 prototype: CType.t vector * CType.t option,
113 return: 'a} -> 'a t
114 end