+inline static uint64_t
+bit_ror64(uint64_t bitmap, uint n)
+{
+#if defined(__arm64__)
+ uint64_t result;
+ uint64_t _n = (uint64_t)n;
+ asm volatile("ror %0, %1, %2" : "=r" (result) : "r" (bitmap), "r" (_n));
+ return result;
+#else
+ n = n & 63;
+ return ((bitmap >> n) | (bitmap << (64 - n)));
+#endif
+}
+
+inline static uint64_t
+bit_rol64(uint64_t bitmap, uint n)
+{
+#if defined(__arm64__)
+ return bit_ror64(bitmap, 64U - n);
+#else
+ n = n & 63;
+ return ((bitmap << n) | (bitmap >> (64 - n)));
+#endif
+}
+