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
18 #define PROTOCOL_HEADER_VERSION 1
20 /* Special indices returned by MATCH_INDEX. */
21 #define BINARY_PROTOCOL_NO_MATCH (-1)
22 #define BINARY_PROTOCOL_MATCH (-2)
24 #define PROTOCOL_ID(method) method ## _id
25 #define PROTOCOL_STRUCT(method) method ## _struct
26 #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method
32 #define TYPE_LONGLONG long long
35 #define TYPE_SIZE size_t
38 #define TYPE_POINTER gpointer
41 #define TYPE_BOOL gboolean
45 #define BEGIN_PROTOCOL_ENTRY0(method) PROTOCOL_ID(method),
46 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) PROTOCOL_ID(method),
47 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
48 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
49 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
50 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
51 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
52 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) PROTOCOL_ID(method),
53 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) PROTOCOL_ID(method),
54 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
55 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
56 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
57 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
58 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
60 #define DEFAULT_PRINT()
61 #define CUSTOM_PRINT(_)
63 #define IS_ALWAYS_MATCH(_)
64 #define MATCH_INDEX(_)
65 #define IS_VTABLE_MATCH(_)
67 #define END_PROTOCOL_ENTRY
68 #define END_PROTOCOL_ENTRY_FLUSH
69 #define END_PROTOCOL_ENTRY_HEAVY
71 #include "sgen-protocol-def.h"
74 /* We pack all protocol structs by default unless specified otherwise */
75 #ifndef PROTOCOL_STRUCT_ATTR
77 #define PROTOCOL_PACK_STRUCTS
80 #define PROTOCOL_STRUCT_ATTR __attribute__ ((packed))
82 #define PROTOCOL_STRUCT_ATTR
87 #define BEGIN_PROTOCOL_ENTRY0(method)
88 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
89 typedef struct PROTOCOL_STRUCT_ATTR { \
91 } PROTOCOL_STRUCT(method);
92 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
93 typedef struct PROTOCOL_STRUCT_ATTR { \
96 } PROTOCOL_STRUCT(method);
97 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
98 typedef struct PROTOCOL_STRUCT_ATTR { \
102 } PROTOCOL_STRUCT(method);
103 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
104 typedef struct PROTOCOL_STRUCT_ATTR { \
109 } PROTOCOL_STRUCT(method);
110 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
111 typedef struct PROTOCOL_STRUCT_ATTR { \
117 } PROTOCOL_STRUCT(method);
118 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
119 typedef struct PROTOCOL_STRUCT_ATTR { \
126 } PROTOCOL_STRUCT(method);
128 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
129 BEGIN_PROTOCOL_ENTRY0 (method)
130 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
131 BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
132 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
133 BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
134 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
135 BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
136 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
137 BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
138 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
139 BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
140 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
141 BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
143 #define DEFAULT_PRINT()
144 #define CUSTOM_PRINT(_)
146 #define IS_ALWAYS_MATCH(_)
147 #define MATCH_INDEX(_)
148 #define IS_VTABLE_MATCH(_)
150 #define END_PROTOCOL_ENTRY
151 #define END_PROTOCOL_ENTRY_FLUSH
152 #define END_PROTOCOL_ENTRY_HEAVY
154 #if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS)
158 #include "sgen-protocol-def.h"
159 #if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS)
161 #undef PROTOCOL_PACK_STRUCTS
164 /* missing: finalizers, roots, non-store wbarriers */
166 void binary_protocol_init (const char *filename, long long limit);
167 gboolean binary_protocol_is_enabled (void);
169 gboolean binary_protocol_flush_buffers (gboolean force);
171 #define BEGIN_PROTOCOL_ENTRY0(method) \
173 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
175 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
176 void method (t1 f1, t2 f2);
177 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
178 void method (t1 f1, t2 f2, t3 f3);
179 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
180 void method (t1 f1, t2 f2, t3 f3, t4 f4);
181 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
182 void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5);
183 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
184 void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
186 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
187 #define binary_protocol_is_heavy_enabled() binary_protocol_is_enabled ()
189 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
190 BEGIN_PROTOCOL_ENTRY0 (method)
191 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
192 BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
193 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
194 BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
195 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
196 BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
197 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
198 BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
199 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
200 BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
201 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
202 BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
204 #define binary_protocol_is_heavy_enabled() FALSE
206 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
207 static inline void method (void) {}
208 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
209 static inline void method (t1 f1) {}
210 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
211 static inline void method (t1 f1, t2 f2) {}
212 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
213 static inline void method (t1 f1, t2 f2, t3 f3) {}
214 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
215 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4) {}
216 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
217 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5) {}
218 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
219 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6) {}
222 #define DEFAULT_PRINT()
223 #define CUSTOM_PRINT(_)
225 #define IS_ALWAYS_MATCH(_)
226 #define MATCH_INDEX(_)
227 #define IS_VTABLE_MATCH(_)
229 #define END_PROTOCOL_ENTRY
230 #define END_PROTOCOL_ENTRY_FLUSH
231 #define END_PROTOCOL_ENTRY_HEAVY
233 #include "sgen-protocol-def.h"