Using own popcount where the compiler builtin is not available.
This commit is contained in:
13
auto/clang
13
auto/clang
@@ -101,6 +101,19 @@ nxt_feature_test="int main() {
|
|||||||
. auto/feature
|
. auto/feature
|
||||||
|
|
||||||
|
|
||||||
|
nxt_feature="GCC __builtin_popcount()"
|
||||||
|
nxt_feature_name=NXT_HAVE_BUILTIN_POPCOUNT
|
||||||
|
nxt_feature_run=
|
||||||
|
nxt_feature_incs=
|
||||||
|
nxt_feature_libs=
|
||||||
|
nxt_feature_test="int main() {
|
||||||
|
if (__builtin_popcount(5) == 2)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}"
|
||||||
|
. auto/feature
|
||||||
|
|
||||||
|
|
||||||
nxt_feature="GCC __attribute__ visibility"
|
nxt_feature="GCC __attribute__ visibility"
|
||||||
nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_VISIBILITY
|
nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_VISIBILITY
|
||||||
nxt_feature_run=
|
nxt_feature_run=
|
||||||
|
|||||||
@@ -132,6 +132,27 @@ nxt_prefetch(a)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if (NXT_HAVE_BUILTIN_POPCOUNT)
|
||||||
|
|
||||||
|
#define nxt_popcount __builtin_popcount
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
nxt_inline int
|
||||||
|
nxt_popcount(unsigned int x)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
for (count = 0; x != 0; x >>= 1) {
|
||||||
|
count += (x & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef NXT_ALIGNMENT
|
#ifndef NXT_ALIGNMENT
|
||||||
|
|
||||||
#if (NXT_SOLARIS)
|
#if (NXT_SOLARIS)
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ nxt_conf_vldt_type(nxt_conf_validation_t *vldt, nxt_str_t *name,
|
|||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
||||||
n = __builtin_popcount(type);
|
n = nxt_popcount(type);
|
||||||
|
|
||||||
if (n > 1) {
|
if (n > 1) {
|
||||||
p = nxt_cpymem(p, "either ", 7);
|
p = nxt_cpymem(p, "either ", 7);
|
||||||
|
|||||||
Reference in New Issue
Block a user