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>
|
#include <rtems.h>
|
||||||
|
|
||||||
#if !defined(RTEMS_UNIX)
|
#if !defined(RTEMS_UNIX)
|
||||||
@@ -26,6 +28,15 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.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.
|
* NOTE: The solaris gettimeofday does not have a second parameter.
|
||||||
*/
|
*/
|
||||||
@@ -35,23 +46,29 @@ int gettimeofday(
|
|||||||
struct timezone *tzp
|
struct timezone *tzp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_status_code status;
|
rtems_interrupt_level level;
|
||||||
rtems_clock_time_value time;
|
rtems_unsigned32 seconds;
|
||||||
|
rtems_unsigned32 microseconds;
|
||||||
|
|
||||||
if ( !tp ) {
|
if ( !tp ) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "POSIX" does not seem to allow for not having a TOD */
|
/*
|
||||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
|
* POSIX does not seem to allow for not having a TOD so we just
|
||||||
if ( status != RTEMS_SUCCESSFUL ) {
|
* grab the time of day.
|
||||||
assert( 0 );
|
*
|
||||||
return -1;
|
* NOTE: XXX this routine should really be in the executive proper.
|
||||||
}
|
*/
|
||||||
|
|
||||||
tp->tv_sec = time.seconds;
|
rtems_interrupt_disable(level);
|
||||||
tp->tv_usec = time.microseconds;
|
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
|
* newlib does not have timezone and daylight savings time
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
#if !defined(RTEMS_UNIX)
|
#if !defined(RTEMS_UNIX)
|
||||||
@@ -26,6 +28,15 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.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.
|
* NOTE: The solaris gettimeofday does not have a second parameter.
|
||||||
*/
|
*/
|
||||||
@@ -35,23 +46,29 @@ int gettimeofday(
|
|||||||
struct timezone *tzp
|
struct timezone *tzp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_status_code status;
|
rtems_interrupt_level level;
|
||||||
rtems_clock_time_value time;
|
rtems_unsigned32 seconds;
|
||||||
|
rtems_unsigned32 microseconds;
|
||||||
|
|
||||||
if ( !tp ) {
|
if ( !tp ) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "POSIX" does not seem to allow for not having a TOD */
|
/*
|
||||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
|
* POSIX does not seem to allow for not having a TOD so we just
|
||||||
if ( status != RTEMS_SUCCESSFUL ) {
|
* grab the time of day.
|
||||||
assert( 0 );
|
*
|
||||||
return -1;
|
* NOTE: XXX this routine should really be in the executive proper.
|
||||||
}
|
*/
|
||||||
|
|
||||||
tp->tv_sec = time.seconds;
|
rtems_interrupt_disable(level);
|
||||||
tp->tv_usec = time.microseconds;
|
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
|
* newlib does not have timezone and daylight savings time
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
#if !defined(RTEMS_UNIX)
|
#if !defined(RTEMS_UNIX)
|
||||||
@@ -26,6 +28,15 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.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.
|
* NOTE: The solaris gettimeofday does not have a second parameter.
|
||||||
*/
|
*/
|
||||||
@@ -35,23 +46,29 @@ int gettimeofday(
|
|||||||
struct timezone *tzp
|
struct timezone *tzp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_status_code status;
|
rtems_interrupt_level level;
|
||||||
rtems_clock_time_value time;
|
rtems_unsigned32 seconds;
|
||||||
|
rtems_unsigned32 microseconds;
|
||||||
|
|
||||||
if ( !tp ) {
|
if ( !tp ) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "POSIX" does not seem to allow for not having a TOD */
|
/*
|
||||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
|
* POSIX does not seem to allow for not having a TOD so we just
|
||||||
if ( status != RTEMS_SUCCESSFUL ) {
|
* grab the time of day.
|
||||||
assert( 0 );
|
*
|
||||||
return -1;
|
* NOTE: XXX this routine should really be in the executive proper.
|
||||||
}
|
*/
|
||||||
|
|
||||||
tp->tv_sec = time.seconds;
|
rtems_interrupt_disable(level);
|
||||||
tp->tv_usec = time.microseconds;
|
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
|
* newlib does not have timezone and daylight savings time
|
||||||
|
|||||||
Reference in New Issue
Block a user