1.1 --- a/libipc/include/ipc/server.h Fri Dec 02 00:48:55 2022 +0100
1.2 +++ b/libipc/include/ipc/server.h Fri Dec 02 00:49:52 2022 +0100
1.3 @@ -30,22 +30,17 @@
1.4 /* A convenience macro for invoking the server mainloop. */
1.5
1.6 #define ipc_server_loop_for(TYPE, POINTER, NAME) \
1.7 - _ipc_server_loop_for(TYPE##_expected_items, (TYPE *) POINTER, \
1.8 - (ipc_server_handler_type) handle_##TYPE, \
1.9 - NAME)
1.10 + _ipc_server_loop_for(&config_##TYPE, (TYPE *) POINTER, NAME)
1.11
1.12 /* A convenience macro for initialising a server. */
1.13
1.14 #define ipc_server_init_for(CONFIG, TYPE, POINTER) \
1.15 - _ipc_server_init_for(CONFIG, TYPE##_expected_items, (TYPE *) POINTER, \
1.16 - (ipc_server_handler_type) handle_##TYPE)
1.17 + _ipc_server_init_for(CONFIG, &config_##TYPE, (TYPE *) POINTER)
1.18
1.19 /* A convenience macro for adding a configuration to an existing server. */
1.20
1.21 #define ipc_server_add_config(CONFIG, TYPE, POINTER, THREAD) \
1.22 - _ipc_server_add_config(CONFIG, TYPE##_expected_items, (TYPE *) POINTER, \
1.23 - (ipc_server_handler_type) handle_##TYPE, \
1.24 - THREAD)
1.25 + _ipc_server_add_config(CONFIG, &config_##TYPE, (TYPE *) POINTER, THREAD)
1.26
1.27 /* A handler function type. */
1.28
1.29 @@ -93,6 +88,15 @@
1.30
1.31 } ipc_server_config_type;
1.32
1.33 +/* Server configuration defaults. */
1.34 +
1.35 +typedef struct ipc_server_default_config_type
1.36 +{
1.37 + int expected_items;
1.38 + ipc_server_handler_type handler;
1.39 +
1.40 +} ipc_server_default_config_type;
1.41 +
1.42
1.43
1.44 /* Associate a notification IRQ with an IPC gate in the main thread. */
1.45 @@ -127,23 +131,25 @@
1.46
1.47 /* Handle incoming messages for a server. */
1.48
1.49 -long _ipc_server_loop_for(int expected_items, void *handler_obj,
1.50 - ipc_server_handler_type handler, const char *name);
1.51 +long _ipc_server_loop_for(ipc_server_default_config_type *default_config,
1.52 + void *handler_obj, const char *name);
1.53
1.54 /* Initialise a server. */
1.55
1.56 -long _ipc_server_init_for(ipc_server_config_type *config, int expected_items,
1.57 - void *handler_obj, ipc_server_handler_type handler);
1.58 +long _ipc_server_init_for(ipc_server_config_type *config,
1.59 + ipc_server_default_config_type *default_config,
1.60 + void *handler_obj);
1.61
1.62 /* Add handling of incoming messages to an existing server. */
1.63
1.64 -long _ipc_server_add_config(ipc_server_config_type *config, int expected_items,
1.65 - void *handler_obj, ipc_server_handler_type handler,
1.66 +long _ipc_server_add_config(ipc_server_config_type *config,
1.67 + ipc_server_default_config_type *default_config,
1.68 + void *handler_obj,
1.69 l4_cap_idx_t thread);
1.70
1.71 /* Handle incoming messages and IRQ notifications for a server. */
1.72
1.73 -long ipc_server_managed_loop(int expected_items, ipc_server_config_type *config);
1.74 +long ipc_server_managed_loop(ipc_server_config_type *config);
1.75
1.76 /* A pthread-compatible mainloop initiation function. */
1.77