(SCM_TIME_UNITS_PER_SECOND): Use sysconf(_SC_CLK_TCK) when
authorKevin Ryde <user42@zip.com.au>
Mon, 6 Sep 2004 01:29:04 +0000 (01:29 +0000)
committerKevin Ryde <user42@zip.com.au>
Mon, 6 Sep 2004 01:29:04 +0000 (01:29 +0000)
available.  This also gets around CLK_TCK being absent when
_GNU_SOURCE and _POSIX_C_SOURCE are defined in stime.c.

libguile/stime.h

index 19f1ffb..87d89f4 100644 (file)
 
 #include "libguile/__scm.h"
 
+#include <unistd.h>  /* for sysconf */
+
 \f
 
-/* This should be figured out by autoconf.  */
+/* This should be figured out by autoconf.
+
+   sysconf(_SC_CLK_TCK) is best, since it's the actual running kernel, not
+   some compile-time CLK_TCK.  On glibc 2.3.2 CLK_TCK (when defined) is in
+   fact sysconf(_SC_CLK_TCK) anyway.
+
+   CLK_TCK is obsolete in POSIX.  In glibc 2.3.2 it's defined by default,
+   but if you define _GNU_SOURCE or _POSIX_C_SOURCE to get other features
+   then it goes away.  */
+
+#if ! defined(SCM_TIME_UNITS_PER_SECOND) && defined(_SC_CLK_TCK)
+#  define SCM_TIME_UNITS_PER_SECOND ((int) sysconf (_SC_CLK_TCK))
+#endif
 #if ! defined(SCM_TIME_UNITS_PER_SECOND) && defined(CLK_TCK)
 #  define SCM_TIME_UNITS_PER_SECOND ((int) CLK_TCK)
 #endif