Changeset 523867d in rtems


Ignore:
Timestamp:
May 11, 2021, 3:27:20 PM (6 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
45a34953
Parents:
6136918d
git-author:
Sebastian Huber <sebastian.huber@…> (05/11/21 15:27:20)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/12/21 19:25:37)
Message:

rtems: Constify rtems_task_wake_when()

Add a parameter to _TOD_Validate() to disable the validation of the
ticks member.

There are two reasons for this change. Firstly, in
rtems_task_wake_when() was a double check for time_buffer == NULL (one
in rtems_task_wake_when() and one in _TOD_Validate()). Secondly, the
ticks member is ignored by rtems_task_wake_when(). This was done with a
write of zero to the ticks member and thus a modification of the
user-provided structure. Now the structure is no longer modified.
Using a mask parameter is quite efficient. You just have to load an
immediate value and there are no additional branches in _TOD_Validate().

Close #4406.

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/altera-cyclone-v/rtc/rtc.c

    r6136918d r523867d  
    354354    temp_tod.year   = ds1339_get_year(&time);
    355355
    356     sc = _TOD_Validate(&temp_tod)
     356    sc = _TOD_Validate(&temp_tod, TOD_ENABLE_TICKS_VALIDATION)
    357357    if (sc == RTEMS_SUCCESSFUL)
    358358      memcpy(tod, &temp_tod, sizeof(temp_tod));
  • bsps/shared/dev/rtc/rtc-support.c

    r6136918d r523867d  
    256256    return -1;
    257257
    258   if (_TOD_Validate(tod) != RTEMS_SUCCESSFUL)
     258  if (_TOD_Validate(tod, TOD_ENABLE_TICKS_VALIDATION) != RTEMS_SUCCESSFUL)
    259259    return -1;
    260260
  • cpukit/include/rtems/rtems/clockimpl.h

    r6136918d r523867d  
    3636
    3737/**
    38  * @brief TOD Validate
     38 * @brief Using this constant for the ticks mask disables the validation of the
     39 *   ticks member in _TOD_Validate().
     40 */
     41#define TOD_DISABLE_TICKS_VALIDATION 0
     42
     43/**
     44 * @brief Using this constant for the ticks mask enables the validation of the
     45 *   ticks member in _TOD_Validate().
     46 */
     47#define TOD_ENABLE_TICKS_VALIDATION UINT32_MAX
     48
     49/**
     50 * @brief Validates the time of day.
    3951 *
    40  * This support function tests whether @a the_tod references
    41  * a valid time of day.
     52 * @param the_tod is the reference to the time of day structure to validate or
     53 *   NULL.
    4254 *
    43  * @param the_tod A reference to the time of day structure to validate.
     55 * @param ticks_mask is the mask for the ticks member of the time of day.  Use
     56 *   #TOD_ENABLE_TICKS_VALIDATION to validate the ticks member.  Use
     57 *   #TOD_DISABLE_TICKS_VALIDATION to skip the validation of the ticks member.
    4458 *
    4559 * @retval RTEMS_SUCCESSFUL @a the_tod references a valid time of day.
     
    4862 */
    4963rtems_status_code _TOD_Validate(
    50   const rtems_time_of_day *the_tod
     64  const rtems_time_of_day *the_tod,
     65  uint32_t                 ticks_mask
    5166);
    5267
  • cpukit/include/rtems/rtems/tasks.h

    r6136918d r523867d  
    20722072 * @endparblock
    20732073 */
    2074 rtems_status_code rtems_task_wake_when( rtems_time_of_day *time_buffer );
     2074rtems_status_code rtems_task_wake_when( const rtems_time_of_day *time_buffer );
    20752075
    20762076/* Generated from spec:/rtems/task/if/get-scheduler */
  • cpukit/rtems/src/clockset.c

    r6136918d r523867d  
    3535  ISR_lock_Context  lock_context;
    3636
    37   status = _TOD_Validate( tod );
     37  status = _TOD_Validate( tod, TOD_ENABLE_TICKS_VALIDATION );
    3838
    3939  if ( status != RTEMS_SUCCESSFUL ) {
  • cpukit/rtems/src/clocktodvalidate.c

    r6136918d r523867d  
    3737
    3838rtems_status_code _TOD_Validate(
    39   const rtems_time_of_day *the_tod
     39  const rtems_time_of_day *the_tod,
     40  uint32_t                 ticks_mask
    4041)
    4142{
     
    4950  ticks_per_second = rtems_clock_get_ticks_per_second();
    5051
    51   if ((the_tod->ticks  >= ticks_per_second)      ||
     52  if ( ( ( the_tod->ticks & ticks_mask ) >= ticks_per_second ) ||
    5253      (the_tod->second >= TOD_SECONDS_PER_MINUTE) ||
    5354      (the_tod->minute >= TOD_MINUTES_PER_HOUR)   ||
  • cpukit/rtems/src/taskwakewhen.c

    r6136918d r523867d  
    2828
    2929rtems_status_code rtems_task_wake_when(
    30   rtems_time_of_day *time_buffer
     30  const rtems_time_of_day *time_buffer
    3131)
    3232{
     
    3939    return RTEMS_NOT_DEFINED;
    4040
    41   if ( !time_buffer )
    42     return RTEMS_INVALID_ADDRESS;
    43 
    44   time_buffer->ticks = 0;
    45   status = _TOD_Validate( time_buffer );
     41  status = _TOD_Validate( time_buffer, TOD_DISABLE_TICKS_VALIDATION );
    4642
    4743  if ( status != RTEMS_SUCCESSFUL ) {
  • cpukit/rtems/src/timercreate.c

    r6136918d r523867d  
    142142    return RTEMS_INVALID_ADDRESS;
    143143
    144   status = _TOD_Validate( wall_time );
     144  status = _TOD_Validate( wall_time, TOD_ENABLE_TICKS_VALIDATION );
    145145
    146146  if ( status != RTEMS_SUCCESSFUL ) {
  • testsuites/sptests/sp2038/init.c

    r6136918d r523867d  
    282282    const rtems_time_of_day *problem2 = &problem_2100_2;
    283283    // 2100 is not a leap year, so it should have 28 days
    284     test_status = _TOD_Validate(problem);
     284    test_status = _TOD_Validate(problem, TOD_ENABLE_TICKS_VALIDATION);
    285285    rtems_test_assert(test_status == RTEMS_SUCCESSFUL);
    286     test_status = _TOD_Validate(problem2);
     286    test_status = _TOD_Validate(problem2, TOD_ENABLE_TICKS_VALIDATION);
    287287    rtems_test_assert(test_status == RTEMS_INVALID_CLOCK);
    288288}
Note: See TracChangeset for help on using the changeset viewer.