| Commit message (Collapse) | Author | Age | Lines |
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
| |
Copying the NUL after the call to mempcpy(3) reduces the need to add an
offset to the pointer. Also, we can call a function that does exactly
that, thus reducing the source code.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
| |
This allows copying with truncation from a measured character sequence
to a string.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
| |
We need to use also the flags declared by our own pc(5) file.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
|
| |
The ternary operator can be removed after the optimization in the
previous commit. This seems to be the optimization that the compiler
was performing, which made it significantly faster than similar code
calling strlen(3).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
|
|
| |
It results in considerably faster code when strings truncate by a large
margin, but surprisingly, it's also slightly faster when there's no
truncation. I suspect that's because it helps simplify how we set
'trunc', but am not entirely sure.
Suggested-by: Noah Goldstein <goldstein.w.n@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We don't need to call strlen(3) until we need it. Since that's only
after the tests for prior truncation, we're still within the same
behavior of strlcpy(3) with regard to making sure strings are strings;
in fact, by calling strlen(3) before the tests for prior truncation, we
were doing even better, since we were testing all of the strings.
However, one can write an instrumented wrapper that does what the old
stpecpyx(3) did:
if (src[strlen(src)] != '\0')
raise(SIGSEGV);
That way we provide the fastest performance possible.
And, anyway, the compiler is also allowed to do that optimization, so we
shouldn't rely on it.
Suggested-by: Noah Goldstein <goldstein.w.n@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
| |
Let's hope the compiler can use this information for something useful.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
| |
This function has several operations that can be skipped in normal
conditions. Inlining will allow the compiler see those, and hopefully
transform some calls into mempcpy(3) or stpcpy(3).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
| |
It was equivalent to stpecpy().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
| |
After implementing this function in terms of mempcpy(3), it's trivial to
make this function crash on invalid input. That removes the need for
stpecpyx(3).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
| |
mempcpy(3) is more optimized than memccpy(3); this implementation also
has less branches (since memccpy(3) has several internally).
Reported-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
| |
Use temporary variable. This will simplify a patch that I'll apply next.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
|
|
|
|
|
| |
unreachable()
Having conditionals with stp_unreachable() makes it look like there's a
branch, but there's not; it's just a hint to the compiler.
This wrapper reduces cognitive load, I hope.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
|
|
| |
'>' cannot be used to compare against NULL.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
| |
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
| |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|