|
From: | Dongsheng Song |
Subject: | Re: [Qemu-devel] [PULL 3/7] qxl: refactor rounding up to a nearest power of 2 |
Date: | Thu, 5 Mar 2015 12:57:40 +0800 |
+/* round up to the nearest power of 2 (0 if overflow) */
+uint64_t pow2ceil(uint64_t value)
+{
+ uint8_t nlz = clz64(value);
+
+ if (is_power_of_2(value)) {
+ return value;
+ }
+ if (!nlz) {
+ return 0;
+ }
+ return 1ULL << (64 - nlz);
+}
+
[Prev in Thread] | Current Thread | [Next in Thread] |