OSDN Git Service

2008-09-03 Chris Fairles <chris.fairles@gmail.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / lib / libstdc++.exp
index b482bf5..23060b4 100644 (file)
@@ -1,6 +1,6 @@
 # libstdc++ "tool init file" for DejaGNU
 
-# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 # Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -81,7 +81,7 @@ proc v3-copy-files {srcfiles} {
 # Called once, during runtest.exp setup.
 proc libstdc++_init { testfile } {
     global env
-    global v3-sharedlib 
+    global v3-sharedlib v3-libgomp
     global srcdir blddir objdir tool_root_dir
     global cc cxx cxxflags cxxpchflags cxxldflags
     global includes
@@ -135,10 +135,13 @@ proc libstdc++_init { testfile } {
     v3track gccdir 3
 
     # Locate libgomp. This is only required for parallel mode.
+    set v3-libgomp 0
     set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.so]
     if {$libgompdir != ""} {
+       set v3-libgomp 1
         set libgompdir [file dirname $libgompdir]
        append ld_library_path_tmp ":${libgompdir}"
+       verbose -log "libgomp support detected"
     }
     v3track libgompdir 3
 
@@ -443,12 +446,13 @@ proc v3_target_compile_as_c { source dest type options } {
        set includestarget "${includesbase}/${machine}"
        set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
 
-        set libsup "${comp_base_dir}/lib"
+        set libdir "-L${comp_base_dir}/lib"
     } else {
-        set libsup "${blddir}/libsupc++/.libs"
+        set libdir "-L${blddir}/libsupc++/.libs"
+       set libdir [concat $libdir "-L${blddir}/src/.libs"]
     }
 
-    set cc_final [concat $cc_final "-L$libsup"]
+    set cc_final [concat $cc_final "$libdir"]
 
     lappend options "compiler=$cc_final"
     lappend options "timeout=600"
@@ -512,7 +516,7 @@ proc v3-build_support { } {
     # Build the support objects.
     set source_files [list testsuite_abi.cc testsuite_allocator.cc \
                          testsuite_character.cc testsuite_hooks.cc \
-                rng/twister_rand_gen.cc io/verified_cmd_line_input.cc \
+                         io/verified_cmd_line_input.cc \
                          io/prog_bar.cc performance/time/elapsed_timer.cc ]
     foreach f $source_files {
        set obj [file rootname $f].o
@@ -686,7 +690,7 @@ proc check_v3_target_c_std { } {
        puts $f "  int i = std::tr1::isnan(f);"
        puts $f "  "
        puts $f "  using std::wctomb;"
-       puts $f "  return 0;"
+       puts $f "  return i;"
        puts $f "}" 
        close $f
 
@@ -938,7 +942,7 @@ proc check_v3_target_debug_mode { } {
     } else {
        set et_debug_mode 0
 
-       # Set up, compile, and execute a C++ test program that depends
+       # Set up and compile a C++ test program that depends
        # on debug mode working.
        set src debug_mode[pid].cc
        set exe debug_mode[pid].exe
@@ -967,7 +971,7 @@ proc check_v3_target_debug_mode { } {
 
 proc check_v3_target_parallel_mode { } {
     global cxxflags
-    global DEFAULT_CXXFLAGS
+    global v3-libgomp
     global et_parallel_mode
 
     global tool        
@@ -992,15 +996,53 @@ proc check_v3_target_parallel_mode { } {
     } else {
        set et_parallel_mode 0
 
-       # Set up, compile, and execute a C++ test program that depends
-       # on parallel mode working.
-       set src parallel_mode[pid].cc
-       set exe parallel_mode[pid].exe
+       # If 'make check-parallel' is running the test succeeds.
+       if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
+           set et_parallel_mode 1
+       }
+    }
+    verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
+    return $et_parallel_mode
+}
+
+proc check_v3_target_cstdint { } {
+    global cxxflags
+    global DEFAULT_CXXFLAGS
+    global et_cstdint
+
+    global tool        
+
+    if { ![info exists et_cstdint_target_name] } {
+       set et_cstdint_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_cstdint_target_name } {
+       verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
+       set et_cstdint_target_name $current_target
+       if [info exists et_cstdint] {
+           verbose "check_v3_target_cstdint: removing cached result" 2
+           unset et_cstdint
+       }
+    }
+
+    if [info exists et_cstdint] {
+       verbose "check_v3_target_cstdint: using cached result" 2
+    } else {
+       set et_cstdint 0
+
+       # Set up and compile a C++0x test program that depends
+       # on the C99 stdint facilities to be available.
+       set src cstdint[pid].cc
+       set exe cstdint[pid].exe
 
        set f [open $src "w"]
-       puts $f "#include <omp.h>"
+       puts $f "#include <tr1/cstdint>"
        puts $f "int main()"
+       puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1"
        puts $f "{ return 0; }"
+       puts $f "#endif"
        close $f
 
        set cxxflags_saved $cxxflags
@@ -1012,11 +1054,127 @@ proc check_v3_target_parallel_mode { } {
 
        if [string match "" $lines] {
            # No error message, compilation succeeded.
-           set et_parallel_mode 1
+           set et_cstdint 1
        } else {
-           verbose "check_v3_target_parallel_mode: compilation failed" 2
+           verbose "check_v3_target_cstdint: compilation failed" 2
        }
     }
-    verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
-    return $et_parallel_mode
+    verbose "check_v3_target_cstdint: $et_cstdint" 2
+    return $et_cstdint
+}
+
+proc check_v3_target_atomic_builtins { } {
+    global cxxflags
+    global DEFAULT_CXXFLAGS
+    global et_cstdint
+
+    global tool        
+
+    if { ![info exists et_atomic_builtins_target_name] } {
+       set et_atomic_builtins_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_atomic_builtins_target_name } {
+       verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
+       set et_atomic_builtins_target_name $current_target
+       if [info exists et_atomic_builtins] {
+           verbose "check_v3_target_atomic_builtins: removing cached result" 2
+           unset et_atomic_builtins
+       }
+    }
+
+    if [info exists et_atomic_builtins] {
+       verbose "check_v3_target_atomic_builtins: using cached result" 2
+    } else {
+       set et_atomic_builtins 0
+
+       # Set up and compile a C++0x test program that depends
+       # on the atomic builtin facilities to be available.
+       set src atomic_builtins[pid].cc
+       set exe atomic_builtins[pid].exe
+
+       set f [open $src "w"]
+       puts $f "#include <bits/c++config.h>"
+       puts $f "int main()"
+       puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4"
+       puts $f "{ return 0; }"
+       puts $f "#endif"
+       close $f
+
+       set cxxflags_saved $cxxflags
+       set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+
+       set lines [v3_target_compile $src $exe executable ""]
+       set cxxflags $cxxflags_saved
+       file delete $src
+
+       if [string match "" $lines] {
+           # No error message, compilation succeeded.
+           set et_atomic_builtins 1
+       } else {
+           verbose "check_v3_target_atomic_builtins: compilation failed" 2
+       }
+    }
+    verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
+    return $et_atomic_builtins
+}
+
+proc check_v3_target_gthreads { } {
+    global cxxflags
+    global DEFAULT_CXXFLAGS
+    global et_gthreads
+
+    global tool
+
+    if { ![info exists et_gthreads_target_name] } {
+        set et_gthreads_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_gthreads_target_name } {
+        verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
+        set et_gthreads_target_name $current_target
+        if [info exists et_gthreads] {
+            verbose "check_v3_target_gthreads: removing cached result" 2
+            unset et_gthreads
+        }
+    }
+
+    if [info exists et_gthreads] {
+        verbose "check_v3_target_gthreads: using cached result" 2
+    } else {
+        set et_gthreads 0
+
+        # Set up and compile a C++0x test program that depends
+        # on the gthreads facilities to be available.
+        set src gthreads[pid].cc
+        set exe gthreads[pid].exe
+
+        set f [open $src "w"]
+       puts $f "#include <bits/c++config.h>"
+        puts $f "int main()"
+        puts $f "#ifdef _GLIBCXX_HAS_GTHREADS"
+        puts $f "{ return 0; }"
+        puts $f "#endif"
+        close $f
+
+        set cxxflags_saved $cxxflags
+        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
+
+        set lines [v3_target_compile $src $exe executable ""]
+        set cxxflags $cxxflags_saved
+        file delete $src
+
+        if [string match "" $lines] {
+            # No error message, compilation succeeded.
+            set et_gthreads 1
+        } else {
+            verbose "check_v3_target_gthreads: compilation failed" 2
+        }
+    }
+    verbose "check_v3_target_gthreads: $et_gthreads" 2
+    return $et_gthreads
 }