From f015798af92e59e3942ae4e8c42a67d0e61ad470 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 17 May 2019 20:19:03 +0200 Subject: [PATCH] LibC: Implement clock() and add CLOCKS_PER_SEC define. --- LibC/time.cpp | 8 ++++++++ LibC/time.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/LibC/time.cpp b/LibC/time.cpp index 59b699062f..30b6b296e6 100644 --- a/LibC/time.cpp +++ b/LibC/time.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -110,4 +111,11 @@ void tzset() ASSERT_NOT_REACHED(); } +clock_t clock() +{ + struct tms tms; + times(&tms); + return tms.tms_utime + tms.tms_stime; +} + } diff --git a/LibC/time.h b/LibC/time.h index 3e02730ead..29e5583512 100644 --- a/LibC/time.h +++ b/LibC/time.h @@ -32,7 +32,10 @@ time_t time(time_t*); char* ctime(const time_t*); void tzset(); char *asctime(const struct tm*); + +#define CLOCKS_PER_SEC 1000 clock_t clock(); + double difftime(time_t, time_t); size_t strftime(char* s, size_t max, const char* format, const struct tm*);