]> pd.if.org Git - pdclib/blobdiff - platform/example/functions/time/clock.c
POSIX interfacing time retrieval
[pdclib] / platform / example / functions / time / clock.c
similarity index 64%
rename from functions/time/time.c
rename to platform/example/functions/time/clock.c
index 4ef5180cf6aba918e291cf00330c03148e4544f2..825e040e9e62ffaad8585972f9b4df508918f35a 100644 (file)
@@ -1,4 +1,4 @@
-/* time( time_t * )
+/* clock( void )
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -8,8 +8,15 @@
 
 #ifndef REGTEST
 
-time_t time( time_t * timer )
+#include <sys/times.h>
+
+clock_t clock( void )
 {
+    struct tms buf;
+    if ( times( &buf ) != (clock_t)-1 )
+    {
+        return buf.tms_utime + buf.tms_stime;
+    }
     return -1;
 }