summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-30 12:19:40 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-30 12:19:40 +0000
commita413e50c415b456cc4b35ede5e3a2521d1bb48d2 (patch)
treeaf39b784e6f415c267eb98c5645501afe43e3e50 /ext
parent70365e5debc95ca98d5564f196a1b49323758d82 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/mkconstants.rb9
-rw-r--r--ext/socket/socket.c9
2 files changed, 16 insertions, 2 deletions
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