Date: Wed, 20 Apr 2016 01:21:39 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298323 - in head/lib/libc: db/hash net Message-ID: <201604200121.u3K1Ldot025919@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Wed Apr 20 01:21:39 2016 New Revision: 298323 URL: https://svnweb.freebsd.org/changeset/base/298323 Log: libc: use our roundup2/rounddown2() macros when param.h is available. rounddown2 tends to produce longer lines than the original code but still it makes the code more readable. Modified: head/lib/libc/db/hash/hash_page.c head/lib/libc/net/ip6opt.c head/lib/libc/net/name6.c Modified: head/lib/libc/db/hash/hash_page.c ============================================================================== --- head/lib/libc/db/hash/hash_page.c Wed Apr 20 01:17:18 2016 (r298322) +++ head/lib/libc/db/hash/hash_page.c Wed Apr 20 01:21:39 2016 (r298323) @@ -677,7 +677,7 @@ overflow_page(HTAB *hashp) bit = hashp->LAST_FREED & ((hashp->BSIZE << BYTE_SHIFT) - 1); j = bit / BITS_PER_MAP; - bit = bit & ~(BITS_PER_MAP - 1); + bit = rounddown2(bit, BITS_PER_MAP); } else { bit = 0; j = 0; Modified: head/lib/libc/net/ip6opt.c ============================================================================== --- head/lib/libc/net/ip6opt.c Wed Apr 20 01:17:18 2016 (r298322) +++ head/lib/libc/net/ip6opt.c Wed Apr 20 01:21:39 2016 (r298323) @@ -130,8 +130,7 @@ inet6_option_append(struct cmsghdr *cmsg /* calculate pad length before the option. */ off = bp - (u_char *)eh; - padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) - - (off % multx); + padlen = roundup2(off % multx, multx) - (off % multx); padlen += plusy; padlen %= multx; /* keep the pad as short as possible */ /* insert padding */ @@ -200,7 +199,7 @@ inet6_option_alloc(struct cmsghdr *cmsg, /* calculate pad length before the option. */ off = bp - (u_char *)eh; - padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) - + padlen = roundup2(off % multx, multx) - (off % multx); padlen += plusy; padlen %= multx; /* keep the pad as short as possible */ Modified: head/lib/libc/net/name6.c ============================================================================== --- head/lib/libc/net/name6.c Wed Apr 20 01:17:18 2016 (r298322) +++ head/lib/libc/net/name6.c Wed Apr 20 01:21:39 2016 (r298323) @@ -330,7 +330,7 @@ getipnodebyaddr(const void *src, size_t *errp = NO_RECOVERY; return NULL; } - if ((long)src & ~(sizeof(struct in_addr) - 1)) { + if (rounddown2((long)src, sizeof(struct in_addr))) { memcpy(&addrbuf, src, len); src = &addrbuf; } @@ -343,7 +343,8 @@ getipnodebyaddr(const void *src, size_t *errp = NO_RECOVERY; return NULL; } - if ((long)src & ~(sizeof(struct in6_addr) / 2 - 1)) { /*XXX*/ + if (rounddown2((long)src, sizeof(struct in6_addr) / 2)) { + /* XXX */ memcpy(&addrbuf, src, len); src = &addrbuf; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604200121.u3K1Ldot025919>