~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/zstd/common/compiler.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /lib/zstd/common/compiler.h (Version linux-6.11-rc3) and /lib/zstd/common/compiler.h (Version linux-2.6.0)


  1 /*                                                  1 
  2  * Copyright (c) Yann Collet, Facebook, Inc.      
  3  * All rights reserved.                           
  4  *                                                
  5  * This source code is licensed under both the    
  6  * LICENSE file in the root directory of this     
  7  * in the COPYING file in the root directory o    
  8  * You may select, at your option, one of the     
  9  */                                               
 10                                                   
 11 #ifndef ZSTD_COMPILER_H                           
 12 #define ZSTD_COMPILER_H                           
 13                                                   
 14 #include "portability_macros.h"                   
 15                                                   
 16 /*-*******************************************    
 17 *  Compiler specifics                             
 18 **********************************************    
 19 /* force inlining */                              
 20                                                   
 21 #if !defined(ZSTD_NO_INLINE)                      
 22 #if (defined(__GNUC__) && !defined(__STRICT_AN    
 23 #  define INLINE_KEYWORD inline                   
 24 #else                                             
 25 #  define INLINE_KEYWORD                          
 26 #endif                                            
 27                                                   
 28 #define FORCE_INLINE_ATTR __attribute__((alway    
 29                                                   
 30 #else                                             
 31                                                   
 32 #define INLINE_KEYWORD                            
 33 #define FORCE_INLINE_ATTR                         
 34                                                   
 35 #endif                                            
 36                                                   
 37 /*                                                
 38   On MSVC qsort requires that functions passed    
 39   This explicitly marks such functions as __cd    
 40   if a CC other than __cdecl has been made the    
 41 */                                                
 42 #define WIN_CDECL                                 
 43                                                   
 44 /*                                                
 45  * FORCE_INLINE_TEMPLATE is used to define C "    
 46  * parameters. They must be inlined for the co    
 47  * branches.                                      
 48  */                                               
 49 #define FORCE_INLINE_TEMPLATE static INLINE_KE    
 50 /*                                                
 51  * HINT_INLINE is used to help the compiler ge    
 52  * used for "templates", so it can be tweaked     
 53  * performance.                                   
 54  *                                                
 55  * gcc-4.8 and gcc-4.9 have been shown to bene    
 56  * always_inline attribute.                       
 57  *                                                
 58  * clang up to 5.0.0 (trunk) benefit tremendou    
 59  * attribute.                                     
 60  */                                               
 61 #if !defined(__clang__) && defined(__GNUC__) &    
 62 #  define HINT_INLINE static INLINE_KEYWORD       
 63 #else                                             
 64 #  define HINT_INLINE static INLINE_KEYWORD FO    
 65 #endif                                            
 66                                                   
 67 /* UNUSED_ATTR tells the compiler it is okay i    
 68 #define UNUSED_ATTR __attribute__((unused))       
 69                                                   
 70 /* force no inlining */                           
 71 #define FORCE_NOINLINE static __attribute__((_    
 72                                                   
 73                                                   
 74 /* target attribute */                            
 75 #define TARGET_ATTRIBUTE(target) __attribute__    
 76                                                   
 77 /* Target attribute for BMI2 dynamic dispatch.    
 78  * Enable lzcnt, bmi, and bmi2.                   
 79  * We test for bmi1 & bmi2. lzcnt is included     
 80  */                                               
 81 #define BMI2_TARGET_ATTRIBUTE TARGET_ATTRIBUTE    
 82                                                   
 83 /* prefetch                                       
 84  * can be disabled, by declaring NO_PREFETCH b    
 85 #if ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) &&     
 86 #  define PREFETCH_L1(ptr)  __builtin_prefetch    
 87 #  define PREFETCH_L2(ptr)  __builtin_prefetch    
 88 #elif defined(__aarch64__)                        
 89 #  define PREFETCH_L1(ptr)  __asm__ __volatile    
 90 #  define PREFETCH_L2(ptr)  __asm__ __volatile    
 91 #else                                             
 92 #  define PREFETCH_L1(ptr) (void)(ptr)  /* dis    
 93 #  define PREFETCH_L2(ptr) (void)(ptr)  /* dis    
 94 #endif  /* NO_PREFETCH */                         
 95                                                   
 96 #define CACHELINE_SIZE 64                         
 97                                                   
 98 #define PREFETCH_AREA(p, s)  {            \       
 99     const char* const _ptr = (const char*)(p);    
