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 /* We pack all protocol structs by default unless specified otherwise */
25 #ifndef PROTOCOL_STRUCT_ATTR
27 #define PROTOCOL_STRUCT_ATTR __attribute__ ((packed))
29 #define PROTOCOL_STRUCT_ATTR
33 #define PROTOCOL_ID(method) method ## _id
34 #define PROTOCOL_STRUCT(method) method ## _struct
35 #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method
41 #define TYPE_LONGLONG long long
44 #define TYPE_SIZE size_t
47 #define TYPE_POINTER gpointer
50 #define TYPE_BOOL gboolean
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),
69 #define DEFAULT_PRINT()
70 #define CUSTOM_PRINT(_)
72 #define IS_ALWAYS_MATCH(_)
73 #define MATCH_INDEX(_)
74 #define IS_VTABLE_MATCH(_)
76 #define END_PROTOCOL_ENTRY
77 #define END_PROTOCOL_ENTRY_FLUSH
78 #define END_PROTOCOL_ENTRY_HEAVY
80 #include "sgen-protocol-def.h"
83 #define BEGIN_PROTOCOL_ENTRY0(method)
84 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
85 typedef struct PROTOCOL_STRUCT_ATTR { \
87 } PROTOCOL_STRUCT(method);
88 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
89 typedef struct PROTOCOL_STRUCT_ATTR { \
92 } PROTOCOL_STRUCT(method);
93 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
94 typedef struct PROTOCOL_STRUCT_ATTR { \
98 } PROTOCOL_STRUCT(method);
99 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
100 typedef struct PROTOCOL_STRUCT_ATTR { \
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 { \
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 { \
122 } PROTOCOL_STRUCT(method);
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)
139 #define DEFAULT_PRINT()
140 #define CUSTOM_PRINT(_)
142 #define IS_ALWAYS_MATCH(_)
143 #define MATCH_INDEX(_)
144 #define IS_VTABLE_MATCH(_)
146 #define END_PROTOCOL_ENTRY
147 #define END_PROTOCOL_ENTRY_FLUSH
148 #define END_PROTOCOL_ENTRY_HEAVY
150 #include "sgen-protocol-def.h"
152 /* missing: finalizers, roots, non-store wbarriers */
154 void binary_protocol_init (const char *filename, long long limit);
155 gboolean binary_protocol_is_enabled (void);
157 void binary_protocol_flush_buffers (gboolean force);
159 #define BEGIN_PROTOCOL_ENTRY0(method) \
161 #define BEGIN_PROTOCOL_ENTRY1(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);
174 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
175 #define binary_protocol_is_heavy_enabled() binary_protocol_is_enabled ()
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)
192 #define binary_protocol_is_heavy_enabled() FALSE
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) {}
210 #define DEFAULT_PRINT()
211 #define CUSTOM_PRINT(_)
213 #define IS_ALWAYS_MATCH(_)
214 #define MATCH_INDEX(_)
215 #define IS_VTABLE_MATCH(_)
217 #define END_PROTOCOL_ENTRY
218 #define END_PROTOCOL_ENTRY_FLUSH
219 #define END_PROTOCOL_ENTRY_HEAVY
221 #include "sgen-protocol-def.h"