]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - include/c/lowlevel/arch-x64/bitops.h
Use GCC builtins for bit scanning. The minor benefit is that it is
[polintos/scott/priv.git] / include / c / lowlevel / arch-x64 / bitops.h
index e165c6df450c8d7f0afbd7198db85177e964814b..c92b2cd5e78b8f99567c05389bb97aad2089a598 100644 (file)
@@ -1,50 +1,6 @@
-// Bit manipulation functions.  These functions are not privileged.
-
 #ifndef _LL_ARCH_BITOPS_H
 #define _LL_ARCH_BITOPS_H
 
 #ifndef _LL_ARCH_BITOPS_H
 #define _LL_ARCH_BITOPS_H
 
-// Find First (least-significant) Set, counting from 0,
-// undefined if no bits set
-
-static inline int ll_ffs(unsigned long val)
-{
-       unsigned long ret;
-       asm("bsfq %1, %0" : "=r" (ret) : "r" (val));
-       return ret;
-}
-
-// Find Last (most-significant) Set, counting from 0, 
-// undefined if no bits set
-
-static inline int ll_fls(unsigned long val)
-{
-       unsigned long ret;
-       asm("bsrq %1, %0" : "=r" (ret) : "r" (val));
-       return ret;
-}
-
-// As above, but on 64-bit values, regardless of sizeof(long)
-static inline int ll_ffs64(uint64_t val)
-{
-       return ll_ffs(val);
-}
-
-static inline int ll_fls64(uint64_t val)
-{
-       return ll_fls(val);
-}
-
-// Set/Clear the nth bit in a multiword bitmap.  These functions
-// are endian and word-size dependent.
-
-static inline void ll_multiword_set_bit(unsigned long *bitmap, int bit)
-{
-       asm("bts %1, %0" : "=m" (bitmap[0]) : "r" (bit) : "memory");
-}
-
-static inline void ll_multiword_clear_bit(unsigned long *bitmap, int bit)
-{
-       asm("btr %1, %0" : "=m" (bitmap[0]) : "r" (bit) : "memory");
-}
+#include <lowlevel/arch-x86-common/bitops.h>
 
 #endif
 
 #endif