[v2,2/3] RISC-V: Add compiler support check in string-fza.h and string-fzi.h

Message ID 20240707145831.9114-2-jz531210@gmail.com
State New
Headers
Series [v2,1/3] RISC-V: Add a macro definition file to check whether the compiler supports extensions. |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed

Commit Message

Julian Zhu July 7, 2024, 2:58 p.m. UTC
  Add macros from `compiler-ext-avail.h` to avoid using Zbb or XTheadBb in unsupported compiler versions.

Signed-off-by: Julian Zhu <jz531210@gmail.com>
---
 sysdeps/riscv/string-fza.h | 5 ++++-
 sysdeps/riscv/string-fzi.h | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
  

Patch

diff --git a/sysdeps/riscv/string-fza.h b/sysdeps/riscv/string-fza.h
index ee5c31317f..57fe39e66a 100644
--- a/sysdeps/riscv/string-fza.h
+++ b/sysdeps/riscv/string-fza.h
@@ -19,7 +19,10 @@ 
 #ifndef _RISCV_STRING_FZA_H
 #define _RISCV_STRING_FZA_H 1
 
-#if defined __riscv_zbb || defined __riscv_xtheadbb
+#include "compiler-ext-avail.h"
+
+#if (defined COMPILER_ZBB_AVAIL && defined __riscv_zbb)                       \
+    || (defined COMPILER_XTHEADBB_AVAIL && defined __riscv_xtheadbb)
 /* With bitmap extension we can use orc.b to find all zero bytes.  */
 # include <string-misc.h>
 # include <string-optype.h>
diff --git a/sysdeps/riscv/string-fzi.h b/sysdeps/riscv/string-fzi.h
index 66237c2f03..dccd759dca 100644
--- a/sysdeps/riscv/string-fzi.h
+++ b/sysdeps/riscv/string-fzi.h
@@ -19,7 +19,10 @@ 
 #ifndef _STRING_RISCV_FZI_H
 #define _STRING_RISCV_FZI_H 1
 
-#if defined __riscv_zbb || defined __riscv_xtheadbb
+#include "compiler-ext-avail.h"
+
+#if (defined COMPILER_ZBB_AVAIL && defined __riscv_zbb)                       \
+    || (defined COMPILER_XTHEADBB_AVAIL && defined __riscv_xtheadbb)
 # include <sysdeps/generic/string-fzi.h>
 #else
 /* Without bitmap clz/ctz extensions, it is faster to direct test the bits