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 /* Special indices returned by MATCH_INDEX. */
18 #define BINARY_PROTOCOL_NO_MATCH (-1)
19 #define BINARY_PROTOCOL_MATCH (-2)
21 #define PROTOCOL_ID(method) method ## _id
22 #define PROTOCOL_STRUCT(method) method ## _struct
23 #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method
26 #define TYPE_LONGLONG long long
27 #define TYPE_SIZE size_t
28 #define TYPE_POINTER gpointer
29 #define TYPE_BOOL gboolean
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),
47 #define DEFAULT_PRINT()
48 #define CUSTOM_PRINT(_)
50 #define IS_ALWAYS_MATCH(_)
51 #define MATCH_INDEX(_)
52 #define IS_VTABLE_MATCH(_)
54 #define END_PROTOCOL_ENTRY
55 #define END_PROTOCOL_ENTRY_FLUSH
56 #define END_PROTOCOL_ENTRY_HEAVY
58 #include "sgen-protocol-def.h"
61 #define BEGIN_PROTOCOL_ENTRY0(method)
62 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
65 } PROTOCOL_STRUCT(method);
66 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
70 } PROTOCOL_STRUCT(method);
71 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
76 } PROTOCOL_STRUCT(method);
77 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
83 } PROTOCOL_STRUCT(method);
84 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
91 } PROTOCOL_STRUCT(method);
92 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
100 } PROTOCOL_STRUCT(method);
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)
117 #define DEFAULT_PRINT()
118 #define CUSTOM_PRINT(_)
120 #define IS_ALWAYS_MATCH(_)
121 #define MATCH_INDEX(_)
122 #define IS_VTABLE_MATCH(_)
124 #define END_PROTOCOL_ENTRY
125 #define END_PROTOCOL_ENTRY_FLUSH
126 #define END_PROTOCOL_ENTRY_HEAVY
128 #include "sgen-protocol-def.h"
130 /* missing: finalizers, roots, non-store wbarriers */
132 void binary_protocol_init (const char *filename, long long limit);
133 gboolean binary_protocol_is_enabled (void);
135 void binary_protocol_flush_buffers (gboolean force);
137 #define BEGIN_PROTOCOL_ENTRY0(method) \
139 #define BEGIN_PROTOCOL_ENTRY1(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);
152 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
153 #define binary_protocol_is_heavy_enabled() binary_protocol_is_enabled ()
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)
170 #define binary_protocol_is_heavy_enabled() FALSE
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) {}
188 #define DEFAULT_PRINT()
189 #define CUSTOM_PRINT(_)
191 #define IS_ALWAYS_MATCH(_)
192 #define MATCH_INDEX(_)
193 #define IS_VTABLE_MATCH(_)
195 #define END_PROTOCOL_ENTRY
196 #define END_PROTOCOL_ENTRY_FLUSH
197 #define END_PROTOCOL_ENTRY_HEAVY
199 #include "sgen-protocol-def.h"