From owner-svn-src-all@freebsd.org Wed Apr 20 01:21:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0EB4CB14AF2; Wed, 20 Apr 2016 01:21:41 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B072216FA; Wed, 20 Apr 2016 01:21:40 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3K1LdAg025922; Wed, 20 Apr 2016 01:21:39 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3K1Ldot025919; Wed, 20 Apr 2016 01:21:39 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604200121.u3K1Ldot025919@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 20 Apr 2016 01:21:39 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2016 01:21:41 -0000 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; }