Merge pull request #2987 from spouliot/ipv6only
[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 #define PROTOCOL_HEADER_CHECK 0xde7ec7ab1ec0de
18 #define PROTOCOL_HEADER_VERSION 1
19
20 /* Special indices returned by MATCH_INDEX. */
21 #define BINARY_PROTOCOL_NO_MATCH (-1)
22 #define BINARY_PROTOCOL_MATCH (-2)
23
24 /* We pack all protocol structs by default unless specified otherwise */
25 #ifndef PROTOCOL_STRUCT_ATTR
26 #ifdef __GNUC__
27 #define PROTOCOL_STRUCT_ATTR __attribute__ ((packed))
28 #else
29 #define PROTOCOL_STRUCT_ATTR
30 #endif
31 #endif
32
33 #define PROTOCOL_ID(method) method ## _id
34 #define PROTOCOL_STRUCT(method) method ## _struct
35 #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method
36
37 #ifndef TYPE_INT
38 #define TYPE_INT int
39 #endif
40 #ifndef TYPE_LONGLONG
41 #define TYPE_LONGLONG long long
42 #endif
43 #ifndef TYPE_SIZE
44 #define TYPE_SIZE size_t
45 #endif
46 #ifndef TYPE_POINTER
47 #define TYPE_POINTER gpointer
48 #endif
49 #ifndef TYPE_BOOL
50 #define TYPE_BOOL gboolean
51 #endif
52
53 enum {
54 #define BEGIN_PROTOCOL_ENTRY0(method) PROTOCOL_ID(method),
55 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) PROTOCOL_ID(method),
56 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
57 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
58 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
59 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
60 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
61 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) PROTOCOL_ID(method),
62 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) PROTOCOL_ID(method),
63 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
64 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
65 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
66 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
67 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
68
69 #define DEFAULT_PRINT()
70 #define CUSTOM_PRINT(_)
71
72 #define IS_ALWAYS_MATCH(_)
73 #define MATCH_INDEX(_)
74 #define IS_VTABLE_MATCH(_)
75
76 #define END_PROTOCOL_ENTRY
77 #define END_PROTOCOL_ENTRY_FLUSH
78 #define END_PROTOCOL_ENTRY_HEAVY
79
80 #include "sgen-protocol-def.h"
81 };
82
83 #define BEGIN_PROTOCOL_ENTRY0(method)
84 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
85         typedef struct PROTOCOL_STRUCT_ATTR { \
86                 t1 f1; \
87         } PROTOCOL_STRUCT(method);
88 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
89         typedef struct PROTOCOL_STRUCT_ATTR { \
90                 t1 f1; \
91                 t2 f2; \
92         } PROTOCOL_STRUCT(method);
93 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
94         typedef struct PROTOCOL_STRUCT_ATTR { \
95                 t1 f1; \
96                 t2 f2; \
97                 t3 f3; \
98         } PROTOCOL_STRUCT(method);
99 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
100         typedef struct PROTOCOL_STRUCT_ATTR { \
101                 t1 f1; \
102                 t2 f2; \
103                 t3 f3; \
104                 t4 f4; \
105         } PROTOCOL_STRUCT(method);
106 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
107         typedef struct PROTOCOL_STRUCT_ATTR { \
108                 t1 f1; \
109                 t2 f2; \
110                 t3 f3; \
111                 t4 f4; \
112                 t5 f5; \
113         } PROTOCOL_STRUCT(method);
114 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
115         typedef struct PROTOCOL_STRUCT_ATTR { \
116                 t1 f1; \
117                 t2 f2; \
118                 t3 f3; \
119                 t4 f4; \
120                 t5 f5; \
121                 t6 f6; \
122         } PROTOCOL_STRUCT(method);
123
124 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
125         BEGIN_PROTOCOL_ENTRY0 (method)
126 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
127         BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
128 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
129         BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
130 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
131         BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
132 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
133         BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
134 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
135         BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
136 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
137         BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
138
139 #define DEFAULT_PRINT()
140 #define CUSTOM_PRINT(_)
141
142 #define IS_ALWAYS_MATCH(_)
143 #define MATCH_INDEX(_)
144 #define IS_VTABLE_MATCH(_)
145
146 #define END_PROTOCOL_ENTRY
147 #define END_PROTOCOL_ENTRY_FLUSH
148 #define END_PROTOCOL_ENTRY_HEAVY
149
150 #include "sgen-protocol-def.h"
151
152 /* missing: finalizers, roots, non-store wbarriers */
153
154 void binary_protocol_init (const char *filename, long long limit);
155 gboolean binary_protocol_is_enabled (void);
156
157 void binary_protocol_flush_buffers (gboolean force);
158
159 #define BEGIN_PROTOCOL_ENTRY0(method) \
160         void method (void);
161 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
162         void method (t1 f1);
163 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
164         void method (t1 f1, t2 f2);
165 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
166         void method (t1 f1, t2 f2, t3 f3);
167 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
168         void method (t1 f1, t2 f2, t3 f3, t4 f4);
169 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
170         void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5);
171 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
172         void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
173
174 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
175 #define binary_protocol_is_heavy_enabled()      binary_protocol_is_enabled ()
176
177 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
178         BEGIN_PROTOCOL_ENTRY0 (method)
179 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
180         BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
181 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
182         BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
183 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
184         BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
185 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
186         BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
187 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
188         BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
189 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
190         BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
191 #else
192 #define binary_protocol_is_heavy_enabled()      FALSE
193
194 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
195         static inline void method (void) {}
196 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
197         static inline void method (t1 f1) {}
198 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
199         static inline void method (t1 f1, t2 f2) {}
200 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
201         static inline void method (t1 f1, t2 f2, t3 f3) {}
202 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
203         static inline void method (t1 f1, t2 f2, t3 f3, t4 f4) {}
204 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
205         static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5) {}
206 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
207         static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6) {}
208 #endif
209
210 #define DEFAULT_PRINT()
211 #define CUSTOM_PRINT(_)
212
213 #define IS_ALWAYS_MATCH(_)
214 #define MATCH_INDEX(_)
215 #define IS_VTABLE_MATCH(_)
216
217 #define END_PROTOCOL_ENTRY
218 #define END_PROTOCOL_ENTRY_FLUSH
219 #define END_PROTOCOL_ENTRY_HEAVY
220
221 #include "sgen-protocol-def.h"
222
223 #undef TYPE_INT
224 #undef TYPE_LONGLONG
225 #undef TYPE_SIZE
226 #undef TYPE_POINTER
227 #undef TYPE_BOOL
228
229 #endif