From babee7d4dfbf0771621f51dc1e438fad019efe1e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 8 Jan 2023 05:20:44 +0000 Subject: drop dlsym use for rb_stderr A weak symbol works fine, here. --- ext/mwrap/mwrap.c | 3 ++- ext/mwrap/mwrap_core.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mwrap/mwrap.c b/ext/mwrap/mwrap.c index d88fee6..a45bb38 100644 --- a/ext/mwrap/mwrap.c +++ b/ext/mwrap/mwrap.c @@ -6,6 +6,7 @@ #include "mwrap_core.h" static ID id_uminus; +extern VALUE __attribute__((weak)) rb_stderr; extern VALUE __attribute__((weak)) rb_cObject; extern VALUE __attribute__((weak)) rb_eTypeError; extern VALUE __attribute__((weak)) rb_yield(VALUE); @@ -33,7 +34,7 @@ static VALUE mwrap_dump(int argc, VALUE *argv, VALUE mod) if (NIL_P(io)) /* library may be linked w/o Ruby */ - io = *((VALUE *)dlsym(RTLD_DEFAULT, "rb_stderr")); + io = rb_stderr; a.min = NIL_P(min) ? 0 : NUM2SIZET(min); io = rb_io_get_io(io); diff --git a/ext/mwrap/mwrap_core.h b/ext/mwrap/mwrap_core.h index c0eea2f..721e5d3 100644 --- a/ext/mwrap/mwrap_core.h +++ b/ext/mwrap/mwrap_core.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3-24-ge0c7