mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/mkmf.rb (check_signedness): should use the prelude code.
[ruby-dev:42731] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									b38cc52c13
								
							
						
					
					
						commit
						30e0f51a5d
					
				
					 4 changed files with 40 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,7 @@
 | 
			
		|||
Fri Dec 10 18:11:08 2010  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
Fri Dec 10 18:11:45 2010  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* lib/mkmf.rb (check_signedness): should use the prelude code.
 | 
			
		||||
	  [ruby-dev:42731]
 | 
			
		||||
 | 
			
		||||
	* lib/mkmf.rb (Logging.log_close): separate from Logging.logfile.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1167,10 +1167,10 @@ end
 | 
			
		|||
# done.
 | 
			
		||||
#
 | 
			
		||||
def check_signedness(type, headers = nil, opts = nil, &b)
 | 
			
		||||
  typedef, member, _ = typedef_expr(type, headers)
 | 
			
		||||
  typedef, member, prelude = typedef_expr(type, headers)
 | 
			
		||||
  signed = nil
 | 
			
		||||
  checking_for("signedness of #{type}", STRING_OR_FAILED_FORMAT) do
 | 
			
		||||
    signed = try_signedness(typedef, member, headers, opts, &b) or next nil
 | 
			
		||||
    signed = try_signedness(typedef, member, [prelude], opts, &b) or next nil
 | 
			
		||||
    $defs.push("-DSIGNEDNESS_OF_%s=%+d" % [type.tr_cpp, signed])
 | 
			
		||||
    signed < 0 ? "signed" : "unsigned"
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,13 @@ class TestMkmf < Test::Unit::TestCase
 | 
			
		|||
  class << MKMFLOG
 | 
			
		||||
    alias to_s call
 | 
			
		||||
  end
 | 
			
		||||
  def mkmflog(msg)
 | 
			
		||||
    log = proc {MKMFLOG[] << msg}
 | 
			
		||||
    class << log
 | 
			
		||||
      alias to_s call
 | 
			
		||||
    end
 | 
			
		||||
    log
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def setup
 | 
			
		||||
    @tmpdir = Dir.mktmpdir
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										27
									
								
								test/mkmf/test_signedness.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								test/mkmf/test_signedness.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
require_relative 'base'
 | 
			
		||||
 | 
			
		||||
class TestMkmf
 | 
			
		||||
  class TestSignedness < TestMkmf
 | 
			
		||||
    def test_typeof_builtin
 | 
			
		||||
      bug4144 = '[ruby-dev:42731]'
 | 
			
		||||
      [["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect|
 | 
			
		||||
        %w[short int long].each do |type|
 | 
			
		||||
          assert_equal(expect.to_i, mkmf {check_signedness(signed+type)}, mkmflog(bug4144))
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def test_typeof_typedef
 | 
			
		||||
      [["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect|
 | 
			
		||||
        %w[short int long].each do |type|
 | 
			
		||||
          open("confdefs.h", "w") {|f|
 | 
			
		||||
            f.puts "typedef #{signed}#{type} test1_t;"
 | 
			
		||||
          }
 | 
			
		||||
          $defs.clear
 | 
			
		||||
          assert_equal(expect.to_i, mkmf {check_signedness("test1_t", "confdefs.h")}, MKMFLOG)
 | 
			
		||||
          assert_includes($defs, "-DSIGNEDNESS_OF_TEST1_T=#{expect}")
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue