- Defining CLOCKS_PER_SEC = 100, instead of 60.
This define is here for legacy reasons, use sysconf(_SC_CLK_TCK) to
retrieve the actual number of clock tick per second of the system in
new code.
- Moving stime prototype to minix/sysutil.h
Change-Id: I76a73cd53ac2361845f2917f62af4125adfc615d
int cycles = 0;
struct tms pre_buf, post_buf;
int status, pid;
-#if _VMD_EXT
- struct timeval start_time, end_time;
-#else
struct tms dummy;
int start_time, end_time;
-#endif
u64_t start_tsc, end_tsc, spent_tsc;
clock_t real_time;
int c;
name = argv[0];
/* Get real time at start of run. */
-#if _VMD_EXT
- (void) sysutime(UTIME_TIMEOFDAY, &start_time);
-#else
start_time = times(&dummy);
-#endif
read_tsc_64(&start_tsc);
/* Fork off child. */
} while (wait(&status) != pid);
read_tsc_64(&end_tsc);
spent_tsc = end_tsc - start_tsc;
-#if _VMD_EXT
- (void) sysutime(UTIME_TIMEOFDAY, &end_time);
- real_time = (end_time.tv_sec - start_time.tv_sec) * CLOCKS_PER_SEC
- + (end_time.tv_usec - start_time.tv_usec) * CLOCKS_PER_SEC / 1000000;
-#else
end_time = times(&dummy);
real_time = (end_time - start_time);
-#endif
if ((status & 0377) != 0) std_err("Command terminated abnormally.\n");
times(&post_buf);
* - synchronizing to the host system time;
* - providing an interface for HGCM communication with the host system.
*/
+#include <minix/sysutil.h>
#include <minix/drivers.h>
#include <minix/driver.h>
#include <minix/optset.h>
void get_randomness(struct k_randomness *, int);
u32_t sqrt_approx(u32_t);
+int stime(time_t *_top);
+
#define asynsend(ep, msg) asynsend3(ep, msg, 0)
int asynsend3(endpoint_t ep, message *msg, int flags);
int asyn_geterror(endpoint_t *dst, message *msg, int *err);
#undef _BSD_TIMER_T_
#endif
-#ifdef __minix
-#define CLOCKS_PER_SEC 60
-#else
#define CLOCKS_PER_SEC 100
-#endif
struct tm {
int tm_sec; /* seconds after the minute [0-61] */
#endif /* _NETBSD_SOURCE */
-#ifdef __minix
-int stime(time_t *_top);
-#endif /* __minix */
-
__END_DECLS
#endif /* !_TIME_H_ */
#define DO_TIMEOUT 7
#define DO_DELTA 0.5
#define MAX_ERROR 5
-#define DELTA(x,y) (x.tv_sec - y.tv_sec) * CLOCKS_PER_SEC \
- + (x.tv_usec - y.tv_usec) * CLOCKS_PER_SEC / 1000000
+#define DELTA(x,y) (x.tv_sec - y.tv_sec) * system_hz \
+ + (x.tv_usec - y.tv_usec) * system_hz / 1000000
int got_signal = 0;
int fd_ap[2];
+int system_hz;
+
static void catch_signal(int sig_no) {
got_signal = 1;
}
float diff;
delta = DELTA(end, start); /* delta is in ticks */
- seconds = (int) (delta / CLOCKS_PER_SEC);
- hundreths = (int) (delta * 100 / CLOCKS_PER_SEC) - (seconds * 100);
+ seconds = (int) (delta / system_hz);
+ hundreths = (int) (delta * 100 / system_hz) - (seconds * 100);
diff = seconds + (hundreths / 100.0);
diff -= compare;
int main(int argc, char **argv) {
int forkres;
+ /* Retrieve actual system frequency. */
+ system_hz = sysconf(_SC_CLK_TCK);
/* Get subtest number */
if(argc != 2) {
printf("Usage: %s subtest_no\n", argv[0]);