ipc_message_macros.h 27 KB

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