summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-14 08:09:34 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-14 08:09:34 +0200
commit45a34953256b237171a2ceea310b370b309cd29b (patch)
tree3e08a78dc8e758fa586509bb31761653c23f4de7
parentrtems: Constify rtems_task_wake_when() (diff)
downloadrtems-45a34953256b237171a2ceea310b370b309cd29b.tar.bz2
rtems: Add TOD_Ticks_validation
Replace defines with an enum. Update #4406.
Diffstat (limited to '')
-rw-r--r--cpukit/include/rtems/rtems/clockimpl.h31
-rw-r--r--cpukit/rtems/src/clocktodvalidate.c8
2 files changed, 24 insertions, 15 deletions
diff --git a/cpukit/include/rtems/rtems/clockimpl.h b/cpukit/include/rtems/rtems/clockimpl.h
index 404b8234ee..c8334afaf3 100644
--- a/cpukit/include/rtems/rtems/clockimpl.h
+++ b/cpukit/include/rtems/rtems/clockimpl.h
@@ -35,16 +35,22 @@ extern "C" {
*/
/**
- * @brief Using this constant for the ticks mask disables the validation of the
- * ticks member in _TOD_Validate().
+ * @brief The enumerators of this type determine if the ticks member is
+ * validated in _TOD_Validate().
*/
-#define TOD_DISABLE_TICKS_VALIDATION 0
+typedef enum {
+ /**
+ * @brief Use this option to disable the validation of the ticks member in
+ * _TOD_Validate().
+ */
+ TOD_DISABLE_TICKS_VALIDATION = 0,
-/**
- * @brief Using this constant for the ticks mask enables the validation of the
- * ticks member in _TOD_Validate().
- */
-#define TOD_ENABLE_TICKS_VALIDATION UINT32_MAX
+ /**
+ * @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.
@@ -52,9 +58,10 @@ extern "C" {
* @param the_tod is the reference to the time of day structure to validate or
* NULL.
*
- * @param ticks_mask is the mask for the ticks member of the time of day. Use
- * #TOD_ENABLE_TICKS_VALIDATION to validate the ticks member. Use
- * #TOD_DISABLE_TICKS_VALIDATION to skip the validation of the ticks member.
+ * @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.
@@ -62,7 +69,7 @@ extern "C" {
*/
rtems_status_code _TOD_Validate(
const rtems_time_of_day *the_tod,
- uint32_t ticks_mask
+ TOD_Ticks_validation ticks_validation
);
/**
diff --git a/cpukit/rtems/src/clocktodvalidate.c b/cpukit/rtems/src/clocktodvalidate.c
index 41a1167287..14b3f79d8e 100644
--- a/cpukit/rtems/src/clocktodvalidate.c
+++ b/cpukit/rtems/src/clocktodvalidate.c
@@ -37,17 +37,19 @@ const uint32_t _TOD_Days_per_month[ 2 ][ 13 ] = {
rtems_status_code _TOD_Validate(
const rtems_time_of_day *the_tod,
- uint32_t ticks_mask
+ TOD_Ticks_validation ticks_validation
)
{
- uint32_t days_in_month;
- uint32_t ticks_per_second;
+ uint32_t days_in_month;
+ uint32_t ticks_per_second;
+ uint32_t ticks_mask;
if ( the_tod == NULL ) {
return RTEMS_INVALID_ADDRESS;
}
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) ||