diff options
Diffstat (limited to 'frida_mode/src/util.c')
-rw-r--r-- | frida_mode/src/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/frida_mode/src/util.c b/frida_mode/src/util.c index 2b0f7be6..d84b7065 100644 --- a/frida_mode/src/util.c +++ b/frida_mode/src/util.c @@ -80,3 +80,24 @@ gboolean util_output_enabled(void) { } +gsize util_rotate(gsize val, gsize shift, gsize size) { + + if (shift == 0) { return val; } + gsize result = ((val >> shift) | (val << (size - shift))); + result = result & ((1 << size) - 1); + return result; + +} + +gsize util_log2(gsize val) { + + for (gsize i = 0; i < 64; i++) { + + if (((gsize)1 << i) == val) { return i; } + + } + + FFATAL("Not a power of two"); + +} + |