From 5153d879c9cca60bd6630e5e8aa2cbf2abd1ac38 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Mon, 16 May 2011 13:55:17 +0000 Subject: =?UTF-8?q?2011-05-16=09Ralf=20Cors=C3=A9pius=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * posix/Makefile.am: Add posixtime.h. * posix/src/clockgetres.c, posix/src/clockgettime.c, posix/src/clocksettime.c: Use CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID. Include posix/src/posixtime.h. * posix/src/posixtime.h: New. --- cpukit/posix/Makefile.am | 1 + cpukit/posix/src/clockgetres.c | 6 ++++-- cpukit/posix/src/clockgettime.c | 6 ++++-- cpukit/posix/src/posixtime.h | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 cpukit/posix/src/posixtime.h (limited to 'cpukit') diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index 34e1cfa0ab..2eac9a921e 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -16,6 +16,7 @@ libposix_a_SOURCES = # Some POSIX functions that are nice to always have libposix_a_SOURCES += src/nanosleep.c src/clockgettime.c src/clocksettime.c \ src/clockgetres.c src/sysconf.c +libposix_a_SOURCES += src/posixtime.h include_rtems_posixdir = $(includedir)/rtems/posix diff --git a/cpukit/posix/src/clockgetres.c b/cpukit/posix/src/clockgetres.c index 7507bee614..3c3e76f38f 100644 --- a/cpukit/posix/src/clockgetres.c +++ b/cpukit/posix/src/clockgetres.c @@ -28,6 +28,8 @@ #include +#include "posixtime.h" + /*PAGE * * 14.2.1 Clocks, P1003.1b-1993, p. 263 @@ -48,8 +50,8 @@ int clock_getres( */ case CLOCK_REALTIME: - case CLOCK_PROCESS_CPUTIME: - case CLOCK_THREAD_CPUTIME: + case CLOCK_PROCESS_CPUTIME_ID: + case CLOCK_THREAD_CPUTIME_ID: if ( res ) { res->tv_sec = rtems_configuration_get_microseconds_per_tick() / TOD_MICROSECONDS_PER_SECOND; diff --git a/cpukit/posix/src/clockgettime.c b/cpukit/posix/src/clockgettime.c index 852ac8e039..5b0b6eebeb 100644 --- a/cpukit/posix/src/clockgettime.c +++ b/cpukit/posix/src/clockgettime.c @@ -23,6 +23,8 @@ #include +#include "posixtime.h" + /*PAGE * * 14.2.1 Clocks, P1003.1b-1993, p. 263 @@ -48,14 +50,14 @@ int clock_gettime( #endif #ifdef _POSIX_CPUTIME - if ( clock_id == CLOCK_PROCESS_CPUTIME ) { + if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) { _TOD_Get_uptime_as_timespec( tp ); return 0; } #endif #ifdef _POSIX_THREAD_CPUTIME - if ( clock_id == CLOCK_THREAD_CPUTIME ) + if ( clock_id == CLOCK_THREAD_CPUTIME_ID ) rtems_set_errno_and_return_minus_one( ENOSYS ); #endif diff --git a/cpukit/posix/src/posixtime.h b/cpukit/posix/src/posixtime.h new file mode 100644 index 0000000000..bc28d60684 --- /dev/null +++ b/cpukit/posix/src/posixtime.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011. + * Ralf Corsépius, Ulm/Germany. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +/* + * Adapt RTEMS to newlibs with broken + * CLOCK_PROCESS_CPUTIME_ID/CLOCK_PROCESS_CPUTIME + * CLOCK_THREAD_CPUTIME_ID/CLOCK_THREAD_CPUTIME + */ + +#ifndef _SRC_POSIX_POSIXTIME_H +#define _SRC_POSIX_POSIXTIME_H + +#include + +#ifdef RTEMS_NEWLIB +/* Older newlibs bogusly used CLOCK_PROCESS_CPUTIME + instead of CLOCK_PROCESS_CPUTIME_ID */ +#ifndef CLOCK_PROCESS_CPUTIME_ID +#define CLOCK_PROCESS_CPUTIME_ID CLOCK_PROCESS_CPUTIME +#endif +/* Older newlibs bogusly used CLOCK_THREAD_CPUTIME + instead of CLOCK_PROCESS_CPUTIME_ID */ +#ifndef CLOCK_THREAD_CPUTIME_ID +#define CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME +#endif +#endif + +#endif -- cgit v1.2.3