This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[COMMITTED] [PATCH] Use PTR_ALIGN_DOWN on strcspn and strspn
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Fri, 1 Apr 2016 18:34:56 -0300
- Subject: [COMMITTED] [PATCH] Use PTR_ALIGN_DOWN on strcspn and strspn
- Authentication-results: sourceware.org; auth=none
Following Roland's suggestion. Tested on aarch64.
* string/strcspn.c (strcspn): Use PTR_ALIGN_DOWN.
* string/strspn.c (strspn): Likewise.
---
ChangeLog | 5 +++++
string/strcspn.c | 3 ++-
string/strspn.c | 4 +++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/string/strcspn.c b/string/strcspn.c
index c535dd1..0e01193 100644
--- a/string/strcspn.c
+++ b/string/strcspn.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <stdint.h>
+#include <libc-internal.h>
#undef strcspn
@@ -52,7 +53,7 @@ STRCSPN (const char *str, const char *reject)
if (p[s[2]]) return 2;
if (p[s[3]]) return 3;
- s = (unsigned char *) ((uintptr_t)(s) & ~3);
+ s = (unsigned char *) PTR_ALIGN_DOWN (s, 4);
unsigned int c0, c1, c2, c3;
do
diff --git a/string/strspn.c b/string/strspn.c
index f98340b..86f76ea 100644
--- a/string/strspn.c
+++ b/string/strspn.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <stdint.h>
+#include <libc-internal.h>
#undef strspn
#ifndef STRSPN
@@ -58,7 +59,8 @@ STRSPN (const char *str, const char *accept)
if (!p[s[2]]) return 2;
if (!p[s[3]]) return 3;
- s = (unsigned char *) ((uintptr_t)(s) & ~3);
+ s = (unsigned char *) PTR_ALIGN_DOWN (s, 4);
+
unsigned int c0, c1, c2, c3;
do {
s += 4;
--
1.9.1