mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/mkmf.rb (try_constant): fix for value 1 at cross compiling.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2bf2f48a0b
commit
c27f8d5b3a
2 changed files with 30 additions and 29 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Jul 9 18:04:14 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/mkmf.rb (try_constant): fix for value 1 at cross compiling.
|
||||||
|
|
||||||
Sun Jul 9 07:58:48 2006 Ryan Davis <ryand@zenspider.com>
|
Sun Jul 9 07:58:48 2006 Ryan Davis <ryand@zenspider.com>
|
||||||
|
|
||||||
* lib/rdoc/parsers/parse_f95.rb: massive overhaul from Yasuhiro
|
* lib/rdoc/parsers/parse_f95.rb: massive overhaul from Yasuhiro
|
||||||
|
|
57
lib/mkmf.rb
57
lib/mkmf.rb
|
@ -235,17 +235,22 @@ def xpopen command, *mode, &block
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_src(src)
|
def log_src(src)
|
||||||
Logging::message <<"EOM", src
|
src = src.split(/^/)
|
||||||
|
fmt = "%#{src.size.to_s.size}d: %s"
|
||||||
|
Logging::message <<"EOM"
|
||||||
checked program was:
|
checked program was:
|
||||||
/* begin */
|
/* begin */
|
||||||
%s/* end */
|
EOM
|
||||||
|
src.each_with_index {|line, no| Logging::message fmt, no+1, line}
|
||||||
|
Logging::message <<"EOM"
|
||||||
|
/* end */
|
||||||
|
|
||||||
EOM
|
EOM
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_tmpsrc(src)
|
def create_tmpsrc(src)
|
||||||
src = yield(src) if block_given?
|
src = yield(src) if block_given?
|
||||||
src = src.sub(/[^\n]\z/, "\\&\n")
|
src = src.gsub(/[ \t]+$/, '').gsub(/\A\n+|^\n+$/, '').sub(/[^\n]\z/, "\\&\n")
|
||||||
open(CONFTEST_C, "wb") do |cfile|
|
open(CONFTEST_C, "wb") do |cfile|
|
||||||
cfile.print src
|
cfile.print src
|
||||||
end
|
end
|
||||||
|
@ -369,6 +374,7 @@ def try_constant(const, headers = nil, opt = "", &b)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
upper = 1
|
upper = 1
|
||||||
|
lower = 0
|
||||||
until try_static_assert("#{const} <= #{upper}", headers, opt)
|
until try_static_assert("#{const} <= #{upper}", headers, opt)
|
||||||
lower = upper
|
lower = upper
|
||||||
upper <<= 1
|
upper <<= 1
|
||||||
|
@ -382,11 +388,6 @@ def try_constant(const, headers = nil, opt = "", &b)
|
||||||
upper = mid
|
upper = mid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless upper == lower
|
|
||||||
if try_static_assert("#{const} == #{lower}", headers, opt)
|
|
||||||
upper = lower
|
|
||||||
end
|
|
||||||
end
|
|
||||||
upper = -upper if neg
|
upper = -upper if neg
|
||||||
return upper
|
return upper
|
||||||
else
|
else
|
||||||
|
@ -429,7 +430,7 @@ def try_var(var, headers = nil, &b)
|
||||||
#{headers}
|
#{headers}
|
||||||
/*top*/
|
/*top*/
|
||||||
int main() { return 0; }
|
int main() { return 0; }
|
||||||
int t() { void *volatile p; p = (void *)&#{var}; return 0; }
|
int t() { const volatile void *volatile p; p = (void *)&#{var}; return 0; }
|
||||||
SRC
|
SRC
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -534,7 +535,7 @@ end
|
||||||
|
|
||||||
def checking_for(m, fmt = nil)
|
def checking_for(m, fmt = nil)
|
||||||
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
|
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
|
||||||
m = "checking for #{m}... "
|
m = "checking #{'for ' if /\Acheck/ !~ f}#{m}... "
|
||||||
message "%s", m
|
message "%s", m
|
||||||
a = r = nil
|
a = r = nil
|
||||||
Logging::postpone do
|
Logging::postpone do
|
||||||
|
@ -555,7 +556,7 @@ def have_macro(macro, headers = nil, opt = "", &b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def have_library(lib, func = nil, header=nil, &b)
|
def have_library(lib, func = nil, headers = nil, &b)
|
||||||
func = "main" if !func or func.empty?
|
func = "main" if !func or func.empty?
|
||||||
lib = with_config(lib+'lib', lib)
|
lib = with_config(lib+'lib', lib)
|
||||||
checking_for "#{func}() in #{LIBARG%lib}" do
|
checking_for "#{func}() in #{LIBARG%lib}" do
|
||||||
|
@ -563,7 +564,7 @@ def have_library(lib, func = nil, header=nil, &b)
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
libs = append_library($libs, lib)
|
libs = append_library($libs, lib)
|
||||||
if try_func(func, libs, header, &b)
|
if try_func(func, libs, headers, &b)
|
||||||
$libs = libs
|
$libs = libs
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
@ -629,14 +630,15 @@ def have_header(header, &b)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_header(header, *paths)
|
def find_header(header, *paths)
|
||||||
|
header = cpp_include(header)
|
||||||
checking_for header do
|
checking_for header do
|
||||||
if try_cpp(cpp_include(header))
|
if try_cpp(header)
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
found = false
|
found = false
|
||||||
paths.each do |dir|
|
paths.each do |dir|
|
||||||
opt = "-I#{dir}".quote
|
opt = "-I#{dir}".quote
|
||||||
if try_cpp(cpp_include(header), opt)
|
if try_cpp(header, opt)
|
||||||
$INCFLAGS << " " << opt
|
$INCFLAGS << " " << opt
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
|
@ -664,17 +666,17 @@ SRC
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def have_type(type, header = nil, opt = "", &b)
|
def have_type(type, headers = nil, opt = "", &b)
|
||||||
checking_for type do
|
checking_for type do
|
||||||
header = cpp_include(header)
|
headers = cpp_include(headers)
|
||||||
if try_compile(<<"SRC", opt, &b) or (/\A\w+\z/n =~ type && try_compile(<<"SRC", opt, &b))
|
if try_compile(<<"SRC", opt, &b) or (/\A\w+\z/n =~ type && try_compile(<<"SRC", opt, &b))
|
||||||
#{COMMON_HEADERS}
|
#{COMMON_HEADERS}
|
||||||
#{header}
|
#{headers}
|
||||||
/*top*/
|
/*top*/
|
||||||
static #{type} t;
|
static #{type} t;
|
||||||
SRC
|
SRC
|
||||||
#{COMMON_HEADERS}
|
#{COMMON_HEADERS}
|
||||||
#{header}
|
#{headers}
|
||||||
/*top*/
|
/*top*/
|
||||||
static #{type} *t;
|
static #{type} *t;
|
||||||
SRC
|
SRC
|
||||||
|
@ -688,22 +690,17 @@ end
|
||||||
|
|
||||||
def check_sizeof(type, header = nil, &b)
|
def check_sizeof(type, header = nil, &b)
|
||||||
expr = "sizeof(#{type})"
|
expr = "sizeof(#{type})"
|
||||||
m = "checking size of #{type}... "
|
fmt = "%d"
|
||||||
message "%s", m
|
def fmt.%(x)
|
||||||
a = size = nil
|
x ? super : "failed"
|
||||||
Logging::postpone do
|
end
|
||||||
|
checking_for("size of #{type}", fmt) do
|
||||||
if size = try_constant(expr, header, &b)
|
if size = try_constant(expr, header, &b)
|
||||||
$defs.push(format("-DSIZEOF_%s=%d", type.upcase.tr_s("^A-Z0-9_", "_"), size))
|
$defs.push(format("-DSIZEOF_%s=%d", type.upcase.tr_s("^A-Z0-9_", "_"), size))
|
||||||
a = "#{size}\n"
|
|
||||||
else
|
|
||||||
a = "failed\n"
|
|
||||||
end
|
|
||||||
"check_sizeof: #{m}-------------------- #{a}\n"
|
|
||||||
end
|
|
||||||
message(a)
|
|
||||||
Logging::message "--------------------\n\n"
|
|
||||||
size
|
size
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def scalar_ptr_type?(type, member = nil, headers = nil, &b)
|
def scalar_ptr_type?(type, member = nil, headers = nil, &b)
|
||||||
try_compile(<<"SRC", &b) # pointer
|
try_compile(<<"SRC", &b) # pointer
|
||||||
|
|
Loading…
Reference in a new issue