From owner-svn-src-head@FreeBSD.ORG Wed Jun 17 12:43:08 2015 Return-Path: Delivered-To: svn-src-head@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1C3122C71; Wed, 17 Jun 2015 12:43:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 0A7B5C30; Wed, 17 Jun 2015 12:43:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5HC55Bc051742; Wed, 17 Jun 2015 12:05:05 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5HC55LI051741; Wed, 17 Jun 2015 12:05:05 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201506171205.t5HC55LI051741@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 17 Jun 2015 12:05:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284511 - head/sys/cddl/contrib/opensolaris/uts/common/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2015 12:43:08 -0000 Author: avg Date: Wed Jun 17 12:05:04 2015 New Revision: 284511 URL: https://svnweb.freebsd.org/changeset/base/284511 Log: illumos compat: use flsl/flsll for highbit/highbit64 This is a micro optimization. The upstream code uses the binary search. Differential Revision: https://reviews.freebsd.org/D2839 Reviewed by: delphij, mav MFC after: 15 days Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h Wed Jun 17 11:48:00 2015 (r284510) +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h Wed Jun 17 12:05:04 2015 (r284511) @@ -32,6 +32,13 @@ #include #include +#ifdef __FreeBSD__ +#ifdef _KERNEL +#include +#else +#include +#endif +#endif #ifdef __cplusplus extern "C" { @@ -382,6 +389,9 @@ extern unsigned char bcd_to_byte[256]; static __inline int highbit(ulong_t i) { +#ifdef __FreeBSD__ + return (flsl(i)); +#else register int h = 1; if (i == 0) @@ -407,6 +417,7 @@ highbit(ulong_t i) h += 1; } return (h); +#endif } /* @@ -416,6 +427,9 @@ highbit(ulong_t i) static __inline int highbit64(uint64_t i) { +#ifdef __FreeBSD__ + return (flsll(i)); +#else int h = 1; if (i == 0) @@ -439,6 +453,7 @@ highbit64(uint64_t i) h += 1; } return (h); +#endif } #ifdef __cplusplus