From 3f2546b2ef55b661fd8dd69682b38992225e86f6 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Mon, 29 Apr 2019 01:17:54 +0100 Subject: Initial import of qemu-2.4.1 --- roms/u-boot/arch/arm/include/asm/utils.h | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 roms/u-boot/arch/arm/include/asm/utils.h (limited to 'roms/u-boot/arch/arm/include/asm/utils.h') diff --git a/roms/u-boot/arch/arm/include/asm/utils.h b/roms/u-boot/arch/arm/include/asm/utils.h new file mode 100644 index 00000000..1b3f1a0c --- /dev/null +++ b/roms/u-boot/arch/arm/include/asm/utils.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2010 + * Texas Instruments, + * Aneesh V + * + * SPDX-License-Identifier: GPL-2.0+ + */ +#ifndef _UTILS_H_ +#define _UTILS_H_ + +static inline s32 log_2_n_round_up(u32 n) +{ + s32 log2n = -1; + u32 temp = n; + + while (temp) { + log2n++; + temp >>= 1; + } + + if (n & (n - 1)) + return log2n + 1; /* not power of 2 - round up */ + else + return log2n; /* power of 2 */ +} + +static inline s32 log_2_n_round_down(u32 n) +{ + s32 log2n = -1; + u32 temp = n; + + while (temp) { + log2n++; + temp >>= 1; + } + + return log2n; +} + +#endif -- cgit v1.2.3