RE: [PATCH v1 00/10] Convert and reformat rtems-tools pt. 1

2021-09-03 Thread Ryan Long
I haven't been building these with clang, so I'll make sure to start doing 
that. I've got a Macbook, so I can test it on there as well.

-Original Message-
From: Chris Johns  
Sent: Thursday, September 2, 2021 11:59 PM
To: Ryan Long ; devel@rtems.org
Subject: Re: [PATCH v1 00/10] Convert and reformat rtems-tools pt. 1

On 3/9/21 5:24 am, Ryan Long wrote:
> For this and the following series of patches I followed this series of 
> steps.
> 
> 1. Convert a file from the C way of doing things to C++ 2. Go through 
> all the files that had to do with the converted file and make the 
> formatting consistent.

Looks good and thanks for taking this on.

Have you built this with clang on FreeBSD? I only ask because the minor fix I 
pushed where clang complained about the `std::ostream::tellp()` return value 
being compared to `long int` 

https://lists.rtems.org/pipermail/build/2021-September/028853.html

I suspect if this change build on FreeBSD it will also build on MacOS. Do you 
have access to a MacOS machine?

There is a new piece of code around `gcount()` and this is the reason for my 
question.

Chris



___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/7] score: Limit the CLOCK_REALTIME setting

2021-09-03 Thread Sebastian Huber
Limit the CLOCK_REALTIME setting to ensure that the CLOCK_REALTIME is defined
for a system uptime of at least 114 years.
---
 cpukit/include/rtems/score/todimpl.h |  9 +
 cpukit/score/src/coretodcheck.c  |  2 +-
 testsuites/psxtests/psxclock/init.c  | 15 +++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/cpukit/include/rtems/score/todimpl.h 
