The branch main has been updated by olce:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ab9fcc5a553a25804b9535190e914e3ba0e746cf

commit ab9fcc5a553a25804b9535190e914e3ba0e746cf
Author:     Olivier Certner <[email protected]>
AuthorDate: 2026-09-30 08:44:16 +0000
Commit:     Olivier Certner <[email protected]>
CommitDate: 2026-10-01 08:23:29 +0000

    ifuncs: Have DEFINE_*IFUNC() macros expand the passed name
    
    While here, make each <machine/ifunc.h> header include <sys/types.h> so
    that it can be included standalone.
    
    Reviewed by:    kib
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D60167
---
 sys/arm/include/ifunc.h     | 18 +++++++++++-------
 sys/arm64/include/ifunc.h   | 16 ++++++++++------
 sys/powerpc/include/ifunc.h | 14 ++++++++------
 sys/riscv/include/ifunc.h   | 19 ++++++++++++-------
 sys/x86/include/ifunc.h     | 18 +++++++++++-------
 5 files changed, 52 insertions(+), 33 deletions(-)

diff --git a/sys/arm/include/ifunc.h b/sys/arm/include/ifunc.h
index 98cc354ae6ca..ec9e9281844d 100644
--- a/sys/arm/include/ifunc.h
+++ b/sys/arm/include/ifunc.h
@@ -8,17 +8,21 @@
 #ifndef __ARM_IFUNC_H
 #define        __ARM_IFUNC_H
 
+#include <sys/types.h>
+
 #define        DEFINE_IFUNC(qual, ret_type, name, args)                        
\
-    static ret_type (*name##_resolver(void))args __used;               \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(void))args
+    static ret_type (*__CONCAT(name, _resolver)(void))args __used;     \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(void))args
 
 #ifdef __not_yet__
 #define        DEFINE_UIFUNC(qual, ret_type, name, args)                       
