1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2011-11-13 14:46:01 +00:00
parent 4b01d611db
commit a0146d1e87
3 changed files with 56 additions and 20 deletions

View file

@ -1,3 +1,12 @@
Sun Nov 13 23:45:57 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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.
Sun Nov 13 23:21:24 2011 Tanaka Akira <akr@fsij.org> Sun Nov 13 23:21:24 2011 Tanaka Akira <akr@fsij.org>
* ext/gdbm/gdbm.c (fgdbm_reorganize): set close-on-exec flag after * ext/gdbm/gdbm.c (fgdbm_reorganize): set close-on-exec flag after

View file

@ -750,9 +750,23 @@ need to put
at the top of the file. You can use the functions below to check at the top of the file. You can use the functions below to check
various conditions. various conditions.
have_library(lib, func): check whether library containing function exists. have_macro(macro[, headers[, opt]]): check whether macro is defined
have_func(func, header): check whether function exists have_library(lib[, func[, headers[, opt]]]): check whether library containing function exists
have_header(header): check whether header file exists find_library(lib[, func, *paths]): find library from paths
have_func(func[, headers[, opt]): check whether function exists
have_var(var[, headers[, opt]]): check whether variable exists
have_header(header[, preheaders[, opt]]): check whether header file exists
find_header(header, *paths): find header from paths
have_framework(fw): check whether framework exists (for MacOS X)
have_struct_member(type, member[, headers]): check whether struct has member
have_type(type[, headers[, opt]]): check whether type exists
find_type(type, opt, *headers): check whether type exists in headers
have_const(const[, headers[, opt]]): check whether constant is defined
check_sizeof(type[, headers[, opts]]): check size of type
check_signedness(type[, headers[, opts]]): check signedness of type
convertible_int(type[, headers[, opts]]): find convertible integer type
find_executable(bin[, path]): find excutable file path
create_header(header): generate configured header
create_makefile(target): generate Makefile create_makefile(target): generate Makefile
The value of the variables below will affect the Makefile. The value of the variables below will affect the Makefile.
@ -1379,12 +1393,12 @@ Appendix C. Functions Available in extconf.rb
These functions are available in extconf.rb: These functions are available in extconf.rb:
have_macro(macro, headers) have_macro(macro, headers, opt)
Checks whether macro is defined with header. Returns true if the macro Checks whether macro is defined with header. Returns true if the macro
is defined. is defined.
have_library(lib, func) have_library(lib, func, opt)
Checks whether the library exists, containing the specified function. Checks whether the library exists, containing the specified function.
Returns true if the library exists. Returns true if the library exists.
@ -1394,19 +1408,23 @@ Returns true if the library exists.
Checks whether a library which contains the specified function exists in Checks whether a library which contains the specified function exists in
path. Returns true if the library exists. path. Returns true if the library exists.
have_func(func, header) have_func(func, headers, opt)
Checks whether func exists with header. Returns true if the function Checks whether func exists with header. Returns true if the function
exists. To check functions in an additional library, you need to exists. To check functions in an additional library, you need to
check that library first using have_library(). check that library first using have_library().
The func shall be either mere function name or function name with
arguments.
Example:
have_func("LONG2NUM(0)")
have_var(var, header) have_var(var, header, opt)
Checks whether var exists with header. Returns true if the variable Checks whether var exists with header. Returns true if the variable
exists. To check variables in an additional library, you need to exists. To check variables in an additional library, you need to
check that library first using have_library(). check that library first using have_library().
have_header(header) have_header(header, preheaders, opt)
Checks whether header exists. Returns true if the header file exists. Checks whether header exists. Returns true if the header file exists.
@ -1415,12 +1433,12 @@ Checks whether header exists. Returns true if the header file exists.
Checks whether header exists in path. Returns true if the header file Checks whether header exists in path. Returns true if the header file
exists. exists.
have_struct_member(type, member, header) have_struct_member(type, member, headers, opt)
Checks whether type has member with header. Returns true if the type Checks whether type has member with header. Returns true if the type
is defined and has the member. is defined and has the member.
have_type(type, header, opt) have_type(type, headers, opt)
Checks whether type is defined with header. Returns true if the type Checks whether type is defined with header. Returns true if the type
is defined. is defined.

View file

@ -811,7 +811,7 @@ def checking_for(m, fmt = nil)
a = r = nil a = r = nil
Logging::postpone do Logging::postpone do
r = yield r = yield
a = (fmt ? fmt % r : r ? "yes" : "no") << "\n" a = (fmt ? "#{fmt % r}" : r ? "yes" : "no") << "\n"
"#{f}#{m}-------------------- #{a}\n" "#{f}#{m}-------------------- #{a}\n"
end end
message(a) message(a)
@ -1020,9 +1020,9 @@ end
# #
# HAVE_ST_BAR is also defined for backward compatibility. # 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 checking_for checking_message("#{type}.#{member}", headers) do
if try_compile(<<"SRC", &b) if try_compile(<<"SRC", opt, &b)
#{cpp_include(headers)} #{cpp_include(headers)}
/*top*/ /*top*/
#{MAIN_DOES_NOTHING} #{MAIN_DOES_NOTHING}
@ -1237,17 +1237,26 @@ def convertible_int(type, headers = nil, opts = nil, &b)
type type
else else
typedef, member, prelude = typedef_expr(type, headers, &b) typedef, member, prelude = typedef_expr(type, headers, &b)
next unless signed = try_signedness(typedef, member, [prelude]) if member
u = "unsigned " if signed > 0 prelude << "static rbcv_typedef_ rbcv_var;"
prelude << "extern rbcv_typedef_ foo();" compat = UNIVERSAL_INTS.find {|t|
compat = UNIVERSAL_INTS.find {|t| try_static_assert("sizeof(rbcv_var.#{member}) == sizeof(#{t})", [prelude], opts, &b)
try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &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 if compat
macname ||= type.sub(/_(?=t\z)/, '').tr_cpp macname ||= type.sub(/_(?=t\z)/, '').tr_cpp
conv = (compat == "long long" ? "LL" : compat.upcase) conv = (compat == "long long" ? "LL" : compat.upcase)
compat = "#{u}#{compat}" 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)) $defs.push(format("-DPRI_%s_PREFIX=PRI_%s_PREFIX", macname, conv))
conv = (u ? "U" : "") + conv conv = (u ? "U" : "") + conv
$defs.push(format("-D%s2NUM=%s2NUM", macname, conv)) $defs.push(format("-D%s2NUM=%s2NUM", macname, conv))