mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
5d223fabb7
commit
894f6ba7f1
3 changed files with 13 additions and 7 deletions
|
@ -1,4 +1,6 @@
|
|||
Wed Jan 23 16:17:59 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Wed Jan 23 16:18:04 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/mkmf.rb (MakeMakefile#try_constant): fix for large unsigned.
|
||||
|
||||
* lib/mkmf.rb (MakeMakefile#try_constant): fix for larger constants.
|
||||
|
||||
|
|
12
lib/mkmf.rb
12
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 <stdio.h>
|
||||
/*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)
|
||||
|
|
|
@ -29,5 +29,9 @@ class TestMkmf
|
|||
decl = "#define CONFTEST_VALUE (unsigned #{type})(((unsigned #{type})1)<<(CHAR_BIT*sizeof(int)))"
|
||||
assert_operator(mkmf {try_constant("CONFTEST_VALUE", [[decl]])}, :>, 0, MKMFLOG)
|
||||
end
|
||||
|
||||
def test_large_unsigned
|
||||
assert_operator(mkmf {try_constant("1U<<(CHAR_BIT*sizeof(int)-1)")}, :>, 0, MKMFLOG)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue