]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
alpha: Use saturating arithmetic in memchr
authorRichard Henderson <rth@twiddle.net>
Wed, 1 Feb 2017 22:37:58 +0000 (14:37 -0800)
committerRichard Henderson <rth@twiddle.net>
Wed, 1 Feb 2017 22:39:04 +0000 (14:39 -0800)
ChangeLog
sysdeps/alpha/memchr.c

index f9b94fb58cac26abce575d3619c89b6016a9a924..b2f41e3da6c585d684f61b50207573e5f0d0decc 100644 (file)
--- 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.
index 82c42c073134198deba484ddff50380e8237cac0..402088dc9e48dbe0fc43bb8fce13a287c8085f2c 100644 (file)
@@ -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;