|
|
00db10 |
From 2fd1041a8d9684978546886d58fdf8add8c8d9f7 Mon Sep 17 00:00:00 2001
|
|
|
00db10 |
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
|
|
|
00db10 |
Date: Tue, 5 Jul 2016 21:20:41 +0530
|
|
|
00db10 |
Subject: [PATCH] powerpc: Fix return code of strcasecmp for unaligned inputs
|
|
|
00db10 |
|
|
|
00db10 |
If the input values are unaligned and if there are null characters in the
|
|
|
00db10 |
memory before the starting address of the input values, strcasecmp
|
|
|
00db10 |
gives incorrect return code. Fixed it by adding mask the bits that
|
|
|
00db10 |
are not part of the string.
|
|
|
00db10 |
|
|
|
00db10 |
(cherry picked from commit 30e4cc5413f72c2c728a544389da0c48500d9904)
|
|
|
00db10 |
---
|
|
|
00db10 |
ChangeLog | 6 ++++++
|
|
|
00db10 |
sysdeps/powerpc/powerpc64/power8/strcasecmp.S | 17 ++++++++++++++---
|
|
|
00db10 |
2 files changed, 20 insertions(+), 3 deletions(-)
|
|
|
00db10 |
|
|
|
00db10 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
00db10 |
index 9385bd0..af5f694 100644
|
|
|
00db10 |
diff --git a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
|
|
|
00db10 |
index 63f6217..c83dc52 100644
|
|
|
00db10 |
--- a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
|
|
|
00db10 |
+++ b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
|
|
|
00db10 |
@@ -40,11 +40,20 @@
|
|
|
00db10 |
vsel v5, v7, v5, v8; \
|
|
|
00db10 |
vcmpequb. v7, v5, v4;
|
|
|
00db10 |
|
|
|
00db10 |
-/* Get 16 bytes for unaligned case. */
|
|
|
00db10 |
+/*
|
|
|
00db10 |
+ * Get 16 bytes for unaligned case.
|
|
|
00db10 |
+ * reg1: Vector to hold next 16 bytes.
|
|
|
00db10 |
+ * reg2: Address to read from.
|
|
|
00db10 |
+ * reg3: Permute control vector.
|
|
|
00db10 |
+ * v8: Tmp vector used to mask unwanted bytes.
|
|
|
00db10 |
+ * v9: Tmp vector,0 when null is found on first 16 bytes
|
|
|
00db10 |
+ */
|
|
|
00db10 |
#ifdef __LITTLE_ENDIAN__
|
|
|
00db10 |
#define GET16BYTES(reg1, reg2, reg3) \
|
|
|
00db10 |
lvx reg1, 0, reg2; \
|
|
|
00db10 |
- vcmpequb. v8, v0, reg1; \
|
|
|
00db10 |
+ vspltisb v8, -1; \
|
|
|
00db10 |
+ vperm v8, v8, reg1, reg3; \
|
|
|
00db10 |
+ vcmpequb. v8, v0, v8; \
|
|
|
00db10 |
beq cr6, 1f; \
|
|
|
00db10 |
vspltisb v9, 0; \
|
|
|
00db10 |
b 2f; \
|
|
|
00db10 |
@@ -57,7 +66,9 @@
|
|
|
00db10 |
#else
|
|
|
00db10 |
#define GET16BYTES(reg1, reg2, reg3) \
|
|
|
00db10 |
lvx reg1, 0, reg2; \
|
|
|
00db10 |
- vcmpequb. v8, v0, reg1; \
|
|
|
00db10 |
+ vspltisb v8, -1; \
|
|
|
00db10 |
+ vperm v8, reg1, v8, reg3; \
|
|
|
00db10 |
+ vcmpequb. v8, v0, v8; \
|
|
|
00db10 |
beq cr6, 1f; \
|
|
|
00db10 |
vspltisb v9, 0; \
|
|
|
00db10 |
b 2f; \
|
|
|
00db10 |
--
|
|
|
00db10 |
2.1.0
|
|
|
00db10 |
|