From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 2D06D1F47C for ; Sun, 8 Jan 2023 05:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1673155244; bh=i/KwFFpbzV89uLsMH9PC+G/ym96vnxc7Lxfr/AUbBhY=; h=From:To:Subject:Date:From; b=q+HZ4ax8A2EaqkGJXnNr4ykDIsl2Gn2bnDdU30yhYASJhRAf0aMGrOXkOWrTqyH6+ pE+4rgTBmh63dmt9WBnXIHQ4iE2/V4gwdDU4sZUSkiOEoHJ1XIa9eIx+QFVeS6fr01 IkP1oFzHsHPkeGhyr/m/V95HKl4s0EkCHAQp6cFI= From: Eric Wong To: mwrap-public@80x24.org Subject: [PATCH] drop dlsym use for rb_stderr Date: Sun, 8 Jan 2023 05:20:44 +0000 Message-Id: <20230108052044.2493205-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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