2 * sgen-protocol.h: Binary protocol of internal activity, to aid
5 * Copyright 2001-2003 Ximian, Inc
6 * Copyright 2003-2010 Novell, Inc.
7 * Copyright (C) 2012 Xamarin Inc
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
12 #ifndef __MONO_SGENPROTOCOL_H__
13 #define __MONO_SGENPROTOCOL_H__
17 #define PROTOCOL_HEADER_CHECK 0xde7ec7ab1ec0de
19 * The version needs to be bumped every time we introduce breaking changes (like
20 * adding new protocol entries or various format changes). The latest protocol grepper
21 * should be able to handle all the previous versions, while an old grepper will
22 * be able to tell if it cannot handle the format.
24 #define PROTOCOL_HEADER_VERSION 2
26 /* Special indices returned by MATCH_INDEX. */
27 #define BINARY_PROTOCOL_NO_MATCH (-1)
28 #define BINARY_PROTOCOL_MATCH (-2)
30 #define PROTOCOL_ID(method) method ## _id
31 #define PROTOCOL_STRUCT(method) method ## _struct
32 #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method
38 #define TYPE_LONGLONG long long
41 #define TYPE_SIZE size_t
44 #define TYPE_POINTER gpointer
47 #define TYPE_BOOL gboolean
51 #define BEGIN_PROTOCOL_ENTRY0(method) PROTOCOL_ID(method),
52 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) PROTOCOL_ID(method),
53 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
54 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
55 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
56 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
57 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
58 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) PROTOCOL_ID(method),
59 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) PROTOCOL_ID(method),
60 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
61 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
62 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
63 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
64 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
66 #define DEFAULT_PRINT()
67 #define CUSTOM_PRINT(_)
69 #define IS_ALWAYS_MATCH(_)
70 #define MATCH_INDEX(_)
71 #define IS_VTABLE_MATCH(_)
73 #define END_PROTOCOL_ENTRY
74 #define END_PROTOCOL_ENTRY_FLUSH
75 #define END_PROTOCOL_ENTRY_HEAVY
77 #include "sgen-protocol-def.h"
80 /* We pack all protocol structs by default unless specified otherwise */
81 #ifndef PROTOCOL_STRUCT_ATTR
83 #define PROTOCOL_PACK_STRUCTS
86 #define PROTOCOL_STRUCT_ATTR __attribute__ ((packed))
88 #define PROTOCOL_STRUCT_ATTR
93 #define BEGIN_PROTOCOL_ENTRY0(method)
94 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
95 typedef struct PROTOCOL_STRUCT_ATTR { \
97 } PROTOCOL_STRUCT(method);
98 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
99 typedef struct PROTOCOL_STRUCT_ATTR { \
102 } PROTOCOL_STRUCT(method);
103 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
104 typedef struct PROTOCOL_STRUCT_ATTR { \
108 } PROTOCOL_STRUCT(method);
109 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
110 typedef struct PROTOCOL_STRUCT_ATTR { \
115 } PROTOCOL_STRUCT(method);
116 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
117 typedef struct PROTOCOL_STRUCT_ATTR { \
123 } PROTOCOL_STRUCT(method);
124 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
125 typedef struct PROTOCOL_STRUCT_ATTR { \
132 } PROTOCOL_STRUCT(method);
134 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
135 BEGIN_PROTOCOL_ENTRY0 (method)
136 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
137 BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
138 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
139 BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
140 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
141 BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
142 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
143 BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
144 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
145 BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
146 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
147 BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
149 #define DEFAULT_PRINT()
150 #define CUSTOM_PRINT(_)
152 #define IS_ALWAYS_MATCH(_)
153 #define MATCH_INDEX(_)
154 #define IS_VTABLE_MATCH(_)
156 #define END_PROTOCOL_ENTRY
157 #define END_PROTOCOL_ENTRY_FLUSH
158 #define END_PROTOCOL_ENTRY_HEAVY
160 #if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS)
164 #include "sgen-protocol-def.h"
165 #if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS)
167 #undef PROTOCOL_PACK_STRUCTS
170 /* missing: finalizers, roots, non-store wbarriers */
172 void binary_protocol_init (const char *filename
, long long limit
);
173 gboolean
binary_protocol_is_enabled (void);
175 gboolean
binary_protocol_flush_buffers (gboolean force
);
177 #define BEGIN_PROTOCOL_ENTRY0(method) \
179 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
181 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
182 void method (t1 f1, t2 f2);
183 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
184 void method (t1 f1, t2 f2, t3 f3);
185 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
186 void method (t1 f1, t2 f2, t3 f3, t4 f4);
187 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
188 void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5);
189 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
190 void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
192 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
193 #define binary_protocol_is_heavy_enabled() binary_protocol_is_enabled ()
195 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
196 BEGIN_PROTOCOL_ENTRY0 (method)
197 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
198 BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
199 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
200 BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
201 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
202 BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
203 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
204 BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
205 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
206 BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
207 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
208 BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
210 #define binary_protocol_is_heavy_enabled() FALSE
212 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
213 static inline void method (void) {}
214 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
215 static inline void method (t1 f1) {}
216 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
217 static inline void method (t1 f1, t2 f2) {}
218 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
219 static inline void method (t1 f1, t2 f2, t3 f3) {}
220 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
221 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4) {}
222 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
223 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5) {}
224 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
225 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6) {}
228 #define DEFAULT_PRINT()
229 #define CUSTOM_PRINT(_)
231 #define IS_ALWAYS_MATCH(_)
232 #define MATCH_INDEX(_)
233 #define IS_VTABLE_MATCH(_)
235 #define END_PROTOCOL_ENTRY
236 #define END_PROTOCOL_ENTRY_FLUSH
237 #define END_PROTOCOL_ENTRY_HEAVY
239 #include "sgen-protocol-def.h"