change log for rtems (2011-09-29)

rtems-vc at rtems.org rtems-vc at rtems.org
Thu Sep 29 10:10:26 UTC 2011


 *sh*:
2011-09-29	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* sp2038/init.c: More test cases.

M  1.491  testsuites/sptests/ChangeLog
M    1.2  testsuites/sptests/sp2038/init.c

diff -u rtems/testsuites/sptests/ChangeLog:1.490 rtems/testsuites/sptests/ChangeLog:1.491
--- rtems/testsuites/sptests/ChangeLog:1.490	Wed Sep 28 11:01:53 2011
+++ rtems/testsuites/sptests/ChangeLog	Thu Sep 29 04:40:32 2011
@@ -1,3 +1,7 @@
+2011-09-29	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+	* sp2038/init.c: More test cases.
+
 2011-09-28	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
 	* sp2038/Makefile.am, sp2038/init.c, sp2038/sp2038.doc,

diff -u rtems/testsuites/sptests/sp2038/init.c:1.1 rtems/testsuites/sptests/sp2038/init.c:1.2
--- rtems/testsuites/sptests/sp2038/init.c:1.1	Wed Sep 28 11:01:53 2011
+++ rtems/testsuites/sptests/sp2038/init.c	Thu Sep 29 04:40:32 2011
@@ -30,6 +30,128 @@
 
 #define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
 
+static const uint32_t sample_seconds [] = {
+  571213695UL,
+  602836095UL,
+  634372095UL,
+  665908095UL,
+  697444095UL,
+  729066495UL,
+  760602495UL,
+  792138495UL,
+  823674495UL,
+  855296895UL,
+  886832895UL,
+  918368895UL,
+  949904895UL,
+  981527295UL,
+  1013063295UL,
+  1044599295UL,
+  1076135295UL,
+  1107757695UL,
+  1139293695UL,
+  1170829695UL,
+  1202365695UL,
+  1233988095UL,
+  1265524095UL,
+  1297060095UL,
+  1328596095UL,
+  1360218495UL,
+  1391754495UL,
+  1423290495UL,
+  1454826495UL,
+  1486448895UL,
+  1517984895UL,
+  1549520895UL,
+  1581056895UL,
+  1612679295UL,
+  1644215295UL,
+  1675751295UL,
+  1707287295UL,
+  1738909695UL,
+  1770445695UL,
+  1801981695UL,
+  1833517695UL,
+  1865140095UL,
+  1896676095UL,
+  1928212095UL,
+  1959748095UL,
+  1991370495UL,
+  2022906495UL,
+  2054442495UL,
+  2085978495UL,
+  2117600895UL,
+  2149136895UL,
+  2180672895UL,
+  2212208895UL,
+  2243831295UL,
+  2275367295UL,
+  2306903295UL,
+  2338439295UL,
+  2370061695UL,
+  2401597695UL,
+  2433133695UL,
+  2464669695UL,
+  2496292095UL,
+  2527828095UL,
+  2559364095UL,
+  2590900095UL,
+  2622522495UL,
+  2654058495UL,
+  2685594495UL,
+  2717130495UL,
+  2748752895UL,
+  2780288895UL,
+  2811824895UL,
+  2843360895UL,
+  2874983295UL,
+  2906519295UL,
+  2938055295UL,
+  2969591295UL,
+  3001213695UL,
+  3032749695UL,
+  3064285695UL,
+  3095821695UL,
+  3127444095UL,
+  3158980095UL,
+  3190516095UL,
+  3222052095UL,
+  3253674495UL,
+  3285210495UL,
+  3316746495UL,
+  3348282495UL,
+  3379904895UL,
+  3411440895UL,
+  3442976895UL,
+  3474512895UL,
+  3506135295UL,
+  3537671295UL,
+  3569207295UL,
+  3600743295UL,
+  3632365695UL,
+  3663901695UL,
+  3695437695UL,
+  3726973695UL,
+  3758596095UL,
+  3790132095UL,
+  3821668095UL,
+  3853204095UL,
+  3884826495UL,
+  3916362495UL,
+  3947898495UL,
+  3979434495UL,
+  4011056895UL,
+  4042592895UL,
+  4074128895UL,
+  4105664895UL,
+  4137200895UL,
+  4168736895UL,
+  4200272895UL,
+  4231808895UL,
+  4263431295UL,
+  4294967295UL
+};
+
 static const rtems_time_of_day nearly_problem_2038 = {
   .year = 2038,
   .month = 1,
@@ -66,15 +188,39 @@
   .second = 16
 };
 
