want_selinux = get_option('selinux')
want_oss_fuzz = get_option('oss-fuzz')
want_seccomp = get_option('seccomp')
+want_thread_safety = get_option('thread-safety')
srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
if coverity
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
endif
+srcconf.set10('ENFORCE_THREAD_SAFETY', want_thread_safety)
+
## PAM.
pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
srcconf.set10('HAVE_PAM', pam.found())
have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE')
srcconf.set10('HAVE_OPENPTY', have)
+have_func_strerror_r = cc.has_function('strerror_r', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
+srcconf.set10('HAVE_STRERROR_R', have)
+
+have_func_strerror_r_char_p = false
+
+if have_func_strerror_r
+ code = '''
+#define _GNU_SOURCE
+#include <string.h>
+int func (void) {
+ char error_string[256];
+ char *ptr = strerror_r (-2, error_string, 256);
+ char c = *strerror_r (-2, error_string, 256);
+ return c != 0 && ptr != (void*) 0L;
+}
+'''
+
+have_func_strerror_r_char_p = cc.compiles(code, name : 'strerror_r() returns char *')
+endif
+
+srcconf.set10('STRERROR_R_CHAR_P', have_func_strerror_r_char_p)
+
## Compiler attributes.
foreach ccattr: [
'fallthrough',
['execveat'],
['faccessat'],
['strchrnul'],
+ ['strerror_r'],
['fgetln'],
['fsconfig'],
['fsmount'],
option('oss-fuzz', type : 'boolean', value : 'false',
description : 'build against oss-fuzz')
+
+option('thread-safety', type : 'boolean', value : 'true',
+ description : 'whether the build fails when thread-safe logging cannot be guaranteed')
* Helper macro to define errno string.
*/
#if HAVE_STRERROR_R
- #if !HAVE_DECL_STRERROR_R
- #ifdef STRERROR_R_CHAR_P
- char *strerror_r(int errnum, char *buf, size_t buflen);
- #else
- int strerror_r(int errnum, char *buf, size_t buflen);
- #endif
+ #ifdef STRERROR_R_CHAR_P
+ char *strerror_r(int errnum, char *buf, size_t buflen);
+ #else
+ int strerror_r(int errnum, char *buf, size_t buflen);
#endif
#ifdef STRERROR_R_CHAR_P