Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jun 2015 06:41:53 +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: r284591 - head/sys/cddl/contrib/opensolaris/uts/common/sys
Message-ID:  <201506190641.t5J6frMA036754@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Fri Jun 19 06:41:53 2015
New Revision: 284591
URL: https://svnweb.freebsd.org/changeset/base/284591

Log:
  illums compat: use flsl/flsll for highbit/highbit64
  
  Do that only when when fast inline versions are available.
  At the moment that can be the case only in the kernel and not for all
  platforms.
  
  The original code uses the binary search and that's kept as a fallback.
  This is a micro optimization.
  
  Differential Revision:	https://reviews.freebsd.org/D2839
  Reviewed by:	delphij, mahrens, mav
  MFC after:	17 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	Fri Jun 19 05:42:24 2015	(r284590)
+++ head/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h	Fri Jun 19 06:41:53 2015	(r284591)
@@ -32,6 +32,9 @@
 
 #include <sys/param.h>
 #include <sys/isa_defs.h>
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/libkern.h>
+#endif
 
 #ifdef	__cplusplus
 extern "C" {
@@ -382,6 +385,9 @@ extern unsigned char bcd_to_byte[256];
 static __inline int
 highbit(ulong_t i)
 {
+#if defined(__FreeBSD__) && defined(_KERNEL) && defined(HAVE_INLINE_FLSL)
+	return (flsl(i));
+#else
 	register int h = 1;
 
 	if (i == 0)
@@ -407,6 +413,7 @@ highbit(ulong_t i)
 		h += 1;
 	}
 	return (h);
+#endif
 }
 
 /*
@@ -416,6 +423,9 @@ highbit(ulong_t i)
 static __inline int
 highbit64(uint64_t i)
 {
+#if defined(__FreeBSD__) && defined(_KERNEL) && defined(HAVE_INLINE_FLSLL)
+	return (flsll(i));
+#else
 	int h = 1;
 
 	if (i == 0)
@@ -439,6 +449,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?201506190641.t5J6frMA036754>