blob: 07d0e6fb84bf6c4ddec846b3874b31f5fe57096e [file] [log] [blame]
Pablo Neira Ayusoa10dd352011-05-07 12:42:45 +02001#ifndef OSMO_SIGNAL_H
2#define OSMO_SIGNAL_H
Harald Welteec8b4502010-02-20 20:34:29 +01003
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +02004#include <stdint.h>
5
Harald Welteaf8e4352011-08-17 16:19:46 +02006/*! \defgroup signal Intra-application signals
7 * @{
8 */
9/*! \file signal.h */
10
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +020011/* subsystem signaling numbers: we split the numberspace for applications and
12 * libraries: from 0 to UINT_MAX/2 for applications, from UINT_MAX/2 to
13 * UINT_MAX for libraries. */
14#define OSMO_SIGNAL_SS_APPS 0
Holger Hans Peter Freytherc2c0ad72011-08-22 15:31:17 +020015#define OSMO_SIGNAL_SS_RESERVED 2147483648u
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +020016
Harald Welteaf8e4352011-08-17 16:19:46 +020017/*! \brief signal subsystems */
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +020018enum {
Harald Welte892e6212011-07-19 14:31:44 +020019 SS_L_GLOBAL = OSMO_SIGNAL_SS_RESERVED,
20 SS_L_INPUT,
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +020021};
22
23/* application-defined signal types. */
24#define OSMO_SIGNAL_T_APPS 0
Holger Hans Peter Freytherc2c0ad72011-08-22 15:31:17 +020025#define OSMO_SIGNAL_T_RESERVED 2147483648u
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +020026
Harald Welteaf8e4352011-08-17 16:19:46 +020027/*! \brief signal types. */
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +020028enum {
Harald Welte892e6212011-07-19 14:31:44 +020029 S_L_GLOBAL_SHUTDOWN = OSMO_SIGNAL_T_RESERVED,
Pablo Neira Ayuso39c02432011-07-07 19:46:34 +020030};
31
Harald Welteaf8e4352011-08-17 16:19:46 +020032/*! signal callback function type */
Pablo Neira Ayusoa10dd352011-05-07 12:42:45 +020033typedef int osmo_signal_cbfn(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data);
Harald Welteec8b4502010-02-20 20:34:29 +010034
35
36/* Management */
Pablo Neira Ayusoa10dd352011-05-07 12:42:45 +020037int osmo_signal_register_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
38void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
Harald Welteec8b4502010-02-20 20:34:29 +010039
40/* Dispatch */
Pablo Neira Ayusoa10dd352011-05-07 12:42:45 +020041void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, void *signal_data);
Harald Welteec8b4502010-02-20 20:34:29 +010042
Harald Welteaf8e4352011-08-17 16:19:46 +020043/*! }@ */
44
Pablo Neira Ayusoa10dd352011-05-07 12:42:45 +020045#endif /* OSMO_SIGNAL_H */