forked from Imagelibrary/rtems
Corrected so it returns the correct date. Previously was getting the number
of seconds since 1988 from RTEMS and not adding in the 1970-1988 correction factor. Plus removed checks for data/time set since POSIX does not permit this call to fail. GNAT 3.12 depends on this.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#if !defined(RTEMS_UNIX)
|
||||
@@ -26,6 +28,15 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* Seconds from January 1, 1970 to January 1, 1988. Used to account for
|
||||
* differences between POSIX API and RTEMS core.
|
||||
*/
|
||||
|
||||
#define POSIX_TIME_SECONDS_1970_THROUGH_1988 \
|
||||
(((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
|
||||
(4 * TOD_SECONDS_PER_DAY))
|
||||
|
||||
/*
|
||||
* NOTE: The solaris gettimeofday does not have a second parameter.
|
||||
*/
|
||||
@@ -35,23 +46,29 @@ int gettimeofday(
|
||||
struct timezone *tzp
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
rtems_clock_time_value time;
|
||||
rtems_interrupt_level level;
|
||||
rtems_unsigned32 seconds;
|
||||
rtems_unsigned32 microseconds;
|
||||
|
||||
if ( !tp ) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* "POSIX" does not seem to allow for not having a TOD */
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
assert( 0 );
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* POSIX does not seem to allow for not having a TOD so we just
|
||||
* grab the time of day.
|
||||
*
|
||||
* NOTE: XXX this routine should really be in the executive proper.
|
||||
*/
|
||||
|
||||
tp->tv_sec = time.seconds;
|
||||
tp->tv_usec = time.microseconds;
|
||||
rtems_interrupt_disable(level);
|
||||
seconds = _TOD_Seconds_since_epoch;
|
||||
microseconds = _TOD_Current.ticks;
|
||||
rtems_interrupt_enable(level);
|
||||
|
||||
tp->tv_sec = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
|
||||
tp->tv_usec = microseconds * _TOD_Microseconds_per_tick;
|
||||
|
||||
/*
|
||||
* newlib does not have timezone and daylight savings time
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#if !defined(RTEMS_UNIX)
|
||||
@@ -26,6 +28,15 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* Seconds from January 1, 1970 to January 1, 1988. Used to account for
|
||||
* differences between POSIX API and RTEMS core.
|
||||
*/
|
||||
|
||||
#define POSIX_TIME_SECONDS_1970_THROUGH_1988 \
|
||||
(((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
|
||||
(4 * TOD_SECONDS_PER_DAY))
|
||||
|
||||
/*
|
||||
* NOTE: The solaris gettimeofday does not have a second parameter.
|
||||
*/
|
||||
@@ -35,23 +46,29 @@ int gettimeofday(
|
||||
struct timezone *tzp
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
rtems_clock_time_value time;
|
||||
rtems_interrupt_level level;
|
||||
rtems_unsigned32 seconds;
|
||||
rtems_unsigned32 microseconds;
|
||||
|
||||
if ( !tp ) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* "POSIX" does not seem to allow for not having a TOD */
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
assert( 0 );
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* POSIX does not seem to allow for not having a TOD so we just
|
||||
* grab the time of day.
|
||||
*
|
||||
* NOTE: XXX this routine should really be in the executive proper.
|
||||
*/
|
||||
|
||||
tp->tv_sec = time.seconds;
|
||||
tp->tv_usec = time.microseconds;
|
||||
rtems_interrupt_disable(level);
|
||||
seconds = _TOD_Seconds_since_epoch;
|
||||
microseconds = _TOD_Current.ticks;
|
||||
rtems_interrupt_enable(level);
|
||||
|
||||
tp->tv_sec = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
|
||||
tp->tv_usec = microseconds * _TOD_Microseconds_per_tick;
|
||||
|
||||
/*
|
||||
* newlib does not have timezone and daylight savings time
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#if !defined(RTEMS_UNIX)
|
||||
@@ -26,6 +28,15 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* Seconds from January 1, 1970 to January 1, 1988. Used to account for
|
||||
* differences between POSIX API and RTEMS core.
|
||||
*/
|
||||
|
||||
#define POSIX_TIME_SECONDS_1970_THROUGH_1988 \
|
||||
(((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
|
||||
(4 * TOD_SECONDS_PER_DAY))
|
||||
|
||||
/*
|
||||
* NOTE: The solaris gettimeofday does not have a second parameter.
|
||||
*/
|
||||
@@ -35,23 +46,29 @@ int gettimeofday(
|
||||
struct timezone *tzp
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
rtems_clock_time_value time;
|
||||
rtems_interrupt_level level;
|
||||
rtems_unsigned32 seconds;
|
||||
rtems_unsigned32 microseconds;
|
||||
|
||||
if ( !tp ) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* "POSIX" does not seem to allow for not having a TOD */
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
assert( 0 );
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* POSIX does not seem to allow for not having a TOD so we just
|
||||
* grab the time of day.
|
||||
*
|
||||
* NOTE: XXX this routine should really be in the executive proper.
|
||||
*/
|
||||
|
||||
tp->tv_sec = time.seconds;
|
||||
tp->tv_usec = time.microseconds;
|
||||
rtems_interrupt_disable(level);
|
||||
seconds = _TOD_Seconds_since_epoch;
|
||||
microseconds = _TOD_Current.ticks;
|
||||
rtems_interrupt_enable(level);
|
||||
|
||||
tp->tv_sec = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
|
||||
tp->tv_usec = microseconds * _TOD_Microseconds_per_tick;
|
||||
|
||||
/*
|
||||
* newlib does not have timezone and daylight savings time
|
||||
|
||||
Reference in New Issue
Block a user