2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: getClockTime.c,v 1.4 1999/05/03 13:22:29 sof Exp $
6 * getClockTime Runtime Support
10 #define NON_POSIX_SOURCE /* gettimeofday */
18 # ifdef HAVE_SYS_TIMERS_H
20 # include <sys/timers.h>
24 # ifdef HAVE_GETTIMEOFDAY
26 # ifdef HAVE_SYS_TIME_H
27 # include <sys/time.h>
41 #include <sys/types.h>
42 #include <sys/timeb.h>
46 getClockTime(StgByteArray sec, StgByteArray nsec)
53 ((unsigned int *)sec)[0] = (unsigned int)t.time;
54 ((unsigned int *)nsec)[0] = (unsigned int)t.millitm * 1000;
56 #elif defined(HAVE_GETCLOCK)
59 if (getclock(TIMEOFDAY, &tp) != 0) {
64 ((unsigned long int *)sec)[0] = tp.tv_sec;
65 ((unsigned long int *)nsec)[0] = tp.tv_nsec;
67 #elif defined(HAVE_GETTIMEOFDAY)
70 if (gettimeofday(&tp, NULL) != 0) {
75 ((unsigned long int *)sec)[0] = tp.tv_sec;
76 ((unsigned long int *)nsec)[0] = tp.tv_usec * 1000;
80 if ((t = time(NULL)) == (time_t) -1) {
85 ((unsigned long int *)sec)[0] = t;
86 ((unsigned long int *)nsec)[0] = 0;
92 prim_getClockTime(StgByteArray sec, StgByteArray nsec)
99 ((unsigned long int *)sec)[0] = t.time;
100 ((unsigned long int *)nsec)[0] = t.millitm * 1000;
102 #elif defined(HAVE_GETCLOCK)
105 if (getclock(TIMEOFDAY, &tp) != 0) {
110 ((StgInt64*)sec)[0] = tp.tv_sec;
111 ((StgInt64*)nsec)[0] = tp.tv_nsec;
113 #elif defined(HAVE_GETTIMEOFDAY)
116 if (gettimeofday(&tp, NULL) != 0) {
121 ((StgInt64*)sec)[0] = tp.tv_sec;
122 ((StgInt64*)nsec)[0] = tp.tv_usec * 1000;
126 if ((t = time(NULL)) == (time_t) -1) {
131 ((StgInt64*)sec)[0] = t;
132 ((StgInt64*)nsec)[0] = 0;