Skip to content

Commit

Permalink
Correctly check for function strerror_r
Browse files Browse the repository at this point in the history
Especially if `strerror_r` return a `int` or a `char*`.
  • Loading branch information
mgautierfr committed Aug 12, 2024
1 parent f9125aa commit 569c77c
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion xapian-core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ check_functions = [
['HAVE_SIGACTION', 'sigaction', '#include<signal.h>'],
['HAVE_SLEEP', 'sleep', '#include<unistd.h>'],
['HAVE_STRERRORDESC_NP', 'strerrordesc_np', '#include <string.h>'],
['HAVE_STRERROR_R', 'strerror_r', '#include<string.h>'],
['HAVE_SYSCONF', 'sysconf', '#include<unistd.h>'],
['HAVE_SYS_ERRLIST_AND_SYS_NERR', 'sys_errlist', '#include<cstdlib>'],
['HAVE_TIMER_CREATE', 'timer_create', '#include <time.h>'],
Expand Down Expand Up @@ -216,6 +215,30 @@ cdata.set('SIZEOF_LONG_LONG', cc.sizeof('long long'))
cdata.set('SIZEOF_SHORT', cc.sizeof('short'))


test_strerror_p_ret = '''#include <string.h>
int
main (void)
{
char buf[100];
char x = *strerror_r (0, buf, sizeof buf);
char *p = strerror_r (0, buf, sizeof buf);
return !p || x;
}
'''

strerror_p_ret = cc.run(
test_strerror_p_ret,
name: 'Test if strerror_p returnt a char.'
)

if strerror_p_ret.compiled()
cdata.set10('HAVE_STRERROR_R', true)
cdata.set10('STRERROR_R_CHAR_P', strerror_p_ret.returncode() == 0)
else
cdata.set10('HAVE_STRERROR_R', false)
cdata.set10('STRERROR_R_CHAR_P', false)
endif


if get_option('enable-backend-chert') or get_option('enable-backend-glass')
zlib_dep = dependency('zlib')
Expand Down

0 comments on commit 569c77c

Please sign in to comment.