diff options
author | 2020-06-26 20:16:21 +0000 | |
---|---|---|
committer | 2020-06-26 20:16:21 +0000 | |
commit | 08b167769c18321999153a88ef267883b1cc33db (patch) | |
tree | ab45ecc04f7b448ab41532cc741304fa42088ca8 /lib/libc/arch/powerpc/string/ffs.S | |
parent | Fix powerpc64 pie binraries, in register renumbering one line was missed. (diff) | |
download | wireguard-openbsd-08b167769c18321999153a88ef267883b1cc33db.tar.xz wireguard-openbsd-08b167769c18321999153a88ef267883b1cc33db.zip |
Provide an optimized implementation of ffs(3) in libc on
aarch64/powerpc/powerpc64, making use of the count leading
zeros instruction. Also add a brief regression test.
ok deraadt@ kettenis@
Diffstat (limited to 'lib/libc/arch/powerpc/string/ffs.S')
-rw-r--r-- | lib/libc/arch/powerpc/string/ffs.S | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libc/arch/powerpc/string/ffs.S b/lib/libc/arch/powerpc/string/ffs.S new file mode 100644 index 00000000000..d7091526d41 --- /dev/null +++ b/lib/libc/arch/powerpc/string/ffs.S @@ -0,0 +1,16 @@ +/* $OpenBSD: ffs.S,v 1.1 2020/06/26 20:16:21 naddy Exp $ */ +/* + * Written by Christian Weisgerber <naddy@openbsd.org>. + * Public domain. + */ + +#include "SYS.h" + +ENTRY(ffs) + neg %r4, %r3 + and %r3, %r3, %r4 + cntlzw %r3, %r3 + subfic %r3, %r3, 32 + blr +END(ffs) +.protected |