From f168f85be61b88c8eb5f6cd2c95e975ad8dd9ddb Mon Sep 17 00:00:00 2001 From: shyouhei Date: Tue, 2 Jan 2018 06:41:55 +0000 Subject: comparing function pointer versus void* is a GCCism However dlsym() requires such feature so this function is non- portable by nature. Cannot but suppress warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dln.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'dln.c') diff --git a/dln.c b/dln.c index 55f29fda51..9634d39582 100644 --- a/dln.c +++ b/dln.c @@ -1242,6 +1242,27 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine) #define translit_separator(str) (void)(str) #endif +MAYBE_UNUSED(static bool xmalloc_mismatch_p(void *handle)); + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpedantic" +#elif defined(__GNUC__) && (__GNUC__ >= 5) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +bool +xmalloc_mismatch_p(void *handle) +{ + void *ex = dlsym(handle, EXTERNAL_PREFIX"ruby_xmalloc"); + return ex && ex != ruby_xmalloc; +} +#ifdef __clang__ +#pragma clang diagnostic pop +#elif defined(__GNUC__) && (__GNUC__ >= 5) +#pragma GCC diagnostic pop +#endif + void* dln_load(const char *file) { @@ -1329,8 +1350,7 @@ dln_load(const char *file) } # if defined RUBY_EXPORT { - void *ex = dlsym(handle, EXTERNAL_PREFIX"ruby_xmalloc"); - if (ex && ex != ruby_xmalloc) { + if (xmalloc_mismatch_p(handle)) { # if defined __APPLE__ && \ defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ -- cgit v1.2.3