Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,14 @@ if test "$os_unix" = "yes"; then

AC_CHECK_FUNC(
[strerror_r],
[AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <errno.h>
#include <string.h>

int main (void)
{
char buf[32];
return strerror_r (EINVAL, buf, 32);
}
]])],
[AC_DEFINE([HAVE_XSI_STRERROR_R], 1, [Whether XSI-compliant strerror_r() is available])],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <errno.h>
#include <string.h>]],
[[/* GNU strerror_r returns char *, XSI returns int */
char buf[32];
return *strerror_r (EINVAL, buf, 32);]])],
[AC_DEFINE([HAVE_GNU_STRERROR_R], 1, [Whether GNU-specific strerror_r() is available])],
[AC_DEFINE([HAVE_XSI_STRERROR_R], 1, [Whether XSI-compliant strerror_r() is available])],
[])],
[])

Expand Down
11 changes: 6 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,21 @@ endforeach

if cc.has_function('strerror_r', prefix: '#include <string.h>')
strerror_r_code = '''
#define _GNU_SOURCE
Comment thread
ueno marked this conversation as resolved.
#include <errno.h>
#include <string.h>

int main (void)
{
/* GNU strerror_r returns char *, XSI returns int */
char buf[32];
return strerror_r (EINVAL, buf, 32);
return *strerror_r (EINVAL, buf, 32);
}
'''
strerror_r_check = cc.run(strerror_r_code, name : 'strerror_r check')
if strerror_r_check.returncode() == 0
conf.set('HAVE_XSI_STRERROR_R', 1)
else
if cc.compiles(strerror_r_code, name : 'GNU strerror_r check')
conf.set('HAVE_GNU_STRERROR_R', 1)
else
conf.set('HAVE_XSI_STRERROR_R', 1)
endif
endif

Expand Down