forked from Imagelibrary/rtems
2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* posix/Makefile.am: Add file missed in previous commit. * posix/src/posixtimespecabsolutetimeout.c: New file.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* posix/Makefile.am: Add file missed in previous commit.
|
||||
* posix/src/posixtimespecabsolutetimeout.c: New file.
|
||||
|
||||
2006-11-15 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* configure.ac: Remove RTEMS_AMPOLISH3.
|
||||
|
||||
@@ -146,9 +146,10 @@ libposix_a_SOURCES += src/pspin.c src/pspindestroy.c src/pspininit.c \
|
||||
## TIME_C_FILES
|
||||
libposix_a_SOURCES += src/adjtime.c src/time.c src/posixtimespecsubtract.c \
|
||||
src/posixtimespectointerval.c src/posixintervaltotimespec.c \
|
||||
src/clockgetcpuclockid.c src/clockgetenableattr.c src/clockgetres.c \
|
||||
src/clockgettime.c src/clocksetenableattr.c src/clocksettime.c \
|
||||
src/nanosleep.c src/sleep.c src/usleep.c
|
||||
src/posixtimespecabsolutetimeout.c src/clockgetcpuclockid.c \
|
||||
src/clockgetenableattr.c src/clockgetres.c src/clockgettime.c \
|
||||
src/clocksetenableattr.c src/clocksettime.c src/nanosleep.c src/sleep.c \
|
||||
src/usleep.c
|
||||
|
||||
# the timer manager needs to be split further but only after its
|
||||
# dependence on the Classic API Timer Manager is removed.
|
||||
|
||||
69
cpukit/posix/src/posixtimespecabsolutetimeout.c
Normal file
69
cpukit/posix/src/posixtimespecabsolutetimeout.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Convert abstime timeout to ticks
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/posix/semaphore.h>
|
||||
#include <rtems/posix/time.h>
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
/*
|
||||
* The abstime is a walltime. We turn it into an interval.
|
||||
*/
|
||||
int _POSIX_Absolute_timeout_to_ticks(
|
||||
const struct timespec *abstime,
|
||||
Watchdog_Interval *ticks_out
|
||||
)
|
||||
{
|
||||
struct timespec current_time;
|
||||
struct timespec difference;
|
||||
|
||||
if ( !abstime )
|
||||
return EINVAL;
|
||||
|
||||
/*
|
||||
* Error check the absolute time to timeout
|
||||
*/
|
||||
#if 0
|
||||
/* they are unsigned so this is impossible */
|
||||
if ( abstime->tv_sec < 0 || abstime->tv_nsec < 0 )
|
||||
return EINVAL;
|
||||
#endif
|
||||
|
||||
if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
|
||||
return EINVAL;
|
||||
|
||||
(void) clock_gettime( CLOCK_REALTIME, ¤t_time );
|
||||
|
||||
/*
|
||||
* Make sure the abstime is in the future
|
||||
*/
|
||||
if ( abstime->tv_sec < current_time.tv_sec )
|
||||
return EINVAL;
|
||||
|
||||
if ( (abstime->tv_sec == current_time.tv_sec) &&
|
||||
(abstime->tv_nsec <= current_time.tv_nsec) )
|
||||
return EINVAL;
|
||||
|
||||
_POSIX_Timespec_subtract( ¤t_time, abstime, &difference );
|
||||
|
||||
*ticks_out = _POSIX_Timespec_to_interval( &difference );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user