[前][次][番号順一覧][スレッド一覧]

ruby-changes:66494

From: Nobuyoshi <ko1@a...>
Date: Wed, 16 Jun 2021 13:17:33 +0900 (JST)
Subject: [ruby-changes:66494] c2d9967f78 (master): Configure ioctl request argument type [Bug #17759]

https://git.ruby-lang.org/ruby.git/commit/?id=c2d9967f78

From c2d9967f78d2e6f93f8d9876c2b3ab25aa6b86e7 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 16 Jun 2021 11:51:21 +0900
Subject: Configure ioctl request argument type [Bug #17759]

---
 configure.ac | 30 ++++++++++++++++++++++++++++++
 io.c         |  4 ++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9306542..38ab4bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2753,6 +2753,36 @@ AS_IF([test "x$rb_cv_const_page_size" = xyes], https://github.com/ruby/ruby/blob/trunk/configure.ac#L2753
     [AC_DEFINE(HAVE_CONST_PAGE_SIZE, 1)],
     [AC_DEFINE(HAVE_CONST_PAGE_SIZE, 0)]
 )
+
+AS_IF([test "x$ac_cv_func_ioctl" = xyes], [
+    AC_CACHE_CHECK([ioctl request type], rb_cv_ioctl_request_type,
+        [rb_cv_ioctl_request_type=no
+        dnl corresponding NUM2IOCTLREQ needs to be defined
+        for type in "unsigned long:ULONG_MAX" int:INT_MAX; do
+            max=`echo $type | sed 's/.*://'`
+            type=`echo $type | sed 's/:.*//'`
+            RUBY_WERROR_FLAG([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+                    @%:@include <limits.h>
+                    @%:@include <sys/types.h>
+                    @%:@if defined(HAVE_SYS_IOCTL_H) && !defined(_WIN32)
+                    @%:@include <sys/ioctl.h>
+                    @%:@endif
+                ]], [[
+                    $type req = $max;
+                    if (ioctl(0, req)) {/* do nothing*/};
+                ]])],
+                [rb_cv_ioctl_request_type="$type"])
+            ])
+            test "x$rb_cv_ioctl_request_type" = xno || break
+        done])
+    AS_CASE(["$rb_cv_ioctl_request_type"], [no|int], [],
+    ["unsigned long"], [
+        AC_DEFINE_UNQUOTED(IOCTL_REQ_TYPE, [$rb_cv_ioctl_request_type])
+        AC_DEFINE_UNQUOTED(NUM2IOCTLREQ(num), [NUM2ULONG(num)])
+    ])
+])
+
 }
 
 : "runtime section" && {
diff --git a/io.c b/io.c
index 1051149..eceec8b 100644
--- a/io.c
+++ b/io.c
@@ -9810,8 +9810,8 @@ rb_f_select(int argc, VALUE *argv, VALUE obj) https://github.com/ruby/ruby/blob/trunk/io.c#L9810
     return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args);
 }
 
-#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
- typedef unsigned long ioctl_req_t;
+#ifdef IOCTL_REQ_TYPE
+ typedef IOCTL_REQ_TYPE ioctl_req_t;
 # define NUM2IOCTLREQ(num) NUM2ULONG(num)
 #else
  typedef int ioctl_req_t;
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]