You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							85 lines
						
					
					
						
							2.4 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							85 lines
						
					
					
						
							2.4 KiB
						
					
					
				| From 93d0c81ecf7b45b2a53e44932f793660173387e9 Mon Sep 17 00:00:00 2001 | |
| From: Nicker <nickersk@gmail.com> | |
| Date: Fri, 20 Jul 2018 13:59:16 +0200 | |
| Subject: [PATCH 2/3] log2-give up on gcc constant optimizations | |
| 
 | |
| 
 | |
| diff --git a/include/linux/log2.h b/include/linux/log2.h | |
| index fd7ff3d9..f38fae23 100644 | |
| --- a/include/linux/log2.h | |
| +++ b/include/linux/log2.h | |
| @@ -15,12 +15,6 @@ | |
|  #include <linux/types.h> | |
|  #include <linux/bitops.h> | |
|   | |
| -/* | |
| - * deal with unrepresentable constant logarithms | |
| - */ | |
| -extern __attribute__((const, noreturn)) | |
| -int ____ilog2_NaN(void); | |
| - | |
|  /* | |
|   * non-constant log of base 2 calculators | |
|   * - the arch may override these in asm/bitops.h if they can be implemented | |
| @@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) | |
|  #define ilog2(n)				\ | |
|  (						\ | |
|  	__builtin_constant_p(n) ? (		\ | |
| -		(n) < 1 ? ____ilog2_NaN() :	\ | |
| +		(n) < 2 ? 0 :			\ | |
|  		(n) & (1ULL << 63) ? 63 :	\ | |
|  		(n) & (1ULL << 62) ? 62 :	\ | |
|  		(n) & (1ULL << 61) ? 61 :	\ | |
| @@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) | |
|  		(n) & (1ULL <<  4) ?  4 :	\ | |
|  		(n) & (1ULL <<  3) ?  3 :	\ | |
|  		(n) & (1ULL <<  2) ?  2 :	\ | |
| -		(n) & (1ULL <<  1) ?  1 :	\ | |
| -		(n) & (1ULL <<  0) ?  0 :	\ | |
| -		____ilog2_NaN()			\ | |
| -				   ) :		\ | |
| +		1 ) :				\ | |
|  	(sizeof(n) <= 4) ?			\ | |
|  	__ilog2_u32(n) :			\ | |
|  	__ilog2_u64(n)				\ | |
| diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h | |
| index 41446668..d5677d39 100644 | |
| --- a/tools/include/linux/log2.h | |
| +++ b/tools/include/linux/log2.h | |
| @@ -12,12 +12,6 @@ | |
|  #ifndef _TOOLS_LINUX_LOG2_H | |
|  #define _TOOLS_LINUX_LOG2_H | |
|   | |
| -/* | |
| - * deal with unrepresentable constant logarithms | |
| - */ | |
| -extern __attribute__((const, noreturn)) | |
| -int ____ilog2_NaN(void); | |
| - | |
|  /* | |
|   * non-constant log of base 2 calculators | |
|   * - the arch may override these in asm/bitops.h if they can be implemented | |
| @@ -78,7 +72,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) | |
|  #define ilog2(n)				\ | |
|  (						\ | |
|  	__builtin_constant_p(n) ? (		\ | |
| -		(n) < 1 ? ____ilog2_NaN() :	\ | |
| +		(n) < 2 ? 0 :			\ | |
|  		(n) & (1ULL << 63) ? 63 :	\ | |
|  		(n) & (1ULL << 62) ? 62 :	\ | |
|  		(n) & (1ULL << 61) ? 61 :	\ | |
| @@ -141,10 +135,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) | |
|  		(n) & (1ULL <<  4) ?  4 :	\ | |
|  		(n) & (1ULL <<  3) ?  3 :	\ | |
|  		(n) & (1ULL <<  2) ?  2 :	\ | |
| -		(n) & (1ULL <<  1) ?  1 :	\ | |
| -		(n) & (1ULL <<  0) ?  0 :	\ | |
| -		____ilog2_NaN()			\ | |
| -				   ) :		\ | |
| +		1 ) :				\ | |
|  	(sizeof(n) <= 4) ?			\ | |
|  	__ilog2_u32(n) :			\ | |
|  	__ilog2_u64(n)				\ | |
| --  | |
| 2.17.1 | |
| 
 | |
| 
 |