]> git.buserror.net Git - polintos/scott/priv.git/blob - include/c/lowlevel/arch-x86-common/bitops.h
Use GCC builtins for bit scanning. The minor benefit is that it is
[polintos/scott/priv.git] / include / c / lowlevel / arch-x86-common / bitops.h
1 // Bit manipulation functions.  These functions are not privileged.
2
3 #ifndef _LL_ARCH_X86C_BITOPS_H
4 #define _LL_ARCH_X86C_BITOPS_H
5
6 // Set/Clear the nth bit in a multiword bitmap.  These functions
7 // are endian and word-size dependent.
8
9 static inline void ll_multiword_set_bit(unsigned long *bitmap, int bit)
10 {
11         asm("bts %1, %0" : "=m" (bitmap[0]) : "r" (bit) : "memory");
12 }
13
14 static inline void ll_multiword_clear_bit(unsigned long *bitmap, int bit)
15 {
16         asm("btr %1, %0" : "=m" (bitmap[0]) : "r" (bit) : "memory");
17 }
18
19 #endif