From 894f6ba7f1237965ae02719140c8710e56b83784 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 23 Jan 2013 07:18:06 +0000 Subject: mkmf.rb: large unsigned * lib/mkmf.rb (MakeMakefile#try_constant): fix for large unsigned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/mkmf.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 900006ec11..8d8ae1a550 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -613,12 +613,12 @@ SRC def try_constant(const, headers = nil, opt = "", &b) includes = cpp_include(headers) + neg = try_static_assert("#{const} < 0", headers, opt) if CROSS_COMPILING - if try_static_assert("#{const} > 0", headers, opt) - # positive constant - elsif try_static_assert("#{const} < 0", headers, opt) - neg = true + if neg const = "-(#{const})" + elsif try_static_assert("#{const} > 0", headers, opt) + # positive constant elsif try_static_assert("#{const} == 0", headers, opt) return 0 else @@ -646,7 +646,7 @@ SRC src = %{#{includes} #include /*top*/ -typedef +typedef#{neg ? '' : ' unsigned'} #ifdef PRI_LL_PREFIX #define PRI_CONFTEST_PREFIX PRI_LL_PREFIX LONG_LONG @@ -656,7 +656,7 @@ long #endif conftest_type; conftest_type conftest_const = (conftest_type)(#{const}); -int main() {printf("%"PRI_CONFTEST_PREFIX"d\\n", conftest_const); return 0;} +int main() {printf("%"PRI_CONFTEST_PREFIX"#{neg ? 'd' : 'u'}\\n", conftest_const); return 0;} } begin if try_link0(src, opt, &b) -- cgit v1.2.3