diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-13 14:46:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-13 14:46:01 +0000 |
commit | a0146d1e8708eb372e415ac733066bee34e3ef36 (patch) | |
tree | 8e61d0ff95316f71740ac66e037f2477a740d54b /lib | |
parent | 4b01d611dbd7911f3f68f1a8b4666125bceaf25b (diff) | |
download | ruby-a0146d1e8708eb372e415ac733066bee34e3ef36.tar.gz |
* lib/mkmf.rb (checking_for): should not modify the result.
* lib/mkmf.rb (have_struct_member): accept compiler opttions.
* lib/mkmf.rb (convertible_int): add restricted support of struct
member, and TYPEOF_ macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mkmf.rb | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb index ad94995379..a3dcadb9ef 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -811,7 +811,7 @@ def checking_for(m, fmt = nil) a = r = nil Logging::postpone do r = yield - a = (fmt ? fmt % r : r ? "yes" : "no") << "\n" + a = (fmt ? "#{fmt % r}" : r ? "yes" : "no") << "\n" "#{f}#{m}-------------------- #{a}\n" end message(a) @@ -1020,9 +1020,9 @@ end # # HAVE_ST_BAR is also defined for backward compatibility. # -def have_struct_member(type, member, headers = nil, &b) +def have_struct_member(type, member, headers = nil, opt = "", &b) checking_for checking_message("#{type}.#{member}", headers) do - if try_compile(<<"SRC", &b) + if try_compile(<<"SRC", opt, &b) #{cpp_include(headers)} /*top*/ #{MAIN_DOES_NOTHING} @@ -1237,17 +1237,26 @@ def convertible_int(type, headers = nil, opts = nil, &b) type else typedef, member, prelude = typedef_expr(type, headers, &b) - next unless signed = try_signedness(typedef, member, [prelude]) - u = "unsigned " if signed > 0 - prelude << "extern rbcv_typedef_ foo();" - compat = UNIVERSAL_INTS.find {|t| - try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b) - } + if member + prelude << "static rbcv_typedef_ rbcv_var;" + compat = UNIVERSAL_INTS.find {|t| + try_static_assert("sizeof(rbcv_var.#{member}) == sizeof(#{t})", [prelude], opts, &b) + } + else + next unless signed = try_signedness(typedef, member, [prelude]) + u = "unsigned " if signed > 0 + prelude << "extern rbcv_typedef_ foo();" + compat = UNIVERSAL_INTS.find {|t| + try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b) + } + end if compat macname ||= type.sub(/_(?=t\z)/, '').tr_cpp conv = (compat == "long long" ? "LL" : compat.upcase) compat = "#{u}#{compat}" - $defs.push(format("-DTYPEOF_%s=%s", type.tr_cpp, compat.quote)) + typename = type.tr_cpp + $defs.push(format("-DSIZEOF_%s=SIZEOF_%s", typename, compat.tr_cpp)) + $defs.push(format("-DTYPEOF_%s=%s", typename, compat.quote)) $defs.push(format("-DPRI_%s_PREFIX=PRI_%s_PREFIX", macname, conv)) conv = (u ? "U" : "") + conv $defs.push(format("-D%s2NUM=%s2NUM", macname, conv)) |