summaryrefslogtreecommitdiff
path: root/include/sys/select.h
blob: 50bdb6a5f436ef616e3f3ca8d3a0c92caaa68957 (plain)
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
#ifndef FORTIFY_SYS_SELECT_H_
#define FORTIFY_SYS_SELECT_H_

#include_next <sys/select.h>

#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0

#ifdef __cplusplus
extern "C" {
#endif

static inline __attribute__ ((always_inline))
int
__fortify_FD_CLR(int fd, fd_set *set)
{
	size_t bos = __builtin_object_size(set, 0);

	if (fd < 0 || fd >= FD_SETSIZE || bos < sizeof(fd_set))
		__builtin_trap();
	return FD_CLR(fd, set);
}

static inline __attribute__ ((always_inline))
int
__fortify_FD_SET(int fd, fd_set *set)
{
	size_t bos = __builtin_object_size(set, 0);

	if (fd < 0 || fd >= FD_SETSIZE || bos < sizeof(fd_set))
		__builtin_trap();
	return FD_SET(fd, set);
}

#undef FD_CLR
#define FD_CLR(fd, set) __fortify_FD_CLR(fd, set)
#undef FD_SET
#define FD_SET(fd, set) __fortify_FD_SET(fd, set)

#ifdef __cplusplus
}
#endif

#endif

#endif