[PATCH v7 1/7] string: Add internal memswap implementation

Cristian Rodríguez cristian@rodriguez.im
Fri Sep 15 15:00:30 GMT 2023


On Thu, Sep 14, 2023 at 3:37 PM Adhemerval Zanella <
adhemerval.zanella@linaro.org> wrote:

> The prototype is:
>
>   void __memswap (void *restrict p1, void *restrict p2, size_t n)
>
> The function swaps the content of two memory blocks P1 and P2 of
> len N.  Memory overlap is NOT handled.
>
> It will be used on qsort optimization.
>
> Checked on x86_64-linux-gnu and aarch64-linux-gnu.
> ---
>  include/string.h      |   3 +
>  string/Makefile       |  13 +++
>  string/memswap.c      |  41 +++++++++
>  string/test-memswap.c | 191 ++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 248 insertions(+)
>  create mode 100644 string/memswap.c
>  create mode 100644 string/test-memswap.c
>
> diff --git a/include/string.h b/include/string.h
> index 86d1fa4abe..f31a7f6006 100644
> --- a/include/string.h
> +++ b/include/string.h
> @@ -45,6 +45,9 @@ extern void *__memrchr (const void *__s, int __c, size_t
> __n)
>  extern void *__memchr (const void *__s, int __c, size_t __n)
>       __attribute_pure__;
>
> +extern void __memswap (void *restrict __p1, void *restrict __p2, size_t
> __n)
> +     attribute_hidden;
> +
>
> +++ b/string/memswap.c
> @
>

An internal inline function should be just fine no ? compiler's are smarter
nowadays.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20230915/3b046a5b/attachment.htm>


More information about the Libc-alpha mailing list