aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2017-02-01 14:37:58 -0800
committerRichard Henderson <rth@twiddle.net>2017-02-01 14:39:04 -0800
commit9c8e64485360d08d95884bddc0958cf3a5ca9c5c (patch)
tree1557bd3522093206acd8236e6e2d24bcb322b55d
parent4283b387253eb68647bd4c91f9d6ac615982919f (diff)
downloadglibc-9c8e64485360d08d95884bddc0958cf3a5ca9c5c.tar
glibc-9c8e64485360d08d95884bddc0958cf3a5ca9c5c.tar.gz
glibc-9c8e64485360d08d95884bddc0958cf3a5ca9c5c.tar.bz2
glibc-9c8e64485360d08d95884bddc0958cf3a5ca9c5c.zip
alpha: Use saturating arithmetic in memchr
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/alpha/memchr.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f9b94fb58c..b2f41e3da6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-01 Richard Henderson <rth@twiddle.net>
+
+ * sysdeps/alpha/memchr.c (__memchr): Use saturating arithmetic
+ adjusting the byte count.
+
2017-02-01 Andreas Schwab <schwab@linux-m68k.org>
* conform/Makefile (linknamespace-libs): Define.
diff --git a/sysdeps/alpha/memchr.c b/sysdeps/alpha/memchr.c
index 82c42c0731..402088dc9e 100644
--- a/sysdeps/alpha/memchr.c
+++ b/sysdeps/alpha/memchr.c
@@ -53,7 +53,10 @@ __memchr (const void *s, int xc, size_t n)
/* Align the source, and decrement the count by the number
of bytes searched in the first word. */
s_align = (const word *)((word)s & -8);
- n += ((word)s & 7);
+ {
+ size_t inc = n + ((word)s & 7);
+ n = inc | -(inc < n);
+ }
/* Deal with misalignment in the first word for the comparison. */
mask = (1ul << ((word)s & 7)) - 1;