summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/system_clock.c
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2011-04-15 07:21:19 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2011-04-15 07:21:19 +0300
commit2aadeae27f225b6b0624a534de16106fb1d2a546 (patch)
treef5a7917eb1d48a5794fc9f24a57e3d55139f7573 /libgfortran/intrinsics/system_clock.c
parentf54d331e46f11ac7b5876a22b30ba52e69985a48 (diff)
downloadgcc-2aadeae27f225b6b0624a534de16106fb1d2a546.tar.gz
PR 47571 Fix bootstrap regression on alpha-dec-osf
From-SVN: r172469
Diffstat (limited to 'libgfortran/intrinsics/system_clock.c')
-rw-r--r--libgfortran/intrinsics/system_clock.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libgfortran/intrinsics/system_clock.c b/libgfortran/intrinsics/system_clock.c
index 3a44dd9666b..f4bac0777b3 100644
--- a/libgfortran/intrinsics/system_clock.c
+++ b/libgfortran/intrinsics/system_clock.c
@@ -29,14 +29,16 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "time_1.h"
-#ifdef HAVE_CLOCK_GETTIME
+
/* POSIX states that CLOCK_REALTIME must be present if clock_gettime
is available, others are optional. */
+#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_GETTIME_LIBRT)
#ifdef CLOCK_MONOTONIC
#define GF_CLOCK_MONOTONIC CLOCK_MONOTONIC
#else
#define GF_CLOCK_MONOTONIC CLOCK_REALTIME
#endif
+#endif
/* Weakref trickery for clock_gettime(). On Glibc, clock_gettime()
requires us to link in librt, which also pulls in libpthread. In
@@ -50,15 +52,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define GTHREAD_USE_WEAK 1
#endif
-#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
+#if SUPPORTS_WEAK && GTHREAD_USE_WEAK && defined(HAVE_CLOCK_GETTIME_LIBRT)
static int weak_gettime (clockid_t, struct timespec *)
__attribute__((__weakref__("clock_gettime")));
-#else
-static inline int weak_gettime (clockid_t clk_id, struct timespec *res)
-{
- return clock_gettime (clk_id, res);
-}
-#endif
#endif
@@ -84,6 +80,13 @@ gf_gettime_mono (time_t * secs, long * nanosecs)
{
int err;
#ifdef HAVE_CLOCK_GETTIME
+ struct timespec ts;
+ err = clock_gettime (GF_CLOCK_MONOTONIC, &ts);
+ *secs = ts.tv_sec;
+ *nanosecs = ts.tv_nsec;
+ return err;
+#else
+#if defined(HAVE_CLOCK_GETTIME_LIBRT) && SUPPORTS_WEAK && GTHREAD_USE_WEAK
if (weak_gettime)
{
struct timespec ts;
@@ -96,6 +99,7 @@ gf_gettime_mono (time_t * secs, long * nanosecs)
err = gf_gettime (secs, nanosecs);
*nanosecs *= 1000;
return err;
+#endif
}
extern void system_clock_4 (GFC_INTEGER_4 *, GFC_INTEGER_4 *, GFC_INTEGER_4 *);