00001
00044 #ifndef COMPILER_H_INCLUDED
00045 #define COMPILER_H_INCLUDED
00046
00047
00048 #if defined(__CHECKER__)
00049 # include <compiler/sparse.h>
00050 #elif defined(__GNUC__)
00051 # include <compiler/gcc.h>
00052 #elif defined(__ICCAVR32__)
00053 # include <compiler/iar.h>
00054 #endif
00055
00056 #ifndef __bitwise
00057 # define __bitwise
00058 #endif
00059
00060 #ifndef __virtual
00061 # define __virtual
00062 #endif
00063
00064 #ifndef __physical
00065 # define __physical
00066 #endif
00067
00068 #ifndef __force
00069 # define __force
00070 #endif
00071
00072 #ifndef __noreturn
00073 # define __noreturn
00074 #endif
00075
00076 #ifndef __must_check
00077 # define __must_check
00078 #endif
00079
00080 #ifndef __packed
00081 # define __packed
00082 # warning Compiler does not support __packed -- expect breakage!
00083 #endif
00084
00085 #ifndef __section
00086 # define __section(name)
00087 # warning Compiler does not support __section -- expect breakage!
00088 #endif
00089
00090 #ifndef __weak
00091 # define __weak
00092 # warning Compiler does not support __weak -- expect breakage!
00093 #endif
00094
00095 #ifndef __used
00096 # define __used
00097 #endif
00098
00099 #ifndef __always_inline
00100 # define __always_inline inline
00101 #endif
00102
00103 #ifndef __printf_format
00104 # define __printf_format(fmt_index, first_arg_index)
00105 #endif
00106
00107 #ifndef likely
00108 # define likely(exp) (exp)
00109 #endif
00110
00111 #ifndef unlikely
00112 # define unlikely(exp) (exp)
00113 #endif
00114
00115 #ifndef barrier
00116 # define barrier() do { } while (0)
00117 # warning Compiler does not support barrier() -- expect breakage!
00118 #endif
00119
00120 #ifndef is_constant
00121 # define is_constant(x) (0)
00122 #endif
00123
00124 #ifndef count_leading_zeroes
00125 # include <stdint.h>
00126
00127 static inline unsigned int count_leading_zeroes(uint32_t x)
00128 {
00129 unsigned int bit = 31;
00130
00131 if (x & 0xffff0000) {
00132 bit -= 16;
00133 x >>= 16;
00134 }
00135 if (x & 0xff00) {
00136 bit -= 8;
00137 x >>= 8;
00138 }
00139 if (x & 0xf0) {
00140 bit -= 4;
00141 x >>= 4;
00142 }
00143 if (x & 0xc) {
00144 bit -= 2;
00145 x >>= 2;
00146 }
00147 if (x & 2)
00148 bit--;
00149
00150 return bit;
00151 }
00152 # define count_leading_zeroes(x) count_leading_zeroes(x)
00153 #endif
00154
00155 #ifndef bit_reverse
00156 static inline unsigned long bit_reverse(unsigned long word)
00157 {
00158 # if BITS_PER_LONG == 32
00159
00160 word = ((word >> 1) & 0x55555555) | ((word & 0x55555555) << 1);
00161
00162 word = ((word >> 2) & 0x33333333) | ((word & 0x33333333) << 2);
00163
00164 word = ((word >> 4) & 0x0F0F0F0F) | ((word & 0x0F0F0F0F) << 4);
00165
00166 word = ((word >> 8) & 0x00FF00FF) | ((word & 0x00FF00FF) << 8);
00167
00168 word = ( word >> 16 ) | ( word << 16);
00169 # else
00170 # error Could not implement bit_reverse for this architecture
00171 # endif
00172 }
00173 # define bit_reverse(word) bit_reverse(word)
00174 #endif
00175
00176 #ifndef min
00177 # define min(a, b) ((a) < (b) ? (a) : (b))
00178 # warning Compiler did not define min() -- using dangerous default definition
00179 #endif
00180
00181 #ifndef max
00182 # define max(a, b) ((a) < (b) ? (b) : (a))
00183 # warning Compiler did not define max() -- using dangerous default definition
00184 #endif
00185
00186 #endif