\
-    static ret_type (*name##_resolver(uint32_t, uint32_t, uint32_t,    \
-       uint32_t))args __used;                                          \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(                                 \
+    static ret_type (*__CONCAT(name, _resolver)(uint32_t, uint32_t,    \
+       uint32_t, uint32_t))args __used;                                \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(                       \
        uint32_t elf_hwcap __unused,                                    \
        uint32_t elf_hwcap2 __unused,                                   \
        uint32_t arg3 __unused,                                         \
diff --git a/sys/arm64/include/ifunc.h b/sys/arm64/include/ifunc.h
index 34e783df8fe5..184c6394e02c 100644
--- a/sys/arm64/include/ifunc.h
+++ b/sys/arm64/include/ifunc.h
@@ -29,6 +29,8 @@
 #ifndef __ARM64_IFUNC_H
 #define        __ARM64_IFUNC_H
 
+#include <sys/types.h>
+
 struct __ifunc_arg_t
 {
        unsigned long _size; /* Size of the struct, so it can grow. */
@@ -43,17 +45,19 @@ typedef struct __ifunc_arg_t __ifunc_arg_t;
 #define _IFUNC_ARG_HWCAP (1ULL << 62)
 
 #define        DEFINE_IFUNC(qual, ret_type, name, args)                        
\
-    static ret_type (*name##_resolver(void))args __used;               \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(void))args
+    static ret_type (*__CONCAT(name, _resolver)(void))args __used;     \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(void))args
 
 #define        DEFINE_UIFUNC(qual, ret_type, name, args)                       
\
-    static ret_type (*name##_resolver(uint64_t,                                
\
+    static ret_type (*__CONCAT(name, _resolver)(uint64_t,              \
        const struct __ifunc_arg_t *ifunc_arg,                          \
        uint64_t, uint64_t, uint64_t, uint64_t, uint64_t,               \
        uint64_t))args __used;                                          \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(                                 \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(                       \
        uint64_t at_hwcap __unused,                                     \
        const struct __ifunc_arg_t *ifunc_arg __unused,                 \
        uint64_t _arg3 __unused,                                        \
diff --git a/sys/powerpc/include/ifunc.h b/sys/powerpc/include/ifunc.h
index eac6019b07d7..c8f1f2a7462d 100644
--- a/sys/powerpc/include/ifunc.h
+++ b/sys/powerpc/include/ifunc.h
@@ -36,16 +36,18 @@
 #include <sys/types.h>
 
 #define        DEFINE_IFUNC(qual, ret_type, name, args)                        
\
-    static ret_type (*name##_resolver(void))args __used;               \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(void))args
+    static ret_type (*__CONCAT(name, _resolver)(void))args __used;     \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(void))args
 
 #define        DEFINE_UIFUNC(qual, ret_type, name, args)                       
\
-    static ret_type (*name##_resolver(register_t, register_t,          \
+    static ret_type (*__CONCAT(name, _resolver)(register_t, register_t,        
\
        register_t, register_t, register_t, register_t, register_t,     \
        register_t))args __used;                                        \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(                                 \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(                       \
        register_t cpu_features,                                        \
        register_t cpu_features2,                                       \
        register_t arg3 __unused,                                       \
diff --git a/sys/riscv/include/ifunc.h b/sys/riscv/include/ifunc.h
index 0f9747a2aa14..6efc437cca77 100644
--- a/sys/riscv/include/ifunc.h
+++ b/sys/riscv/include/ifunc.h
@@ -30,17 +30,22 @@
 #ifndef __RISCV_IFUNC_H
 #define        __RISCV_IFUNC_H
 
+#include <sys/types.h>
+
 #define        DEFINE_IFUNC(qual, ret_type, name, args)                        
\
-    static ret_type (*name##_resolver(void))args __used;               \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(void))args
+    static ret_type (*__CONCAT(name, _resolver)(void))args __used;     \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(void))args
 
 #define        DEFINE_UIFUNC(qual, ret_type, name, args)                       
\
-    static ret_type (*name##_resolver(unsigned long, unsigned long,    \
+    static ret_type (*__CONCAT(name, _resolver)(unsigned long,         \
        unsigned long, unsigned long, unsigned long, unsigned long,     \
-       unsigned long, unsigned long))args __used;                      \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(unsigned long elf_hwcap __unused,        
\
+       unsigned long, unsigned long, unsigned long))args __used;       \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)                                
\
+       (unsigned long elf_hwcap __unused,                              \
        unsigned long _arg2 __unused, unsigned long _arg3 __unused,     \
        unsigned long _arg4 __unused, unsigned long _arg5 __unused,     \
        unsigned long _arg6 __unused, unsigned long _arg7 __unused,     \
diff --git a/sys/x86/include/ifunc.h b/sys/x86/include/ifunc.h
index 51b7cca1dc09..040dc6781aba 100644
--- a/sys/x86/include/ifunc.h
+++ b/sys/x86/include/ifunc.h
@@ -29,16 +29,20 @@
 #ifndef __X86_IFUNC_H
 #define        __X86_IFUNC_H
 
+#include <sys/types.h>
+
 #define        DEFINE_IFUNC(qual, ret_type, name, args)                        
\
-    static ret_type (*name##_resolver(void))args __used;               \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(void))args
+    static ret_type (*__CONCAT(name, _resolver)(void))args __used;     \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(void))args
 
 #define        DEFINE_UIFUNC(qual, ret_type, name, args)                       
\
-    static ret_type (*name##_resolver(uint32_t, uint32_t, uint32_t,    \
-       uint32_t))args __used;                                          \
-    qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
-    static ret_type (*name##_resolver(                         \
+    static ret_type (*__CONCAT(name, _resolver)                                
\
+       (uint32_t, uint32_t, uint32_t, uint32_t))args __used;           \
+    qual ret_type name args                                            \
+       __attribute__((ifunc(__XSTRING(name) "_resolver")));            \
+    static ret_type (*__CONCAT(name, _resolver)(                       \
        uint32_t cpu_feature __unused,                                  \
        uint32_t cpu_feature2 __unused,                                 \
        uint32_t cpu_stdext_feature __unused,                           \

Reply via email to