diff mbox series

[v2,02/15] string/memchr: Add mechanism to set function attributes

Message ID 20240527111900.1060546-3-christoph.muellner@vrull.eu
State New
Headers show
Series RISC-V: Add Zbb-optimized string routines as ifuncs | expand

Commit Message

Christoph Müllner May 27, 2024, 11:18 a.m. UTC
This patch introduces the __CODEGEN_ATTRIBUTES macro which can be
used to set function attributes when building the code.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
 string/memchr.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Adhemerval Zanella Aug. 13, 2024, 6:16 p.m. UTC | #1
On 27/05/24 08:18, Christoph Müllner wrote:
> This patch introduces the __CODEGEN_ATTRIBUTES macro which can be
> used to set function attributes when building the code.
> 
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
>  string/memchr.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/string/memchr.c b/string/memchr.c
> index 08b5c41667..a2bcd0419e 100644
> --- a/string/memchr.c
> +++ b/string/memchr.c
> @@ -29,6 +29,10 @@
>  # define __memchr MEMCHR
>  #endif
>  
> +#ifndef __CODEGEN_ATTRIBUTES
> +# define __CODEGEN_ATTRIBUTES
> +#endif

This seems more straightforward than add a generic header, since it would
overridden by each ifunc variant.  I am not sure about tying the same
identifier to the __always_inline macro, but it should be ok since only
riscv actually uses it.

> +
>  static __always_inline const char *
>  sadd (uintptr_t x, uintptr_t y)
>  {
> @@ -36,6 +40,7 @@ sadd (uintptr_t x, uintptr_t y)
>  }
>  
>  /* Search no more than N bytes of S for C.  */
> +__CODEGEN_ATTRIBUTES
>  void *
>  __memchr (void const *s, int c_in, size_t n)
>  {
diff mbox series

Patch

diff --git a/string/memchr.c b/string/memchr.c
index 08b5c41667..a2bcd0419e 100644
--- a/string/memchr.c
+++ b/string/memchr.c
@@ -29,6 +29,10 @@ 
 # define __memchr MEMCHR
 #endif
 
+#ifndef __CODEGEN_ATTRIBUTES
+# define __CODEGEN_ATTRIBUTES
+#endif
+
 static __always_inline const char *
 sadd (uintptr_t x, uintptr_t y)
 {
@@ -36,6 +40,7 @@  sadd (uintptr_t x, uintptr_t y)
 }
 
 /* Search no more than N bytes of S for C.  */
+__CODEGEN_ATTRIBUTES
 void *
 __memchr (void const *s, int c_in, size_t n)
 {