about summary refs log tree commit diff
path: root/frida_mode/src/util.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-11-10 18:05:29 +0000
committerYour Name <you@example.com>2021-11-10 18:05:29 +0000
commit7e1dba2e6b00f620d6ec3f1c2a75e69dcc7a82e5 (patch)
tree233928e21db382786a5aea477073ee9f2b028ae9 /frida_mode/src/util.c
parent533e979010ca338df6fc415d87668f8187752915 (diff)
downloadafl++-7e1dba2e6b00f620d6ec3f1c2a75e69dcc7a82e5.tar.gz
Fix block ID handling
Diffstat (limited to 'frida_mode/src/util.c')
-rw-r--r--frida_mode/src/util.c21
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");
+
+}
+