summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ext/socket/mkconstants.rb9
-rw-r--r--ext/socket/socket.c9
3 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ac90533540..cc5b5d1874 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Dec 30 21:17:00 2008 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/mkconstants.rb: use sock_define_uconst for INADDR_*
+ constants because Socket::INADDR_LOOPBACK should be 0x7f000001
+ instead of -0xffffff.
+
+ * ext/socket/socket.c (sock_define_uconst): defined.
+
Tue Dec 30 18:23:10 2008 Ryan Davis <ryand-ruby@zenspider.com>
* lib/minitest/*.rb: Imported minitest 1.3.1 r4506.
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index bb05250805..589e3b2bb3 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -7,11 +7,16 @@ $out.puts("#define pseudo_AF_FTIP pseudo_AF_RTIP")
DATA.each_line do |s|
name, value = s.scan(/\S+/)
if name && name[0] != ?#
+ if name =~ /\AINADDR_/
+ define = "sock_define_uconst"
+ else
+ define = "sock_define_const"
+ end
$out.puts("#ifdef #{name}")
- $out.puts(" sock_define_const(\"#{name}\", #{name});")
+ $out.puts(" #{define}(\"#{name}\", #{name});")
if value
$out.puts("#else")
- $out.puts(" sock_define_const(\"#{name}\", #{value});")
+ $out.puts(" #{define}(\"#{name}\", #{value});")
end
$out.puts("#endif")
$out.puts
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 0646f7bef4..b9de752d71 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -3557,7 +3557,16 @@ sock_define_const(const char *name, int value, VALUE mConst)
rb_define_const(rb_cSocket, name, INT2FIX(value));
rb_define_const(mConst, name, INT2FIX(value));
}
+
+static void
+sock_define_uconst(const char *name, unsigned int value, VALUE mConst)
+{
+ rb_define_const(rb_cSocket, name, UINT2NUM(value));
+ rb_define_const(mConst, name, UINT2NUM(value));
+}
+
#define sock_define_const(name, value) sock_define_const(name, value, mConst)
+#define sock_define_uconst(name, value) sock_define_uconst(name, value, mConst)
/*
* Class +Socket+ provides access to the underlying operating system