[2/2] riscv: Add big-endian support to string-fzi.h.
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-arm |
success
|
Build passed
|
| redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
| linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
Functions index_first and index_last should depend on endianness,
considering we are looking at raw bytes.
Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
Signed-off-by: Đorđe Todorović <djordje.todorovic@htecgroup.com>
ChangeLog:
* sysdeps/riscv/string-fzi.h (index_first): Add big-endian
implementation.
(index_last): Likewise.
---
sysdeps/riscv/string-fzi.h | 68 ++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
--
2.34.1
@@ -26,6 +26,73 @@
instead of calling compiler auxiliary functions. */
# include <string-optype.h>
+# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+static __always_inline unsigned int
+index_first (find_t c)
+{
+ if (sizeof (op_t) == 8)
+ {
+ if (c & 0xff00000000000000UL)
+ return 0;
+ if (c & 0xff000000000000UL)
+ return 1;
+ if (c & 0xff0000000000UL)
+ return 2;
+ if (c & 0xff00000000UL)
+ return 3;
+ if (c & 0xff000000UL)
+ return 4;
+ if (c & 0xff0000UL)
+ return 5;
+ if (c & 0xff00UL)
+ return 6;
+ return 7;
+ }
+ else
+ {
+ if (c & 0xff000000U)
+ return 0;
+ if (c & 0xff0000U)
+ return 1;
+ if (c & 0xff00U)
+ return 2;
+ return 3;
+ }
+}
+
+static __always_inline unsigned int
+index_last (find_t c)
+{
+ if (sizeof (op_t) == 8)
+ {
+ if (c & 0xffUL)
+ return 7;
+ if (c & 0xff00UL)
+ return 6;
+ if (c & 0xff0000UL)
+ return 5;
+ if (c & 0xff000000UL)
+ return 4;
+ if (c & 0xff00000000UL)
+ return 3;
+ if (c & 0xff0000000000UL)
+ return 2;
+ if (c & 0xff000000000000UL)
+ return 1;
+ return 0;
+ }
+ else
+ {
+ if (c & 0xffU)
+ return 3;
+ if (c & 0xff00U)
+ return 2;
+ if (c & 0xff0000U)
+ return 1;
+ return 0;
+ }
+}
+# else
static __always_inline unsigned int
index_first (find_t c)
{
@@ -72,6 +139,7 @@ index_last (find_t c)
return 1;
return 0;
}
+# endif /* __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */
#endif
#endif /* STRING_FZI_H */