From eddf43dd7642d70891417e85bb3291a4bd63ee09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 6 Oct 2005 17:33:10 +0000 Subject: [PATCH] Added missing clock() function. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14329 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/time/Jamfile | 1 + src/system/libroot/posix/time/clock.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/system/libroot/posix/time/clock.c diff --git a/src/system/libroot/posix/time/Jamfile b/src/system/libroot/posix/time/Jamfile index 4614429b6d..8d93807b8c 100644 --- a/src/system/libroot/posix/time/Jamfile +++ b/src/system/libroot/posix/time/Jamfile @@ -7,6 +7,7 @@ UsePrivateHeaders [ FDirName libroot time ] ; KernelMergeObject posix_time.o : asctime.c + clock.c ctime.c difftime.c localtime.c diff --git a/src/system/libroot/posix/time/clock.c b/src/system/libroot/posix/time/clock.c new file mode 100644 index 0000000000..fc16c9c463 --- /dev/null +++ b/src/system/libroot/posix/time/clock.c @@ -0,0 +1,22 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + + +clock_t +clock(void) +{ + thread_info info; + get_thread_info(find_thread(NULL), &info); + + return (clock_t)((info.kernel_time + info.user_time) / 1000); + // unlike the XSI specs say, CLOCKS_PER_SEC is 1000 and not 1000000 in + // BeOS - that means we have to convert the bigtime_t to CLOCKS_PER_SEC + // before we return it +} +