From ad0e8eb0a565a44fe9616354d4e7556c3df9ae76 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 3 Mar 2003 04:57:09 +0000 Subject: Update. 2003-03-02 Ulrich Drepper * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define _POSIX_MONOTONIC_CLOCK. * linuxthreads/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise. --- sysdeps/posix/clock_getres.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'sysdeps/posix') diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c index 8bf648f51f..91c57629ca 100644 --- a/sysdeps/posix/clock_getres.c +++ b/sysdeps/posix/clock_getres.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ #include -#if HP_TIMING_AVAIL +#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME /* Clock frequency of the processor. */ static long int nsec; #endif @@ -38,24 +38,33 @@ clock_getres (clockid_t clock_id, struct timespec *res) switch (clock_id) { - case CLOCK_REALTIME: - { - long int clk_tck = sysconf (_SC_CLK_TCK); - - if (__builtin_expect (clk_tck != -1, 1)) - { - /* This implementation assumes that the realtime clock has a - resolution higher than 1 second. This is the case for any - reasonable implementation. */ - res->tv_sec = 0; - res->tv_nsec = 1000000000 / clk_tck; +#define HANDLE_REALTIME \ + do { \ + long int clk_tck = sysconf (_SC_CLK_TCK); \ + \ + if (__builtin_expect (clk_tck != -1, 1)) \ + { \ + /* This implementation assumes that the realtime clock has a \ + resolution higher than 1 second. This is the case for any \ + reasonable implementation. */ \ + res->tv_sec = 0; \ + res->tv_nsec = 1000000000 / clk_tck; \ + \ + retval = 0; \ + } \ + } while (0) + +#ifdef SYSDEP_GETRES + SYSDEP_GETRES; +#endif - retval = 0; - } - } +#ifndef HANDLED_REALTIME + case CLOCK_REALTIME: + HANDLE_REALTIME; break; +#endif /* handled REALTIME */ -#if HP_TIMING_AVAIL +#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME case CLOCK_PROCESS_CPUTIME_ID: case CLOCK_THREAD_CPUTIME_ID: { -- cgit 1.4.1