]> pd.if.org Git - pdclib/blob - platform/example/functions/time/clock.c
POSIX interfacing time retrieval
[pdclib] / platform / example / functions / time / clock.c
1 /* clock( void )
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #include <time.h>
8
9 #ifndef REGTEST
10
11 #include <sys/times.h>
12
13 clock_t clock( void )
14 {
15     struct tms buf;
16     if ( times( &buf ) != (clock_t)-1 )
17     {
18         return buf.tms_utime + buf.tms_stime;
19     }
20     return -1;
21 }
22
23 #endif
24
25 #ifdef TEST
26
27 #include "_PDCLIB_test.h"
28
29 int main( void )
30 {
31     TESTCASE( NO_TESTDRIVER );
32     return TEST_RESULTS;
33 }
34
35 #endif