[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 16/17] misc: Add grub_log2ull macro for calculating log base 2
From: |
Glenn Washburn |
Subject: |
[PATCH v7 16/17] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers |
Date: |
Fri, 4 Dec 2020 10:43:45 -0600 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
include/grub/misc.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/grub/misc.h b/include/grub/misc.h
index 780a34e90..73a514eb1 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -482,4 +482,7 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file,
#define grub_max(a, b) (((a) > (b)) ? (a) : (b))
#define grub_min(a, b) (((a) < (b)) ? (a) : (b))
+#define grub_log2ull(n) (GRUB_TYPE_BITS (grub_uint64_t) \
+ - __builtin_clzll (n) - 1)
+
#endif /* ! GRUB_MISC_HEADER */
--
2.27.0
- Re: [PATCH v7 09/17] cryptodisk: Add macros GRUB_TYPE_U_MAX/MIN(type) to replace literals, (continued)
- [PATCH v7 07/17] luks2: Add string "index" to user strings using a json index., Glenn Washburn, 2020/12/04
- [PATCH v7 10/17] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors, Glenn Washburn, 2020/12/04
- [PATCH v7 01/17] disk: Rename grub_disk_get_size to grub_disk_native_sectors, Glenn Washburn, 2020/12/04
- [PATCH v7 16/17] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers,
Glenn Washburn <=
- [PATCH v7 13/17] luks2: Error check segment.sector_size, Glenn Washburn, 2020/12/04
- [PATCH v7 08/17] cryptodisk: Add macro GRUB_TYPE_BITS() to replace some literals, Glenn Washburn, 2020/12/04
- [PATCH v7 06/17] luks2: Use more intuitive slot key instead of index in user messages, Glenn Washburn, 2020/12/04