Installed headers relicensing and cleanup
[lttng-ust.git] / libringbuffer / backend_internal.h
index f61d1d61bc0a2cce0ca84469aa79093960937e7a..dbe34fc1e4419dbee03d2993c115d140582c2f78 100644 (file)
@@ -430,4 +430,45 @@ do {                                                               \
                inline_memcpy(dest, src, __len);                \
 } while (0)
 
+/* arch-agnostic implementation */
+
+static inline int fls(unsigned int x)
+{
+       int r = 32;
+
+       if (!x)
+               return 0;
+       if (!(x & 0xFFFF0000U)) {
+               x <<= 16;
+               r -= 16;
+       }
+       if (!(x & 0xFF000000U)) {
+               x <<= 8;
+               r -= 8;
+       }
+       if (!(x & 0xF0000000U)) {
+               x <<= 4;
+               r -= 4;
+       }
+       if (!(x & 0xC0000000U)) {
+               x <<= 2;
+               r -= 2;
+       }
+       if (!(x & 0x80000000U)) {
+               x <<= 1;
+               r -= 1;
+       }
+       return r;
+}
+
+static inline int get_count_order(unsigned int count)
+{
+       int order;
+
+       order = fls(count) - 1;
+       if (count & (count - 1))
+               order++;
+       return order;
+}
+
 #endif /* _LINUX_RING_BUFFER_BACKEND_INTERNAL_H */
This page took 0.023947 seconds and 4 git commands to generate.