• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Defining IPC Messages
6 //
7 // Your IPC messages will be defined by macros inside of an XXX_messages.h
8 // header file.  Most of the time, the system can automatically generate all
9 // of messaging mechanism from these definitions, but sometimes some manual
10 // coding is required.  In these cases, you will also have an XXX_messages.cc
11 // implementation file as well.
12 //
13 // The senders of your messages will include your XXX_messages.h file to
14 // get the full set of definitions they need to send your messages.
15 //
16 // Each XXX_messages.h file must be registered with the IPC system.  This
17 // requires adding two things:
18 //   - An XXXMsgStart value to the IPCMessageStart enum in ipc_message_start.h
19 //   - An inclusion of XXX_messages.h file in a message generator .h file
20 //
21 // The XXXMsgStart value is an enumeration that ensures uniqueness for
22 // each different message file.  Later, you will use this inside your
23 // XXX_messages.h file before invoking message declaration macros:
24 //     #define IPC_MESSAGE_START XXXMsgStart
25 //       ( ... your macro invocations go here ... )
26 //
27 // Message Generator Files
28 //
29 // A message generator .h header file pulls in all other message-declaring
30 // headers for a given component.  It is included by a message generator
31 // .cc file, which is where all the generated code will wind up.  Typically,
32 // you will use an existing generator (e.g. common_message_generator.cc
33 // in /chrome/common), but there are circumstances where you may add a
34 // new one.
35 //
36 // In the rare circumstances where you can't re-use an existing file,
37 // your YYY_message_generator.cc file for a component YYY would contain
38 // the following code:
39 //     // Get basic type definitions.
40 //     #define IPC_MESSAGE_IMPL
41 //     #include "path/to/YYY_message_generator.h"
42 //     // Generate constructors.
43 //     #include "ipc/struct_constructor_macros.h"
44 //     #include "path/to/YYY_message_generator.h"
45 //     // Generate destructors.
46 //     #include "ipc/struct_destructor_macros.h"
47 //     #include "path/to/YYY_message_generator.h"
48 //     // Generate param traits write methods.
49 //     #include "ipc/param_traits_write_macros.h"
50 //     namespace IPC {
51 //     #include "path/to/YYY_message_generator.h"
52 //     }  // namespace IPC
53 //     // Generate param traits read methods.
54 //     #include "ipc/param_traits_read_macros.h"
55 //     namespace IPC {
56 //     #include "path/to/YYY_message_generator.h"
57 //     }  // namespace IPC
58 //     // Generate param traits log methods.
59 //     #include "ipc/param_traits_log_macros.h"
60 //     namespace IPC {
61 //     #include "path/to/YYY_message_generator.h"
62 //     }  // namespace IPC
63 //
64 // In cases where manual generation is required, in your XXX_messages.cc
65 // file, put the following after all the includes for param types:
66 //     #define IPC_MESSAGE_IMPL
67 //     #include "XXX_messages.h"
68 //        (... implementation of traits not auto-generated ...)
69 //
70 // Multiple Inclusion
71 //
72 // The XXX_messages.h file will be multiply-included by the
73 // YYY_message_generator.cc file, so your XXX_messages file can't be
74 // guarded in the usual manner.  Ideally, there will be no need for any
75 // inclusion guard, since the XXX_messages.h file should consist solely
76 // of inclusions of other headers (which are self-guarding) and IPC
77 // macros (which are multiply evaluating).
78 //
79 // Note that #pragma once cannot be used here; doing so would mark the whole
80 // file as being singly-included.  Since your XXX_messages.h file is only
81 // partially-guarded, care must be taken to ensure that it is only included
82 // by other .cc files (and the YYY_message_generator.h file).  Including an
83 // XXX_messages.h file in some other .h file may result in duplicate
84 // declarations and a compilation failure.
85 //
86 // Type Declarations
87 //
88 // It is generally a bad idea to have type definitions in a XXX_messages.h
89 // file; most likely the typedef will then be used in the message, as opposed
90 // to the struct itself.  Later, an IPC message dispatcher will need to call
91 // a function taking that type, and that function is declared in some other
92 // header.  Thus, in order to get the type definition, the other header
93 // would have to include the XXX_messages.h file, violating the rule above
94 // about not including XXX_messages.h file in other .h files.
95 //
96 // One approach here is to move these type definitions to another (guarded)
97 // .h file and include this second .h in your XXX_messages.h file.  This
98 // is still less than ideal, because the dispatched function would have to
99 // redeclare the typedef or include this second header.  This may be
100 // reasonable in a few cases.
101 //
102 // Failing all of the above, then you will want to bracket the smallest
103 // possible section of your XXX_messages.h file containing these types
104 // with an include guard macro.  Be aware that providing an incomplete
105 // class type declaration to avoid pulling in a long chain of headers is
106 // acceptable when your XXX_messages.h header is being included by the
107 // message sending caller's code, but not when the YYY_message_generator.c
108 // is building the messages. In addition, due to the multiple inclusion
109 // restriction, these type ought to be guarded.  Follow a convention like:
110 //      #ifndef SOME_GUARD_MACRO
111 //      #define SOME_GUARD_MACRO
112 //      class some_class;        // One incomplete class declaration
113 //      class_some_other_class;  // Another incomplete class declaration
114 //      #endif  // SOME_GUARD_MACRO
115 //      #ifdef IPC_MESSAGE_IMPL
116 //      #include "path/to/some_class.h"        // Full class declaration
117 //      #include "path/to/some_other_class.h"  // Full class declaration
118 //      #endif  // IPC_MESSAGE_IMPL
119 //        (.. IPC macros using some_class and some_other_class ...)
120 //
121 // Macro Invocations
122 //
123 // You will use IPC message macro invocations for three things:
124 //   - New struct definitions for IPC
125 //   - Registering existing struct and enum definitions with IPC
126 //   - Defining the messages themselves
127 //
128 // New structs are defined with IPC_STRUCT_BEGIN(), IPC_STRUCT_MEMBER(),
129 // IPC_STRUCT_END() family of macros.  These cause the XXX_messages.h
130 // to proclaim equivalent struct declarations for use by callers, as well
131 // as later registering the type with the message generation.  Note that
132 // IPC_STRUCT_MEMBER() is only permitted inside matching calls to
133 // IPC_STRUCT_BEGIN() / IPC_STRUCT_END(). There is also an
134 // IPC_STRUCT_BEGIN_WITH_PARENT(), which behaves like IPC_STRUCT_BEGIN(),
135 // but also accommodates structs that inherit from other structs.
136 //
137 // Externally-defined structs are registered with IPC_STRUCT_TRAITS_BEGIN(),
138 // IPC_STRUCT_TRAITS_MEMBER(), and IPC_STRUCT_TRAITS_END() macros. These
139 // cause registration of the types with message generation only.
140 // There's also IPC_STRUCT_TRAITS_PARENT, which is used to register a parent
141 // class (whose own traits are already defined). Note that
142 // IPC_STRUCT_TRAITS_MEMBER() and IPC_STRUCT_TRAITS_PARENT are only permitted
143 // inside matching calls to IPC_STRUCT_TRAITS_BEGIN() /
144 // IPC_STRUCT_TRAITS_END().
145 //
146 // Enum types are registered with a single IPC_ENUM_TRAITS_VALIDATE() macro.
147 // There is no need to enumerate each value to the IPC mechanism. Instead,
148 // pass an expression in terms of the parameter |value| to provide
149 // range-checking.  For convenience, the IPC_ENUM_TRAITS() is provided which
150 // performs no checking, passing everything including out-of-range values.
151 // Its use is discouraged. The IPC_ENUM_TRAITS_MAX_VALUE() macro can be used
152 // for the typical case where the enum must be in the range 0..maxvalue
153 // inclusive. The IPC_ENUM_TRAITS_MIN_MAX_VALUE() macro can be used for the
154 // less typical case where the enum must be in the range minvalue..maxvalue
155 // inclusive.
156 //
157 // Do not place semicolons following these IPC_ macro invocations.  There
158 // is no reason to expect that their expansion corresponds one-to-one with
159 // C++ statements.
160 //
161 // Once the types have been declared / registered, message definitions follow.
162 // "Sync" messages are just synchronous calls, the Send() call doesn't return
163 // until a reply comes back.  To declare a sync message, use the IPC_SYNC_
164 // macros.  The numbers at the end show how many input/output parameters there
165 // are (i.e. 1_2 is 1 in, 2 out).  Input parameters are first, followed by
166 // output parameters.  The caller uses Send([route id, ], in1, &out1, &out2).
167 // The receiver's handler function will be
168 //     void OnSyncMessageName(const type1& in1, type2* out1, type3* out2)
169 //
170 // A caller can also send a synchronous message, while the receiver can respond
171 // at a later time.  This is transparent from the sender's side.  The receiver
172 // needs to use a different handler that takes in a IPC::Message* as the output
173 // type, stash the message, and when it has the data it can Send the message.
174 //
175 // Use the IPC_MESSAGE_HANDLER_DELAY_REPLY macro instead of IPC_MESSAGE_HANDLER
176 //     IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncMessageName,
177 //                                     OnSyncMessageName)
178 // Unlike IPC_MESSAGE_HANDLER which works with IPC_BEGIN_MESSAGE_MAP as well as
179 // IPC_BEGIN_MESSAGE_MAP_WITH_PARAM, one needs to use
180 // IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY to properly handle the param.
181 //
182 // The handler function will look like:
183 //     void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg);
184 //
185 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does:
186 //     ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2);
187 //     Send(reply_msg);
188 
189 // Files that want to export their ipc messages should do
190 //   #undef IPC_MESSAGE_EXPORT
191 //   #define IPC_MESSAGE_EXPORT VISIBILITY_MACRO
192 // after including this header, but before using any of the macros below.
193 // (This needs to be before the include guard.)
194 #undef IPC_MESSAGE_EXPORT
195 #define IPC_MESSAGE_EXPORT
196 
197 #ifndef IPC_IPC_MESSAGE_MACROS_H_
198 #define IPC_IPC_MESSAGE_MACROS_H_
199 
200 #include <stdint.h>
201 
202 #include <tuple>
203 
204 #include "base/export_template.h"
205 #include "ipc/ipc_message_templates.h"
206 #include "ipc/ipc_message_utils.h"
207 #include "ipc/param_traits_macros.h"
208 
209 // Convenience macro for defining structs without inheritance. Should not need
210 // to be subsequently redefined.
211 #define IPC_STRUCT_BEGIN(struct_name) \
212   IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, IPC::NoParams)
213 
214 // Macros for defining structs. Will be subsequently redefined.
215 #define IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, parent) \
216   struct struct_name; \
217   IPC_STRUCT_TRAITS_BEGIN(struct_name) \
218   IPC_STRUCT_TRAITS_END() \
219   struct IPC_MESSAGE_EXPORT struct_name : parent { \
220     struct_name(); \
221     struct_name(const struct_name&) = default; \
222     struct_name(struct_name&&) = default; \
223     struct_name& operator=(const struct_name&) = default; \
224     struct_name& operator=(struct_name&&) = default; \
225     ~struct_name();
226 // Optional variadic parameters specify the default value for this struct
227 // member. They are passed through to the constructor for |type|.
228 #define IPC_STRUCT_MEMBER(type, name, ...) type name;
229 #define IPC_STRUCT_END() };
230 
231 // Message macros collect arguments and funnel them into the common message
232 // generation macro.  These should never be redefined.
233 
234 // Asynchronous messages have only in parameters and are declared like:
235 //     IPC_MESSAGE_CONTROL(FooMsg, int, float)
236 #define IPC_MESSAGE_CONTROL(msg_class, ...) \
237   IPC_MESSAGE_DECL(msg_class, CONTROL, IPC_TUPLE(__VA_ARGS__), void)
238 #define IPC_MESSAGE_ROUTED(msg_class, ...) \
239   IPC_MESSAGE_DECL(msg_class, ROUTED, IPC_TUPLE(__VA_ARGS__), void)
240 
241 // Synchronous messages have both in and out parameters, so the lists need to
242 // be parenthesized to disambiguate:
243 //      IPC_SYNC_MESSAGE_CONTROL(BarMsg, (int, int), (bool))
244 //
245 // Implementation detail: The parentheses supplied by the caller for
246 // disambiguation are also used to trigger the IPC_TUPLE invocations below,
247 // so "IPC_TUPLE in" and "IPC_TUPLE out" are intentional.
248 #define IPC_SYNC_MESSAGE_CONTROL(msg_class, in, out) \
249   IPC_MESSAGE_DECL(msg_class, CONTROL, IPC_TUPLE in, IPC_TUPLE out)
250 #define IPC_SYNC_MESSAGE_ROUTED(msg_class, in, out) \
251   IPC_MESSAGE_DECL(msg_class, ROUTED, IPC_TUPLE in, IPC_TUPLE out)
252 
253 #define IPC_TUPLE(...) IPC::CheckedTuple<__VA_ARGS__>::Tuple
254 
255 #define IPC_MESSAGE_DECL(msg_name, kind, in_tuple, out_tuple)       \
256   struct IPC_MESSAGE_EXPORT msg_name##_Meta {                       \
257     using InTuple = in_tuple;                                       \
258     using OutTuple = out_tuple;                                     \
259     enum { ID = IPC_MESSAGE_ID() };                                 \
260     static const IPC::MessageKind kKind = IPC::MessageKind::kind;   \
261     static const char kName[];                                      \
262   };                                                                \
263   extern template class EXPORT_TEMPLATE_DECLARE(IPC_MESSAGE_EXPORT) \
264       IPC::MessageT<msg_name##_Meta>;                               \
265   using msg_name = IPC::MessageT<msg_name##_Meta>;                  \
266   IPC_MESSAGE_EXTRA(msg_name)
267 
268 #if defined(IPC_MESSAGE_IMPL)
269 
270 // "Implementation" inclusion provides the explicit template definition
271 // for msg_name.
272 #define IPC_MESSAGE_EXTRA(msg_name)                         \
273   const char msg_name##_Meta::kName[] = #msg_name;          \
274   IPC_MESSAGE_DEFINE_KIND(msg_name)                         \
275   template class EXPORT_TEMPLATE_DEFINE(IPC_MESSAGE_EXPORT) \
276       IPC::MessageT<msg_name##_Meta>;
277 
278 // MSVC has an intentionally non-compliant "feature" that results in LNK2005
279 // ("symbol already defined") errors if we provide an out-of-line definition
280 // for kKind.  Microsoft's official response is to test for _MSC_EXTENSIONS:
281 // https://connect.microsoft.com/VisualStudio/feedback/details/786583/
282 #if defined(_MSC_EXTENSIONS)
283 #define IPC_MESSAGE_DEFINE_KIND(msg_name)
284 #else
285 #define IPC_MESSAGE_DEFINE_KIND(msg_name) \
286   const IPC::MessageKind msg_name##_Meta::kKind;
287 #endif
288 
289 #elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED)
290 
291 #ifndef IPC_LOG_TABLE_ADD_ENTRY
292 #error You need to define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger)
293 #endif
294 
295 // "Log table" inclusion produces extra logging registration code.
296 #define IPC_MESSAGE_EXTRA(msg_name)                                \
297   class LoggerRegisterHelper##msg_name {                           \
298    public:                                                         \
299     LoggerRegisterHelper##msg_name() {                             \
300       const uint32_t msg_id = static_cast<uint32_t>(msg_name::ID); \
301       IPC_LOG_TABLE_ADD_ENTRY(msg_id, msg_name::Log);              \
302     }                                                              \
303   };                                                               \
304   LoggerRegisterHelper##msg_name g_LoggerRegisterHelper##msg_name;
305 
306 #else
307 
308 // Normal inclusion produces nothing extra.
309 #define IPC_MESSAGE_EXTRA(msg_name)
310 
311 #endif  // defined(IPC_MESSAGE_IMPL)
312 
313 // Message IDs
314 // Note: we currently use __LINE__ to give unique IDs to messages within
315 // a file.  They're globally unique since each file defines its own
316 // IPC_MESSAGE_START.
317 #define IPC_MESSAGE_ID() ((IPC_MESSAGE_START << 16) + __LINE__)
318 #define IPC_MESSAGE_ID_CLASS(id) ((id) >> 16)
319 #define IPC_MESSAGE_ID_LINE(id) ((id) & 0xffff)
320 
321 // Message crackers and handlers. Usage:
322 //
323 //   bool MyClass::OnMessageReceived(const IPC::Message& msg) {
324 //     bool handled = true;
325 //     IPC_BEGIN_MESSAGE_MAP(MyClass, msg)
326 //       IPC_MESSAGE_HANDLER(MsgClassOne, OnMsgClassOne)
327 //       ...more handlers here ...
328 //       IPC_MESSAGE_HANDLER(MsgClassTen, OnMsgClassTen)
329 //       IPC_MESSAGE_UNHANDLED(handled = false)
330 //     IPC_END_MESSAGE_MAP()
331 //     return handled;
332 //   }
333 
334 
335 #define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \
336   { \
337     typedef class_name _IpcMessageHandlerClass ALLOW_UNUSED_TYPE; \
338     void* param__ = NULL; \
339     (void)param__; \
340     const IPC::Message& ipc_message__ = msg; \
341     switch (ipc_message__.type()) {
342 
343 #define IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(class_name, msg, param)  \
344   {                                                               \
345     typedef class_name _IpcMessageHandlerClass ALLOW_UNUSED_TYPE; \
346     decltype(param) param__ = param;                              \
347     const IPC::Message& ipc_message__ = msg;                      \
348     switch (ipc_message__.type()) {
349 
350 #define IPC_MESSAGE_FORWARD(msg_class, obj, member_func)                       \
351     case msg_class::ID: {                                                      \
352         if (!msg_class::Dispatch(&ipc_message__, obj, this, param__,           \
353                                  &member_func))                                \
354           ipc_message__.set_dispatch_error();                                  \
355       }                                                                        \
356       break;
357 
358 #define IPC_MESSAGE_HANDLER(msg_class, member_func) \
359   IPC_MESSAGE_FORWARD(msg_class, this, _IpcMessageHandlerClass::member_func)
360 
361 #define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func)           \
362     case msg_class::ID: {                                                      \
363         if (!msg_class::DispatchDelayReply(&ipc_message__, obj, param__,       \
364                                            &member_func))                      \
365           ipc_message__.set_dispatch_error();                                  \
366       }                                                                        \
367       break;
368 
369 #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func)                \
370     IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this,                           \
371                                     _IpcMessageHandlerClass::member_func)
372 
373 #define IPC_MESSAGE_FORWARD_WITH_PARAM_DELAY_REPLY(msg_class, obj,             \
374                                                    member_func)                \
375   case msg_class::ID: {                                                        \
376     if (!msg_class::DispatchWithParamDelayReply(&ipc_message__, obj, param__,  \
377                                                 &member_func))                 \
378       ipc_message__.set_dispatch_error();                                      \
379   }                                                                            \
380   break;
381 
382 #define IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY(msg_class, member_func)     \
383     IPC_MESSAGE_FORWARD_WITH_PARAM_DELAY_REPLY(                                \
384         msg_class, this, _IpcMessageHandlerClass::member_func)
385 
386 #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code)                           \
387     case msg_class::ID: {                                                      \
388         code;                                                                  \
389       }                                                                        \
390       break;
391 
392 #define IPC_REPLY_HANDLER(func)                                                \
393     case IPC_REPLY_ID: {                                                       \
394         func(ipc_message__);                                                   \
395       }                                                                        \
396       break;
397 
398 
399 #define IPC_MESSAGE_UNHANDLED(code)                                            \
400     default: {                                                                 \
401         code;                                                                  \
402       }                                                                        \
403       break;
404 
405 #define IPC_MESSAGE_UNHANDLED_ERROR() \
406   IPC_MESSAGE_UNHANDLED(NOTREACHED() << \
407                               "Invalid message with type = " << \
408                               ipc_message__.type())
409 
410 #define IPC_END_MESSAGE_MAP() \
411   } \
412 }
413 
414 // This corresponds to an enum value from IPCMessageStart.
415 #define IPC_MESSAGE_CLASS(message) IPC_MESSAGE_ID_CLASS((message).type())
416 
417 // Deprecated legacy macro names.
418 // TODO(mdempsky): Replace uses with generic names.
419 
420 #define IPC_MESSAGE_CONTROL0(msg) IPC_MESSAGE_CONTROL(msg)
421 #define IPC_MESSAGE_CONTROL1(msg, a) IPC_MESSAGE_CONTROL(msg, a)
422 #define IPC_MESSAGE_CONTROL2(msg, a, b) IPC_MESSAGE_CONTROL(msg, a, b)
423 #define IPC_MESSAGE_CONTROL3(msg, a, b, c) IPC_MESSAGE_CONTROL(msg, a, b, c)
424 #define IPC_MESSAGE_CONTROL4(msg, a, b, c, d) \
425   IPC_MESSAGE_CONTROL(msg, a, b, c, d)
426 #define IPC_MESSAGE_CONTROL5(msg, a, b, c, d, e) \
427   IPC_MESSAGE_CONTROL(msg, a, b, c, d, e)
428 
429 #define IPC_MESSAGE_ROUTED0(msg) IPC_MESSAGE_ROUTED(msg)
430 #define IPC_MESSAGE_ROUTED1(msg, a) IPC_MESSAGE_ROUTED(msg, a)
431 #define IPC_MESSAGE_ROUTED2(msg, a, b) IPC_MESSAGE_ROUTED(msg, a, b)
432 #define IPC_MESSAGE_ROUTED3(msg, a, b, c) IPC_MESSAGE_ROUTED(msg, a, b, c)
433 #define IPC_MESSAGE_ROUTED4(msg, a, b, c, d) IPC_MESSAGE_ROUTED(msg, a, b, c, d)
434 #define IPC_MESSAGE_ROUTED5(msg, a, b, c, d, e) \
435   IPC_MESSAGE_ROUTED(msg, a, b, c, d, e)
436 
437 #define IPC_SYNC_MESSAGE_CONTROL0_0(msg) IPC_SYNC_MESSAGE_CONTROL(msg, (), ())
438 #define IPC_SYNC_MESSAGE_CONTROL0_1(msg, a) \
439   IPC_SYNC_MESSAGE_CONTROL(msg, (), (a))
440 #define IPC_SYNC_MESSAGE_CONTROL0_2(msg, a, b) \
441   IPC_SYNC_MESSAGE_CONTROL(msg, (), (a, b))
442 #define IPC_SYNC_MESSAGE_CONTROL0_3(msg, a, b, c) \
443   IPC_SYNC_MESSAGE_CONTROL(msg, (), (a, b, c))
444 #define IPC_SYNC_MESSAGE_CONTROL0_4(msg, a, b, c, d) \
445   IPC_SYNC_MESSAGE_CONTROL(msg, (), (a, b, c, d))
446 #define IPC_SYNC_MESSAGE_CONTROL1_0(msg, a) \
447   IPC_SYNC_MESSAGE_CONTROL(msg, (a), ())
448 #define IPC_SYNC_MESSAGE_CONTROL1_1(msg, a, b) \
449   IPC_SYNC_MESSAGE_CONTROL(msg, (a), (b))
450 #define IPC_SYNC_MESSAGE_CONTROL1_2(msg, a, b, c) \
451   IPC_SYNC_MESSAGE_CONTROL(msg, (a), (b, c))
452 #define IPC_SYNC_MESSAGE_CONTROL1_3(msg, a, b, c, d) \
453   IPC_SYNC_MESSAGE_CONTROL(msg, (a), (b, c, d))
454 #define IPC_SYNC_MESSAGE_CONTROL1_4(msg, a, b, c, d, e) \
455   IPC_SYNC_MESSAGE_CONTROL(msg, (a), (b, c, d, e))
456 #define IPC_SYNC_MESSAGE_CONTROL2_0(msg, a, b) \
457   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b), ())
458 #define IPC_SYNC_MESSAGE_CONTROL2_1(msg, a, b, c) \
459   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b), (c))
460 #define IPC_SYNC_MESSAGE_CONTROL2_2(msg, a, b, c, d) \
461   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b), (c, d))
462 #define IPC_SYNC_MESSAGE_CONTROL2_3(msg, a, b, c, d, e) \
463   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b), (c, d, e))
464 #define IPC_SYNC_MESSAGE_CONTROL2_4(msg, a, b, c, d, e, f) \
465   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b), (c, d, e, f))
466 #define IPC_SYNC_MESSAGE_CONTROL3_0(msg, a, b, c) \
467   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c), ())
468 #define IPC_SYNC_MESSAGE_CONTROL3_1(msg, a, b, c, d) \
469   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c), (d))
470 #define IPC_SYNC_MESSAGE_CONTROL3_2(msg, a, b, c, d, e) \
471   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c), (d, e))
472 #define IPC_SYNC_MESSAGE_CONTROL3_3(msg, a, b, c, d, e, f) \
473   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c), (d, e, f))
474 #define IPC_SYNC_MESSAGE_CONTROL3_4(msg, a, b, c, d, e, f, g) \
475   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c), (d, e, f, g))
476 #define IPC_SYNC_MESSAGE_CONTROL4_0(msg, a, b, c, d) \
477   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d), ())
478 #define IPC_SYNC_MESSAGE_CONTROL4_1(msg, a, b, c, d, e) \
479   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d), (e))
480 #define IPC_SYNC_MESSAGE_CONTROL4_2(msg, a, b, c, d, e, f) \
481   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d), (e, f))
482 #define IPC_SYNC_MESSAGE_CONTROL4_3(msg, a, b, c, d, e, f, g) \
483   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d), (e, f, g))
484 #define IPC_SYNC_MESSAGE_CONTROL4_4(msg, a, b, c, d, e, f, g, h) \
485   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d), (e, f, g, h))
486 #define IPC_SYNC_MESSAGE_CONTROL5_0(msg, a, b, c, d, e) \
487   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d, e), ())
488 #define IPC_SYNC_MESSAGE_CONTROL5_1(msg, a, b, c, d, e, f) \
489   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d, e), (f))
490 #define IPC_SYNC_MESSAGE_CONTROL5_2(msg, a, b, c, d, e, f, g) \
491   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d, e), (f, g))
492 #define IPC_SYNC_MESSAGE_CONTROL5_3(msg, a, b, c, d, e, f, g, h) \
493   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d, e), (f, g, h))
494 #define IPC_SYNC_MESSAGE_CONTROL5_4(msg, a, b, c, d, e, f, g, h, i) \
495   IPC_SYNC_MESSAGE_CONTROL(msg, (a, b, c, d, e), (f, g, h, i))
496 
497 #define IPC_SYNC_MESSAGE_ROUTED0_0(msg) IPC_SYNC_MESSAGE_ROUTED(msg, (), ())
498 #define IPC_SYNC_MESSAGE_ROUTED0_1(msg, a) IPC_SYNC_MESSAGE_ROUTED(msg, (), (a))
499 #define IPC_SYNC_MESSAGE_ROUTED0_2(msg, a, b) \
500   IPC_SYNC_MESSAGE_ROUTED(msg, (), (a, b))
501 #define IPC_SYNC_MESSAGE_ROUTED0_3(msg, a, b, c) \
502   IPC_SYNC_MESSAGE_ROUTED(msg, (), (a, b, c))
503 #define IPC_SYNC_MESSAGE_ROUTED0_4(msg, a, b, c, d) \
504   IPC_SYNC_MESSAGE_ROUTED(msg, (), (a, b, c, d))
505 #define IPC_SYNC_MESSAGE_ROUTED1_0(msg, a) IPC_SYNC_MESSAGE_ROUTED(msg, (a), ())
506 #define IPC_SYNC_MESSAGE_ROUTED1_1(msg, a, b) \
507   IPC_SYNC_MESSAGE_ROUTED(msg, (a), (b))
508 #define IPC_SYNC_MESSAGE_ROUTED1_2(msg, a, b, c) \
509   IPC_SYNC_MESSAGE_ROUTED(msg, (a), (b, c))
510 #define IPC_SYNC_MESSAGE_ROUTED1_3(msg, a, b, c, d) \
511   IPC_SYNC_MESSAGE_ROUTED(msg, (a), (b, c, d))
512 #define IPC_SYNC_MESSAGE_ROUTED1_4(msg, a, b, c, d, e) \
513   IPC_SYNC_MESSAGE_ROUTED(msg, (a), (b, c, d, e))
514 #define IPC_SYNC_MESSAGE_ROUTED2_0(msg, a, b) \
515   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b), ())
516 #define IPC_SYNC_MESSAGE_ROUTED2_1(msg, a, b, c) \
517   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b), (c))
518 #define IPC_SYNC_MESSAGE_ROUTED2_2(msg, a, b, c, d) \
519   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b), (c, d))
520 #define IPC_SYNC_MESSAGE_ROUTED2_3(msg, a, b, c, d, e) \
521   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b), (c, d, e))
522 #define IPC_SYNC_MESSAGE_ROUTED2_4(msg, a, b, c, d, e, f) \
523   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b), (c, d, e, f))
524 #define IPC_SYNC_MESSAGE_ROUTED3_0(msg, a, b, c) \
525   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c), ())
526 #define IPC_SYNC_MESSAGE_ROUTED3_1(msg, a, b, c, d) \
527   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c), (d))
528 #define IPC_SYNC_MESSAGE_ROUTED3_2(msg, a, b, c, d, e) \
529   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c), (d, e))
530 #define IPC_SYNC_MESSAGE_ROUTED3_3(msg, a, b, c, d, e, f) \
531   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c), (d, e, f))
532 #define IPC_SYNC_MESSAGE_ROUTED3_4(msg, a, b, c, d, e, f, g) \
533   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c), (d, e, f, g))
534 #define IPC_SYNC_MESSAGE_ROUTED4_0(msg, a, b, c, d) \
535   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d), ())
536 #define IPC_SYNC_MESSAGE_ROUTED4_1(msg, a, b, c, d, e) \
537   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d), (e))
538 #define IPC_SYNC_MESSAGE_ROUTED4_2(msg, a, b, c, d, e, f) \
539   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d), (e, f))
540 #define IPC_SYNC_MESSAGE_ROUTED4_3(msg, a, b, c, d, e, f, g) \
541   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d), (e, f, g))
542 #define IPC_SYNC_MESSAGE_ROUTED4_4(msg, a, b, c, d, e, f, g, h) \
543   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d), (e, f, g, h))
544 #define IPC_SYNC_MESSAGE_ROUTED5_0(msg, a, b, c, d, e) \
545   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), ())
546 #define IPC_SYNC_MESSAGE_ROUTED5_1(msg, a, b, c, d, e, f) \
547   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f))
548 #define IPC_SYNC_MESSAGE_ROUTED5_2(msg, a, b, c, d, e, f, g) \
549   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g))
550 #define IPC_SYNC_MESSAGE_ROUTED5_3(msg, a, b, c, d, e, f, g, h) \
551   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h))
552 #define IPC_SYNC_MESSAGE_ROUTED5_4(msg, a, b, c, d, e, f, g, h, i) \
553   IPC_SYNC_MESSAGE_ROUTED(msg, (a, b, c, d, e), (f, g, h, i))
554 
555 #endif  // IPC_IPC_MESSAGE_MACROS_H_
556 
557 // Clean up IPC_MESSAGE_START in this unguarded section so that the
558 // XXX_messages.h files need not do so themselves.  This makes the
559 // XXX_messages.h files easier to write.
560 #undef IPC_MESSAGE_START
561