blob: 0c57785f7ba7e91fbbdf06e75e0de601d9061897 [file] [log] [blame]
Ed Tanouscd9b1c52025-04-22 08:59:45 -07001conf = configuration_data()
2check_headers = [
3 'dlfcn.h',
4 'endian.h',
5 'fcntl.h',
6 'float.h',
7 'inttypes.h',
8 'limits.h',
9 'memory.h',
10 'stdarg.h',
11 'stdint.h',
12 'stdlib.h',
13 'strings.h',
14 'string.h',
15 'syslog.h',
16 'sys/cdefs.h',
17 'sys/param.h',
18 'sys/stat.h',
19 'sys/types.h',
20 'unistd.h',
21 'xlocale.h',
22]
23
24foreach header : check_headers
25 if cc.has_header(header)
26 conf.set('HAVE_@0@'.format(header.underscorify().to_upper()), 1)
27 endif
28endforeach
29
30have_stdc = true
31foreach header : ['stdlib.h', 'stdarg.h', 'string.h', 'float.h']
32 if not conf.has('HAVE_@0@'.format(header.underscorify().to_upper()))
33 have_stdc = false
34 endif
35endforeach
36conf.set10('STDC_HEADERS', have_stdc)
37
38foreach symbol : ['_isnan', '_finite']
39 if cc.has_header_symbol('float.h', symbol)
40 conf.set('HAVE_DECL_@0@'.format(symbol.to_upper()), 1)
41 endif
42endforeach
43
44foreach symbol : ['INFINITY', 'isinf', 'isnan', 'nan']
45 if cc.has_header_symbol('math.h', symbol)
46 conf.set('HAVE_DECL_@0@'.format(symbol.to_upper()), 1)
47 endif
48endforeach
49
50check_function = [
51 'vasprintf',
52 'realloc',
53 'strcasecmp',
54 'strdup',
55 'strerror',
56 'vsyslog',
57 'open',
58 'strtoll',
59]
60
61if conf.has('HAVE_STRINGS_H')
62 check_function += 'strncasecmp'
63endif
64
65foreach function : check_function
66 if cc.has_function(function)
67 conf.set('HAVE_@0@'.format(function.to_upper()), 1)
68 endif
69endforeach
70conf.set10('HAVE_DOPRNT', cc.has_function('_doprnt'))
71
72foreach f : ['snprintf', 'vsnprintf', 'vprintf']
73 if cc.has_header_symbol('stdio.h', f)
74 conf.set('HAVE_@0@'.format(f.to_upper()), 1)
75 endif
76endforeach
77
78size = cc.sizeof('size_t', prefix: '#include <stddef.h>')
79conf.set('SIZEOF_SIZE_T', size)
80
81if cc.get_argument_syntax() == 'msvc'
82 size = cc.sizeof('SSIZE_T', prefix: '#include <BaseTsd.h>')
83else
84 size = cc.sizeof('ssize_t', prefix: '#include <sys/types.h>')
85endif
86conf.set('SIZEOF_SSIZE_T', size)
87
88foreach type : ['int', 'int64_t', 'long', 'long long']
89 size = cc.sizeof(type, prefix: '#include <stdint.h>')
90 conf.set('SIZEOF_@0@'.format(type.underscorify().to_upper()), size)
91endforeach
92
93if cc.links('int main(){__sync_synchronize();}', name: 'atomic builtins')
94 conf.set('HAVE_ATOMIC_BUILTINS', 1)
95endif
96
97if cc.compiles('static __thread int x = 0;', name: '__thread')
98 conf.set('HAVE___THREAD', 1)
99endif
100
101if conf.has('HAVE___THREAD')
102 conf.set('SPEC___THREAD', '__thread')
103elif cc.get_argument_syntax() == 'msvc'
104 conf.set('SPEC___THREAD', '__declspec(thread)')
105endif
106
107conf.set_quoted('VERSION', meson.project_version())
108
109config_h = configure_file(configuration: conf, output: 'config.h')
110