From bc1344dacf99b21e9b19f3b930c899123817f5ed Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 28 Sep 2016 20:24:10 +0200 Subject: [PATCH] Document clock(3) as obsolete. --- doc/obsolete-stuff | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/obsolete-stuff b/doc/obsolete-stuff index 028fdbe7..73a63a63 100644 --- a/doc/obsolete-stuff +++ b/doc/obsolete-stuff @@ -53,6 +53,20 @@ similarly poorly named flag O_CREAT that does what you need. Sortix currently implement this function for compatibility reasons. +clock +----- + +The clock() function suffers from overflow issues where it wraps around and the +caller has to handle that, meaning it's not suitable for measuring long +intervals. Converting a clock interval to seconds it also bothersome and +requires division by CLOCKS_PER_SEC. + +You should use clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) instead as it has no +overflow issues, provides nanosecond precision if available, and can be combined +with APIs such as Sortix's for convenient computing. + +Sortix currently implements this function for compatibility reasons. + ctime, ctime_r --------------