[PATCH 11/20] rtems: Move _Partition_Is_buffer_on_boundary()

Gedare Bloom gedare at rtems.org
Fri Nov 20 16:10:10 UTC 2020


On Fri, Nov 20, 2020 at 4:16 AM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> It is used only by rtems_partition_return_buffer().    Make the PTCB the
> first parameter.
> ---
>  cpukit/include/rtems/rtems/partimpl.h | 22 ----------------------
>  cpukit/rtems/src/partreturnbuffer.c   | 17 ++++++++++++++++-
>  2 files changed, 16 insertions(+), 23 deletions(-)
>
> diff --git a/cpukit/include/rtems/rtems/partimpl.h b/cpukit/include/rtems/rtems/partimpl.h
> index 23d5422bec..0d15d1e991 100644
> --- a/cpukit/include/rtems/rtems/partimpl.h
> +++ b/cpukit/include/rtems/rtems/partimpl.h
> @@ -19,7 +19,6 @@
>  #define _RTEMS_RTEMS_PARTIMPL_H
>
>  #include <rtems/rtems/partdata.h>
> -#include <rtems/score/address.h>
>  #include <rtems/score/chainimpl.h>
>  #include <rtems/score/objectimpl.h>
>
> @@ -35,27 +34,6 @@ extern "C" {
>   * @{
>   */
>
> -/**
> - *  @brief Checks whether is on a valid buffer boundary for the_partition.
> - *
> - *  This function returns TRUE if the_buffer is on a valid buffer
> - *  boundary for the_partition, and FALSE otherwise.

I think keep these two lines. This function is not so clear without
thinking through what it means to do pointer arithmetic (subtraction
and mod).

> - */
> -RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary (
> -  void              *the_buffer,
> -  Partition_Control *the_partition
> -)
> -{
> -  intptr_t offset;
> -
> -  offset = _Addresses_Subtract(
> -    the_buffer,
> -    the_partition->starting_address
> -  );
> -
> -  return ((offset % the_partition->buffer_size) == 0);
> -}
> -
>  RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned(
>    uint32_t buffer_size
>  )
> diff --git a/cpukit/rtems/src/partreturnbuffer.c b/cpukit/rtems/src/partreturnbuffer.c
> index 61900fa735..bc0d273719 100644
> --- a/cpukit/rtems/src/partreturnbuffer.c
> +++ b/cpukit/rtems/src/partreturnbuffer.c
> @@ -24,6 +24,21 @@
>  #include <rtems/score/address.h>
>  #include <rtems/score/chainimpl.h>
>
> +static bool _Partition_Is_buffer_on_boundary (
> +  const Partition_Control *the_partition,
> +  const void              *the_buffer
> +)
> +{
> +  intptr_t offset;
> +
> +  offset = _Addresses_Subtract(
> +    the_buffer,
> +    the_partition->starting_address
> +  );
> +
> +  return ( ( offset % the_partition->buffer_size ) == 0);
> +}
> +
>  static bool _Partition_Is_buffer_valid(
>     const Partition_Control *the_partition,
>     const void              *the_buffer
> @@ -36,7 +51,7 @@ static bool _Partition_Is_buffer_valid(
>    ending   = _Addresses_Add_offset( starting, the_partition->length );
>
>    return _Addresses_Is_in_range( the_buffer, starting, ending )
> -    && _Partition_Is_buffer_on_boundary( the_buffer, the_partition );
> +    && _Partition_Is_buffer_on_boundary( the_partition, the_buffer );
>  }
>
>  static void _Partition_Free_buffer(
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list