From 1861f7cfbf7d3a2bf1c7746dc2c95b09fa351891 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 7 Jan 2021 01:18:08 -0500 Subject: [PATCH] sim: cris: fix C tests with newer toolchains Make sure we include unistd.h for getpid prototypes to fix build warnings/errors with newer compilers & C libraries. Doing that for close in openpf highlights these were using the wrong function -- need to use fclose on FILE*, not close. These tests pass again with a cris-elf toolchain. --- sim/testsuite/sim/cris/ChangeLog | 8 ++++++++ sim/testsuite/sim/cris/c/kill2.c | 2 ++ sim/testsuite/sim/cris/c/openpf1.c | 2 +- sim/testsuite/sim/cris/c/openpf2.c | 2 +- sim/testsuite/sim/cris/c/pipe1.c | 1 + sim/testsuite/sim/cris/c/sched1.c | 1 + sim/testsuite/sim/cris/c/sched2.c | 1 + sim/testsuite/sim/cris/c/sched3.c | 1 + sim/testsuite/sim/cris/c/sched4.c | 1 + sim/testsuite/sim/cris/c/sig5.c | 2 ++ sim/testsuite/sim/cris/c/sig8.c | 2 ++ 11 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sim/testsuite/sim/cris/ChangeLog b/sim/testsuite/sim/cris/ChangeLog index 76dcec50ea8..641ad7ed976 100644 --- a/sim/testsuite/sim/cris/ChangeLog +++ b/sim/testsuite/sim/cris/ChangeLog @@ -1,3 +1,11 @@ +2021-01-07 Mike Frysinger + + * kill2.c: Include unistd.h. + * pipe1.c, sched1.c, sched2.c, sched3.c, sched4.c, sig5.c, + sig8.c: Likewise. + * openpf1.c (main): Change close to fclose. + * openpf2.c: Likewise. + 2016-01-04 Mike Frysinger * asm/opterr1.ms: Update expected output. diff --git a/sim/testsuite/sim/cris/c/kill2.c b/sim/testsuite/sim/cris/c/kill2.c index 6b064e782a9..0a79db0567a 100644 --- a/sim/testsuite/sim/cris/c/kill2.c +++ b/sim/testsuite/sim/cris/c/kill2.c @@ -7,6 +7,8 @@ #include #include #include +#include + int main (void) { diff --git a/sim/testsuite/sim/cris/c/openpf1.c b/sim/testsuite/sim/cris/c/openpf1.c index 1d71e0bddb0..e0d8e5c9140 100644 --- a/sim/testsuite/sim/cris/c/openpf1.c +++ b/sim/testsuite/sim/cris/c/openpf1.c @@ -27,7 +27,7 @@ int main (int argc, char *argv[]) f = fopen (fnam, "rb"); if (f == NULL) abort (); - close (f); + fclose (f); /* Cover another execution path. */ if (fopen ("/nonexistent", "rb") != NULL diff --git a/sim/testsuite/sim/cris/c/openpf2.c b/sim/testsuite/sim/cris/c/openpf2.c index fe7c265a272..50337b110d4 100644 --- a/sim/testsuite/sim/cris/c/openpf2.c +++ b/sim/testsuite/sim/cris/c/openpf2.c @@ -10,7 +10,7 @@ int main (int argc, char *argv[]) FILE *f = fopen ("openpf2.c", "rb"); if (f == NULL) abort (); - close (f); + fclose (f); printf ("pass\n"); return 0; } diff --git a/sim/testsuite/sim/cris/c/pipe1.c b/sim/testsuite/sim/cris/c/pipe1.c index ddc4285e02f..735974b6cfa 100644 --- a/sim/testsuite/sim/cris/c/pipe1.c +++ b/sim/testsuite/sim/cris/c/pipe1.c @@ -11,6 +11,7 @@ #include #include #include +#include int main (void) { diff --git a/sim/testsuite/sim/cris/c/sched1.c b/sim/testsuite/sim/cris/c/sched1.c index 04dae4bd5db..1b778f4a401 100644 --- a/sim/testsuite/sim/cris/c/sched1.c +++ b/sim/testsuite/sim/cris/c/sched1.c @@ -5,6 +5,7 @@ #include #include #include +#include int main (void) { diff --git a/sim/testsuite/sim/cris/c/sched2.c b/sim/testsuite/sim/cris/c/sched2.c index 5371c787f77..f40a19a8085 100644 --- a/sim/testsuite/sim/cris/c/sched2.c +++ b/sim/testsuite/sim/cris/c/sched2.c @@ -6,6 +6,7 @@ #include #include #include +#include int main (void) { diff --git a/sim/testsuite/sim/cris/c/sched3.c b/sim/testsuite/sim/cris/c/sched3.c index 601e7e00eea..2909a4b6c52 100644 --- a/sim/testsuite/sim/cris/c/sched3.c +++ b/sim/testsuite/sim/cris/c/sched3.c @@ -6,6 +6,7 @@ #include #include #include +#include int main (void) { diff --git a/sim/testsuite/sim/cris/c/sched4.c b/sim/testsuite/sim/cris/c/sched4.c index 57f761fe535..df372f217e8 100644 --- a/sim/testsuite/sim/cris/c/sched4.c +++ b/sim/testsuite/sim/cris/c/sched4.c @@ -6,6 +6,7 @@ #include #include #include +#include int main (void) { diff --git a/sim/testsuite/sim/cris/c/sig5.c b/sim/testsuite/sim/cris/c/sig5.c index 2748aa52b53..f80da2b6990 100644 --- a/sim/testsuite/sim/cris/c/sig5.c +++ b/sim/testsuite/sim/cris/c/sig5.c @@ -8,6 +8,8 @@ #include #include #include +#include + int main (void) { kill (getpid (), SIGBUS); diff --git a/sim/testsuite/sim/cris/c/sig8.c b/sim/testsuite/sim/cris/c/sig8.c index 889892f7f36..ea2d7f5dc11 100644 --- a/sim/testsuite/sim/cris/c/sig8.c +++ b/sim/testsuite/sim/cris/c/sig8.c @@ -10,6 +10,8 @@ #include #include #include +#include + int main (void) { signal (SIGALRM, SIG_IGN); -- 2.30.2