Changeset ce691c51 in rtems


Ignore:
Timestamp:
06/18/98 15:14:48 (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
9a6994b4
Parents:
bdb1057
Message:

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.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libcsupport/src/__gettod.c

    rbdb1057 rce691c51  
     1#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
     2
    13#include <rtems.h>
    24
     
    2830
    2931/*
     32 *  Seconds from January 1, 1970 to January 1, 1988.  Used to account for
     33 *  differences between POSIX API and RTEMS core.
     34 */
     35
     36#define POSIX_TIME_SECONDS_1970_THROUGH_1988 \
     37  (((1987 - 1970 + 1)  * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
     38  (4 * TOD_SECONDS_PER_DAY))
     39
     40/*
    3041 *  NOTE:  The solaris gettimeofday does not have a second parameter.
    3142 */
     
    3647)
    3748{
    38   rtems_status_code      status;
    39   rtems_clock_time_value time;
     49  rtems_interrupt_level level;
     50  rtems_unsigned32      seconds;
     51  rtems_unsigned32      microseconds;
    4052
    4153  if ( !tp ) {
     
    4456  }
    4557
    46   /* "POSIX" does not seem to allow for not having a TOD */
    47   status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
    48   if ( status != RTEMS_SUCCESSFUL ) {
    49     assert( 0 );
    50     return -1;
    51   }
     58  /*
     59   *  POSIX does not seem to allow for not having a TOD so we just
     60   *  grab the time of day.
     61   *
     62   *  NOTE: XXX this routine should really be in the executive proper.
     63   */
     64 
     65  rtems_interrupt_disable(level);
     66    seconds      = _TOD_Seconds_since_epoch;
     67    microseconds = _TOD_Current.ticks;
     68  rtems_interrupt_enable(level);
    5269
    53   tp->tv_sec  = time.seconds;
    54   tp->tv_usec = time.microseconds;
     70  tp->tv_sec  = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
     71  tp->tv_usec = microseconds * _TOD_Microseconds_per_tick;
    5572
    5673  /*
  • c/src/lib/libc/__gettod.c

    rbdb1057 rce691c51  
     1#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
     2
    13#include <rtems.h>
    24
     
    2830
    2931/*
     32 *  Seconds from January 1, 1970 to January 1, 1988.  Used to account for
     33 *  differences between POSIX API and RTEMS core.
     34 */
     35
     36#define POSIX_TIME_SECONDS_1970_THROUGH_1988 \
     37  (((1987 - 1970 + 1)  * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
     38  (4 * TOD_SECONDS_PER_DAY))
     39
     40/*
    3041 *  NOTE:  The solaris gettimeofday does not have a second parameter.
    3142 */
     
    3647)
    3748{
    38   rtems_status_code      status;
    39   rtems_clock_time_value time;
     49  rtems_interrupt_level level;
     50  rtems_unsigned32      seconds;
     51  rtems_unsigned32      microseconds;
    4052
    4153  if ( !tp ) {
     
    4456  }
    4557
    46   /* "POSIX" does not seem to allow for not having a TOD */
    47   status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
    48   if ( status != RTEMS_SUCCESSFUL ) {
    49     assert( 0 );
    50     return -1;
    51   }
     58  /*
     59   *  POSIX does not seem to allow for not having a TOD so we just
     60   *  grab the time of day.
     61   *
     62   *  NOTE: XXX this routine should really be in the executive proper.
     63   */
     64 
     65  rtems_interrupt_disable(level);
     66    seconds      = _TOD_Seconds_since_epoch;
     67    microseconds = _TOD_Current.ticks;
     68  rtems_interrupt_enable(level);
    5269
    53   tp->tv_sec  = time.seconds;
    54   tp->tv_usec = time.microseconds;
     70  tp->tv_sec  = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
     71  tp->tv_usec = microseconds * _TOD_Microseconds_per_tick;
    5572
    5673  /*
  • cpukit/libcsupport/src/__gettod.c

    rbdb1057 rce691c51  
     1#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
     2
    13#include <rtems.h>
    24
     
    2830
    2931/*
     32 *  Seconds from January 1, 1970 to January 1, 1988.  Used to account for
     33 *  differences between POSIX API and RTEMS core.
     34 */
     35
     36#define POSIX_TIME_SECONDS_1970_THROUGH_1988 \
     37  (((1987 - 1970 + 1)  * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
     38  (4 * TOD_SECONDS_PER_DAY))
     39
     40/*
    3041 *  NOTE:  The solaris gettimeofday does not have a second parameter.
    3142 */
     
    3647)
    3748{
    38   rtems_status_code      status;
    39   rtems_clock_time_value time;
     49  rtems_interrupt_level level;
     50  rtems_unsigned32      seconds;
     51  rtems_unsigned32      microseconds;
    4052
    4153  if ( !tp ) {
     
    4456  }
    4557
    46   /* "POSIX" does not seem to allow for not having a TOD */
    47   status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
    48   if ( status != RTEMS_SUCCESSFUL ) {
    49     assert( 0 );
    50     return -1;
    51   }
     58  /*
     59   *  POSIX does not seem to allow for not having a TOD so we just
     60   *  grab the time of day.
     61   *
     62   *  NOTE: XXX this routine should really be in the executive proper.
     63   */
     64 
     65  rtems_interrupt_disable(level);
     66    seconds      = _TOD_Seconds_since_epoch;
     67    microseconds = _TOD_Current.ticks;
     68  rtems_interrupt_enable(level);
    5269
    53   tp->tv_sec  = time.seconds;
    54   tp->tv_usec = time.microseconds;
     70  tp->tv_sec  = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
     71  tp->tv_usec = microseconds * _TOD_Microseconds_per_tick;
    5572
    5673  /*
Note: See TracChangeset for help on using the changeset viewer.