From: brarcher Date: Tue, 1 Oct 2013 22:21:08 +0000 (+0000) Subject: If clocks are not defined, set to (hopefully) invalid value X-Git-Tag: 0.10.0~395 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8aea7f052b5b9e77ed128bcfa5781fc77f42a25;p=check If clocks are not defined, set to (hopefully) invalid value Likely, if clock_gettime() is implemented on a system, the first valid clock will be set to '0'. If not all clock are defined, by setting our fake definitions to '0', we may accidental use a valid clock when we did not mean to. Setting the clocks to '-1' in hopes to avoid this. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@819 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/lib/libcompat.h b/lib/libcompat.h index 0848f67..57c43ab 100644 --- a/lib/libcompat.h +++ b/lib/libcompat.h @@ -123,12 +123,17 @@ int unsetenv (const char *name); * be available. These should define which type of clock * clock_gettime() should use. We define it here if it is * not defined simply so the reimplementation can ignore it. + * + * We set the values of these clocks to some (hopefully) + * invalid value, to avoid the case where we define a + * clock with a valid value, and unintentionally use + * an actual good clock by accident. */ #ifndef CLOCK_MONOTONIC -#define CLOCK_MONOTONIC 0 +#define CLOCK_MONOTONIC -1 #endif #ifndef CLOCK_REALTIME -#define CLOCK_REALTIME 0 +#define CLOCK_REALTIME -1 #endif #ifndef HAVE_LIBRT