echo "#include \"compat/endian.h\"" >>$CONFIG_H
fi
-if [ -z "$FFS64" ]; then
- printf "Testing for ffs64 ... "
- cat <<EOF >_ffs64.c
+if [ -z "$FLS64" ]; then
+ printf "Testing for fls64 ... "
+ cat <<EOF >_fls64.c
#include <sys/bitops.h>
int main(void) {
- return (int)ffs64(1337);
+ return (int)fls64(1337);
}
EOF
- if $XCC _ffs64.c -o _ffs64 2>&3; then
- FFS64=yes
+ if $XCC _fls64.c -o _fls64 2>&3; then
+ FLS64=yes
else
- FFS64=no
+ FLS64=no
fi
- echo "$FFS64"
- rm -f _ffs64.c _ffs64
+ echo "$FLS64"
+ rm -f _fls64.c _fls64
fi
-if [ "$FFS64" = yes ]; then
+if [ "$FLS64" = yes ]; then
echo "#define HAVE_SYS_BITOPS_H" >>$CONFIG_H
fi
sla_max = 0;
TAILQ_FOREACH(ifi, ifp->ctx->ifaces, next) {
- if (ifi != ifp && ifi->index > sla_max)
+ if (ifi->index > sla_max)
sla_max = ifi->index;
}
} else
sla_max = ia->sla_max;
- bits = ffs32(sla_max);
+ bits = fls32(sla_max);
if (prefix->prefix_len + bits > UINT8_MAX)
asla.prefix_len = UINT8_MAX;
asla.prefix_len = 64;
else
asla.prefix_len = (uint8_t)ROUNDUP8(asla.prefix_len);
-
}
-#define BIT(n) (1l << (n))
+#define BIT(n) (1UL << (n))
#define BIT_MASK(len) (BIT(len) - 1)
if (ia->sla_max == 0)
/* Work out the real sla_max from our bits used */
sla, ia)) == -1)
return NULL;
- if (ffs64(sla->suffix) > 128 - pfxlen) {
+ if (fls64(sla->suffix) > 128 - pfxlen) {
logger(ifp->ctx, LOG_ERR,
"%s: suffix %" PRIu64 " + prefix_len %d > 128",
ifp->name, sla->suffix, pfxlen);