Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit 6d76699

Browse files
authored
Wd
1 parent 83973dd commit 6d76699

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

kernel/include/util.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ typedef u8 bool;
3535

3636
#define CLI() asm ("cli")
3737
#define STI() asm ("sti")
38+
39+
#define PACKED __attribute__((packed))
40+
41+
#define HIBIT(_x) (31 - __builtin_clz((_x)))
42+
#define LOBIT(_x)\
43+
__extension__({ __typeof__(_x) __x = (_x); HIBIT(__x & -__x); })
44+
45+
#define BIT_SET(_v, _n, _x) __extension__({\
46+
__typeof__(_v) __v = (_v);\
47+
(__v ^ ((-(_x) ^ __v) & (1 << (_n))));\
48+
})
49+
3850

3951
static inline u16 inports(u16 port) {
4052
u16 r;

0 commit comments

Comments
 (0)