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

ruby-changes:28686

From: nobu <ko1@a...>
Date: Tue, 14 May 2013 23:24:52 +0900 (JST)
Subject: [ruby-changes:28686] nobu:r40738 (trunk): socket: fix build error and warnings on mingw

nobu	2013-05-14 23:24:42 +0900 (Tue, 14 May 2013)

  New Revision: 40738

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40738

  Log:
    socket: fix build error and warnings on mingw
    
    * ext/socket/extconf.rb: check for if_nametoindex() for
      i686-w64-mingw32, and check for declarations of if_indextoname() and
      if_nametoindex().
    * ext/socket/ifaddr.c (ifaddr_ifindex): not-implement unless
      if_nametoindex() is available.
    * ext/socket/rubysocket.h: declare if_indextoname() and
      if_nametoindex() if available but not declared.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/extconf.rb
    trunk/ext/socket/ifaddr.c
    trunk/ext/socket/rubysocket.h

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40737)
+++ ChangeLog	(revision 40738)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue May 14 23:24:31 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/socket/extconf.rb: check for if_nametoindex() for
+	  i686-w64-mingw32, and check for declarations of if_indextoname() and
+	  if_nametoindex().
+
+	* ext/socket/ifaddr.c (ifaddr_ifindex): not-implement unless
+	  if_nametoindex() is available.
+
+	* ext/socket/rubysocket.h: declare if_indextoname() and
+	  if_nametoindex() if available but not declared.
+
 Tue May 14 19:58:17 2013  CHIKANAGA Tomoyuki  <nagachika@r...>
 
 	* ext/dl/lib/dl/func.rb (DL::Function#call): check tainted when
Index: ext/socket/rubysocket.h
===================================================================
--- ext/socket/rubysocket.h	(revision 40737)
+++ ext/socket/rubysocket.h	(revision 40738)
@@ -106,6 +106,13 @@ https://github.com/ruby/ruby/blob/trunk/ext/socket/rubysocket.h#L106
 typedef int socklen_t;
 #endif
 
+#ifdef NEED_IF_INDEXTONAME_DECL
+char *if_indextoname(unsigned int, char *);
+#endif
+#ifdef NEED_IF_NAMETOINDEX_DECL
+unsigned int if_nametoindex(const char *);
+#endif
+
 #define SOCKLEN_MAX \
   (0 < (socklen_t)-1 ? \
    ~(socklen_t)0 : \
Index: ext/socket/extconf.rb
===================================================================
--- ext/socket/extconf.rb	(revision 40737)
+++ ext/socket/extconf.rb	(revision 40738)
@@ -421,7 +421,20 @@ EOF https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L421
 
   have_func("getpeerucred(0, (ucred_t **)NULL)", headers) # SunOS
 
-  have_func('if_indextoname(0, "")', headers)
+  have_func_decl = proc do |name, headers|
+    if !checking_for("declaration of #{name}()") {!%w[int void].all? {|ret| try_compile(<<EOF)}}
+#{cpp_include(headers)}
+#{ret} #{name}(void);
+EOF
+      $defs << "-DNEED_#{name.tr_cpp}_DECL"
+    end
+  end
+  if have_func('if_indextoname(0, "")', headers)
+    have_func_decl["if_indextoname"]
+  end
+  if have_func('if_nametoindex("")', headers)
+    have_func_decl["if_nametoindex"]
+  end
 
   have_func("hsterror", headers)
   have_func('getipnodebyname("", 0, 0, (int *)0)', headers) # RFC 2553
Index: ext/socket/ifaddr.c
===================================================================
--- ext/socket/ifaddr.c	(revision 40737)
+++ ext/socket/ifaddr.c	(revision 40738)
@@ -135,6 +135,7 @@ ifaddr_name(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/socket/ifaddr.c#L135
  * Returns the interface index of _ifaddr_.
  */
 
+#ifdef HAVE_IF_NAMETOINDEX
 static VALUE
 ifaddr_ifindex(VALUE self)
 {
@@ -146,6 +147,9 @@ ifaddr_ifindex(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/socket/ifaddr.c#L147
     }
     return UINT2NUM(ifindex);
 }
+#else
+#define ifaddr_ifindex rb_f_notimplement
+#endif
 
 /*
  * call-seq:

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

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