X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=include%2Flinux%2Fcompiler.h;fp=include%2Flinux%2Fcompiler.h;h=e40d8aec3c45f5ab284e03156bdcab93f31e97b5;hb=a1f8f8c3924cff7ffbe15236c18e393f046ad755;hp=9ef76ec7311f25c79d9ed54d436501fe6f12b5b4;hpb=c60a8805f6ac6d6ff054c3ab39af6146bb1bc223;p=carl9170fw.git diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 9ef76ec..e40d8ae 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -25,6 +25,9 @@ #define __in_section(s) __attribute__((section("." # s))) #define __visible __attribute__((externally_visible)) +#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) + + #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) @@ -101,4 +104,11 @@ static inline long IS_ERR_OR_NULL(const void *ptr) return !ptr || IS_ERR_VALUE((unsigned long)ptr); } +static inline unsigned int hweight8(unsigned int w) +{ + unsigned int res = w - ((w >> 1) & 0x55); + res = (res & 0x33) + ((res >> 2) & 0x33); + return (res + (res >> 4)) & 0x0F; +} + #endif /* __SHARED_COMPILER_H */