2011-05-19 Ralf Corsépius <ralf.corsepius@rtems.org>

* 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.
This commit is contained in:
Ralf Corsepius
2011-05-19 15:32:44 +00:00
parent d1e85c41ea
commit 3af5699804
6 changed files with 58 additions and 6 deletions

View File

@@ -1,3 +1,12 @@
2011-05-19 Ralf Corsépius <ralf.corsepius@rtems.org>
* 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.
2011-05-17 Chris Johns <chrisj@rtems.org> 2011-05-17 Chris Johns <chrisj@rtems.org>
PR 1774/filesystem PR 1774/filesystem

View File

@@ -17,6 +17,7 @@ libposix_a_SOURCES =
libposix_a_SOURCES += src/sleep.c src/usleep.c libposix_a_SOURCES += src/sleep.c src/usleep.c
libposix_a_SOURCES += src/nanosleep.c src/clockgettime.c src/clocksettime.c \ libposix_a_SOURCES += src/nanosleep.c src/clockgettime.c src/clocksettime.c \
src/clockgetres.c src/sysconf.c src/clockgetres.c src/sysconf.c
libposix_a_SOURCES += src/posixtime.h
include_rtems_posixdir = $(includedir)/rtems/posix include_rtems_posixdir = $(includedir)/rtems/posix

View File

@@ -28,6 +28,8 @@
#include <rtems/seterr.h> #include <rtems/seterr.h>
#include "posixtime.h"
/*PAGE /*PAGE
* *
* 14.2.1 Clocks, P1003.1b-1993, p. 263 * 14.2.1 Clocks, P1003.1b-1993, p. 263
@@ -48,8 +50,8 @@ int clock_getres(
*/ */
case CLOCK_REALTIME: case CLOCK_REALTIME:
case CLOCK_PROCESS_CPUTIME: case CLOCK_PROCESS_CPUTIME_ID:
case CLOCK_THREAD_CPUTIME: case CLOCK_THREAD_CPUTIME_ID:
if ( res ) { if ( res ) {
res->tv_sec = rtems_configuration_get_microseconds_per_tick() / res->tv_sec = rtems_configuration_get_microseconds_per_tick() /
TOD_MICROSECONDS_PER_SECOND; TOD_MICROSECONDS_PER_SECOND;

View File

@@ -23,6 +23,8 @@
#include <rtems/seterr.h> #include <rtems/seterr.h>
#include "posixtime.h"
/*PAGE /*PAGE
* *
* 14.2.1 Clocks, P1003.1b-1993, p. 263 * 14.2.1 Clocks, P1003.1b-1993, p. 263
@@ -48,14 +50,14 @@ int clock_gettime(
#endif #endif
#ifdef _POSIX_CPUTIME #ifdef _POSIX_CPUTIME
if ( clock_id == CLOCK_PROCESS_CPUTIME ) { if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) {
_TOD_Get_uptime_as_timespec( tp ); _TOD_Get_uptime_as_timespec( tp );
return 0; return 0;
} }
#endif #endif
#ifdef _POSIX_THREAD_CPUTIME #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 ); rtems_set_errno_and_return_minus_one( ENOSYS );
#endif #endif

View File

@@ -23,6 +23,8 @@
#include <rtems/seterr.h> #include <rtems/seterr.h>
#include "posixtime.h"
/*PAGE /*PAGE
* *
* 14.2.1 Clocks, P1003.1b-1993, p. 263 * 14.2.1 Clocks, P1003.1b-1993, p. 263
@@ -45,11 +47,11 @@ int clock_settime(
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
} }
#ifdef _POSIX_CPUTIME #ifdef _POSIX_CPUTIME
else if ( clock_id == CLOCK_PROCESS_CPUTIME ) else if ( clock_id == CLOCK_PROCESS_CPUTIME_ID )
rtems_set_errno_and_return_minus_one( ENOSYS ); rtems_set_errno_and_return_minus_one( ENOSYS );
#endif #endif
#ifdef _POSIX_THREAD_CPUTIME #ifdef _POSIX_THREAD_CPUTIME
else if ( clock_id == CLOCK_THREAD_CPUTIME ) else if ( clock_id == CLOCK_THREAD_CPUTIME_ID )
rtems_set_errno_and_return_minus_one( ENOSYS ); rtems_set_errno_and_return_minus_one( ENOSYS );
#endif #endif
else else

View File

@@ -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 <time.h>
#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