* [PATCH, libcpp]: Correctly advance the pointer to an aligned address.
@ 2015-11-03 19:02 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2015-11-03 19:02 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Henderson
Hello!
The formulae to advance the pointer to an aligned address is:
/* This macro rounds x up to the y boundary. */
#define ROUND_UP(x,y) (((x) + (y) - 1) & ~((y) - 1))
Another example of missing "-1" can be found in libcpp,
lex.c/search_line_sse42. Luckily, we already checked for unaligned
input, so the bug is benign, but nevertheless, we should use the
correct value.
2015-11-03 Uros Bizjak <ubizjak@gmail.com>
* lex.c (search_line_sse42): Correctly advance the pointer to an
aligned address.
Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
Committed to mainline SVN as obvious.
Uros.
Index: lex.c
===================================================================
--- lex.c (revision 229712)
+++ lex.c (working copy)
@@ -447,7 +447,7 @@ search_line_sse42 (const uchar *s, const uchar *en
/* Advance the pointer to an aligned address. We will re-scan a
few bytes, but we no longer need care for reading past the
end of a page, since we're guaranteed a match. */
- s = (const uchar *)((si + 16) & -16);
+ s = (const uchar *)((si + 15) & -16);
}
/* Main loop, processing 16 bytes at a time. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-11-03 19:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-03 19:02 [PATCH, libcpp]: Correctly advance the pointer to an aligned address Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).