Add swap utility

This commit is contained in:
2026-09-21 22:03:54 +01:00
parent 8da18774f0
commit b014ffa3b1
+5
View File
@@ -49,6 +49,11 @@ BEGIN_C_LINKAGE
#define wpMiscUtilsIsPowerOfTwo(NUM) ((NUM & (NUM - 1)) == 0) #define wpMiscUtilsIsPowerOfTwo(NUM) ((NUM & (NUM - 1)) == 0)
#define wpMiscUtilsOffsetPointer(PTR, OFFSET) ((void *)((uptr)(PTR) + (OFFSET))) #define wpMiscUtilsOffsetPointer(PTR, OFFSET) ((void *)((uptr)(PTR) + (OFFSET)))
#define wpMiscUtilsSwap(TYPE, A_PTR, B_PTR) do { \
TYPE tmp = *(A_PTR); \
*(A_PTR) = *(B_PTR); \
*(B_PTR) = tmp; \
} while(0)
wp_intern inline u64 wpMiscUtilsRotl64(u64 x, i8 rotation) { wp_intern inline u64 wpMiscUtilsRotl64(u64 x, i8 rotation) {
return (x << rotation) | (x >> (64 - rotation)); return (x << rotation) | (x >> (64 - rotation));