From 2ac8079b9414be67a99f736e15383e85da56f7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 19 Jul 2017 10:34:45 +0100 Subject: [PATCH] meson: fix unit tests and "Invalid byte sequence in conversion input" Check if strerror_r returns a char * and define STRERROR_R_CHAR_P if so, which is needed by g_strerror() since c8e268b https://bugzilla.gnome.org/show_bug.cgi?id=784000 --- config.h.meson | 3 +++ meson.build | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/config.h.meson b/config.h.meson index a3d090e7b..9be790187 100644 --- a/config.h.meson +++ b/config.h.meson @@ -398,6 +398,9 @@ /* Define to 1 if you have the `strerror_r' function. */ #mesondefine HAVE_STRERROR_R +/* Define if strerror_r returns char * */ +#mesondefine STRERROR_R_CHAR_P + /* Define to 1 if you have the header file. */ #mesondefine HAVE_STRINGS_H diff --git a/meson.build b/meson.build index 8c82fb845..99afed062 100644 --- a/meson.build +++ b/meson.build @@ -339,6 +339,23 @@ foreach f : functions endif endforeach +# Check whether strerror_r returns char * +if have_func_strerror_r + if cc.compiles('''#define _GNU_SOURCE + #include + 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; + } + ''', + name : 'strerror_r() returns char *') + glib_conf.set('STRERROR_R_CHAR_P', 1, + description: 'Defined if strerror_r returns char *') + endif +endif + # Special-case these functions that have alternative names on Windows/MSVC if cc.has_function('snprintf') or cc.has_header_symbol('stdio.h', 'snprintf') glib_conf.set('HAVE_SNPRINTF', 1)