Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jun 2015 12:05:05 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
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
Message-ID:  <201506171205.t5HC55LI051741@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/param.h>
 #include <sys/isa_defs.h>
+#ifdef __FreeBSD__
+#ifdef _KERNEL
+#include <machine/cpufunc.h>
+#else
+#include <strings.h>
+#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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506171205.t5HC55LI051741>