[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 17/18] misc: Add grub_log2ull macro for calculating log base 2
From: |
Glenn Washburn |
Subject: |
[PATCH v8 17/18] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers |
Date: |
Tue, 8 Dec 2020 16:45:48 -0600 |
Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.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 v8 11/18] cryptodisk: Add macros GRUB_TYPE_U_MAX/MIN(type) to replace literals, (continued)
- [PATCH v8 12/18] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors, Glenn Washburn, 2020/12/08
- [PATCH v8 05/18] luks2: Make sure all fields of output argument in luks2_parse_digest() are written to, Glenn Washburn, 2020/12/08
- [PATCH v8 13/18] cryptodisk: Properly handle non-512 byte sized sectors, Glenn Washburn, 2020/12/08
- [PATCH v8 06/18] luks2: Add idx member to struct grub_luks2_keyslot/segment/digest, Glenn Washburn, 2020/12/08
- [PATCH v8 17/18] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers,
Glenn Washburn <=
- [PATCH v8 02/18] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN arguments, Glenn Washburn, 2020/12/08
- [PATCH v8 09/18] luks2: Add string "index" to user strings using a json index., Glenn Washburn, 2020/12/08
- [PATCH v8 10/18] cryptodisk: Add macro GRUB_TYPE_BITS() to replace some literals, Glenn Washburn, 2020/12/08
- [PATCH v8 14/18] luks2: Better error handling when setting up the cryptodisk, Glenn Washburn, 2020/12/08