signal: reserve signal subsystems >= INT_MAX/2 for libraries
[osmocom-bb.git] / include / osmocom / core / signal.h
1 #ifndef OSMO_SIGNAL_H
2 #define OSMO_SIGNAL_H
3
4 #include <stdint.h>
5
6 /* subsystem signaling numbers: we split the numberspace for applications and
7  * libraries: from 0 to UINT_MAX/2 for applications, from UINT_MAX/2 to
8  * UINT_MAX for libraries. */
9 #define OSMO_SIGNAL_SS_APPS             0
10 #define OSMO_SIGNAL_SS_RESERVED         2147483648
11
12 /* signal subsystems. */
13 enum {
14         SS_GLOBAL               = OSMO_SIGNAL_SS_RESERVED,
15         SS_INPUT,
16 };
17
18 /* application-defined signal types. */
19 #define OSMO_SIGNAL_T_APPS              0
20 #define OSMO_SIGNAL_T_RESERVED          2147483648
21
22 /* signal types. */
23 enum {
24         S_GLOBAL_SHUTDOWN       = OSMO_SIGNAL_T_RESERVED,
25 };
26
27 typedef int osmo_signal_cbfn(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data);
28
29
30 /* Management */
31 int osmo_signal_register_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
32 void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
33
34 /* Dispatch */
35 void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, void *signal_data);
36
37 #endif /* OSMO_SIGNAL_H */