-static void test_case(void)
+static void test_tod_to_seconds(void)
+{
+  rtems_status_code sc = RTEMS_SUCCESSFUL;
+  size_t i = 0;
+  size_t n = sizeof(sample_seconds) / sizeof(sample_seconds [0]);
+
+  for (i = 0; i < n; ++i) {
+    rtems_time_of_day tod = nearly_problem_2106;
+    uint32_t seconds = 0;
+    rtems_interval seconds_as_interval = 0;
+
+    tod.year = 1988 + i;
+    seconds = _TOD_To_seconds(&tod);
+    rtems_test_assert(seconds == sample_seconds [i]);
+
+    sc = rtems_clock_set(&tod);
+    ASSERT_SC(sc);
+
+    sc = rtems_clock_get_seconds_since_epoch(&seconds_as_interval);
+    ASSERT_SC(sc);
+    rtems_test_assert(seconds_as_interval == sample_seconds [i]);
+  }
+}
+
+static void test_problem_year(void)
 {
 #if TEST_APPLICABLE
   rtems_status_code sc = RTEMS_SUCCESSFUL;
-  int64_t one = 1;
-  int64_t large = one << 32;
-  time_t time_t_large = (time_t) large;
-  bool time_t_is_32_bit = time_t_large != large;
-  bool time_t_is_signed = (((time_t) 0) - ((time_t) 1)) < 0;
+  time_t zero = 0;
+  time_t one = 1;
+  time_t maybe_negative = zero - one;
+  bool time_t_is_32_bit = sizeof(time_t) == 4;
+  bool time_t_is_signed = maybe_negative < zero;
 
   if (time_t_is_32_bit) {
     const rtems_time_of_day *nearly_problem = NULL;
@@ -108,7 +254,8 @@
 {
   puts("\n\n*** TEST 2038 ***");
 
-  test_case();
+  test_tod_to_seconds();
+  test_problem_year();
 
   puts("*** END OF TEST 2038 ***");
 


 *sh*:
2011-09-29	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* score/include/rtems/score/tod.h: Declare _TOD_Set_with_timestamp()
	and _TOD_Get_as_timestamp().
	* score/src/coretodset.c: Define _TOD_Set_with_timestamp().
	* score/src/coretodget.c: Define _TOD_Get_as_timestamp().
	* rtems/src/clockset.c: Use _TOD_Set_with_timestamp().
	* score/include/rtems/score/timestamp64.h, score/src/ts64set.c:
	Changed parameter types of _Timestamp64_Set().
	* rtems/src/clocktodtoseconds.c: Year 2100 is not a leap year.

M 1.2929  cpukit/ChangeLog
M   1.11  cpukit/rtems/src/clockset.c
M   1.11  cpukit/rtems/src/clocktodtoseconds.c
M    1.7  cpukit/score/include/rtems/score/timestamp64.h
M   1.44  cpukit/score/include/rtems/score/tod.h
M    1.6  cpukit/score/src/coretodget.c
M   1.13  cpukit/score/src/coretodset.c
M    1.3  cpukit/score/src/ts64set.c

diff -u rtems/cpukit/ChangeLog:1.2928 rtems/cpukit/ChangeLog:1.2929
--- rtems/cpukit/ChangeLog:1.2928	Wed Sep 28 10:46:12 2011
+++ rtems/cpukit/ChangeLog	Thu Sep 29 04:55:53 2011
@@ -1,3 +1,14 @@
+2011-09-29	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+	* score/include/rtems/score/tod.h: Declare _TOD_Set_with_timestamp()
+	and _TOD_Get_as_timestamp().
+	* score/src/coretodset.c: Define _TOD_Set_with_timestamp().
+	* score/src/coretodget.c: Define _TOD_Get_as_timestamp().
+	* rtems/src/clockset.c: Use _TOD_Set_with_timestamp().
+	* score/include/rtems/score/timestamp64.h, score/src/ts64set.c:
+	Changed parameter types of _Timestamp64_Set().
+	* rtems/src/clocktodtoseconds.c: Year 2100 is not a leap year.
+
 2011-09-28	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
 	* rtems/include/rtems/rtems/clock.h, rtems/src/clockset.c: Added const

diff -u rtems/cpukit/rtems/src/clockset.c:1.10 rtems/cpukit/rtems/src/clockset.c:1.11
--- rtems/cpukit/rtems/src/clockset.c:1.10	Wed Sep 28 10:46:13 2011
+++ rtems/cpukit/rtems/src/clockset.c	Thu Sep 29 04:55:54 2011
@@ -30,7 +30,7 @@
  *  This directive sets the date and time for this node.
  *
  *  Input parameters:
- *    time_buffer - pointer to the time and date structure
+ *    tod - pointer to the time and date structure
  *
  *  Output parameters:
  *    RTEMS_SUCCESSFUL - if successful
@@ -38,23 +38,26 @@
  */
 
 rtems_status_code rtems_clock_set(
-  const rtems_time_of_day *time_buffer
+  const rtems_time_of_day *tod
 )
 {
-  struct timespec  newtime;
-
-  if ( !time_buffer )
+  if ( !tod )
     return RTEMS_INVALID_ADDRESS;
 
-  if ( _TOD_Validate( time_buffer ) ) {
-    newtime.tv_sec = _TOD_To_seconds( time_buffer );
-    newtime.tv_nsec = time_buffer->ticks *
-      rtems_configuration_get_nanoseconds_per_tick();
+  if ( _TOD_Validate( tod ) ) {
+    Timestamp_Control tod_as_timestamp;
+    uint32_t seconds = _TOD_To_seconds( tod );
+    uint32_t nanoseconds = tod->ticks
+      * rtems_configuration_get_nanoseconds_per_tick();
+
+    _Timestamp_Set( &tod_as_timestamp, seconds, nanoseconds );
 
     _Thread_Disable_dispatch();
-      _TOD_Set( &newtime );
+      _TOD_Set_with_timestamp( &tod_as_timestamp );
     _Thread_Enable_dispatch();
+
     return RTEMS_SUCCESSFUL;
   }
+
   return RTEMS_INVALID_CLOCK;
 }

diff -u rtems/cpukit/rtems/src/clocktodtoseconds.c:1.10 rtems/cpukit/rtems/src/clocktodtoseconds.c:1.11
--- rtems/cpukit/rtems/src/clocktodtoseconds.c:1.10	Sun Jul 24 18:55:09 2011
+++ rtems/cpukit/rtems/src/clocktodtoseconds.c	Thu Sep 29 04:55:54 2011
@@ -18,6 +18,8 @@
 #include <rtems/system.h>
 #include <rtems/rtems/clock.h>
 
+#define TOD_SECONDS_AT_2100_03_01_00_00 4107538800UL
+
 /*
  *  The following array contains the number of days in all months
  *  up to the month indicated by the index of the second dimension.
@@ -78,6 +80,12 @@
 
   time += the_tod->second;
 
+  /* The year 2100 is not a leap year */
+  if ( time
+      >= (TOD_SECONDS_AT_2100_03_01_00_00 - TOD_SECONDS_1970_THROUGH_1988)) {
+    time -= TOD_SECONDS_PER_DAY;
+  }
+
   time += TOD_SECONDS_1970_THROUGH_1988;
 
   return( time );

diff -u rtems/cpukit/score/include/rtems/score/timestamp64.h:1.6 rtems/cpukit/score/include/rtems/score/timestamp64.h:1.7
--- rtems/cpukit/score/include/rtems/score/timestamp64.h:1.6	Wed Sep 28 09:42:12 2011
+++ rtems/cpukit/score/include/rtems/score/timestamp64.h	Thu Sep 29 04:55:54 2011
@@ -55,14 +55,11 @@
 
 static inline void _Timestamp64_implementation_Set(
   Timestamp64_Control *_time,
-  long                 _seconds,
-  long                 _nanoseconds
+  Timestamp64_Control  _seconds,
+  Timestamp64_Control  _nanoseconds
 )
 {
-  Timestamp64_Control _seconds64 = _seconds;
-  Timestamp64_Control _nanoseconds64 = _nanoseconds;
-
-  *_time = _seconds64 * 1000000000L + _nanoseconds64;
+  *_time = _seconds * 1000000000L + _nanoseconds;
 }
 
 /**
@@ -81,8 +78,8 @@
 #else
   void _Timestamp64_Set(
     Timestamp64_Control *_time,
-    long                _seconds,
-    long                _nanoseconds
+    Timestamp64_Control  _seconds,
+    Timestamp64_Control  _nanoseconds
   );
 #endif
 
@@ -406,8 +403,8 @@
   struct timespec           *_timespec
 )
 {
-  _timespec->tv_sec = *_timestamp / 1000000000L;
-  _timespec->tv_nsec = *_timestamp % 1000000000L;
+  _timespec->tv_sec = (time_t) (*_timestamp / 1000000000L);
+  _timespec->tv_nsec = (long) (*_timestamp % 1000000000L);
 }
 
 /**

diff -u rtems/cpukit/score/include/rtems/score/tod.h:1.43 rtems/cpukit/score/include/rtems/score/tod.h:1.44
--- rtems/cpukit/score/include/rtems/score/tod.h:1.43	Fri Jun 17 10:40:09 2011
+++ rtems/cpukit/score/include/rtems/score/tod.h	Thu Sep 29 04:55:54 2011
@@ -163,27 +163,48 @@
 void _TOD_Handler_initialization(void);
 
 /**
- *  @brief _TOD_Set
+ *  @brief Sets the time of day according to @a tod_as_timestamp.
  *
- *  This routine sets the current time of day to @a time and
- *  the equivalent SECONDS_SINCE_EPOCH.
+ *  The @a tod_as_timestamp timestamp represents the time since UNIX epoch.  The watchdog
+ *  seconds chain will be adjusted.
  */
-void _TOD_Set(
-  const struct timespec *time
+void _TOD_Set_with_timestamp(
+  const Timestamp_Control *tod_as_timestamp
 );
 
+static inline void _TOD_Set(
+  const struct timespec *tod_as_timespec
+)
+{
+  Timestamp_Control tod_as_timestamp;
+
+  _Timestamp_Set(
+    &tod_as_timestamp,
+    tod_as_timespec->tv_sec,
+    tod_as_timespec->tv_nsec
+  );
+  _TOD_Set_with_timestamp( &tod_as_timestamp );
+}
+
 /**
- *  @brief _TOD_Get
- *
- *  This routine returns the current time of day with potential accuracy
- *  to the nanosecond.
+ *  @brief Returns the time of day in @a tod_as_timestamp.
  *
- *  @param[in] time is a pointer to the time to be returned
+ *  The @a tod_as_timestamp timestamp represents the time since UNIX epoch.
  */
-void _TOD_Get(
-  struct timespec *time
+void _TOD_Get_as_timestamp(
+  Timestamp_Control *tod_as_timestamp
 );
 
+static inline void _TOD_Get(
+  struct timespec *tod_as_timespec
+)
+{
+  Timestamp_Control tod_as_timestamp;
+
+  _TOD_Get_as_timestamp( &tod_as_timestamp );
+  _Timestamp_To_timespec( &tod_as_timestamp, tod_as_timespec );
+}
+
 /**
  *  @brief _TOD_Get_uptime
  *

diff -u rtems/cpukit/score/src/coretodget.c:1.5 rtems/cpukit/score/src/coretodget.c:1.6
--- rtems/cpukit/score/src/coretodget.c:1.5	Thu Dec 16 08:50:12 2010
+++ rtems/cpukit/score/src/coretodget.c	Thu Sep 29 04:55:54 2011
@@ -22,19 +22,8 @@
 #include <rtems/score/tod.h>
 #include <rtems/score/watchdog.h>
 
-/*
- *  _TOD_Get
- *
- *  This routine is used to obtain the current date and time.
- *
- *  Input parameters:
- *    time  - pointer to the time and date structure
- *
- *  Output parameters: NONE
- */
-
-void _TOD_Get(
-  struct timespec *time
+void _TOD_Get_as_timestamp(
+  Timestamp_Control *tod
 )
 {
   ISR_Level         level;
@@ -52,5 +41,6 @@
 
   _Timestamp_Set( &offset, 0, nanoseconds );
   _Timestamp_Add_to( &now, &offset );
-  _Timestamp_To_timespec( &now, time );
+
+  *tod = now;
 }

diff -u rtems/cpukit/score/src/coretodset.c:1.12 rtems/cpukit/score/src/coretodset.c:1.13
--- rtems/cpukit/score/src/coretodset.c:1.12	Sun Jul 24 18:55:13 2011
+++ rtems/cpukit/score/src/coretodset.c	Thu Sep 29 04:55:54 2011
@@ -23,39 +23,26 @@
 #include <rtems/score/tod.h>
 #include <rtems/score/watchdog.h>
 
-/*
- *  _TOD_Set
- *
- *  This rountine sets the current date and time with the specified
- *  new date and time structure.
- *
- *  Input parameters:
- *    time                - pointer to the time and date structure
- *
- *  Output parameters: NONE
- */
-
-void _TOD_Set(
-  const struct timespec *time
+void _TOD_Set_with_timestamp(
+  const Timestamp_Control *tod
 )
 {
-  long seconds;
+  Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod );
+  Watchdog_Interval seconds_now;
 
   _Thread_Disable_dispatch();
   _TOD_Deactivate();
 
-  seconds = _TOD_Seconds_since_epoch();
+  seconds_now = _TOD_Seconds_since_epoch();
 
-  if ( time->tv_sec < seconds )
-    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds - time->tv_sec );
+  if ( seconds_next < seconds_now )
+    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
   else
-    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, time->tv_sec - seconds );
+    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
 
-  /* POSIX format TOD (timespec) */
-  _Timestamp_Set( &_TOD_Now, time->tv_sec, time->tv_nsec );
+  _TOD_Now = *tod;
   _TOD_Is_set = true;
 
   _TOD_Activate();
-
   _Thread_Enable_dispatch();
 }

diff -u rtems/cpukit/score/src/ts64set.c:1.2 rtems/cpukit/score/src/ts64set.c:1.3
--- rtems/cpukit/score/src/ts64set.c:1.2	Wed Sep 28 09:42:12 2011
+++ rtems/cpukit/score/src/ts64set.c	Thu Sep 29 04:55:54 2011
@@ -22,8 +22,8 @@
 #if CPU_TIMESTAMP_USE_INT64 == TRUE
 void _Timestamp64_Set(
   Timestamp64_Control *_time,
-  long                 _seconds,
-  long                 _nanoseconds
+  Timestamp64_Control  _seconds,
+  Timestamp64_Control  _nanoseconds
 )
 {
   _Timestamp64_implementation_Set( _time, _seconds, _nanoseconds );



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20110929/730dbb86/attachment.html>


More information about the vc mailing list