svn commit: r322032 - in head/sys: amd64/include i386/include

Conrad Meyer cem at FreeBSD.org
Thu Aug 3 22:28:32 UTC 2017


Author: cem
Date: Thu Aug  3 22:28:30 2017
New Revision: 322032
URL: https://svnweb.freebsd.org/changeset/base/322032

Log:
  x86: Tag some intrinsics with __pure2
  
  Some C wrappers for x86 instructions do not touch global memory and only act
  on their arguments; they can be marked __pure2, aka __const__.  Without this
  annotation, Clang 3.9.1 is not intelligent enough on its own to grok that
  these functions are __const__.
  
  Submitted by:	Anton Rang <anton.rang AT isilon.com>
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/amd64/include/cpufunc.h
  head/sys/i386/include/cpufunc.h

Modified: head/sys/amd64/include/cpufunc.h
==============================================================================
--- head/sys/amd64/include/cpufunc.h	Thu Aug  3 21:37:57 2017	(r322031)
+++ head/sys/amd64/include/cpufunc.h	Thu Aug  3 22:28:30 2017	(r322032)
@@ -63,7 +63,7 @@ breakpoint(void)
 	__asm __volatile("int $3");
 }
 
-static __inline u_int
+static __inline __pure2 u_int
 bsfl(u_int mask)
 {
 	u_int	result;
@@ -72,7 +72,7 @@ bsfl(u_int mask)
 	return (result);
 }
 
-static __inline u_long
+static __inline __pure2 u_long
 bsfq(u_long mask)
 {
 	u_long	result;
@@ -81,7 +81,7 @@ bsfq(u_long mask)
 	return (result);
 }
 
-static __inline u_int
+static __inline __pure2 u_int
 bsrl(u_int mask)
 {
 	u_int	result;
@@ -90,7 +90,7 @@ bsrl(u_int mask)
 	return (result);
 }
 
-static __inline u_long
+static __inline __pure2 u_long
 bsrq(u_long mask)
 {
 	u_long	result;
@@ -155,7 +155,7 @@ enable_intr(void)
 
 #define	HAVE_INLINE_FFSL
 
-static __inline int
+static __inline __pure2 int
 ffsl(long mask)
 {
 	return (mask == 0 ? mask : (int)bsfq((u_long)mask) + 1);
@@ -163,7 +163,7 @@ ffsl(long mask)
 
 #define	HAVE_INLINE_FFSLL
 
-static __inline int
+static __inline __pure2 int
 ffsll(long long mask)
 {
 	return (ffsl((long)mask));
@@ -171,7 +171,7 @@ ffsll(long long mask)
 
 #define	HAVE_INLINE_FLS
 
-static __inline int
+static __inline __pure2 int
 fls(int mask)
 {
 	return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
@@ -179,7 +179,7 @@ fls(int mask)
 
 #define	HAVE_INLINE_FLSL
 
-static __inline int
+static __inline __pure2 int
 flsl(long mask)
 {
 	return (mask == 0 ? mask : (int)bsrq((u_long)mask) + 1);
@@ -187,7 +187,7 @@ flsl(long mask)
 
 #define	HAVE_INLINE_FLSLL
 
-static __inline int
+static __inline __pure2 int
 flsll(long long mask)
 {
 	return (flsl((long)mask));

Modified: head/sys/i386/include/cpufunc.h
==============================================================================
--- head/sys/i386/include/cpufunc.h	Thu Aug  3 21:37:57 2017	(r322031)
+++ head/sys/i386/include/cpufunc.h	Thu Aug  3 22:28:30 2017	(r322032)
@@ -60,7 +60,7 @@ breakpoint(void)
 	__asm __volatile("int $3");
 }
 
-static __inline u_int
+static __inline __pure2 u_int
 bsfl(u_int mask)
 {
 	u_int	result;
@@ -69,7 +69,7 @@ bsfl(u_int mask)
 	return (result);
 }
 
-static __inline u_int
+static __inline __pure2 u_int
 bsrl(u_int mask)
 {
 	u_int	result;
@@ -169,7 +169,7 @@ sfence(void)
 
 #define	HAVE_INLINE_FFS
 
-static __inline int
+static __inline __pure2 int
 ffs(int mask)
 {
 	/*
@@ -183,7 +183,7 @@ ffs(int mask)
 
 #define	HAVE_INLINE_FFSL
 
-static __inline int
+static __inline __pure2 int
 ffsl(long mask)
 {
 	return (ffs((int)mask));
@@ -191,7 +191,7 @@ ffsl(long mask)
 
 #define	HAVE_INLINE_FLS
 
-static __inline int
+static __inline __pure2 int
 fls(int mask)
 {
 	return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
@@ -199,7 +199,7 @@ fls(int mask)
 
 #define	HAVE_INLINE_FLSL
 
-static __inline int
+static __inline __pure2 int
 flsl(long mask)
 {
 	return (fls((int)mask));


More information about the svn-src-head mailing list