summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xarch/arm/bits/alltypes.h.sh2
-rwxr-xr-xarch/i386/bits/alltypes.h.sh2
-rwxr-xr-xarch/microblaze/bits/alltypes.h.sh2
-rwxr-xr-xarch/mips/bits/alltypes.h.sh2
-rwxr-xr-xarch/powerpc/bits/alltypes.h.sh2
-rw-r--r--src/time/clock.c17
6 files changed, 15 insertions, 12 deletions
diff --git a/arch/arm/bits/alltypes.h.sh b/arch/arm/bits/alltypes.h.sh
index c1db1a0c..62e0327c 100755
--- a/arch/arm/bits/alltypes.h.sh
+++ b/arch/arm/bits/alltypes.h.sh
@@ -104,7 +104,7 @@ TYPEDEF unsigned long long fsfilcnt_t;
TYPEDEF void * timer_t;
TYPEDEF int clockid_t;
-TYPEDEF unsigned long clock_t;
+TYPEDEF long clock_t;
TYPEDEF struct { unsigned long __bits[128/sizeof(long)]; } sigset_t;
TYPEDEF struct __siginfo siginfo_t;
diff --git a/arch/i386/bits/alltypes.h.sh b/arch/i386/bits/alltypes.h.sh
index aec73731..76c50ec1 100755
--- a/arch/i386/bits/alltypes.h.sh
+++ b/arch/i386/bits/alltypes.h.sh
@@ -117,7 +117,7 @@ TYPEDEF unsigned long long fsfilcnt_t;
TYPEDEF void * timer_t;
TYPEDEF int clockid_t;
-TYPEDEF unsigned long clock_t;
+TYPEDEF long clock_t;
TYPEDEF struct { unsigned long __bits[128/sizeof(long)]; } sigset_t;
TYPEDEF struct __siginfo siginfo_t;
diff --git a/arch/microblaze/bits/alltypes.h.sh b/arch/microblaze/bits/alltypes.h.sh
index 23f12d8e..268321a1 100755
--- a/arch/microblaze/bits/alltypes.h.sh
+++ b/arch/microblaze/bits/alltypes.h.sh
@@ -104,7 +104,7 @@ TYPEDEF unsigned long long fsfilcnt_t;
TYPEDEF void * timer_t;
TYPEDEF int clockid_t;
-TYPEDEF unsigned long clock_t;
+TYPEDEF long clock_t;
TYPEDEF struct { unsigned long __bits[128/sizeof(long)]; } sigset_t;
TYPEDEF struct __siginfo siginfo_t;
diff --git a/arch/mips/bits/alltypes.h.sh b/arch/mips/bits/alltypes.h.sh
index 23f12d8e..268321a1 100755
--- a/arch/mips/bits/alltypes.h.sh
+++ b/arch/mips/bits/alltypes.h.sh
@@ -104,7 +104,7 @@ TYPEDEF unsigned long long fsfilcnt_t;
TYPEDEF void * timer_t;
TYPEDEF int clockid_t;
-TYPEDEF unsigned long clock_t;
+TYPEDEF long clock_t;
TYPEDEF struct { unsigned long __bits[128/sizeof(long)]; } sigset_t;
TYPEDEF struct __siginfo siginfo_t;
diff --git a/arch/powerpc/bits/alltypes.h.sh b/arch/powerpc/bits/alltypes.h.sh
index 7d3cdc36..5fe05e27 100755
--- a/arch/powerpc/bits/alltypes.h.sh
+++ b/arch/powerpc/bits/alltypes.h.sh
@@ -104,7 +104,7 @@ TYPEDEF unsigned long long fsfilcnt_t;
TYPEDEF void * timer_t;
TYPEDEF int clockid_t;
-TYPEDEF unsigned long clock_t;
+TYPEDEF long clock_t;
TYPEDEF struct { unsigned long __bits[128/sizeof(long)]; } sigset_t;
TYPEDEF struct __siginfo siginfo_t;
diff --git a/src/time/clock.c b/src/time/clock.c
index 78403af3..c348e398 100644
--- a/src/time/clock.c
+++ b/src/time/clock.c
@@ -1,15 +1,18 @@
#include <time.h>
-#include <sys/times.h>
-#include "syscall.h"
+#include <limits.h>
int __clock_gettime(clockid_t, struct timespec *);
clock_t clock()
{
struct timespec ts;
- struct tms tms;
- if (!__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
- return ts.tv_sec*1000000 + ts.tv_nsec/1000;
- __syscall(SYS_times, &tms);
- return (tms.tms_utime + tms.tms_stime)*10000;
+
+ if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
+ return -1;
+
+ if (ts.tv_sec > LONG_MAX/1000000
+ || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
+ return -1;
+
+ return ts.tv_sec*1000000 + ts.tv_nsec/1000;
}