X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2Ftime%2Fclock.c;fp=platform%2Fexample%2Ffunctions%2Ftime%2Fclock.c;h=825e040e9e62ffaad8585972f9b4df508918f35a;hb=686f7a4b4a7e154990831d13e0431190c60a335d;hp=0000000000000000000000000000000000000000;hpb=8481519337ff8acf46db6b91fb9484777fd89609;p=pdclib diff --git a/platform/example/functions/time/clock.c b/platform/example/functions/time/clock.c new file mode 100644 index 0000000..825e040 --- /dev/null +++ b/platform/example/functions/time/clock.c @@ -0,0 +1,35 @@ +/* clock( void ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +#include + +clock_t clock( void ) +{ + struct tms buf; + if ( times( &buf ) != (clock_t)-1 ) + { + return buf.tms_utime + buf.tms_stime; + } + return -1; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + TESTCASE( NO_TESTDRIVER ); + return TEST_RESULTS; +} + +#endif