From 06fbefd10046a0fae7e588b7c6d25fb51811b931 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 19 Apr 2017 00:20:54 +0200 Subject: add a_clz_64 helper function counts leading zero bits of a 64bit int, undefined on zero input. (has nothing to do with atomics, added to atomic.h so target specific helper functions are together.) there is a logarithmic generic implementation and another in terms of a 32bit a_clz_32 on targets where that's available. --- arch/aarch64/atomic_arch.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'arch/aarch64') diff --git a/arch/aarch64/atomic_arch.h b/arch/aarch64/atomic_arch.h index 8ab68c1c..40fefc25 100644 --- a/arch/aarch64/atomic_arch.h +++ b/arch/aarch64/atomic_arch.h @@ -73,3 +73,10 @@ static inline int a_ctz_64(uint64_t x) : "=r"(x) : "r"(x)); return x; } + +#define a_clz_64 a_clz_64 +static inline int a_clz_64(uint64_t x) +{ + __asm__("clz %0, %1" : "=r"(x) : "r"(x)); + return x; +} -- cgit v1.2.1