summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket')
-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 bb05250805b..589e3b2bb36 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 0646f7bef40..b9de752d719 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