~sircmpwn/hare

hare/rt/+linux/signal.ha -rw-r--r-- 824 bytes
e9f718c9Drew DeVault hare::module: re-introduce README hack 19 hours ago
                                                                                
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
// TODO: work when _NSIG != 64

export fn sigemptyset(set: *sigset) int = {
	if (set.__val[0] == 0) {
		return 1;
	};
	set.__val[0] = 0;
	return 0;
};

export fn sigaddset(set: *sigset, signum: int) (int | errno) = {
	if (signum > NSIG) {
		return EINVAL;
	};
	signum -= 1;
	set.__val[0] |= (1 << signum): u64;
	return 0;
};

export fn sigdelset(set: *sigset, signum: int) (int | errno) = {
	if (signum > NSIG) {
		return EINVAL;
	};
	signum -= 1;
	set.__val[0] &= ~(1 << signum: u64);
	return 0;
};

export fn sigismember(set: *sigset, signum: int) (int | errno) = {
	if (signum > NSIG) {
		return EINVAL;
	};
	signum -= 1;
	if ((set.__val[0] & (1 << signum: u64)) != 0) {
		return 1;
	} else {
		return 0;
	};
};

export fn sigfillset(set: *sigset) (int | errno) = {
	set.__val[0] = 0xffffffffffffffff: u64;
	return 0;
};