__builtin函数总结

__builtin_clz(unsigned x); // count leading zeros

__builtin_ctz(unsigned x); // count trailing zeros

__builtin_popcount(unsigned x); // 1的个数

// ffs, parity 感觉没啥用。前者返回ctz+1,后者返回popcount&1

// 另:与大多数函数一样,后缀 l 表示long型参数,后缀 ll 表示long long型参数。

__builtin_popcountll(unsigned long long x);

__builtin_clz(unsigned x); // count leading zeros

__builtin_ctz(unsigned x); // count trailing zeros

__builtin_popcount(unsigned x); // 1的个数

ffs, parity 感觉没啥用。前者返回ctz+1,后者返回popcount&1

另:与大多数函数一样,后缀 l 表示long型参数,后缀 ll 表示long long型参数。

如__builtin_popcountll(unsigned long long x);

猜你喜欢

转载自blog.csdn.net/weixin_40676873/article/details/85239890