ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Multiplatform / Protocol / VP_Os / win32 / intrin.h
1
2 #ifndef __INTRIN__H__
3 #define __INTRIN__H__
4
5
6 #ifdef USE_MINGW32
7
8 // #undef always_inline
9
10 #ifdef __GNUC__
11
12 static INLINE uint32_t _BitScanReverse(uint32_t* index, uint32_t mask)
13 {
14   __asm__("bsrl %[mask], %[index]" : [index] "=r" (*index) : [mask] "mr" (mask));
15
16   return mask ? 1 : 0;
17 }
18
19
20 static INLINE uint32_t _byteswap_ulong(uint32_t value)
21 {
22   __asm("bswap %0":
23       "=r" (value):
24       "0" (value));
25
26   return value;
27 }
28
29 #endif // __GNUC__
30
31 #else // USE_MINGW32
32 #endif // USE_MINGW32
33
34
35 static inline uint32_t clz(uint32_t code)
36 {
37   uint32_t index = 0;
38   if( code )
39   {
40     _BitScanReverse(&index, code);
41     index ^= 31;
42   }
43
44   return index;
45 }
46
47
48 #define bswap _byteswap_ulong
49
50
51 #endif // ! __INTRIN__H__
52