summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-02 06:41:55 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-02 06:41:55 +0000
commit8dc0c7c035eb2ef22608968aeca63f24ade0eee0 (patch)
tree0c90d41824a848cd73fd80103842201b3edc93e4 /dln.c
parent1f76918a33c1ca0e563910940f292303016f34fe (diff)
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
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c24
1 files changed, 22 insertions, 2 deletions
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) && \