b/cpukit/include/rtems/score/todimpl.h
index ceeef2e21b..f85689fd9c 100644
--- a/cpukit/include/rtems/score/todimpl.h
+++ b/cpukit/include/rtems/score/todimpl.h
@@ -115,6 +115,15 @@ extern "C" {
   (((1987 - 1970 + 1)  * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
   (4 * TOD_SECONDS_PER_DAY))
 
+/**
+ * @brief Seconds from 1970-01-01T00:00:00Z to 2400-01-01T00:00:00Z.
+ *
+ * This is the latest time of day which should be set by _TOD_Set().  The year
+ * 2400 was chosen to guarantee a defined CLOCK_REALTIME within the range of a
+ * system uptime of about 114 years.
+ */
+#define TOD_SECONDS_1970_THROUGH_2400 13569465600
+
 /**
  *  @brief Earliest year to which an time of day can be initialized.
  *
diff --git a/cpukit/score/src/coretodcheck.c b/cpukit/score/src/coretodcheck.c
index b42435aa43..8c012c5070 100644
--- a/cpukit/score/src/coretodcheck.c
+++ b/cpukit/score/src/coretodcheck.c
@@ -51,7 +51,7 @@ Status_Control _TOD_Is_valid_new_time_of_day( const struct 
timespec *tod )
 return STATUS_INVALID_NUMBER;
   }
 
-  if ( _Watchdog_Is_far_future_timespec( tod ) ) {
+  if ( tod->tv_sec > TOD_SECONDS_1970_THROUGH_2400 ) {
 return STATUS_INVALID_NUMBER;
   }
 
diff --git a/testsuites/psxtests/psxclock/init.c 
b/testsuites/psxtests/psxclock/init.c
index 778637b4fd..3f88f1d401 100644
--- a/testsuites/psxtests/psxclock/init.c
+++ b/testsuites/psxtests/psxclock/init.c
@@ -131,6 +131,21 @@ static rtems_task Init(
   rtems_test_assert( sc == -1 );
   rtems_test_assert( errno == EINVAL );
 
+  puts( "Init: clock_settime - 2400-01-01T00:00:00Z SUCCESSFUL" );
+  tv.tv_sec = 13569465600;
+  tv.tv_nsec = 0;
+  errno = 0;
+  sc = clock_settime( CLOCK_REALTIME, &tv );
+  rtems_test_assert( sc == 0 );
+
+  puts( "Init: clock_settime - 2400-01-01T00:00:01Z EINVAL" );
+  tv.tv_sec = 13569465601;
+  tv.tv_nsec = 0;
+  errno = 0;
+  sc = clock_settime( CLOCK_REALTIME, &tv );
+  rtems_test_assert( sc == -1 );
+  rtems_test_assert( errno == EINVAL );
+
   puts( "Init: clock_settime - far future EINVAL" );
   tv.tv_sec = 17179869184;
   tv.tv_nsec = 0;
-- 
2.26.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 6/7] score: Always validate ticks in _TOD_Validate()

2021-09-03 Thread Sebastian Huber
The behaviour with respect to the handling of the ticks member in the *_when()
directives was inconsistent.  In all *_when() directives the ticks member is
not used to calculate the watchdog expiration time.  However, the
rtems_task_wake_when() directive ignores the ticks member of the time of day
completely, unlike the rtems_timer_fire_when() and
rtems_timer_server_fire_when() directives which check that the ticks are valid
and then ignore them.

This commit changes _TOD_Validate() to unconditionally check the ticks value.
Ignoring the value would make it more difficult to support the ticks in the
future.  The watchdog implementation supports a nanoseconds resolution.
Checking the ticks in rtems_task_wake_when() may case problems for existing
applications which could now get an error status due to an invalid ticks value.

Applications should set the ticks value to zero for future compatibility.  This
recommendation needs to be added to the documentation.
---
 bsps/arm/altera-cyclone-v/rtc/rtc.c|  4 ++--
 bsps/shared/dev/rtc/rtc-support.c  |  2 +-
 cpukit/include/rtems/rtems/clockimpl.h | 28 +-
 cpukit/rtems/src/clockset.c|  2 +-
 cpukit/rtems/src/clocktodvalidate.c| 12 ++-
 cpukit/rtems/src/taskwakewhen.c|  2 +-
 cpukit/rtems/src/timercreate.c |  2 +-
 testsuites/sptests/sp2038/init.c   |  4 ++--
 testsuites/sptests/sptask_err02/init.c |  5 +++--
 9 files changed, 14 insertions(+), 47 deletions(-)

diff --git a/bsps/arm/altera-cyclone-v/rtc/rtc.c 
b/bsps/arm/altera-cyclone-v/rtc/rtc.c
index 779a093459..d1c12ee874 100644
--- a/bsps/arm/altera-cyclone-v/rtc/rtc.c
+++ b/bsps/arm/altera-cyclone-v/rtc/rtc.c
@@ -353,7 +353,7 @@ static int altera_cyclone_v_ds1339_get_time(int minor, 
rtems_time_of_day* tod)
 temp_tod.month  = ds1339_get_month(&time);
 temp_tod.year   = ds1339_get_year(&time);
 
-sc = _TOD_Validate(&temp_tod, TOD_ENABLE_TICKS_VALIDATION);
+sc = _TOD_Validate(&temp_tod);
 if (sc == RTEMS_SUCCESSFUL)
   memcpy(tod, &temp_tod, sizeof(temp_tod));
   }
@@ -736,7 +736,7 @@ static int  altera_cyclone_v_m41st87_get_time(int minor, 
rtems_time_of_day* tod)
   temp_tod.month  = m41st87_get_month(&time);
   temp_tod.year   = m41st87_get_year(&time);
 
-  sc = _TOD_Validate(&temp_tod, TOD_ENABLE_TICKS_VALIDATION);
+  sc = _TOD_Validate(&temp_tod);
   if (sc == RTEMS_SUCCESSFUL)
 memcpy(tod, &temp_tod, sizeof(temp_tod));
 
diff --git a/bsps/shared/dev/rtc/rtc-support.c 
b/bsps/shared/dev/rtc/rtc-support.c
index c0b639ec7c..04b8f0c847 100644
--- a/bsps/shared/dev/rtc/rtc-support.c
+++ b/bsps/shared/dev/rtc/rtc-support.c
@@ -255,7 +255,7 @@ int setRealTime(
   if (!RTC_Is_present())
 return -1;
 
-  if (_TOD_Validate(tod, TOD_ENABLE_TICKS_VALIDATION) != RTEMS_SUCCESSFUL)
+  if (_TOD_Validate(tod) != RTEMS_SUCCESSFUL)
 return -1;
 
   RTC_Table[RTC_Minor].pDeviceFns->deviceSetTime(RTC_Minor, tod);
diff --git a/cpukit/include/rtems/rtems/clockimpl.h 
b/cpukit/include/rtems/rtems/clockimpl.h
index c8334afaf3..85d7341c9a 100644
--- a/cpukit/include/rtems/rtems/clockimpl.h
+++ b/cpukit/include/rtems/rtems/clockimpl.h
@@ -34,43 +34,17 @@ extern "C" {
  * @{
  */
 
-/**
- * @brief The enumerators of this type determine if the ticks member is
- *   validated in _TOD_Validate().
- */
-typedef enum {
-  /**
-   * @brief Use this option to disable the validation of the ticks member in
-   *   _TOD_Validate().
-   */
-  TOD_DISABLE_TICKS_VALIDATION = 0,
-
-  /**
-   * @brief Use this option to enable the validation of the ticks member in
-   *   _TOD_Validate().
-   */
-  TOD_ENABLE_TICKS_VALIDATION = -1
-} TOD_Ticks_validation;
-
 /**
  * @brief Validates the time of day.
  *
  * @param the_tod is the reference to the time of day structure to validate or
  *   NULL.
  *
- * @param ticks_validation indicates if the ticks member of the time of day
- *   should be validated.  Use #TOD_ENABLE_TICKS_VALIDATION to validate the
- *   ticks member.  Use #TOD_DISABLE_TICKS_VALIDATION to skip the validation of
- *   the ticks member.
- *
  * @retval RTEMS_SUCCESSFUL @a the_tod references a valid time of day.
  * @retval RTEMS_INVALID_CLOCK @a the_tod references an invalid time of day.
  * @retval RTEMS_INVALID_ADDRESS @a the_tod reference is @c NULL.
  */
-rtems_status_code _TOD_Validate(
-  const rtems_time_of_day *the_tod,
-  TOD_Ticks_validation ticks_validation
-);
+rtems_status_code _TOD_Validate( const rtems_time_of_day *the_tod );
 
 /**
  * @brief TOD to Seconds
diff --git a/cpukit/rtems/src/clockset.c b/cpukit/rtems/src/clockset.c
index 07384290b8..df163531a7 100644
--- a/cpukit/rtems/src/clockset.c
+++ b/cpukit/rtems/src/clockset.c
@@ -34,7 +34,7 @@ rtems_status_code rtems_clock_set(
   struct timespec   tod_as_timespec;
   ISR_lock_Context  lock_context;
 
-  status = _TOD_Validate( tod, TOD_ENABLE_TICKS_VALIDATION );
+  status = _TOD_Validate( tod );
 
   if ( status != RTEMS_SUCCESSFUL ) {
 return sta

[PATCH 0/7] Clean up some CLOCK_REALTIME related issues

2021-09-03 Thread Sebastian Huber
See also:

https://lists.rtems.org/pipermail/devel/2021-May/067247.html

https://devel.rtems.org/ticket/4338

Sebastian Huber (7):
  score: Return status in _TOD_Adjust()
  score: Remove TOD_TICKS_PER_SECOND_method()
  score: Add _TOD_Is_valid_new_time_of_day()
  score: Limit the CLOCK_REALTIME setting
  score: Simplify _TOD_Validate()
  score: Always validate ticks in _TOD_Validate()
  score: Change TOD_LATEST_YEAR to 2099

 bsps/arm/altera-cyclone-v/rtc/rtc.c |  4 +-
 bsps/bfin/shared/dev/rtc.c  |  9 +--
 bsps/shared/dev/rtc/rtc-support.c   |  2 +-
 cpukit/Makefile.am  |  2 +-
 cpukit/include/rtems/rtems/clockimpl.h  | 28 +
 cpukit/include/rtems/score/todimpl.h| 79 ++---
 cpukit/posix/src/adjtime.c  |  6 +-
 cpukit/posix/src/clocksettime.c |  5 ++
 cpukit/rtems/src/clockgettod.c  |  6 +-
 cpukit/rtems/src/clockset.c |  2 +-
 cpukit/rtems/src/clocktodtoseconds.c| 33 +++
 cpukit/rtems/src/clocktodvalidate.c | 62 ++-
 cpukit/rtems/src/taskwakewhen.c |  2 +-
 cpukit/rtems/src/timercreate.c  |  2 +-
 cpukit/score/src/coretodadjust.c| 12 +++-
 cpukit/score/src/coretodcheck.c | 59 ++
 cpukit/score/src/coretodset.c   | 22 +--
 cpukit/score/src/coretodtickspersec.c   | 30 --
 spec/build/cpukit/librtemscpu.yml   |  2 +-
 testsuites/psxtests/psxclock/init.c | 15 +
 testsuites/sptests/sp2038/init.c| 47 +++
 testsuites/sptests/spclock_err02/init.c |  8 +--
 testsuites/sptests/sptask_err02/init.c  |  5 +-
 23 files changed, 222 insertions(+), 220 deletions(-)
 create mode 100644 cpukit/score/src/coretodcheck.c
 delete mode 100644 cpukit/score/src/coretodtickspersec.c

-- 
2.26.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/7] score: Return status in _TOD_Adjust()

2021-09-03 Thread Sebastian Huber
---
 cpukit/include/rtems/score/todimpl.h | 5 -
 cpukit/posix/src/adjtime.c   | 6 +-
 cpukit/score/src/coretodadjust.c | 7 +--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/cpukit/include/rtems/score/todimpl.h 
b/cpukit/include/rtems/score/todimpl.h
index 316a56ec74..02a7fb1092 100644
--- a/cpukit/include/rtems/score/todimpl.h
+++ b/cpukit/include/rtems/score/todimpl.h
@@ -337,8 +337,11 @@ RTEMS_INLINE_ROUTINE void _TOD_Get_timeval(
  * specified amount.
  *
  * @param delta is the amount to adjust.
+ *
+ * @retval STATUS_SUCCESSFUL Successful operation.
+ * @retval other Some error occurred.
  */
-void _TOD_Adjust(
+Status_Control _TOD_Adjust(
   const struct timespec *delta
 );
 
diff --git a/cpukit/posix/src/adjtime.c b/cpukit/posix/src/adjtime.c
index ab61693f19..ec8cb19a2e 100644
--- a/cpukit/posix/src/adjtime.c
+++ b/cpukit/posix/src/adjtime.c
@@ -44,6 +44,7 @@ int adjtime(
 )
 {
   struct timespec delta_as_timespec;
+  Status_Control  status;
 
   /*
* Simple validations
@@ -83,7 +84,10 @@ int adjtime(
   /*
* Now apply the adjustment
*/
-  _TOD_Adjust( &delta_as_timespec );
+  status = _TOD_Adjust( &delta_as_timespec );
+  if ( status != STATUS_SUCCESSFUL ) {
+rtems_set_errno_and_return_minus_one( STATUS_GET_POSIX( status ) );
+  }
 
   return 0;
 }
diff --git a/cpukit/score/src/coretodadjust.c b/cpukit/score/src/coretodadjust.c
index a746b0e004..90c99803e1 100644
--- a/cpukit/score/src/coretodadjust.c
+++ b/cpukit/score/src/coretodadjust.c
@@ -22,12 +22,13 @@
 
 #include 
 
-void _TOD_Adjust(
+Status_Control _TOD_Adjust(
   const struct timespec *delta
 )
 {
   ISR_lock_Context lock_context;
   struct timespec  tod;
+  Status_Control   status;
 
   /*
* Currently, RTEMS does the adjustment in one movement.
@@ -41,6 +42,8 @@ void _TOD_Adjust(
   _TOD_Acquire( &lock_context );
   _TOD_Get( &tod );
   _Timespec_Add_to( &tod, delta );
-  _TOD_Set( &tod, &lock_context );
+  status = _TOD_Set( &tod, &lock_context );
   _TOD_Unlock();
+
+  return status;
 }
-- 
2.26.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 5/7] score: Simplify _TOD_Validate()

2021-09-03 Thread Sebastian Huber
Split up the multi line if statement into smaller parts.
---
 cpukit/rtems/src/clocktodvalidate.c | 34 +
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/cpukit/rtems/src/clocktodvalidate.c 
b/cpukit/rtems/src/clocktodvalidate.c
index 14b3f79d8e..0e3b5772b5 100644
--- a/cpukit/rtems/src/clocktodvalidate.c
+++ b/cpukit/rtems/src/clocktodvalidate.c
@@ -51,15 +51,31 @@ rtems_status_code _TOD_Validate(
   ticks_per_second = rtems_clock_get_ticks_per_second();
   ticks_mask = (uint32_t) ticks_validation;
 
-  if ( ( ( the_tod->ticks & ticks_mask ) >= ticks_per_second ) ||
-  (the_tod->second >= TOD_SECONDS_PER_MINUTE) ||
-  (the_tod->minute >= TOD_MINUTES_PER_HOUR)   ||
-  (the_tod->hour   >= TOD_HOURS_PER_DAY)  ||
-  (the_tod->month  == 0)  ||
-  (the_tod->month  >  TOD_MONTHS_PER_YEAR)||
-  (the_tod->year   <  TOD_BASE_YEAR)  ||
-  (the_tod->year   >  TOD_LATEST_YEAR)||
-  (the_tod->day== 0) ) {
+  if ( ( the_tod->ticks & ticks_mask ) >= ticks_per_second ) {
+return RTEMS_INVALID_CLOCK;
+  }
+
+  if ( the_tod->second >= TOD_SECONDS_PER_MINUTE ) {
+return RTEMS_INVALID_CLOCK;
+  }
+
+  if ( the_tod->minute >= TOD_MINUTES_PER_HOUR ) {
+return RTEMS_INVALID_CLOCK;
+  }
+
+  if ( the_tod->hour >= TOD_HOURS_PER_DAY ) {
+return RTEMS_INVALID_CLOCK;
+  }
+
+  if ( the_tod->month == 0 || the_tod->month > TOD_MONTHS_PER_YEAR ) {
+return RTEMS_INVALID_CLOCK;
+  }
+
+  if ( the_tod->year < TOD_BASE_YEAR || the_tod->year > TOD_LATEST_YEAR ) {
+return RTEMS_INVALID_CLOCK;
+  }
+
+  if ( the_tod->day == 0 ) {
 return RTEMS_INVALID_CLOCK;
   }
 
-- 
2.26.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/7] score: Remove TOD_TICKS_PER_SECOND_method()

2021-09-03 Thread Sebastian Huber
Use _Watchdog_Ticks_per_second instead.
---
 cpukit/Makefile.am|  1 -
 cpukit/include/rtems/score/todimpl.h  | 20 ++
 cpukit/score/src/coretodtickspersec.c | 30 ---
 spec/build/cpukit/librtemscpu.yml |  1 -
 4 files changed, 2 insertions(+), 50 deletions(-)
 delete mode 100644 cpukit/score/src/coretodtickspersec.c

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 1afac8f7dc..cc6bd48a9b 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -1004,7 +1004,6 @@ librtemscpu_a_SOURCES += 
score/src/timespecdividebyinteger.c
 librtemscpu_a_SOURCES += score/src/timespecgetasnanoseconds.c
 librtemscpu_a_SOURCES += score/src/coretod.c
 librtemscpu_a_SOURCES += score/src/coretodset.c
-librtemscpu_a_SOURCES += score/src/coretodtickspersec.c
 librtemscpu_a_SOURCES += score/src/coretodadjust.c
 librtemscpu_a_SOURCES += score/src/watchdoginsert.c
 librtemscpu_a_SOURCES += score/src/coretodhookdata.c
diff --git a/cpukit/include/rtems/score/todimpl.h 
b/cpukit/include/rtems/score/todimpl.h
index 02a7fb1092..5346f12e53 100644
--- a/cpukit/include/rtems/score/todimpl.h
+++ b/cpukit/include/rtems/score/todimpl.h
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -295,27 +296,10 @@ static inline uint32_t _TOD_Seconds_since_epoch( void )
   return (uint32_t) _Timecounter_Time_second;
 }
 
-/**
- * @brief Gets number of ticks in a second.
- *
- * This method returns the number of ticks in a second.
- *
- * @note If the clock tick value does not multiply evenly into a second
- *   then this number of ticks will be slightly shorter than a second.
- *
- * @return The number of ticks in a second.
- */
-uint32_t TOD_TICKS_PER_SECOND_method(void);
-
 /**
  *  @brief Gets number of ticks in a second.
- *
- *  This method exists to hide the fact that TOD_TICKS_PER_SECOND can not
- *  be implemented as a macro in a .h file due to visibility issues.
- *  The Configuration Table is not available to SuperCore .h files but
- *  is available to their .c files.
  */
-#define TOD_TICKS_PER_SECOND TOD_TICKS_PER_SECOND_method()
+#define TOD_TICKS_PER_SECOND _Watchdog_Ticks_per_second
 
 /**
  * @brief This routine returns a timeval based upon the internal timespec
diff --git a/cpukit/score/src/coretodtickspersec.c 
b/cpukit/score/src/coretodtickspersec.c
deleted file mode 100644
index f4860975bc..00
--- a/cpukit/score/src/coretodtickspersec.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @file
- *
- * @ingroup RTEMSScoreTOD
- *
- * @brief This source file contains the implementation of
- *   TOD_TICKS_PER_SECOND_method().
- */
-
-/*  COPYRIGHT (c) 1989-2014.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include 
-#include 
-
-uint32_t TOD_TICKS_PER_SECOND_method(void)
-{
-  return (TOD_MICROSECONDS_PER_SECOND /
-  rtems_configuration_get_microseconds_per_tick());
-}
diff --git a/spec/build/cpukit/librtemscpu.yml 
b/spec/build/cpukit/librtemscpu.yml
index 48266d408b..80fba92483 100644
--- a/spec/build/cpukit/librtemscpu.yml
+++ b/spec/build/cpukit/librtemscpu.yml
@@ -1395,7 +1395,6 @@ source:
 - cpukit/score/src/coretodhookrun.c
 - cpukit/score/src/coretodhookunregister.c
 - cpukit/score/src/coretodset.c
-- cpukit/score/src/coretodtickspersec.c
 - cpukit/score/src/debugisthreaddispatchingallowed.c
 - cpukit/score/src/freechain.c
 - cpukit/score/src/futex.c
-- 
2.26.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/7] score: Add _TOD_Is_valid_new_time_of_day()

2021-09-03 Thread Sebastian Huber
Move the TOD validation to the callers of _TOD_Set().  This avoids dead code in
case only rtems_clock_set() is used in an application because rtems_clock_set()
always calls _TOD_Set() with a valid time of day.
---
 cpukit/Makefile.am   |  1 +
 cpukit/include/rtems/score/todimpl.h | 14 ++-
 cpukit/posix/src/clocksettime.c  |  5 +++
 cpukit/score/src/coretodadjust.c |  7 +++-
 cpukit/score/src/coretodcheck.c  | 59 
 cpukit/score/src/coretodset.c| 22 +--
 spec/build/cpukit/librtemscpu.yml|  1 +
 7 files changed, 87 insertions(+), 22 deletions(-)
 create mode 100644 cpukit/score/src/coretodcheck.c

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index cc6bd48a9b..a883941c9a 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -1005,6 +1005,7 @@ librtemscpu_a_SOURCES += 
score/src/timespecgetasnanoseconds.c
 librtemscpu_a_SOURCES += score/src/coretod.c
 librtemscpu_a_SOURCES += score/src/coretodset.c
 librtemscpu_a_SOURCES += score/src/coretodadjust.c
+librtemscpu_a_SOURCES += score/src/coretodcheck.c
 librtemscpu_a_SOURCES += score/src/watchdoginsert.c
 librtemscpu_a_SOURCES += score/src/coretodhookdata.c
 librtemscpu_a_SOURCES += score/src/coretodhookregister.c
diff --git a/cpukit/include/rtems/score/todimpl.h 
b/cpukit/include/rtems/score/todimpl.h
index 5346f12e53..ceeef2e21b 100644
--- a/cpukit/include/rtems/score/todimpl.h
+++ b/cpukit/include/rtems/score/todimpl.h
@@ -206,13 +206,25 @@ static inline void _TOD_Release( ISR_lock_Context 
*lock_context )
   _Timecounter_Release( lock_context );
 }
 
+/**
+ * @brief Checks the time point is a valid new time of day for _TOD_Set().
+ *
+ * @param tod the time of day to check.
+ *
+ * @retval STATUS_SUCCESSFUL The time of day is valid.
+ *
+ * @retval STATUS_INVALID_NUMBER The time of day is invalid.
+ */
+Status_Control _TOD_Is_valid_new_time_of_day( const struct timespec *tod );
+
 /**
  * @brief Sets the time of day.
  *
  * The caller must be the owner of the TOD lock.
  *
  * @param tod The new time of day in timespec format representing
- *   the time since UNIX Epoch.
+ *   the time since UNIX Epoch.  The new time of day shall be valid according
+ *   to _TOD_Is_valid_new_time_of_day().
  * @param lock_context The ISR lock context used for the corresponding
  *   _TOD_Acquire().  The caller must be the owner of the TOD lock.  This
  *   function will release the TOD lock.
diff --git a/cpukit/posix/src/clocksettime.c b/cpukit/posix/src/clocksettime.c
index 53e728762e..23bb14a86d 100644
--- a/cpukit/posix/src/clocksettime.c
+++ b/cpukit/posix/src/clocksettime.c
@@ -41,6 +41,11 @@ int clock_settime(
   if ( clock_id == CLOCK_REALTIME ) {
 ISR_lock_Context lock_context;
 
+status = _TOD_Is_valid_new_time_of_day( tp );
+if ( status != STATUS_SUCCESSFUL ) {
+  rtems_set_errno_and_return_minus_one( STATUS_GET_POSIX( status ) );
+}
+
 _TOD_Lock();
 _TOD_Acquire( &lock_context );
   status = _TOD_Set( tp, &lock_context );
diff --git a/cpukit/score/src/coretodadjust.c b/cpukit/score/src/coretodadjust.c
index 90c99803e1..b048aeee71 100644
--- a/cpukit/score/src/coretodadjust.c
+++ b/cpukit/score/src/coretodadjust.c
@@ -42,7 +42,12 @@ Status_Control _TOD_Adjust(
   _TOD_Acquire( &lock_context );
   _TOD_Get( &tod );
   _Timespec_Add_to( &tod, delta );
-  status = _TOD_Set( &tod, &lock_context );
+  status = _TOD_Is_valid_new_time_of_day( &tod );
+
+  if ( status == STATUS_SUCCESSFUL ) {
+status = _TOD_Set( &tod, &lock_context );
+  }
+
   _TOD_Unlock();
 
   return status;
diff --git a/cpukit/score/src/coretodcheck.c b/cpukit/score/src/coretodcheck.c
new file mode 100644
index 00..b42435aa43
--- /dev/null
+++ b/cpukit/score/src/coretodcheck.c
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreTOD
+ *
+ * @brief This source file contains the implementation of
+ *   _TOD_Is_valid_new_time_of_day().
+ */
+
+/*
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ 

[PATCH 7/7] score: Change TOD_LATEST_YEAR to 2099

2021-09-03 Thread Sebastian Huber
This simplifies the implementation a bit.  Declare _TOD_Days_to_date[] in
.  Make _TOD_Days_per_month[] and
_TOD_Days_since_last_leap_year[] static.

Update #4338.
---
 bsps/bfin/shared/dev/rtc.c  |  9 ++
 cpukit/include/rtems/score/todimpl.h| 31 --
 cpukit/rtems/src/clockgettod.c  |  6 ++--
 cpukit/rtems/src/clocktodtoseconds.c| 33 +--
 cpukit/rtems/src/clocktodvalidate.c | 18 +--
 testsuites/sptests/sp2038/init.c| 43 +++--
 testsuites/sptests/spclock_err02/init.c |  8 ++---
 7 files changed, 58 insertions(+), 90 deletions(-)

diff --git a/bsps/bfin/shared/dev/rtc.c b/bsps/bfin/shared/dev/rtc.c
index cb15ca0607..e3fb48b4bf 100644
--- a/bsps/bfin/shared/dev/rtc.c
+++ b/bsps/bfin/shared/dev/rtc.c
@@ -22,11 +22,6 @@
 #include 
 #include 
 
-/* The following are inside RTEMS -- we are violating visibility!!!
- * Perhaps an API could be defined to get days since 1 Jan.
- */
-extern const uint16_t   _TOD_Days_to_date[2][13];
-
 /*
  *  Prototypes and routines used below
  */
@@ -75,7 +70,7 @@ int setRealTime(
   tod_temp = *tod;
 
   days = (tod_temp.year - TOD_BASE_YEAR) * 365 + \
-  _TOD_Days_to_date[0][tod_temp.month] + tod_temp.day - 1;
+  _TOD_Days_to_date[1][tod_temp.month] + tod_temp.day - 1;
   if (tod_temp.month < 3)
 days +=  Leap_years_until_now (tod_temp.year - 1);
   else
@@ -115,7 +110,7 @@ void getRealTime(
 
   /* finding month and day */
   Leap_year = (((!(tod_temp.year%4)) && (tod_temp.year%100)) ||
-  (!(tod_temp.year%400)))?1:0;
+  (!(tod_temp.year%400)))?0:1;
   for (n=1; n<=12; n++) {
 if (days <= _TOD_Days_to_date[Leap_year][n+1]) {
   tod_temp.month = n;
diff --git a/cpukit/include/rtems/score/todimpl.h 
b/cpukit/include/rtems/score/todimpl.h
index f85689fd9c..acfec00186 100644
--- a/cpukit/include/rtems/score/todimpl.h
+++ b/cpukit/include/rtems/score/todimpl.h
@@ -142,12 +142,16 @@ extern "C" {
  *  32 bits can accept as latest point in time 2106-Feb-7 6:28:15
  *  but to simplify the implementation, is was decided to only
  *  check that the year is not greater than the year of this constant.
+ *  The year 2099 was chosen because all years evenly divisible by 4 from 1988
+ *  to 2099 are leap years.  In this time frame, years evenly divisible by 100
+ *  are no leap years unless they are evenly divisible by 400.  Thus the year
+ *  2000 is a leap year.
  *
- *  The internal realtime clock can run centuries longer but in
+ *  The internal CLOCK_REALTIME can run centuries longer but in
  *  contrast to the POSIX API, the RTEMS Classic API does not
  *  support this for efficiency reasons.
  */
-#define TOD_LATEST_YEAR 2105
+#define TOD_LATEST_YEAR 2099
 
 /**
  * @addtogroup RTEMSScoreTOD
@@ -175,6 +179,14 @@ typedef struct {
  */
 extern TOD_Control _TOD;
 
+/**
+ * @brief This array contains the number of days in all months up to the month
+ *   indicated by the index of the second dimension.
+ *
+ * The first dimension should be 0 for leap years, and 1 otherwise.
+ */
+extern const uint16_t _TOD_Days_to_date[ 2 ][ 13 ];
+
 /**
  * @brief Locks the time of day mutex.
  */
@@ -215,6 +227,21 @@ static inline void _TOD_Release( ISR_lock_Context 
*lock_context )
   _Timecounter_Release( lock_context );
 }
 
+/**
+ * @brief Maps the year to the leap year index.
+ *
+ * @param year is the year to map.
+ *
+ * @retval 0 The year is a leap year.
+ *
+ * @retval 1 The year is not a leap year.
+ */
+static inline size_t _TOD_Get_leap_year_index( uint32_t year )
+{
+  _Assert( year % 4 != 0 || year % 100 != 0 || year % 400 == 0 );
+  return ( ( year % 4 ) + 3 ) / 4;
+}
+
 /**
  * @brief Checks the time point is a valid new time of day for _TOD_Set().
  *
diff --git a/cpukit/rtems/src/clockgettod.c b/cpukit/rtems/src/clockgettod.c
index dea136d477..5058b42375 100644
--- a/cpukit/rtems/src/clockgettod.c
+++ b/cpukit/rtems/src/clockgettod.c
@@ -32,8 +32,6 @@
 #define RTEMS_DAYS_PER_YEAR   (365UL)
 #define RTEMS_YEAR_BASE   (1970UL)
 
-extern const uint16_t _TOD_Days_to_date[2][13];
-
 static bool _Leap_year(
   uint32_t year
 )
@@ -64,9 +62,9 @@ static uint32_t _Year_day_as_month(
   uint32_tmonth = 0;
 
   if ( _Leap_year( year ) )
-days_to_date = _TOD_Days_to_date[1];
-  else
 days_to_date = _TOD_Days_to_date[0];
+  else
+days_to_date = _TOD_Days_to_date[1];
 
   days_to_date += 2;
 
diff --git a/cpukit/rtems/src/clocktodtoseconds.c 
b/cpukit/rtems/src/clocktodtoseconds.c
index 86e89f86eb..43bf6c59c5 100644
--- a/cpukit/rtems/src/clocktodtoseconds.c
+++ b/cpukit/rtems/src/clocktodtoseconds.c
@@ -23,16 +23,9 @@
 #include 
 #include 
 
-#define TOD_SECONDS_AT_2100_03_01_00_00 4107542400UL
-
-/*
- *  The following array contains the number of days in all months
- *  up to the month indicated by the index of the second dimension.
- *  The first dimension should be 1 for leap years, and 0 otherwise.
- */
-const uint16_t   _

[PATCH] c-user: Document time of day constraints

2021-09-03 Thread Sebastian Huber
Close #4338.
---
 c-user/clock/directives.rst | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/c-user/clock/directives.rst b/c-user/clock/directives.rst
index e0f858a..50272ba 100644
--- a/c-user/clock/directives.rst
+++ b/c-user/clock/directives.rst
@@ -70,10 +70,15 @@ Sets the :term:`CLOCK_REALTIME` to the time of day.
 The date, time, and ticks specified by ``time_of_day`` are all range-checked,
 and an error is returned if any one is out of its valid range.
 
-RTEMS can represent time points of this clock in nanoseconds ranging from
-1988-01-01T00:00:00.0Z to 2514-05-31T01:53:03.9Z.  The future
-uptime of the system shall be in this range, otherwise the system behaviour is
-undefined.
+RTEMS can represent time points of the :term:`CLOCK_REALTIME` clock in
+nanoseconds ranging from 1988-01-01T00:00:00.0Z to
+2514-05-31T01:53:03.9Z.  The future uptime of the system shall be in
+this range, otherwise the system behaviour is undefined.  Due to implementation
+constraints, the time of day set by the directive shall be before
+2100-01-01:00:00.0Z.  The latest valid time of day accepted by the
+POSIX `clock_settime()
+`_
+is 2400-01-01T00:00:00.0Z.
 
 The specified time is based on the configured :term:`clock tick` rate, see the
 :ref:`CONFIGURE_MICROSECONDS_PER_TICK` application configuration option.
@@ -102,6 +107,12 @@ The following constraints apply to this directive:
 * The directive may unblock a task.  This may cause the calling task to be
   preempted.
 
+* The time of day set by the directive shall be 1988-01-01T00:00:00.0Z
+  or later.
+
+* The time of day set by the directive shall be before
+  2100-01-01T00:00:00.0Z.
+
 .. Generated from spec:/rtems/clock/if/get-tod
 
 .. raw:: latex
-- 
2.31.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Ryan Long
Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to aarch64 tool
builds with newlib.
---
 rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
index 69c4fb5..3594d1c 100644
--- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
@@ -13,6 +13,9 @@
 %patch add gcc -p1 
https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
 %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
 
+%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
+%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
ad183b6c9a168d1d751505e64873f117c11fb059819d341c5d715619985b285c324ef27c1177c6300088df7bbe3aebd7fa034034c3892f2bf6ec57324c9b1e2a
+
 %define newlib_version 4f81149
 %define newlib_external 1
 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] score: Split up rbtreenext.c

2021-09-03 Thread Sebastian Huber
Split up rbtreenext.c since only _RBTree_Minimum() is used by the operating
system core services (thread queues and the EDF scheduler).

Change license to BSD-2-Clause according to file history and re-licensing
agreement.

Update #3053.
---
 cpukit/Makefile.am|  3 ++
 cpukit/score/src/rbtreemax.c  | 55 +++
 cpukit/score/src/rbtreemin.c  | 55 +++
 cpukit/score/src/rbtreenext.c | 48 +++
 cpukit/score/src/rbtreeprev.c | 47 ++
 spec/build/cpukit/librtemscpu.yml |  3 ++
 6 files changed, 183 insertions(+), 28 deletions(-)
 create mode 100644 cpukit/score/src/rbtreemax.c
 create mode 100644 cpukit/score/src/rbtreemin.c
 create mode 100644 cpukit/score/src/rbtreeprev.c

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index a883941c9a..35de56615d 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -952,8 +952,11 @@ librtemscpu_a_SOURCES += score/src/freechain.c
 librtemscpu_a_SOURCES += score/src/rbtreeextract.c
 librtemscpu_a_SOURCES += score/src/rbtreeinsert.c
 librtemscpu_a_SOURCES += score/src/rbtreeiterate.c
+librtemscpu_a_SOURCES += score/src/rbtreemax.c
+librtemscpu_a_SOURCES += score/src/rbtreemin.c
 librtemscpu_a_SOURCES += score/src/rbtreenext.c
 librtemscpu_a_SOURCES += score/src/rbtreepostorder.c
+librtemscpu_a_SOURCES += score/src/rbtreeprev.c
 librtemscpu_a_SOURCES += score/src/rbtreereplace.c
 librtemscpu_a_SOURCES += score/src/threadallocateunlimited.c
 librtemscpu_a_SOURCES += score/src/thread.c
diff --git a/cpukit/score/src/rbtreemax.c b/cpukit/score/src/rbtreemax.c
new file mode 100644
index 00..1b0e463aa2
--- /dev/null
+++ b/cpukit/score/src/rbtreemax.c
@@ -0,0 +1,55 @@
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreRBTree
+ *
+ * @brief This source file contains the implementation of
+ *   _RBTree_Maximum().
+ */
+
+/*
+ * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+
+RBTree_Node *_RBTree_Maximum( const RBTree_Control *tree )
+{
+  RBTree_Node *parent;
+  RBTree_Node *node;
+
+  parent = NULL;
+  node = _RBTree_Root( tree );
+
+  while ( node != NULL ) {
+parent = node;
+node = _RBTree_Right( node );
+  }
+
+  return parent;
+}
diff --git a/cpukit/score/src/rbtreemin.c b/cpukit/score/src/rbtreemin.c
new file mode 100644
index 00..b3cd4331c1
--- /dev/null
+++ b/cpukit/score/src/rbtreemin.c
@@ -0,0 +1,55 @@
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreRBTree
+ *
+ * @brief This source file contains the implementation of
+ *   _RBTree_Minimum().
+ */
+
+/*
+ * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUE

[PATCH] score: Move _Thread_Dispatch()

2021-09-03 Thread Sebastian Huber
The _Thread_Dispatch() function was customized over time and now the
work is done by _Thread_Do_dispatch() and specialized wrappers.  The
plain _Thread_Dispatch() is now only used in some CPU ports.  Move it to
a separate file to avoid dead code in the general.

Change license to BSD-2-Clause according to file history and
re-licensing agreement.

Update #3053.
---
 cpukit/Makefile.am |  1 +
 cpukit/score/src/threaddispatch.c  | 21 +
 cpukit/score/src/threadplaindispatch.c | 60 ++
 spec/build/cpukit/librtemscpu.yml  |  1 +
 4 files changed, 63 insertions(+), 20 deletions(-)
 create mode 100644 cpukit/score/src/threadplaindispatch.c

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 1afac8f7dc..93100b5e5a 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -966,6 +966,7 @@ librtemscpu_a_SOURCES += score/src/threadhandler.c
 librtemscpu_a_SOURCES += score/src/threadinitialize.c
 librtemscpu_a_SOURCES += score/src/threadidledefault.c
 librtemscpu_a_SOURCES += score/src/threadloadenv.c
+librtemscpu_a_SOURCES += score/src/threadplaindispatch.c
 librtemscpu_a_SOURCES += score/src/threadrestart.c
 librtemscpu_a_SOURCES += score/src/threadselfid.c
 librtemscpu_a_SOURCES += score/src/threadsetstate.c
diff --git a/cpukit/score/src/threaddispatch.c 
b/cpukit/score/src/threaddispatch.c
index fd3f4eda4d..1d317ad2b1 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -5,7 +5,7 @@
  *
  * @brief This source file contains the definition of ::_Thread_Allocated_fp
  *   and ::_User_extensions_Switches_list and the implementation of
- *   _Thread_Dispatch(), _Thread_Dispatch_direct(), _Thread_Dispatch_enable(),
+ *   _Thread_Dispatch_direct(), _Thread_Dispatch_enable(),
  *   and _Thread_Do_dispatch().
  */
 
@@ -327,25 +327,6 @@ post_switch:
   _Thread_Run_post_switch_actions( executing );
 }
 
-void _Thread_Dispatch( void )
-{
-  ISR_Levellevel;
-  Per_CPU_Control *cpu_self;
-
-  _ISR_Local_disable( level );
-
-  cpu_self = _Per_CPU_Get();
-
-  if ( cpu_self->dispatch_necessary ) {
-_Profiling_Thread_dispatch_disable( cpu_self, 0 );
-_Assert( cpu_self->thread_dispatch_disable_level == 0 );
-cpu_self->thread_dispatch_disable_level = 1;
-_Thread_Do_dispatch( cpu_self, level );
-  } else {
-_ISR_Local_enable( level );
-  }
-}
-
 void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self )
 {
   ISR_Level level;
diff --git a/cpukit/score/src/threadplaindispatch.c 
b/cpukit/score/src/threadplaindispatch.c
new file mode 100644
index 00..eeb52ec42d
--- /dev/null
+++ b/cpukit/score/src/threadplaindispatch.c
@@ -0,0 +1,60 @@
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreThread
+ *
+ * @brief This source file contains the implementation of _Thread_Dispatch().
+ */
+
+/*
+ * Copyright (C) 2015, 2017 embedded brains GmbH 
(http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+
+void _Thread_Dispatch( void )
+{
+  ISR_Levellevel;
+  Per_CPU_Control *cpu_self;
+
+  _ISR_Local_disable( level );
+
+  cpu_self = _Per_CPU_Get();
+
+  if ( cpu_self->dispatch_necessary ) {
+_Profiling_Thread_dispatch_disable( cpu_self, 0 );
+_Assert( cpu_self->thread_dispatch_disable_level == 0 );
+cpu_self->thread_dispatch_disable_level = 1;
+_Thread_Do_dispatch( cpu_self, level );
+  } else {
+_ISR_Local_enable( level );
+  }
+}
diff --git a/spec/build/cpukit/librtemscpu.yml 
b/spec/build/cpukit/librtemscpu.yml
index 48266d408b..c03323379d 100644
--- a/spec/build/cpukit/librtemscpu.yml
+++ b/spec/build/cpukit/

Re: [PATCH RSB] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Joel Sherrill
On Fri, Sep 3, 2021 at 9:27 AM Ryan Long  wrote:
>
> Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to aarch64 tool
> builds with newlib.

This doesn't explain why. This patch is needed to prevent the use of
the assembly
versions of some methods in newlib which are incorrect for ilp32. This
can be removed
when those methods are updated from ARM. Newlib is quite behind ARM for these
methods and that will require work from an ARM Newlib person.

Updates #4215,

Improve the comment and ensure the ticket is clear that this is temporary for
those reasons.

> ---
>  rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
> b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
> index 69c4fb5..3594d1c 100644
> --- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
> +++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
> @@ -13,6 +13,9 @@
>  %patch add gcc -p1 
> https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
>  %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
> afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
>
> +%patch add newlib -p1 
> https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
> +%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
> ad183b6c9a168d1d751505e64873f117c11fb059819d341c5d715619985b285c324ef27c1177c6300088df7bbe3aebd7fa034034c3892f2bf6ec57324c9b1e2a
> +

Looks like you forgot to use sha512-base64


>  %define newlib_version 4f81149
>  %define newlib_external 1
>  %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
> --
> 1.8.3.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH RSB] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Joel Sherrill
You also should add the patch in the gcc-head-newlib-head
configuration as well for rtems7 tools.

--joel

On Fri, Sep 3, 2021 at 11:01 AM Joel Sherrill  wrote:
>
> On Fri, Sep 3, 2021 at 9:27 AM Ryan Long  wrote:
> >
> > Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to aarch64 tool
> > builds with newlib.
>
> This doesn't explain why. This patch is needed to prevent the use of
> the assembly
> versions of some methods in newlib which are incorrect for ilp32. This
> can be removed
> when those methods are updated from ARM. Newlib is quite behind ARM for these
> methods and that will require work from an ARM Newlib person.
>
> Updates #4215,
>
> Improve the comment and ensure the ticket is clear that this is temporary for
> those reasons.
>
> > ---
> >  rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
> > b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
> > index 69c4fb5..3594d1c 100644
> > --- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
> > +++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
> > @@ -13,6 +13,9 @@
> >  %patch add gcc -p1 
> > https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
> >  %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
> > afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
> >
> > +%patch add newlib -p1 
> > https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
> > +%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
> > ad183b6c9a168d1d751505e64873f117c11fb059819d341c5d715619985b285c324ef27c1177c6300088df7bbe3aebd7fa034034c3892f2bf6ec57324c9b1e2a
> > +
>
> Looks like you forgot to use sha512-base64
>
>
> >  %define newlib_version 4f81149
> >  %define newlib_external 1
> >  %define newlib_expand_name 
> > sourceware-mirror-newlib-cygwin-%{newlib_version}
> > --
> > 1.8.3.1
> >
> > ___
> > devel mailing list
> > devel@rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB v2 2/2] rtems-gcc-head-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Ryan Long
Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to AArch64 tools
builds with newlib. This forces the generation of AArch64 assembly from
C sources instead of using the hand-optimized code in newlib since it
does not support ILP32. This can be removed when it is fixed upstream.

Updates #4510
---
 rtems/config/tools/rtems-gcc-head-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
index 4939ca5..c17895b 100644
--- a/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-head-newlib-head.cfg
@@ -12,6 +12,9 @@
 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
 %source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz 
https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.gz/%{newlib_version}
 %hash sha512 newlib-%{newlib_version}.tar.gz 
9ded46b3077508ef05bbb4bf424777a0baa5aab9c7c0c902fb5529bb73b5b5034c35282e2dbf270cbcd44d84940a20ee270e329db4e4b501046978c18f78a11c
+%
+%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
+%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
rRg7bJoWjR11FQXmSHPxF8EfsFmBnTQcXXFWGZhbKFwyTvJ8EXfGMACI33u+OuvX+gNANMOJLyv27FcyTJseKg==
 
 %define with_threads 1
 %define with_plugin 0
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RSB v2 1/2] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Ryan Long
Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to AArch64 tool
builds with newlib. This forces the generation of AArch64 assembly from
C sources instead of using the hand-optimized code in newlib since it
does not support ILP32. This can be removed when it is fixed upstream.

Updates #4510
---
 rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
index 69c4fb5..85308c5 100644
--- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
+++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
@@ -13,6 +13,9 @@
 %patch add gcc -p1 
https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
 %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
 
+%patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
+%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
rRg7bJoWjR11FQXmSHPxF8EfsFmBnTQcXXFWGZhbKFwyTvJ8EXfGMACI33u+OuvX+gNANMOJLyv27FcyTJseKg==
+
 %define newlib_version 4f81149
 %define newlib_external 1
 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version}
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Ticket #4203 clarification

2021-09-03 Thread zack leung
Say i find an exception (ex format string printing a decimal.) How do I
test that my improvement works?

Thanks
Zack

On Fri, 3 Sept 2021 at 01:36, Joel Sherrill  wrote:

> On Thu, Sep 2, 2021 at 8:01 PM zack leung 
> wrote:
> >
> > Hello!
> >
> > I'd like to begin working on 4203. It involves improving the exception
> output  I'd like to know how I spot exceptions that could be reported
> better by the system?   How do I also know how do I test it and what BSPs i
> can test with only my computer Also joel told me The list of exception
> number/names is in the manual for the architecture. For an i386 or later,
> that should be in many places. Where do i find the documentation of the
> bsps?
> >
>
> Bringing this over from chat.
>
> The methods are architecture specific and may be in score/cpu or
> bsps/shared or a specific BSP (hope now there). For an example,
> score/cpu/i386/cpu.c has an exception printer. It seems to be the one
> cited as an example that could be improved. The thread id is printed
> in decimal, not hex. The exception type is only printed as a number.
> This could be turned into a number and exception name. The list of
> exception number/names is in the manual for the architecture. For an
> i386 or later, that should be in many places. There is only so much
> information in the exception frame passed in, so just make it more
> useful. If you look on other architectures for similar exception
> printers, you may find some print RTEMS state. Perhaps that's common
> info that could be printed by a shared subroutine.
>
> For a manual, this is the grandparent for i386 info:
>
> https://css.csail.mit.edu/6.858/2014/readings/i386.pdf
>
> And yes, that is from 1986 and I think I have a paper copy that old.
> But all x86 info should be essentially the same as what's presented in
> there. There may be additions but that's the original root.
>
> I wouldn't look actively at other architecture exception handlers. You
> could easily get lost in the details of each architecture and
> confused. Focus on the i386 first and how it could be better. For
> example, taking the exception number of printing a string name so you
> don't have to look it up. You find the list in the manual.
>
> FWIW I think the PowerPC prints numbers also.
>
> The name of the handler may be architecture specific. Hopefully
> someone can point to some for other architectures. But a good solution
> on x86 would be a good start.
>
> --joel
>
> --joel
> > Thanks
> >
> > Zack
> > ___
> > devel mailing list
> > devel@rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v1 00/10] Convert and reformat rtems-tools pt. 1

2021-09-03 Thread Chris Johns
On 3/9/21 10:07 pm, Ryan Long wrote:
> I haven't been building these with clang, so I'll make sure to start doing 
> that. I've got a Macbook, so I can test it on there as well.

This great and thanks. I am amazed how each compiler and version of that
compiler generates new issues. On the positive side the code is getting cleaner.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH RSB] rtems-gcc-10-newlib-head.cfg: Add newlib patch

2021-09-03 Thread Chris Johns
Can we please join onto this an rtems-tools update so the recent fixes I pushed
can be picked up?

Thanks
Chris

On 4/9/21 2:40 am, Joel Sherrill wrote:
> You also should add the patch in the gcc-head-newlib-head
> configuration as well for rtems7 tools.
> 
> --joel
> 
> On Fri, Sep 3, 2021 at 11:01 AM Joel Sherrill  wrote:
>>
>> On Fri, Sep 3, 2021 at 9:27 AM Ryan Long  wrote:
>>>
>>> Adds patch to add the -DPREFER_SIZE_OVER_SPEED flag to aarch64 tool
>>> builds with newlib.
>>
>> This doesn't explain why. This patch is needed to prevent the use of
>> the assembly
>> versions of some methods in newlib which are incorrect for ilp32. This
>> can be removed
>> when those methods are updated from ARM. Newlib is quite behind ARM for these
>> methods and that will require work from an ARM Newlib person.
>>
>> Updates #4215,
>>
>> Improve the comment and ensure the ticket is clear that this is temporary for
>> those reasons.
>>
>>> ---
>>>  rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg 
>>> b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
>>> index 69c4fb5..3594d1c 100644
>>> --- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
>>> +++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg
>>> @@ -13,6 +13,9 @@
>>>  %patch add gcc -p1 
>>> https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch
>>>  %hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch 
>>> afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881
>>>
>>> +%patch add newlib -p1 
>>> https://devel.rtems.org/raw-attachment/ticket/4510/0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch
>>> +%hash sha512 0001-configure.host-Add-DPREFER_SIZE_OVER_SPEED.patch 
>>> ad183b6c9a168d1d751505e64873f117c11fb059819d341c5d715619985b285c324ef27c1177c6300088df7bbe3aebd7fa034034c3892f2bf6ec57324c9b1e2a
>>> +
>>
>> Looks like you forgot to use sha512-base64
>>
>>
>>>  %define newlib_version 4f81149
>>>  %define newlib_external 1
>>>  %define newlib_expand_name 
>>> sourceware-mirror-newlib-cygwin-%{newlib_version}
>>> --
>>> 1.8.3.1
>>>
>>> ___
>>> devel mailing list
>>> devel@rtems.org
>>> http://lists.rtems.org/mailman/listinfo/devel
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Does the arm/xilinx-zynqmp BSP work?

2021-09-03 Thread Chris Johns
Hi,

I am testing the console driver with the aarch64/xilinx_zynqmp_lp64_zu3eg BSP
when I saw the BSP.

Is this BSP still valid?

Does this BSP work on real hardware?

Who is looking after this BSP?

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 6/7] score: Always validate ticks in _TOD_Validate()

2021-09-03 Thread Chris Johns
On 3/9/21 11:33 pm, Sebastian Huber wrote:
> The behaviour with respect to the handling of the ticks member in the *_when()
> directives was inconsistent.  In all *_when() directives the ticks member is
> not used to calculate the watchdog expiration time.  However, the
> rtems_task_wake_when() directive ignores the ticks member of the time of day
> completely, unlike the rtems_timer_fire_when() and
> rtems_timer_server_fire_when() directives which check that the ticks are valid
> and then ignore them.
> 
> This commit changes _TOD_Validate() to unconditionally check the ticks value.
> Ignoring the value would make it more difficult to support the ticks in the
> future.  The watchdog implementation supports a nanoseconds resolution.
> Checking the ticks in rtems_task_wake_when() may case problems for existing
> applications which could now get an error status due to an invalid ticks 
> value.
> 
> Applications should set the ticks value to zero for future compatibility.  
> This
> recommendation needs to be added to the documentation.

What happens with existing applications that do not touch this value?

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 6/7] score: Always validate ticks in _TOD_Validate()

2021-09-03 Thread Chris Johns
On 3/9/21 11:33 pm, Sebastian Huber wrote:
> diff --git a/bsps/arm/altera-cyclone-v/rtc/rtc.c 
> b/bsps/arm/altera-cyclone-v/rtc/rtc.c
> index 779a093459..d1c12ee874 100644
> --- a/bsps/arm/altera-cyclone-v/rtc/rtc.c
> +++ b/bsps/arm/altera-cyclone-v/rtc/rtc.c
> @@ -353,7 +353,7 @@ static int altera_cyclone_v_ds1339_get_time(int minor, 
> rtems_time_of_day* tod)
>  temp_tod.month  = ds1339_get_month(&time);
>  temp_tod.year   = ds1339_get_year(&time);
>  
> -sc = _TOD_Validate(&temp_tod, TOD_ENABLE_TICKS_VALIDATION);
> +sc = _TOD_Validate(&temp_tod);

This has leaked out of the internal implementation interface. Should it?

I prefer this does not happen and BSPs use an API.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 6/7] score: Always validate ticks in _TOD_Validate()

2021-09-03 Thread Joel Sherrill
On Fri, Sep 3, 2021, 11:01 PM Chris Johns  wrote:

> On 3/9/21 11:33 pm, Sebastian Huber wrote:
> > The behaviour with respect to the handling of the ticks member in the
> *_when()
> > directives was inconsistent.  In all *_when() directives the ticks
> member is
> > not used to calculate the watchdog expiration time.  However, the
> > rtems_task_wake_when() directive ignores the ticks member of the time of
> day
> > completely, unlike the rtems_timer_fire_when() and
> > rtems_timer_server_fire_when() directives which check that the ticks are
> valid
> > and then ignore them.
> >
> > This commit changes _TOD_Validate() to unconditionally check the ticks
> value.
> > Ignoring the value would make it more difficult to support the ticks in
> the
> > future.  The watchdog implementation supports a nanoseconds resolution.
> > Checking the ticks in rtems_task_wake_when() may case problems for
> existing
> > applications which could now get an error status due to an invalid ticks
> value.
> >
> > Applications should set the ticks value to zero for future
> compatibility.  This
> > recommendation needs to be added to the documentation.
>
> What happens with existing applications that do not touch this value?
>

Randomly different behaviour.

Before all _when operations occurred on seconds boundaries.  This will
implicitly change that or return an error.

I'm not opposed to the improved granularity but hope it doesn't burn too
many users.

--joel

>
> Chris
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 6/7] score: Always validate ticks in _TOD_Validate()

2021-09-03 Thread Joel Sherrill
On Fri, Sep 3, 2021, 11:10 PM Chris Johns  wrote:

> On 3/9/21 11:33 pm, Sebastian Huber wrote:
> > diff --git a/bsps/arm/altera-cyclone-v/rtc/rtc.c
> b/bsps/arm/altera-cyclone-v/rtc/rtc.c
> > index 779a093459..d1c12ee874 100644
> > --- a/bsps/arm/altera-cyclone-v/rtc/rtc.c
> > +++ b/bsps/arm/altera-cyclone-v/rtc/rtc.c
> > @@ -353,7 +353,7 @@ static int altera_cyclone_v_ds1339_get_time(int
> minor, rtems_time_of_day* tod)
> >  temp_tod.month  = ds1339_get_month(&time);
> >  temp_tod.year   = ds1339_get_year(&time);
> >
> > -sc = _TOD_Validate(&temp_tod, TOD_ENABLE_TICKS_VALIDATION);
> > +sc = _TOD_Validate(&temp_tod);
>
> This has leaked out of the internal implementation interface. Should it?
>
> I prefer this does not happen and BSPs use an API.
>

I noticed this also. It needs an API.

>
> Chris
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 6/7] score: Always validate ticks in _TOD_Validate()

2021-09-03 Thread Chris Johns
On 4/9/21 2:20 pm, Joel Sherrill wrote:
 On Fri, Sep 3, 2021, 11:01 PM Chris Johns  > wrote:
> 
> On 3/9/21 11:33 pm, Sebastian Huber wrote:
> > The behaviour with respect to the handling of the ticks member in the 
> *_when()
> > directives was inconsistent.  In all *_when() directives the ticks 
> member is
> > not used to calculate the watchdog expiration time.  However, the
> > rtems_task_wake_when() directive ignores the ticks member of the time 
> of day
> > completely, unlike the rtems_timer_fire_when() and
> > rtems_timer_server_fire_when() directives which check that the ticks 
> are valid
> > and then ignore them.
> >
> > This commit changes _TOD_Validate() to unconditionally check the ticks 
> value.
> > Ignoring the value would make it more difficult to support the ticks in 
> the
> > future.  The watchdog implementation supports a nanoseconds resolution.
> > Checking the ticks in rtems_task_wake_when() may case problems for 
> existing
> > applications which could now get an error status due to an invalid ticks
> value.
> >
> > Applications should set the ticks value to zero for future 
> compatibility. 
> This
> > recommendation needs to be added to the documentation.
> 
> What happens with existing applications that do not touch this value?
> 
> 
> Randomly different behaviour.
> 
> Before all _when operations occurred on seconds boundaries.  This will
> implicitly change that or return an error.
> 
> I'm not opposed to the improved granularity but hope it doesn't burn too many 
> users.

What about the proposed behaviour being the default and a confdefs disable
being available for a release? Updating to a new version can be time consuming
and frustrating and a disable would at least let a user see if this is an issue
they need to take care of at a less pressured time?

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel