]> git.baikalelectronics.ru Git - kernel.git/commit
sparc: Optimize strncpy_from_user() zero byte search.
authorDavid S. Miller <davem@davemloft.net>
Thu, 24 May 2012 02:20:20 +0000 (19:20 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 24 May 2012 02:20:20 +0000 (19:20 -0700)
commit169e0e271c653bb2c9380665886b2a3e5cd9895b
tree7456cbb6d71b3f92385d94cab546e2b93dc19c6a
parent580f9effdfb25654f0a88d8b53902699ae378167
sparc: Optimize strncpy_from_user() zero byte search.

Compute a mask that will only have 0x80 in the bytes which
had a zero in them.  The formula is:

~(((x & 0x7f7f7f7f) + 0x7f7f7f7f) | x | 0x7f7f7f7f)

In the inner word iteration, we have to compute the "x | 0x7f7f7f7f"
part, so we can reuse that in the above calculation.

Once we have this mask, we perform divide and conquer to find the
highest 0x80 location.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/lib/usercopy.c