First set of licensing changes
[mono.git] / mono / sgen / sgen-protocol.h
1 /*
2  * sgen-protocol.h: Binary protocol of internal activity, to aid
3  * debugging.
4  *
5  * Copyright 2001-2003 Ximian, Inc
6  * Copyright 2003-2010 Novell, Inc.
7  * Copyright (C) 2012 Xamarin Inc
8  *
9  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
10  */
11
12 #ifndef __MONO_SGENPROTOCOL_H__
13 #define __MONO_SGENPROTOCOL_H__
14
15 #include "sgen-gc.h"
16
17 /* Special indices returned by MATCH_INDEX. */
18 #define BINARY_PROTOCOL_NO_MATCH (-1)
19 #define BINARY_PROTOCOL_MATCH (-2)
20
21 #define PROTOCOL_ID(method) method ## _id
22 #define PROTOCOL_STRUCT(method) method ## _struct
23 #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method
24
25 #define TYPE_INT int
26 #define TYPE_LONGLONG long long
27 #define TYPE_SIZE size_t
28 #define TYPE_POINTER gpointer
29 #define TYPE_BOOL gboolean
30
31 enum {
32 #define BEGIN_PROTOCOL_ENTRY0(method) PROTOCOL_ID(method),
33 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) PROTOCOL_ID(method),
34 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
35 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
36 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
37 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
38 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
39 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) PROTOCOL_ID(method),
40 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) PROTOCOL_ID(method),
41 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
42 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
43 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
44 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
45 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
46
47 #define DEFAULT_PRINT()
48 #define CUSTOM_PRINT(_)
49
50 #define IS_ALWAYS_MATCH(_)
51 #define MATCH_INDEX(_)
52 #define IS_VTABLE_MATCH(_)
53
54 #define END_PROTOCOL_ENTRY
55 #define END_PROTOCOL_ENTRY_FLUSH
56 #define END_PROTOCOL_ENTRY_HEAVY
57
58 #include "sgen-protocol-def.h"
59 };
60
61 #define BEGIN_PROTOCOL_ENTRY0(method)
62 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
63         typedef struct { \
64                 t1 f1; \
65         } PROTOCOL_STRUCT(method);
66 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
67         typedef struct { \
68                 t1 f1; \
69                 t2 f2; \
70         } PROTOCOL_STRUCT(method);
71 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
72         typedef struct { \
73                 t1 f1; \
74                 t2 f2; \
75                 t3 f3; \
76         } PROTOCOL_STRUCT(method);
77 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
78         typedef struct { \
79                 t1 f1; \
80                 t2 f2; \
81                 t3 f3; \
82                 t4 f4; \
83         } PROTOCOL_STRUCT(method);
84 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
85         typedef struct { \
86                 t1 f1; \
87                 t2 f2; \
88                 t3 f3; \
89                 t4 f4; \
90                 t5 f5; \
91         } PROTOCOL_STRUCT(method);
92 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
93         typedef struct { \
94                 t1 f1; \
95                 t2 f2; \
96                 t3 f3; \
97                 t4 f4; \
98                 t5 f5; \
99                 t6 f6; \
100         } PROTOCOL_STRUCT(method);
101
102 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
103         BEGIN_PROTOCOL_ENTRY0 (method)
104 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
105         BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
106 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
107         BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
108 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
109         BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
110 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
111         BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
112 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
113         BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
114 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
115         BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
116
117 #define DEFAULT_PRINT()
118 #define CUSTOM_PRINT(_)
119
120 #define IS_ALWAYS_MATCH(_)
121 #define MATCH_INDEX(_)
122 #define IS_VTABLE_MATCH(_)
123
124 #define END_PROTOCOL_ENTRY
125 #define END_PROTOCOL_ENTRY_FLUSH
126 #define END_PROTOCOL_ENTRY_HEAVY
127
128 #include "sgen-protocol-def.h"
129
130 /* missing: finalizers, roots, non-store wbarriers */
131
132 void binary_protocol_init (const char *filename, long long limit);
133 gboolean binary_protocol_is_enabled (void);
134
135 void binary_protocol_flush_buffers (gboolean force);
136
137 #define BEGIN_PROTOCOL_ENTRY0(method) \
138         void method (void);
139 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
140         void method (t1 f1);
141 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
142         void method (t1 f1, t2 f2);
143 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
144         void method (t1 f1, t2 f2, t3 f3);
145 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
146         void method (t1 f1, t2 f2, t3 f3, t4 f4);
147 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
148         void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5);
149 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
150         void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
151
152 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
153 #define binary_protocol_is_heavy_enabled()      binary_protocol_is_enabled ()
154
155 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
156         BEGIN_PROTOCOL_ENTRY0 (method)
157 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
158         BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
159 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
160         BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
161 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
162         BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
163 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
164         BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
165 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
166         BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
167 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
168         BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
169 #else
170 #define binary_protocol_is_heavy_enabled()      FALSE
171
172 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
173         static inline void method (void) {}
174 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
175         static inline void method (t1 f1) {}
176 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
177         static inline void method (t1 f1, t2 f2) {}
178 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
179         static inline void method (t1 f1, t2 f2, t3 f3) {}
180 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
181         static inline void method (t1 f1, t2 f2, t3 f3, t4 f4) {}
182 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
183         static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5) {}
184 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
185         static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6) {}
186 #endif
187
188 #define DEFAULT_PRINT()
189 #define CUSTOM_PRINT(_)
190
191 #define IS_ALWAYS_MATCH(_)
192 #define MATCH_INDEX(_)
193 #define IS_VTABLE_MATCH(_)
194
195 #define END_PROTOCOL_ENTRY
196 #define END_PROTOCOL_ENTRY_FLUSH
197 #define END_PROTOCOL_ENTRY_HEAVY
198
199 #include "sgen-protocol-def.h"
200
201 #undef TYPE_INT
202 #undef TYPE_LONGLONG
203 #undef TYPE_SIZE
204 #undef TYPE_POINTER
205 #undef TYPE_BOOL
206
207 #endif