For an arm-none-eabi toolchain, at least built with newlib, the fork()
function exists, but it returns failure. The implementation is part of
libnosys.a and is there only to allow linking (runtime failure).
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_fork_runtime): New function to
check that target has a working fork() implementation.
* lib/target-supports-dg.exp (dg-require-fork): When test is
"run", then call check_fork_runtime, else check_fork_available.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
# If this target does not have fork, skip this test.
proc dg-require-fork { args } {
- if { ![check_fork_available] } {
- upvar dg-do-what dg-do-what
- set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ upvar dg-do-what dg-do-what
+
+ set doaction [lindex ${dg-do-what} 0]
+ if { $doaction == "run" } {
+ if { ![check_fork_runtime] } {
+ set dg-do-what [list $doaction "N" "P"]
+ }
+ } elseif { ![check_fork_available] } {
+ set dg-do-what [list $doaction "N" "P"]
}
}
return [check_function_available "fork"]
}
+# Returns true iff "fork" is working on the target system.
+
+proc check_fork_runtime {} {
+ if { ![check_fork_available] } {
+ return 0
+ }
+
+ return [check_runtime fork_runtime {
+ #include <unistd.h>
+ #include <stdlib.h>
+
+ int main()
+ {
+ pid_t p = fork();
+ if (p < 0)
+ abort();
+ return 0;
+ }
+ }]
+}
+
# Returns true iff "mkfifo" is available on the target system.
proc check_mkfifo_available {} {