diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-19 00:23:48 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-19 00:23:48 +0000 |
commit | 80980a98b10c0fae6b041e4b85fb888467b2dfaa (patch) | |
tree | c0d26ad479f48e97222460929849f8508a5f14ae /ext/socket | |
parent | 4316e4d99b856fcd16a2aa0f08cb6285dcab24af (diff) | |
download | ruby-80980a98b10c0fae6b041e4b85fb888467b2dfaa.tar.gz |
* ext/socket/raddrinfo.c (addrinfo_mdump, addrinfo_mload): support
UNIX socket only on platforms which support it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/mkconstants.rb | 12 | ||||
-rw-r--r-- | ext/socket/raddrinfo.c | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index cfc0fbe069..1d4e90ba79 100644 --- a/ext/socket/mkconstants.rb +++ b/ext/socket/mkconstants.rb @@ -74,17 +74,15 @@ def each_name(pat) } end +MISSING_DEFS = {} + ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(define, name, default_value)") % if default_value -#ifndef <%=name%> -#define <%=name%> <%=default_value%> -#endif - <%=define%>(<%=c_str name%>, <%=name%>); -% else +% MISSING_DEFS[name] = default_value +% end #if defined(<%=name%>) <%=define%>(<%=c_str name%>, <%=name%>); #endif -% end EOS ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs") @@ -273,6 +271,8 @@ init_constants(VALUE mConst) EOS header_result = ERB.new(<<'EOS', nil, '%').result(binding) +<%= MISSING_DEFS.map {|name, value| ["\#ifndef #{name}", "\# define #{name} #{value}", '#endif']}.join("\n") %> + <%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %> <%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| decl }.join("\n") %> diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 43bbad28a0..e9785d448b 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -1153,6 +1153,7 @@ addrinfo_mdump(VALUE self) afamily = rb_id2str(id); switch(afamily_int) { +#ifdef HAVE_SYS_UN_H case AF_UNIX: { struct sockaddr_un *su = (struct sockaddr_un *)&rai->addr; @@ -1164,6 +1165,7 @@ addrinfo_mdump(VALUE self) sockaddr = rb_str_new(s, e-s); break; } +#endif default: { @@ -1250,6 +1252,7 @@ addrinfo_mload(VALUE self, VALUE ary) v = rb_ary_entry(ary, 1); switch(afamily) { +#ifdef HAVE_SYS_UN_H case AF_UNIX: { struct sockaddr_un *su = (struct sockaddr_un *)&ss; @@ -1263,6 +1266,7 @@ addrinfo_mload(VALUE self, VALUE ary) len = sizeof(*su); break; } +#endif default: { |