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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/usr/bin/env python
import os
VERSION = "1.4.2"
def configure(conf):
if conf.CHECK_SOCKET_WRAPPER():
conf.DEFINE('USING_SYSTEM_SOCKET_WRAPPER', 1)
libsocket_wrapper_so_path = 'libsocket_wrapper.so'
else:
if conf.CONFIG_SET("HAVE___THREAD"):
conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
# check HAVE_FUNCTION_ATTRIBUTE_FORMAT
conf.CHECK_CODE('''
void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int main(void) {
return 0;
}
''',
'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
addmain=False,
strict=True,
msg='Checking for printf format validation support')
conf.CHECK_HEADERS('sys/signalfd.h')
conf.CHECK_HEADERS('sys/eventfd.h')
conf.CHECK_HEADERS('sys/timerfd.h')
conf.CHECK_HEADERS('gnu/lib-names.h')
conf.CHECK_HEADERS('rpc/rpc.h')
conf.CHECK_HEADERS('netinet/tcp_fsm.h')
conf.CHECK_STRUCTURE_MEMBER('struct msghdr',
'msg_control',
headers='sys/types.h sys/socket.h',
define='HAVE_STRUCT_MSGHDR_MSG_CONTROL')
conf.CHECK_STRUCTURE_MEMBER('struct in_pktinfo',
'ipi_addr',
headers='sys/types.h sys/socket.h netinet/in.h',
define='HAVE_STRUCT_IN_PKTINFO')
conf.CHECK_STRUCTURE_MEMBER('struct in6_pktinfo',
'ipi6_addr',
headers='sys/types.h sys/socket.h netinet/in.h',
define='HAVE_STRUCT_IN6_PKTINFO')
conf.CHECK_FUNCS('getaddrinfo')
conf.CHECK_FUNCS('signalfd eventfd timerfd_create')
conf.CHECK_FUNCS('bindresvport')
conf.CHECK_FUNCS('pledge')
conf.CHECK_FUNCS('accept4')
conf.CHECK_FUNCS('sendmmsg recvmmsg')
conf.CHECK_FUNCS('__close_nocancel')
conf.CHECK_FUNCS('openat64')
conf.CHECK_FUNCS('fopen64')
conf.CHECK_FUNCS('open64')
conf.CHECK_FUNCS('fcntl64')
conf.CHECK_FUNCS_IN('bind',
'socket',
checklibc=True,
headers='sys/types.h sys/socket.h')
conf.CHECK_C_PROTOTYPE('accept',
'int accept(int s, struct sockaddr *addr, Psocklen_t addrlen)',
define='HAVE_ACCEPT_PSOCKLEN_T', headers='sys/types.h sys/socket.h')
# Linux legacy glibc < 2.21
conf.CHECK_C_PROTOTYPE('recvmmsg',
'int recvmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags, const struct timespec *__tmo)',
define='HAVE_RECVMMSG_CONST_TIMEOUT', headers='sys/types.h sys/socket.h')
# FreeBSD
conf.CHECK_C_PROTOTYPE('recvmmsg',
'ssize_t recvmmsg(int __fd, struct mmsghdr * __restrict __vmessages, size_t __vlen, int __flags, const struct timespec * __restrict __tmo)',
define='HAVE_RECVMMSG_SSIZE_T_CONST_TIMEOUT', headers='sys/types.h sys/socket.h')
# FreeBSD
conf.CHECK_C_PROTOTYPE('sendmmsg',
'ssize_t sendmmsg(int __fd, struct mmsghdr * __restrict __vmessages, size_t __vlen, int __flags)',
define='HAVE_SENDMMSG_SSIZE_T', headers='sys/types.h sys/socket.h')
conf.CHECK_C_PROTOTYPE('ioctl',
'int ioctl(int s, int r, ...)',
define='HAVE_IOCTL_INT', headers='unistd.h sys/ioctl.h')
if conf.CONFIG_SET("HAVE_EVENTFD"):
conf.CHECK_C_PROTOTYPE('eventfd',
'int eventfd(unsigned int count, int flags)',
define='HAVE_EVENTFD_UNSIGNED_INT', headers='sys/eventfd.h')
# FreeBSD exports each syscall also with '_' as prefix
# and these symbols are used if called by system libraries itself.
# That means socket_wrapper needs to implement these too
# in order to inject itself into system libraries,
# we just check for _socket and _close and assume the rest
# is also there...
conf.CHECK_FUNCS('_socket _close')
# Create full path to socket_wrapper
blddir = os.path.realpath(conf.bldnode.abspath())
libsocket_wrapper_so_path = blddir + '/default/third_party/socket_wrapper/libsocket-wrapper.so'
conf.DEFINE('LIBSOCKET_WRAPPER_SO_PATH', libsocket_wrapper_so_path)
conf.DEFINE('SOCKET_WRAPPER', 1)
def build(bld):
if not bld.CONFIG_SET("USING_SYSTEM_SOCKET_WRAPPER"):
# We need to do it this way or the library wont work.
# We need force_unversioned=True as symbol versioning
# breaks preloading!
bld.SAMBA_LIBRARY('socket_wrapper',
source='socket_wrapper.c',
cflags='-D%s="%s" -D%s="%s"' % (
"SOCKET_WRAPPER_PACKAGE",
"samba_socket_wrapper",
"SOCKET_WRAPPER_VERSION",
VERSION),
deps='dl pthread tirpc',
install=False,
force_unversioned=True,
realname='libsocket-wrapper.so')
|