master
h 27 lines 907 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_SIGNAL_CODE_H
4 #define NETDATA_SIGNAL_CODE_H
5
6 #include "libnetdata/libnetdata-base.h"
7 #include "../template-enum.h"
8
9 // SIGNAL_CODE combines signal number and signal code into a single 64-bit identifier
10 typedef uint64_t SIGNAL_CODE;
11
12 // Create a SIGNAL_CODE from signal number and signal code
13 SIGNAL_CODE signal_code(int signo, int si_code);
14
15 // Extract the signal number from a SIGNAL_CODE
16 #define SIGNAL_CODE_GET_SIGNO(code) ((int)((code) >> 32))
17
18 // Extract the signal code from a SIGNAL_CODE
19 #define SIGNAL_CODE_GET_SI_CODE(code) ((int)((code) & 0xFFFFFFFF))
20
21 // convert a signal code to string, by name or hex (if no name is available)
22 void SIGNAL_CODE_2str_h(SIGNAL_CODE code, char *buf, size_t size);
23
24 // parse a signal code from a string, by name or hex
25 SIGNAL_CODE SIGNAL_CODE_2id_h(const char *str);
26
27 #endif /* NETDATA_SIGNAL_CODE_H */