aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2014-12-17 15:28:01 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2014-12-17 15:28:01 +0100
commit4461db2bd92973b83bbd74c8f2eec16d702cffed (patch)
treeb02c8d646631662a5309238c13306a7d1f3e72db /test
parent20c70573181f81c99ea4e8797615dac8308a9b18 (diff)
parentc1daedb244d1f7586c12749642b0d78ae910e60a (diff)
downloadcompcert-4461db2bd92973b83bbd74c8f2eec16d702cffed.tar.gz
compcert-4461db2bd92973b83bbd74c8f2eec16d702cffed.zip
Merge branch 'master' into pure-makefiles
Diffstat (limited to 'test')
-rw-r--r--test/regression/Makefile3
-rw-r--r--test/regression/Results/decl11
-rw-r--r--test/regression/decl1.c21
-rw-r--r--test/spass/clock.c26
-rw-r--r--test/spass/clock.h4
5 files changed, 43 insertions, 12 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile
index f4f96233..5c601211 100644
--- a/test/regression/Makefile
+++ b/test/regression/Makefile
@@ -16,7 +16,8 @@ TESTS=int32 int64 floats floats-basics \
expr1 expr6 funptr2 initializers initializers2 initializers3 \
volatile1 volatile2 volatile3 \
funct3 expr5 struct7 struct8 struct11 casts1 casts2 char1 \
- sizeof1 sizeof2 binops bool for1 switch switch2 compound
+ sizeof1 sizeof2 binops bool for1 switch switch2 compound \
+ decl1
# Can run, but only in compiled mode, and have reference output in Results
diff --git a/test/regression/Results/decl1 b/test/regression/Results/decl1
new file mode 100644
index 00000000..fa8248b0
--- /dev/null
+++ b/test/regression/Results/decl1
@@ -0,0 +1 @@
+Result is 2
diff --git a/test/regression/decl1.c b/test/regression/decl1.c
new file mode 100644
index 00000000..6049b4af
--- /dev/null
+++ b/test/regression/decl1.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+/* Local function declarations */
+
+int f (int p)
+{
+ p = p + 1;
+ return p;
+}
+
+int main (int argc, char **argv)
+{
+ int (*p)(int);
+ int f();
+ int i;
+
+ p = f;
+ i = (*p)(1);
+ printf("Result is %d\n", i);
+ return 0;
+}
diff --git a/test/spass/clock.c b/test/spass/clock.c
index 7106669a..d9472338 100644
--- a/test/spass/clock.c
+++ b/test/spass/clock.c
@@ -104,7 +104,7 @@ void clock_StartCounter(CLOCK_CLOCKS ClockCounter)
**********************************************************/
{
#ifndef CLOCK_NO_TIMING
- ftime(&(clock_Counters[ClockCounter]));
+ gettimeofday(&(clock_Counters[ClockCounter]), NULL);
#endif
}
@@ -121,7 +121,7 @@ void clock_StopPassedTime(CLOCK_CLOCKS ClockCounter)
{
#ifndef CLOCK_NO_TIMING
CLOCK_TMS newtime;
- ftime(&newtime);
+ gettimeofday(&newtime, NULL);
clock_Akku[ClockCounter] = clock_GetSeconds(ClockCounter);
#endif
}
@@ -139,7 +139,7 @@ void clock_StopAddPassedTime(CLOCK_CLOCKS ClockCounter)
{
#ifndef CLOCK_NO_TIMING
CLOCK_TMS newtime;
- ftime(&newtime);
+ gettimeofday(&newtime, NULL);
clock_Akku[ClockCounter] += clock_GetSeconds(ClockCounter);
#endif
}
@@ -157,13 +157,21 @@ float clock_GetSeconds(CLOCK_CLOCKS ClockCounter)
{
#ifndef CLOCK_NO_TIMING
CLOCK_TMS newtime;
- ftime(&newtime);
- return ((float) (newtime.time - clock_Counters[ClockCounter].time)
- + (((newtime.millitm - clock_Counters[ClockCounter].millitm))
- /(float)1000));
-#else
+ time_t seconds_passed;
+ long microseconds_passed;
+
+ gettimeofday(&newtime, NULL);
+
+ seconds_passed = newtime.tv_sec - clock_Counters[ClockCounter].tv_sec;
+ microseconds_passed = newtime.tv_usec - clock_Counters[ClockCounter].tv_usec;
+
+ return ((float) seconds_passed
+ + (microseconds_passed /(float)1000000));
+
+#else /* CLOCK_NO_TIMING */
return 0;
-#endif
+#endif /* ! CLOCK_NO_TIMING */
+
}
#ifdef WIN
diff --git a/test/spass/clock.h b/test/spass/clock.h
index 6e675742..80f6c003 100644
--- a/test/spass/clock.h
+++ b/test/spass/clock.h
@@ -49,7 +49,7 @@
#include "misc.h"
#include <sys/types.h>
-#include <sys/timeb.h>
+#include <sys/time.h>
typedef enum {
clock_BACKTRACK,
@@ -61,7 +61,7 @@ typedef enum {
clock_TYPESIZE
} CLOCK_CLOCKS;
-typedef struct timeb CLOCK_TMS;
+typedef struct timeval CLOCK_TMS;
void clock_Init(void);
void clock_InitCounter(CLOCK_CLOCKS);