-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsig.h
70 lines (55 loc) · 2.59 KB
/
sig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/// Synchronous signal handling.
#ifndef BMM_SIG_H
#define BMM_SIG_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define BMM_SIG_MIN (SIG_ATOMIC_MIN + 2)
#define BMM_SIG_MAX (SIG_ATOMIC_MAX - 1)
/// The call `bmm_sig_handler(signum)`
/// handles the signal with the number `signum`.
/// This should be registered as a signal handler with `bmm_sig_register`.
void bmm_sig_handler(int);
/// The call `bmm_sig_register(sigs, n)` tries to register `bmm_sig_handler`
/// as the signal handler of each signal in the array `sigs` of length `n`.
/// If the operation is successful, `SIZE_MAX` is returned.
/// Otherwise the registering is stopped at the first failure and
/// the index of the first signal that failed to be registered is returned.
size_t bmm_sig_register(int const *, size_t);
/// The call `bmm_sig_unregister(sigs, n)` tries to restore the default
/// signal handler for each signal in the array `sigs` of length `n`.
/// If the operation is successful, `SIZE_MAX` is returned.
/// Otherwise the registering is stopped at the first failure and
/// the index of the first signal that failed to be unregistered is returned.
size_t bmm_sig_unregister(int const *, size_t);
/// The call `bmm_sig_unset()` returns `true` if a signal has not been caught.
/// Otherwise `false` is returned.
bool bmm_sig_unset(void);
/// The call `bmm_sig_set()` returns `true` if a signal has been caught.
/// Otherwise `false` is returned.
bool bmm_sig_set(void);
/// The call `bmm_sig_under()` returns `true`
/// if a signal below the representable minimum (negative) has been caught.
/// Otherwise `false` is returned.
bool bmm_sig_under(void);
/// The call `bmm_sig_normal(ptr)` returns `true`
/// if a normal signal (with a small enough magnitude) has been caught and
/// copies its value into `ptr` if `ptr` is not `NULL`.
/// Otherwise `false` is returned and no copying is done.
bool bmm_sig_normal(int *);
/// The call `bmm_sig_null()` returns `true`
/// if a null signal (zero) has been caught.
/// Otherwise `false` is returned.
bool bmm_sig_null(void);
/// The call `bmm_sig_over()` returns `true`
/// if a signal above the representable maximum (positive) has been caught.
/// Otherwise `false` is returned.
bool bmm_sig_over(void);
/// The call `bmm_sig_forget()` forgets about any previously caught signals.
/// Calling `bmm_sig_forget` before using any other signal handling procedures
/// from this compilation unit is not necessary.
void bmm_sig_forget(void);
/// The call `bmm_sig_use(ptr)` is equivalent
/// to performing `bmm_sig_normal(ptr)` and `bmm_sig_forget()` atomically.
bool bmm_sig_use(int *);
#endif