ruby-changes:49452
From: shyouhei <ko1@a...>
Date: Tue, 2 Jan 2018 22:49:33 +0900 (JST)
Subject: [ruby-changes:49452] shyouhei:r61559 (trunk): comparing function pointer versus void* is a GCCism
shyouhei 2018-01-02 15:41:55 +0900 (Tue, 02 Jan 2018) New Revision: 61559 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61559 Log: 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. Modified files: trunk/dln.c Index: dln.c =================================================================== --- dln.c (revision 61558) +++ dln.c (revision 61559) @@ -1242,6 +1242,27 @@ rb_w32_check_imported(HMODULE ext, HMODU https://github.com/ruby/ruby/blob/trunk/dln.c#L1242 #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) https://github.com/ruby/ruby/blob/trunk/dln.c#L1350 } # 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) && \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/