mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 11:25:45 +01:00
add a utility macro for getting the bitwise ceiling. (e.i. the next power of 2)
This commit is contained in:
6
src/util/util.h
Normal file
6
src/util/util.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
/* Acquires the next power of two of value `x`.
|
||||
* Automatically determines the type (and therefore the width) of `x`.
|
||||
* Explicitly cast `x` to a desired width, if necessary. */
|
||||
#define bit_ceil(x) (1 << (sizeof(__typeof__(x)) * 8 - __builtin_clzg(((x) - !!(x)) | 1)))
|
||||
Reference in New Issue
Block a user