2011-03-18 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / libstdc++-v3 / testsuite / lib / libstdc++.exp
blobac67ebbb51fba6b7b12bb85173e1ad7e620167d9
1 # libstdc++ "tool init file" for DejaGNU
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 # 2009, 2010, 2011
5 # Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
22 # Define callbacks and load other libraries. This file is loaded relatively
23 # early, and before any other file we write ourselves. "load_lib" will
24 # find anything in the DejaGNU installation tree, or in our lib directory.
25 # "load_gcc_lib" will search the core compiler's .exp collection instead.
27 # The naming rule is that dg.exp looks for "tool-" and runtest.exp looks
28 # for "tool_" when finding callbacks. Utility routines we define for
29 # our callbacks begin with "v3-".
31 # libstdc++_* callbacks we don't define, but could:
32 # ..._option_help prints additional --help output
33 # ..._option_proc (--foo) process our own options
34 # ..._init (normal.exp) called once per test file
35 # ..._finish bracketing function for libstdc++_init
36 # ...-dg-prune removing output text, see top of system dg.exp
38 # Useful hook: if ${hostname}_init exists, it will be called, almost
39 # the last thing before testing begins. This can be defined in, e.g.,
40 # ~/.dejagnurc or $DEJAGNU.
42 proc load_gcc_lib { filename } {
43 global srcdir
44 load_file $srcdir/../../gcc/testsuite/lib/$filename
47 # system routines
48 load_lib dg.exp
49 load_lib libgloss.exp
50 # compiler routines, then ours
51 load_gcc_lib target-supports.exp
52 load_gcc_lib target-supports-dg.exp
53 load_lib prune.exp
54 load_lib dg-options.exp
55 load_gcc_lib scanasm.exp
56 load_gcc_lib target-libpath.exp
57 load_gcc_lib timeout.exp
58 load_gcc_lib timeout-dg.exp
59 load_gcc_lib wrapper.exp
61 # Useful for debugging. Pass the name of a variable and the verbosity
62 # threshold (number of -v's on the command line).
63 proc v3track { var n } {
64 upvar $var val
65 verbose "++ $var is $val" $n
68 # Called by v3-init below. "Static" to this file.
69 proc v3-copy-files {srcfiles} {
70 foreach f $srcfiles {
71 if { [catch { set symlink [file readlink $f] } x] } then {
72 remote_download target $f
73 } else {
74 if { [regexp "^/" "$symlink"] } then {
75 remote_download target $symlink
76 } else {
77 set dirname [file dirname $f]
78 remote_download target $dirname/$symlink
84 # Called once, during runtest.exp setup.
85 proc libstdc++_init { testfile } {
86 global env
87 global v3-sharedlib v3-libgomp
88 global srcdir blddir objdir tool_root_dir
89 global cc cxx cxxflags cxxpchflags cxxldflags
90 global includes
91 global gluefile wrap_flags
92 global ld_library_path
93 global target_triplet
94 global flags_file
95 global tool_timeout
96 global DEFAULT_CXXFLAGS
97 global STATIC_LIBCXXFLAGS
99 # We set LC_ALL and LANG to C so that we get the same error
100 # messages as expected.
101 setenv LC_ALL C
102 setenv LANG C
104 # Many hosts now default to a non-ASCII C locale, however, so
105 # they can set a charset encoding here if they need.
106 if { [ishost "*-*-cygwin*"] } {
107 setenv LC_ALL C.ASCII
108 setenv LANG C.ASCII
111 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
112 set flags_file "${blddir}/scripts/testsuite_flags"
113 set shlib_ext [get_shlib_extension]
114 v3track flags_file 2
116 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
117 # Use this variable if the behavior
118 # 1) only applies to libstdc++ testing
119 # 2) might need to be negated
120 # In particular, some tests have to be run without precompiled
121 # headers, or without assertions.
123 if ![info exists DEFAULT_CXXFLAGS] then {
124 set DEFAULT_CXXFLAGS ""
125 # Host specific goo here.
126 if { [string match "powerpc-*-darwin*" $target_triplet] } {
127 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
130 v3track DEFAULT_CXXFLAGS 2
132 # By default, we assume we want to run program images.
133 global dg-do-what-default
134 set dg-do-what-default run
136 # Copy any required data files.
137 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
138 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
140 set ld_library_path_tmp ""
142 # Locate libgcc.a so we don't need to account for different values of
143 # SHLIB_EXT on different platforms
144 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
145 if {$gccdir != ""} {
146 set gccdir [file dirname $gccdir]
147 append ld_library_path_tmp ":${gccdir}"
149 v3track gccdir 3
151 # Locate libgomp. This is only required for parallel mode.
152 set v3-libgomp 0
153 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
154 if {$libgompdir != ""} {
155 set v3-libgomp 1
156 set libgompdir [file dirname $libgompdir]
157 append ld_library_path_tmp ":${libgompdir}"
158 verbose -log "libgomp support detected"
160 v3track libgompdir 3
162 # Locate libstdc++ shared library. (ie libstdc++.so.)
163 set v3-sharedlib 0
164 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
165 if {$sharedlibdir != ""} {
166 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
167 set v3-sharedlib 1
168 verbose -log "shared library support detected"
171 v3track v3-sharedlib 3
173 set STATIC_LIBCXXFLAGS ""
174 set staticlibdir [lookfor_file $blddir src/.libs/libstdc++.a]
175 if {$staticlibdir != ""} {
176 set staticlibdir [file dirname $staticlibdir]
177 # Some targets use libstdc++.a%s in their specs, so they need a
178 # -B option for uninstalled testing.
179 set STATIC_LIBCXXFLAGS " -B${staticlibdir} "
182 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
183 if {$gccdir != ""} {
184 set compiler ${gccdir}/g++
185 set ld_library_path ${ld_library_path_tmp}
186 append ld_library_path ":${blddir}/src/.libs"
188 if { [is_remote host] == 0 && [which $compiler] != 0 } {
189 foreach i "[exec $compiler --print-multi-lib]" {
190 set mldir ""
191 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
192 set mldir [string trimright $mldir "\;@"]
193 if { "$mldir" == "." } {
194 continue
196 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
197 append ld_library_path ":${gccdir}/${mldir}"
202 set_ld_library_path_env_vars
203 if [info exists env(LD_LIBRARY_PATH)] {
204 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
206 } else {
207 set compiler [transform "g++"]
210 # Set the default timeout for v3 tests.
211 set tool_timeout 600
213 # Default settings.
214 set cxx [transform "g++"]
215 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
216 set cxxpchflags ""
217 set cxxldflags ""
218 set cc [transform "gcc"]
219 # Locate testsuite_hooks.h and other testsuite headers.
220 set includes "-I${srcdir}/util"
221 # Adapt the defaults for special circumstances.
222 if [is_remote host] {
223 # A remote host does not, in general, have access to the
224 # $srcdir so we copy the testsuite headers into the current
225 # directory, and then add that to the search path.
226 foreach src [glob "${srcdir}/util/*.h" \
227 "${srcdir}/util/*.cc" \
228 "${srcdir}/util/*.tcc" \
229 "${srcdir}/util/*.hpp" \
230 "${srcdir}/util/*/*.h" \
231 "${srcdir}/util/*/*.cc" \
232 "${srcdir}/util/*/*.tcc" \
233 "${srcdir}/util/*/*.hpp" \
234 "${srcdir}/util/*/*/*.h" \
235 "${srcdir}/util/*/*/*.cc" \
236 "${srcdir}/util/*/*/*.tcc" \
237 "${srcdir}/util/*/*/*.hpp" \
238 "${srcdir}/util/*/*/*/*.h" \
239 "${srcdir}/util/*/*/*/*.cc" \
240 "${srcdir}/util/*/*/*/*.tcc" \
241 "${srcdir}/util/*/*/*/*.hpp" \
242 "${srcdir}/util/*/*/*/*/*.h" \
243 "${srcdir}/util/*/*/*/*/*.cc" \
244 "${srcdir}/util/*/*/*/*/*.tcc" \
245 "${srcdir}/util/*/*/*/*/*.hpp" ] {
246 # Remove everything up to "util/..."
247 set dst [string range $src [string length "${srcdir}/"] end]
248 # Create the directory containing the file.
249 set dir [file dirname $dst]
250 remote_exec host "mkdir" [list "-p" "$dir"]
251 # Download the file.
252 set result [remote_download host $src $dst]
253 if { $result == "" } {
254 verbose -log "Unable to download ${srcdir}/${src} to host."
255 return "untested"
258 set includes "-Iutil"
259 } elseif { [file exists $flags_file] } {
260 # If we find a testsuite_flags file, we're testing in the build dir.
261 set cxx [exec sh $flags_file --build-cxx]
262 set cxxflags [exec sh $flags_file --cxxflags]
263 set cxxpchflags [exec sh $flags_file --cxxpchflags]
264 set cxxldflags [exec sh $flags_file --cxxldflags]
265 set cc [exec sh $flags_file --build-cc]
266 set includes [exec sh $flags_file --build-includes]
268 append cxxflags " "
269 append cxxflags [getenv CXXFLAGS]
270 v3track cxxflags 2
272 # Always use MO files built by this test harness.
273 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
274 set ccflags "$cxxflags -DLOCALEDIR=\".\""
276 # If a PCH file is available, use it. We must delay performing
277 # this check until $cxx and such have been initialized because we
278 # perform a test compilation. (Ideally, gcc --print-file-name would
279 # list PCH files, but it does not.)
280 if { $cxxpchflags != "" } {
281 set src "config[pid].cc"
282 set f [open $src "w"]
283 puts $f "int main () {}"
284 close $f
286 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
287 # useful as then the requested variant of the pre-build PCH
288 # files could be tested to see if it works.
289 set lines [v3_target_compile $src "config[pid].o" object \
290 "additional_flags=-include additional_flags=bits/stdc++.h"]
291 if { $lines != "" } {
292 verbose -log "Requested PCH file: $cxxpchflags"
293 verbose -log "is not working, and will not be used."
294 set cxxpchflags ""
296 file delete $src
298 v3track cxxpchflags 2
300 global PCH_CXXFLAGS
301 if ![info exists PCH_CXXFLAGS] then {
302 set PCH_CXXFLAGS $cxxpchflags
303 v3track PCH_CXXFLAGS 2
306 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
309 # Callback for cleanup routines.
310 proc libstdc++_exit { } {
311 global gluefile;
313 if [info exists gluefile] {
314 file_on_build delete $gluefile;
315 unset gluefile;
319 # Callback from system dg-test.
320 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
321 # Set up the compiler flags, based on what we're going to do.
322 switch $do_what {
323 "preprocess" {
324 set compile_type "preprocess"
325 set output_file "[file rootname [file tail $prog]].i"
327 "compile" {
328 set compile_type "assembly"
329 set output_file "[file rootname [file tail $prog]].s"
331 "assemble" {
332 set compile_type "object"
333 set output_file "[file rootname [file tail $prog]].o"
335 "link" {
336 set compile_type "executable"
337 set output_file "./[file rootname [file tail $prog]].exe"
339 "run" {
340 set compile_type "executable"
341 # FIXME: "./" is to cope with "." not being in $PATH.
342 # Should this be handled elsewhere?
343 # YES.
344 set output_file "./[file rootname [file tail $prog]].exe"
345 # This is the only place where we care if an executable was
346 # created or not. If it was, dg.exp will try to run it.
347 catch { remote_file build delete $output_file }
349 default {
350 perror "$do_what: not a valid dg-do keyword"
351 return ""
355 # Short-circut a bunch of complicated goo here for the special
356 # case of compiling a test file as a "C" file, not as C++. Why? So
357 # -nostdc++ doesn't trip us up. So all the extra object files
358 # don't trip us up. So automatically linking in libstdc++ doesn't
359 # happen. So CXXFLAGS don't error.
360 set select_compile "v3_target_compile"
361 set options ""
362 if { $extra_tool_flags != "" } {
363 verbose -log "extra_tool_flags are:"
364 verbose -log $extra_tool_flags
365 if { [string first "-x c" $extra_tool_flags ] != -1 } {
366 verbose -log "compiling and executing as C, not C++"
367 set edit_tool_flags $extra_tool_flags
368 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
369 lappend options "additional_flags=$edit_tool_flags"
370 set select_compile "v3_target_compile_as_c"
371 } else {
372 lappend options "additional_flags=$extra_tool_flags"
376 # There is a libstdc++_compile made for us by default (via the tool-
377 # and-target file), but the defaults are lacking in goodness.
378 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
380 return [list $comp_output $output_file]
383 # Override the DejaGnu dg-test in order to clear flags after a test, as
384 # is done for compiler tests in gcc-dg.exp.
386 if { [info procs saved-dg-test] == [list] } {
387 rename dg-test saved-dg-test
389 proc dg-test { args } {
390 global additional_prunes
391 global errorInfo
393 if { [ catch { eval saved-dg-test $args } errmsg ] } {
394 set saved_info $errorInfo
395 set additional_prunes ""
396 unset_timeout_vars
397 error $errmsg $saved_info
399 set additional_prunes ""
400 unset_timeout_vars
404 # True if the library supports wchar_t.
405 set v3-wchar_t 0
407 # True if the library supports threads.
408 set v3-threads 0
410 # True if the library supports symbol versioning.
411 set v3-symver 0
413 # Called from libstdc++-dg-test above. Calls back into system's
414 # target_compile to actually do the work.
415 proc v3_target_compile { source dest type options } {
416 global gluefile
417 global wrap_flags
418 global cxx
419 global cxxflags
420 global cxxldflags
421 global includes
422 global STATIC_LIBCXXFLAGS
424 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
425 lappend options "libs=${gluefile}"
426 lappend options "ldflags=${wrap_flags}"
429 set cxx_final $cxx
430 set cxxlibglossflags [libgloss_link_flags]
431 set cxx_final [concat $cxx_final $cxxlibglossflags]
432 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
433 set cxx_final [concat $cxx_final $cxxflags]
434 set cxx_final [concat $cxx_final $includes]
436 # Flag setting based on type argument.
437 if { $type == "executable" } {
438 # Link the support objects into executables.
439 lappend options "additional_flags=./libtestc++.a $cxxldflags"
440 } else {
441 if { $type == "sharedlib" } {
442 # Don't link in anything.
443 set type "executable"
447 lappend options "compiler=$cxx_final"
448 lappend options "timeout=[timeout_value]"
450 return [target_compile $source $dest $type $options]
454 # Called from libstdc++-dg-test above, but only for "C" compilation.
455 # Calls back into system's target_compile to actually do the work.
456 proc v3_target_compile_as_c { source dest type options } {
457 global gluefile
458 global wrap_flags
459 global includes
460 global flags_file
461 global blddir
462 global cc
463 global cxxflags
464 global STATIC_LIBCXXFLAGS
466 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
467 lappend options "libs=${gluefile}"
468 lappend options "ldflags=${wrap_flags}"
471 set tname [target_info name]
472 set cc_final $cc
473 set cxxlibglossflags [libgloss_link_flags]
474 set cc_final [concat $cc_final $cxxlibglossflags]
475 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
476 set cc_final [concat $cc_final $cxxflags]
477 set cc_final [concat $cc_final $includes]
478 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
480 # This is needed for "C" tests, as this type of test may need the
481 # C++ includes. And if we're not testing in the build directory,
482 # the includes variable is not likely to include the necessary
483 # info.
484 if { ![file exists $flags_file] } {
485 # ??? We need a --print-include-dirs option to GCC, so that
486 # we can avoid these hacks. The heuristics here will not
487 # work with non-standard --with-includedir= options.
488 set version [remote_exec host ${cc} -dumpversion]
489 # Remove the trailing newline from the output.
490 set version [string trimright [lindex $version 1]]
491 set machine [remote_exec host ${cc} -dumpmachine]
492 set machine [string trimright [lindex $machine 1]]
493 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
494 set comp_base_dir [lindex $comp_base_dir 1]
495 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
496 # For a cross compiler, the header files will be located in a
497 # machine-specific subdirectory.
498 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
499 set crosstarget "${crossbase}/${machine}"
500 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
501 # For a native compiler, the header files will be located at
502 # the top level.
503 set includesbase "${comp_base_dir}/include/c++/${version}"
504 set includestarget "${includesbase}/${machine}"
505 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
507 set libdir "-L${comp_base_dir}/lib"
508 } else {
509 set libdir "-L${blddir}/libsupc++/.libs"
510 set libdir [concat $libdir "-L${blddir}/src/.libs"]
513 set cc_final [concat $cc_final "$libdir"]
515 lappend options "compiler=$cc_final"
516 lappend options "timeout=[timeout_value]"
518 return [target_compile $source $dest $type $options]
521 # Build the support objects linked in with the libstdc++ tests. In
522 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
523 proc v3-build_support { } {
524 global env
525 global srcdir
526 global v3-wchar_t
527 global v3-threads
528 global v3-symver
529 global v3-sharedlib
531 # Figure out whether or not the library supports certain features.
532 set v3-wchar_t 0
533 set v3-threads 0
534 set v3-symver 0
535 set libtest_objs ""
537 set config_src "config.cc"
538 set config_out "config.ii"
539 set f [open $config_src "w"]
540 puts $f "#include <bits/c++config.h>"
541 puts $f "#include <bits/gthr.h>"
542 close $f
543 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
544 set file [open $config_out r]
545 set preprocessed [read $file]
546 close $file
547 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
548 verbose -log "wchar_t support detected"
549 set v3-wchar_t 1
551 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
552 verbose -log "symbol versioning support detected"
553 set v3-symver 1
555 if { [string first "__GTHREADS" $preprocessed] != -1 } {
556 verbose -log "thread support detected"
557 set v3-threads 1
560 # Try to build the MO files that are used by some of the locale
561 # tests. If we can't build them, that's OK; it just means that
562 # those tests will fail.
563 foreach lang [list "fr" "de"] {
564 catch {
565 file mkdir "$lang/LC_MESSAGES"
566 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
567 if [is_remote host] {
568 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
569 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
574 # Build the support objects.
575 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
576 testsuite_character.cc testsuite_hooks.cc \
577 io/verified_cmd_line_input.cc \
578 io/prog_bar.cc performance/time/elapsed_timer.cc ]
579 foreach f $source_files {
580 set obj [file rootname $f].o
581 set object_file [file tail $obj]
582 # Compile with "-w" so that warnings issued by the compiler
583 # do not prevent compilation.
584 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
585 [list "incdir=$srcdir" "additional_flags=-w"]]
586 != "" } {
587 error "could not compile $f"
589 append libtest_objs "$object_file "
592 # Collect into libtestc++.a
593 # Delete libtestc++.a first. Mixed 32 and 64-bit archives cannot be
594 # linked on IRIX 6.
595 # Use same procedure as gcc-dg.exp (remove-build-file).
596 if [is_remote host] {
597 # Ensure the host knows the file is gone by deleting there
598 # first.
599 remote_file host delete "./libtestc++.a"
601 remote_file build delete "./libtestc++.a"
602 if [info exists env(AR)] {
603 set ar $env(AR)
604 } else {
605 set ar [transform "ar"]
607 set arargs "-rc ./libtestc++.a ${libtest_objs}"
608 verbose -log "$ar $arargs"
609 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
610 verbose "link result is $result"
611 if { $result == 0 } {
612 if [info exists env(RANLIB)] {
613 set ranlib $env(RANLIB)
614 } else {
615 set ranlib [transform "ranlib"]
617 set ranlibargs "./libtestc++.a"
618 verbose -log "$ranlib $ranlibargs"
619 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
620 if { $result != 0 } {
621 error "could not link libtestc++.a"
625 # Build any shared objects needed for regression testing.
626 if { ${v3-sharedlib} == 1 } {
627 set source_files [list testsuite_shared.cc]
628 foreach f $source_files {
629 set object_file [file rootname $f].so
630 # Compile with "-w" so that warnings issued by the compiler
631 # do not prevent compilation.
632 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
633 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
634 != "" } {
635 error "could not compile $f"
641 proc check_v3_target_fileio { } {
642 global et_fileio_saved
643 global et_fileio_target_name
644 global tool
645 global srcdir
647 if { ![info exists et_fileio_target_name] } {
648 set et_fileio_target_name ""
651 # If the target has changed since we set the cached value, clear it.
652 set current_target [current_target_name]
653 if { $current_target != $et_fileio_target_name } {
654 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
655 set et_fileio_target_name $current_target
656 if [info exists et_fileio_saved] {
657 verbose "check_v3_target_fileio: removing cached result" 2
658 unset et_fileio_saved
662 if [info exists et_fileio_saved] {
663 verbose "check_v3_target_fileio: using cached result" 2
664 } else {
665 set et_fileio_saved 0
667 # Set up, compile, and execute a C++ test program that tries to use
668 # the file functions
669 set src fileio[pid].cc
670 set exe fileio[pid].x
671 set testfile "cin_unget-1.txt"
672 v3-copy-files "$srcdir/data/$testfile"
674 set f [open $src "w"]
675 puts $f "#include <sys/types.h>"
676 puts $f "#include <sys/stat.h>"
677 puts $f "#include <fcntl.h>"
678 puts $f "#include <unistd.h>"
679 puts $f "#include <errno.h>"
680 puts $f "#include <string.h>"
681 puts $f "using namespace std;"
682 puts $f "int main ()"
683 puts $f "{"
684 puts $f " int fd = open (\"$testfile\", O_RDONLY);"
685 puts $f " int ret = 0;"
686 puts $f " char buf\[10\];"
687 puts $f " if (fd == -1)"
688 puts $f " ret = 1;"
689 puts $f " else"
690 puts $f " {"
691 puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
692 puts $f " ret = 1;"
693 puts $f " errno = 0;"
694 puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
695 puts $f " || read (fd, buf, 4) != 4"
696 puts $f " || memcmp (buf, \"1234\", 4) != 0"
697 puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
698 puts $f " || read (fd, buf, 2) != 2"
699 puts $f " || memcmp (buf, \"34\", 2) != 0)"
700 puts $f " ret = 1;"
701 puts $f " close (fd);"
702 puts $f " }"
703 puts $f " return ret;"
704 puts $f "}"
705 close $f
707 set lines [v3_target_compile $src $exe executable ""]
708 file delete $src
710 if [string match "" $lines] {
711 # No error message, compilation succeeded.
712 set result [${tool}_load "./$exe" "" ""]
713 set status [lindex $result 0]
714 remote_file build delete $exe
716 verbose "check_v3_target_fileio: status is <$status>" 2
718 if { $status == "pass" } {
719 set et_fileio_saved 1
721 } else {
722 verbose "check_v3_target_fileio: compilation failed" 2
725 return $et_fileio_saved
728 # Eventually we want C90/C99 determining and switching from this.
729 proc check_v3_target_c_std { } {
730 global et_c_std_saved
731 global et_c_std_target_name
732 global tool
734 if { ![info exists et_c_std_target_name] } {
735 set et_c_std_target_name ""
738 # If the target has changed since we set the cached value, clear it.
739 set current_target [current_target_name]
740 if { $current_target != $et_c_std_target_name } {
741 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
742 set et_c_std_target_name $current_target
743 if [info exists et_c_std_saved] {
744 verbose "check_v3_target_c_std: removing cached result" 2
745 unset et_c_std_saved
749 if [info exists et_c_std_saved] {
750 verbose "check_v3_target_c_std: using cached result" 2
751 } else {
752 set et_c_std_saved 0
754 # Set up, compile, and execute a C++ test program that tries to use
755 # C99 functionality.
756 # For math bits, could use check_effective_target_c99_math.
757 set src fileio[pid].cc
758 set exe fileio[pid].x
760 set f [open $src "w"]
761 puts $f "#include <tr1/cmath>"
762 puts $f "#include <cstdlib>"
763 puts $f "int main ()"
764 puts $f "{"
765 puts $f " float f = 45.55;"
766 puts $f " int i = std::tr1::isnan(f);"
767 puts $f " "
768 puts $f " using std::wctomb;"
769 puts $f " return i;"
770 puts $f "}"
771 close $f
773 set lines [v3_target_compile $src $exe executable ""]
774 file delete $src
776 if [string match "" $lines] {
777 # No error message, compilation succeeded.
778 set result [${tool}_load "./$exe" "" ""]
779 set status [lindex $result 0]
780 remote_file build delete $exe
782 verbose "check_v3_target_c_std: status is <$status>" 2
784 if { $status == "pass" } {
785 set et_c_std_saved 1
787 } else {
788 verbose "check_v3_target_c_std: compilation failed" 2
791 return $et_c_std_saved
794 proc check_v3_target_sharedlib { } {
795 global v3-sharedlib
796 return ${v3-sharedlib}
799 proc check_v3_target_time { } {
800 global et_time_saved
801 global et_time_target_name
802 global tool
804 if { ![info exists et_time_target_name] } {
805 set et_time_target_name ""
808 # If the target has changed since we set the cached value, clear it.
809 set current_target [current_target_name]
810 if { $current_target != $et_time_target_name } {
811 verbose "check_v3_target_time: `$et_time_target_name'" 2
812 set et_time_target_name $current_target
813 if [info exists et_time_saved] {
814 verbose "check_v3_target_time: removing cached result" 2
815 unset et_time_saved
819 if [info exists et_time_saved] {
820 verbose "check_v3_target_time: using cached result" 2
821 } else {
822 set et_time_saved 0
824 # Set up and compile a C++ test program that tries to use
825 # the time function
826 set src time[pid].cc
827 set exe time[pid].x
829 set f [open $src "w"]
830 puts $f "#include <time.h>"
831 puts $f "using namespace std;"
832 puts $f "int main ()"
833 puts $f "{"
834 puts $f " time (0);"
835 puts $f "}"
836 close $f
838 set lines [v3_target_compile $src $exe executable ""]
839 file delete $src
841 if [string match "" $lines] {
842 # No error message, compilation succeeded.
843 verbose "check_v3_target_time: compilation succeeded" 2
844 remote_file build delete $exe
845 set et_time_saved 1
846 } else {
847 verbose "check_v3_target_time: compilation failed" 2
850 return $et_time_saved
853 proc check_v3_target_namedlocale { args } {
854 global et_namedlocale
855 global tool
857 set et_namedlocale 0
859 # Set up, compile, and execute a C++ test program that tries to use
860 # the required named locale.
861 set exe nlocale[pid].x
863 if ![file exists ./$exe] {
864 set src nlocale[pid].cc
866 set f [open $src "w"]
867 puts $f "#include <locale>"
868 puts $f "#include <cstdio>"
869 puts $f "using namespace std;"
870 puts $f "int main (int argc, char** argv)"
871 puts $f "{"
872 puts $f " try"
873 puts $f " {"
874 puts $f " locale(*(argv + 1));"
875 puts $f " return 0;"
876 puts $f " }"
877 puts $f " catch(...)"
878 puts $f " {"
879 puts $f " printf(\"locale '%s' not supported\\n\", *(argv + 1));"
880 puts $f " return 1;"
881 puts $f " }"
882 puts $f "}"
883 close $f
885 set lines [v3_target_compile $src $exe executable ""]
886 file delete $src
888 if ![string match "" $lines] {
889 verbose "check_v3_target_namedlocale: compilation failed" 2
890 return $et_namedlocale
892 # else No error message, compilation succeeded.
895 set result [${tool}_load "./$exe" "$args" ""]
896 set status [lindex $result 0]
898 verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
900 if { $status == "pass" } {
901 set et_namedlocale 1
903 return $et_namedlocale
906 proc check_v3_target_debug_mode { } {
907 global et_debug_mode
908 global tool
910 if { ![info exists et_debug_mode_target_name] } {
911 set et_debug_mode_target_name ""
914 # If the target has changed since we set the cached value, clear it.
915 set current_target [current_target_name]
916 if { $current_target != $et_debug_mode_target_name } {
917 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
918 set et_debug_mode_target_name $current_target
919 if [info exists et_debug_mode] {
920 verbose "check_v3_target_debug_mode: removing cached result" 2
921 unset et_debug_mode
925 if [info exists et_debug_mode] {
926 verbose "check_v3_target_debug_mode: using cached result" 2
927 } else {
928 set et_debug_mode 0
930 # Set up and compile a C++ test program that depends
931 # on debug mode activated.
932 set src debug_mode[pid].cc
933 set exe debug_mode[pid].exe
935 set f [open $src "w"]
936 puts $f "#ifndef _GLIBCXX_DEBUG"
937 puts $f "# error No debug mode"
938 puts $f "#endif"
939 puts $f "int main()"
940 puts $f "{ return 0; }"
941 close $f
943 set lines [v3_target_compile $src $exe executable ""]
944 file delete $src
946 if [string match "" $lines] {
947 # No error message, compilation succeeded.
948 remote_file build delete $exe
949 set et_debug_mode 1
952 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
953 return $et_debug_mode
956 proc check_v3_target_profile_mode { } {
957 global et_profile_mode
958 global tool
960 if { ![info exists et_profile_mode_target_name] } {
961 set et_profile_mode_target_name ""
964 # If the target has changed since we set the cached value, clear it.
965 set current_target [current_target_name]
966 if { $current_target != $et_profile_mode_target_name } {
967 verbose "check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
968 set et_profile_mode_target_name $current_target
969 if [info exists et_profile_mode] {
970 verbose "check_v3_target_profile_mode: removing cached result" 2
971 unset et_profile_mode
975 if [info exists et_profile_mode] {
976 verbose "check_v3_target_profile_mode: using cached result" 2
977 } else {
978 set et_profile_mode 0
980 # Set up and compile a C++ test program that depends
981 # on profile mode activated.
982 set src profile_mode[pid].cc
983 set exe profile_mode[pid].exe
985 set f [open $src "w"]
986 puts $f "#ifndef _GLIBCXX_PROFILE"
987 puts $f "# error No profile mode"
988 puts $f "#endif"
989 puts $f "int main()"
990 puts $f "{ return 0; }"
991 close $f
993 set lines [v3_target_compile $src $exe executable ""]
994 file delete $src
996 if [string match "" $lines] {
997 # No error message, compilation succeeded.
998 remote_file build delete $exe
999 set et_profile_mode 1
1002 verbose "check_v3_target_profile_mode: $et_profile_mode" 2
1003 return $et_profile_mode
1006 proc check_v3_target_normal_mode { } {
1007 global et_normal_mode
1008 global tool
1010 if { ![info exists et_normal_mode_target_name] } {
1011 set et_normal_mode_target_name ""
1014 # If the target has changed since we set the cached value, clear it.
1015 set current_target [current_target_name]
1016 if { $current_target != $et_normal_mode_target_name } {
1017 verbose "check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1018 set et_normal_mode_target_name $current_target
1019 if [info exists et_normal_mode] {
1020 verbose "check_v3_target_normal_mode: removing cached result" 2
1021 unset et_normal_mode
1025 if [info exists et_normal_mode] {
1026 verbose "check_v3_target_normal_mode: using cached result" 2
1027 } else {
1028 set et_normal_mode 0
1030 # Set up and compile a C++ test program that depends
1031 # on normal mode activated.
1032 set src normal_mode[pid].cc
1033 set exe normal_mode[pid].exe
1035 set f [open $src "w"]
1036 puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
1037 puts $f "# error No normal mode"
1038 puts $f "#endif"
1039 puts $f "int main()"
1040 puts $f "{ return 0; }"
1041 close $f
1043 set lines [v3_target_compile $src $exe executable ""]
1044 file delete $src
1046 if [string match "" $lines] {
1047 # No error message, compilation succeeded.
1048 set et_normal_mode 1
1051 verbose "check_v3_target_normal_mode: $et_normal_mode" 2
1052 return $et_normal_mode
1055 proc check_v3_target_parallel_mode { } {
1056 global cxxflags
1057 global v3-libgomp
1058 global et_parallel_mode
1060 global tool
1062 if { ![info exists et_parallel_mode_target_name] } {
1063 set et_parallel_mode_target_name ""
1066 # If the target has changed since we set the cached value, clear it.
1067 set current_target [current_target_name]
1068 if { $current_target != $et_parallel_mode_target_name } {
1069 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1070 set et_parallel_mode_target_name $current_target
1071 if [info exists et_parallel_mode] {
1072 verbose "check_v3_target_parallel_mode: removing cached result" 2
1073 unset et_parallel_mode
1077 if [info exists et_parallel_mode] {
1078 verbose "check_v3_target_parallel_mode: using cached result" 2
1079 } else {
1080 set et_parallel_mode 0
1082 # If 'make check-parallel' is running the test succeeds.
1083 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1084 set et_parallel_mode 1
1087 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1088 return $et_parallel_mode
1091 proc check_v3_target_cstdint { } {
1092 global cxxflags
1093 global DEFAULT_CXXFLAGS
1094 global et_cstdint
1096 global tool
1098 if { ![info exists et_cstdint_target_name] } {
1099 set et_cstdint_target_name ""
1102 # If the target has changed since we set the cached value, clear it.
1103 set current_target [current_target_name]
1104 if { $current_target != $et_cstdint_target_name } {
1105 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1106 set et_cstdint_target_name $current_target
1107 if [info exists et_cstdint] {
1108 verbose "check_v3_target_cstdint: removing cached result" 2
1109 unset et_cstdint
1113 if [info exists et_cstdint] {
1114 verbose "check_v3_target_cstdint: using cached result" 2
1115 } else {
1116 set et_cstdint 0
1118 # Set up and compile a C++0x test program that depends
1119 # on the C99 stdint facilities to be available.
1120 set src cstdint[pid].cc
1121 set exe cstdint[pid].exe
1123 set f [open $src "w"]
1124 puts $f "#include <tr1/cstdint>"
1125 puts $f "int main()"
1126 puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1"
1127 puts $f "{ return 0; }"
1128 puts $f "#endif"
1129 close $f
1131 set cxxflags_saved $cxxflags
1132 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1134 set lines [v3_target_compile $src $exe executable ""]
1135 set cxxflags $cxxflags_saved
1136 file delete $src
1138 if [string match "" $lines] {
1139 # No error message, compilation succeeded.
1140 set et_cstdint 1
1141 } else {
1142 verbose "check_v3_target_cstdint: compilation failed" 2
1145 verbose "check_v3_target_cstdint: $et_cstdint" 2
1146 return $et_cstdint
1149 proc check_v3_target_c99_math { } {
1150 global cxxflags
1151 global DEFAULT_CXXFLAGS
1152 global et_c99_math
1154 global tool
1156 if { ![info exists et_c99_math_target_name] } {
1157 set et_c99_math_target_name ""
1160 # If the target has changed since we set the cached value, clear it.
1161 set current_target [current_target_name]
1162 if { $current_target != $et_c99_math_target_name } {
1163 verbose "check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1164 set et_c99_math_target_name $current_target
1165 if [info exists et_c99_math] {
1166 verbose "check_v3_target_c99_math: removing cached result" 2
1167 unset et_c99_math
1171 if [info exists et_c99_math] {
1172 verbose "check_v3_target_c99_math: using cached result" 2
1173 } else {
1174 set et_c99_math 0
1176 # Set up and compile a C++0x test program that depends
1177 # on the C99 math facilities to be available.
1178 set src c99_math[pid].cc
1179 set exe c99_math[pid].exe
1181 set f [open $src "w"]
1182 puts $f "#include <tr1/cmath>"
1183 puts $f "int main()"
1184 puts $f "#ifdef _GLIBCXX_USE_C99_MATH_TR1"
1185 puts $f "{ return 0; }"
1186 puts $f "#endif"
1187 close $f
1189 set cxxflags_saved $cxxflags
1190 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1192 set lines [v3_target_compile $src $exe executable ""]
1193 set cxxflags $cxxflags_saved
1194 file delete $src
1196 if [string match "" $lines] {
1197 # No error message, compilation succeeded.
1198 set et_c99_math 1
1199 } else {
1200 verbose "check_v3_target_c99_math: compilation failed" 2
1203 verbose "check_v3_target_c99_math: $et_c99_math" 2
1204 return $et_c99_math
1207 proc check_v3_target_atomic_builtins { } {
1208 global cxxflags
1209 global DEFAULT_CXXFLAGS
1210 global et_atomic_builtins
1212 global tool
1214 if { ![info exists et_atomic_builtins_target_name] } {
1215 set et_atomic_builtins_target_name ""
1218 # If the target has changed since we set the cached value, clear it.
1219 set current_target [current_target_name]
1220 if { $current_target != $et_atomic_builtins_target_name } {
1221 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1222 set et_atomic_builtins_target_name $current_target
1223 if [info exists et_atomic_builtins] {
1224 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1225 unset et_atomic_builtins
1229 if [info exists et_atomic_builtins] {
1230 verbose "check_v3_target_atomic_builtins: using cached result" 2
1231 } else {
1232 set et_atomic_builtins 0
1234 # Set up and compile a C++0x test program that depends
1235 # on the atomic builtin facilities to be available.
1236 set src atomic_builtins[pid].cc
1237 set exe atomic_builtins[pid].exe
1239 set f [open $src "w"]
1240 puts $f "#include <bits/c++config.h>"
1241 puts $f "int main()"
1242 puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4"
1243 puts $f "{ return 0; }"
1244 puts $f "#endif"
1245 close $f
1247 set cxxflags_saved $cxxflags
1248 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1250 set lines [v3_target_compile $src $exe executable ""]
1251 set cxxflags $cxxflags_saved
1252 file delete $src
1254 if [string match "" $lines] {
1255 # No error message, compilation succeeded.
1256 set et_atomic_builtins 1
1257 } else {
1258 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1261 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1262 return $et_atomic_builtins
1265 proc check_v3_target_gthreads { } {
1266 global cxxflags
1267 global DEFAULT_CXXFLAGS
1268 global et_gthreads
1270 global tool
1272 if { ![info exists et_gthreads_target_name] } {
1273 set et_gthreads_target_name ""
1276 # If the target has changed since we set the cached value, clear it.
1277 set current_target [current_target_name]
1278 if { $current_target != $et_gthreads_target_name } {
1279 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1280 set et_gthreads_target_name $current_target
1281 if [info exists et_gthreads] {
1282 verbose "check_v3_target_gthreads: removing cached result" 2
1283 unset et_gthreads
1287 if [info exists et_gthreads] {
1288 verbose "check_v3_target_gthreads: using cached result" 2
1289 } else {
1290 set et_gthreads 0
1292 # Set up and compile a C++0x test program that depends
1293 # on the gthreads facilities to be available.
1294 set src gthreads[pid].cc
1295 set exe gthreads[pid].exe
1297 set f [open $src "w"]
1298 puts $f "#include <bits/c++config.h>"
1299 puts $f "int main()"
1300 puts $f "#ifdef _GLIBCXX_HAS_GTHREADS"
1301 puts $f "{ return 0; }"
1302 puts $f "#endif"
1303 close $f
1305 set cxxflags_saved $cxxflags
1306 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1308 set lines [v3_target_compile $src $exe executable ""]
1309 set cxxflags $cxxflags_saved
1310 file delete $src
1312 if [string match "" $lines] {
1313 # No error message, compilation succeeded.
1314 set et_gthreads 1
1315 } else {
1316 verbose "check_v3_target_gthreads: compilation failed" 2
1319 verbose "check_v3_target_gthreads: $et_gthreads" 2
1320 return $et_gthreads
1323 proc check_v3_target_nanosleep { } {
1324 global cxxflags
1325 global DEFAULT_CXXFLAGS
1326 global et_nanosleep
1328 global tool
1330 if { ![info exists et_nanosleep_target_name] } {
1331 set et_nanosleep_target_name ""
1334 # If the target has changed since we set the cached value, clear it.
1335 set current_target [current_target_name]
1336 if { $current_target != $et_nanosleep_target_name } {
1337 verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1338 set et_nanosleep_target_name $current_target
1339 if [info exists et_nanosleep] {
1340 verbose "check_v3_target_nanosleep: removing cached result" 2
1341 unset et_nanosleep
1345 if [info exists et_nanosleep] {
1346 verbose "check_v3_target_nanosleep: using cached result" 2
1347 } else {
1348 set et_nanosleep 0
1350 # Set up and compile a C++0x test program that depends
1351 # on the nanosleep facilities to be available.
1352 set src nanosleep[pid].cc
1353 set exe nanosleep[pid].exe
1355 set f [open $src "w"]
1356 puts $f "#include <bits/c++config.h>"
1357 puts $f "int main()"
1358 puts $f "#ifdef _GLIBCXX_USE_NANOSLEEP"
1359 puts $f "{ return 0; }"
1360 puts $f "#endif"
1361 close $f
1363 set cxxflags_saved $cxxflags
1364 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1366 set lines [v3_target_compile $src $exe executable ""]
1367 set cxxflags $cxxflags_saved
1368 file delete $src
1370 if [string match "" $lines] {
1371 # No error message, compilation succeeded.
1372 set et_nanosleep 1
1373 } else {
1374 verbose "check_v3_target_nanosleep: compilation failed" 2
1377 verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1378 return $et_nanosleep
1381 proc check_v3_target_sched_yield { } {
1382 global cxxflags
1383 global DEFAULT_CXXFLAGS
1384 global et_sched_yield
1386 global tool
1388 if { ![info exists et_sched_yield_target_name] } {
1389 set et_sched_yield_target_name ""
1392 # If the target has changed since we set the cached value, clear it.
1393 set current_target [current_target_name]
1394 if { $current_target != $et_sched_yield_target_name } {
1395 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1396 set et_sched_yield_target_name $current_target
1397 if [info exists et_sched_yield] {
1398 verbose "check_v3_target_sched_yield: removing cached result" 2
1399 unset et_sched_yield
1403 if [info exists et_sched_yield] {
1404 verbose "check_v3_target_sched_yield: using cached result" 2
1405 } else {
1406 set et_sched_yield 0
1408 # Set up and compile a C++0x test program that depends
1409 # on the sched_yield facility to be available.
1410 set src sched_yield[pid].cc
1411 set exe sched_yield[pid].exe
1413 set f [open $src "w"]
1414 puts $f "#include <bits/c++config.h>"
1415 puts $f "int main()"
1416 puts $f "#ifdef _GLIBCXX_USE_SCHED_YIELD"
1417 puts $f "{ return 0; }"
1418 puts $f "#endif"
1419 close $f
1421 set cxxflags_saved $cxxflags
1422 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1424 set lines [v3_target_compile $src $exe executable ""]
1425 set cxxflags $cxxflags_saved
1426 file delete $src
1428 if [string match "" $lines] {
1429 # No error message, compilation succeeded.
1430 set et_sched_yield 1
1431 } else {
1432 verbose "check_v3_target_sched_yield: compilation failed" 2
1435 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1436 return $et_sched_yield
1439 proc check_v3_target_string_conversions { } {
1440 global cxxflags
1441 global DEFAULT_CXXFLAGS
1442 global et_string_conversions
1444 global tool
1446 if { ![info exists et_string_conversions_target_name] } {
1447 set et_string_conversions_target_name ""
1450 # If the target has changed since we set the cached value, clear it.
1451 set current_target [current_target_name]
1452 if { $current_target != $et_string_conversions_target_name } {
1453 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1454 set et_string_conversions_target_name $current_target
1455 if [info exists et_string_conversions] {
1456 verbose "check_v3_target_string_conversions: removing cached result" 2
1457 unset et_string_conversions
1461 if [info exists et_string_conversions] {
1462 verbose "check_v3_target_string_conversions: using cached result" 2
1463 } else {
1464 set et_string_conversions 0
1466 # Set up and compile a C++0x test program that depends
1467 # on the string_conversions facilities to be available.
1468 set src string_conversions[pid].cc
1469 set exe string_conversions[pid].exe
1471 set f [open $src "w"]
1472 puts $f "#include <bits/c++config.h>"
1473 puts $f "int main()"
1474 puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1475 puts $f "{ return 0; }"
1476 puts $f "#endif"
1477 close $f
1479 set cxxflags_saved $cxxflags
1480 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1482 set lines [v3_target_compile $src $exe executable ""]
1483 set cxxflags $cxxflags_saved
1484 file delete $src
1486 if [string match "" $lines] {
1487 # No error message, compilation succeeded.
1488 set et_string_conversions 1
1489 } else {
1490 verbose "check_v3_target_string_conversions: compilation failed" 2
1493 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1494 return $et_string_conversions
1497 proc check_v3_target_swprintf { } {
1498 global cxxflags
1499 global DEFAULT_CXXFLAGS
1500 global et_swprintf
1502 global tool
1504 if { ![info exists et_swprintf_target_name] } {
1505 set et_swprintf_target_name ""
1508 # If the target has changed since we set the cached value, clear it.
1509 set current_target [current_target_name]
1510 if { $current_target != $et_swprintf_target_name } {
1511 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1512 set et_swprintf_target_name $current_target
1513 if [info exists et_swprintf] {
1514 verbose "check_v3_target_swprintf: removing cached result" 2
1515 unset et_swprintf
1519 if [info exists et_swprintf] {
1520 verbose "check_v3_target_swprintf: using cached result" 2
1521 } else {
1522 set et_swprintf 0
1524 # Set up and compile a C++0x test program that depends
1525 # on a standard swprintf function to be available.
1526 set src swprintf[pid].cc
1527 set exe swprintf[pid].exe
1529 set f [open $src "w"]
1530 puts $f "#include <bits/c++config.h>"
1531 puts $f "int main()"
1532 puts $f "#if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1533 puts $f "{ return 0; }"
1534 puts $f "#endif"
1535 close $f
1537 set cxxflags_saved $cxxflags
1538 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1540 set lines [v3_target_compile $src $exe executable ""]
1541 set cxxflags $cxxflags_saved
1542 file delete $src
1544 if [string match "" $lines] {
1545 # No error message, compilation succeeded.
1546 set et_swprintf 1
1547 } else {
1548 verbose "check_v3_target_swprintf: compilation failed" 2
1551 verbose "check_v3_target_swprintf: $et_swprintf" 2
1552 return $et_swprintf
1555 proc check_v3_target_binary_io { } {
1556 global cxxflags
1557 global DEFAULT_CXXFLAGS
1558 global et_binary_io
1560 global tool
1562 if { ![info exists et_binary_io_target_name] } {
1563 set et_binary_io_target_name ""
1566 # If the target has changed since we set the cached value, clear it.
1567 set current_target [current_target_name]
1568 if { $current_target != $et_binary_io_target_name } {
1569 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1570 set et_binary_io_target_name $current_target
1571 if [info exists et_binary_io] {
1572 verbose "check_v3_target_binary_io: removing cached result" 2
1573 unset et_binary_io
1577 if [info exists et_binary_io] {
1578 verbose "check_v3_target_binary_io: using cached result" 2
1579 } else {
1580 set et_binary_io 0
1582 # Set up and compile a C++0x test program that depends
1583 # on text and binary I/O being the same.
1584 set src binary_io[pid].cc
1585 set exe binary_io[pid].exe
1587 set f [open $src "w"]
1588 puts $f "#include <bits/c++config.h>"
1589 puts $f "int main()"
1590 puts $f "#if !defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1591 puts $f "{ return 0; }"
1592 puts $f "#endif"
1593 close $f
1595 set cxxflags_saved $cxxflags
1596 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1598 set lines [v3_target_compile $src $exe executable ""]
1599 set cxxflags $cxxflags_saved
1600 file delete $src
1602 if [string match "" $lines] {
1603 # No error message, compilation succeeded.
1604 set et_binary_io 1
1605 } else {
1606 verbose "check_v3_target_binary_io: compilation failed" 2
1609 verbose "check_v3_target_binary_io: $et_binary_io" 2
1610 return $et_binary_io
1613 set additional_prunes ""