From nobody Fri Sep 27 23:45:39 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XFnCR5tQFz5XPwP; Fri, 27 Sep 2024 23:45:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XFnCR5LVbz4rKw; Fri, 27 Sep 2024 23:45:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727480739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dkrrJUJMabSqqSMyRHHcHHSjignACw8ExdNF3PcAiVA=; b=SX9ETz9doOGsGkAbOKke3eX5UDWKXzJ7QtfR086ESvLVoDgAPpwDTvbxVJqG3niJeBlEc3 m8fyZlzZHPpSy5imgGs8Mg6bGOWkXQGFOfVlsGse7Nut+1v0ZEo5qUVxfRHD7hImoQxaUj IpZY+AkiDJwmUqPxDYin/LaCC9tN3WWciGewCZGItgwIqvExDxD+4WObSZheEfygPNhWgr ZEuP51quf9YZJkQ/KUgLHIRnuaWJZpycrbpddQPIhpzJU9ZtcR9laFR4qdUuGWAC0LXEbv mXeWej8ykyatnXryTydEl3oADOgUse7fK5lU+nUZMlb6R6T0jFhshs7AD55HKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727480739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dkrrJUJMabSqqSMyRHHcHHSjignACw8ExdNF3PcAiVA=; b=tIsTtystwJaMMHBC8Tx6IU17pYc/yBv2JDk1U8r5BWx1i9Cq5+YLh9sbOxs/T8Y5EH2DWZ p1QNHkpJsOWrkkKPpq48n/GPZdSb9I6b5fJ9cIkHIKMs0XtNqPHICXl+3e0H8EitBa1rQM wGLMZx38+FDFkcI3H56geOBqUWRWdAq+azMlHJ1GZZtsY6vJ2yjlq0Kfl9cb52tsxK/E0G fJUH1BDbY1XK01gM0/BEihe6EebZdAKHqSBbc/H+ppDE9aLcPSPX+xY/EFoucvV8d83V38 7M2uzVRRCKttlve8yEgKP2JVQj2LBRLAHENj+WSlXWYE7KNQUZVVrg7lLDizCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727480739; a=rsa-sha256; cv=none; b=W2dZ1i8g6tHq7HfHwBiHzFt61a2NoyIOvshVhtV7qWoA08LPYJd8v9jRhTVjyEA28WO2Q3 uOMT0JENYttWLPIDvokNs5pCq+YG9AHo27sCwNIwpNCIAASJMfkv1PwTuqcQZEkGXr1e4D BxPBKNwGwX/XBPgcfHyiJYuc3EEjqUJ3cI4dDgaKNZ1vS+ODLY3FCpdP3z2LivaxrODo+B urkKlR8c/ovWw56MgTOCvpqhbZmnrAmu7+R+iLnMTiUwd1oSyrbBXOA+VJ2zaKBlkkzs46 7YDhluPsd5eirUUDjA/RYS5TCFLCnCWV80XI3SAFwjMILHYhZijv/n/7AHedew== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XFnCR4qYRz117Y; Fri, 27 Sep 2024 23:45:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48RNjdSf090764; Fri, 27 Sep 2024 23:45:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48RNjdmF090761; Fri, 27 Sep 2024 23:45:39 GMT (envelope-from git) Date: Fri, 27 Sep 2024 23:45:39 GMT Message-Id: <202409272345.48RNjdmF090761@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: b7cbf741d554 - main - libkern: avoid local var in order_base_2() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b7cbf741d55468ba34305a14ac3acc1c286af034 Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=b7cbf741d55468ba34305a14ac3acc1c286af034 commit b7cbf741d55468ba34305a14ac3acc1c286af034 Author: Doug Moore AuthorDate: 2024-09-27 23:43:07 +0000 Commit: Doug Moore CommitDate: 2024-09-27 23:43:07 +0000 libkern: avoid local var in order_base_2() order_base_2(n) is implemented with a variable, which keeps it from being used at file scope. Implement it instead as ilog2(2*n-1), which produces a different result when 2*n overflows, which appears unlikely in practice. Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D46826 --- sys/sys/libkern.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 64744f57b5c3..ad64d0fb0a57 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -227,10 +227,7 @@ ilog2_long_long(long long n) #define ilog2(n) (__builtin_constant_p(n) ? ilog2_const(n) : ilog2_var(n)) #define rounddown_pow_of_two(n) ((__typeof(n))1 << ilog2(n)) -#define order_base_2(n) ({ \ - __typeof(n) _n = (n); \ - _n == 1 ? 0 : 1 + ilog2(_n - 1); \ -}) +#define order_base_2(n) ilog2(2*(n)-1) #define roundup_pow_of_two(n) ((__typeof(n))1 << order_base_2(n)) #define bitcount64(x) __bitcount64((uint64_t)(x))