100     size_t const _size = (size_t)(s);     \       
101     size_t _pos;                          \       
102     for (_pos=0; _pos<_size; _pos+=CACHELINE_S    
103         PREFETCH_L2(_ptr + _pos);         \       
104     }                                     \       
105 }                                                 
106                                                   
107 /* vectorization                                  
108  * older GCC (pre gcc-4.3 picked as the cutoff    
109  * and some compilers, like Intel ICC and MCST    
110 #if !defined(__INTEL_COMPILER) && !defined(__c    
111 #  if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) ||    
112 #    define DONT_VECTORIZE __attribute__((opti    
113 #  else                                           
114 #    define DONT_VECTORIZE _Pragma("GCC optimi    
115 #  endif                                          
116 #else                                             
117 #  define DONT_VECTORIZE                          
118 #endif                                            
119                                                   
120 /* Tell the compiler that a branch is likely o    
121  * Only use these macros if it causes the comp    
122  * If you can remove a LIKELY/UNLIKELY annotat    
123  * and clang, please do.                          
124  */                                               
125 #define LIKELY(x) (__builtin_expect((x), 1))      
126 #define UNLIKELY(x) (__builtin_expect((x), 0))    
127                                                   
128 #if __has_builtin(__builtin_unreachable) || (d    
129 #  define ZSTD_UNREACHABLE { assert(0), __buil    
130 #else                                             
131 #  define ZSTD_UNREACHABLE { assert(0); }         
132 #endif                                            
133                                                   
134 /* disable warnings */                            
135                                                   
136 /*Like DYNAMIC_BMI2 but for compile time deter    
137                                                   
138                                                   
139 /* compile time determination of SIMD support     
140                                                   
141 /* C-language Attributes are added in C23. */     
142 #if defined(__STDC_VERSION__) && (__STDC_VERSI    
143 # define ZSTD_HAS_C_ATTRIBUTE(x) __has_c_attri    
144 #else                                             
145 # define ZSTD_HAS_C_ATTRIBUTE(x) 0                
146 #endif                                            
147                                                   
148 /* Only use C++ attributes in C++. Some compil    
149  * attributes when compiling with C.              
150  */                                               
151 #define ZSTD_HAS_CPP_ATTRIBUTE(x) 0               
152                                                   
153 /* Define ZSTD_FALLTHROUGH macro for annotatin    
154  * - C23: https://en.cppreference.com/w/c/lang    
155  * - CPP17: https://en.cppreference.com/w/cpp/    
156  * - Else: __attribute__((__fallthrough__))       
157  */                                               
158 #define ZSTD_FALLTHROUGH fallthrough              
159                                                   
160 /*-*******************************************    
161 *  Alignment check                                
162 **********************************************    
163                                                   
164 /* this test was initially positioned in mem.h    
165  * but this file is removed (or replaced) for     
166  * so it's now hosted in compiler.h,              
167  * which remains valid for both user & kernel     
168  */                                               
169                                                   
170 #ifndef ZSTD_ALIGNOF                              
171 /* covers gcc, clang & MSVC */                    
172 /* note : this section must come first, before    
173  * due to a limitation in the kernel source ge    
174 #  define ZSTD_ALIGNOF(T) __alignof(T)            
175                                                   
176 #endif /* ZSTD_ALIGNOF */                         
177                                                   
178 /*-*******************************************    
179 *  Sanitizer                                      
180 **********************************************    
181                                                   
182                                                   
183                                                   
184 #endif /* ZSTD_COMPILER_H */                      
185                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php