diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2010-05-03 11:32:35 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2010-05-03 11:36:59 +0200 |
commit | a5cf90922eb4752fcfe2de17ac7c458b26b7d430 (patch) | |
tree | 2ddd5d719d90bf76deec040a3e4eee43f1f4caf0 | |
parent | ae40f270cfbe4629c041074e2b0c28dfd3f554b8 (diff) | |
download | spice-a5cf90922eb4752fcfe2de17ac7c458b26b7d430.tar.gz spice-a5cf90922eb4752fcfe2de17ac7c458b26b7d430.tar.xz spice-a5cf90922eb4752fcfe2de17ac7c458b26b7d430.zip |
Add C version of find_msb()
This patch allows people to build the spice-client on any 32bit/64bit
architecture.
by Bryan Stillwell <bryan@bokeoa.com>
-rw-r--r-- | common/gl_utils.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/common/gl_utils.h b/common/gl_utils.h index eeb9f02e..eecff269 100644 --- a/common/gl_utils.h +++ b/common/gl_utils.h @@ -60,7 +60,7 @@ found: return r + 1; } -#else +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) static inline int find_msb(unsigned int val) { int ret; @@ -73,6 +73,25 @@ static inline int find_msb(unsigned int val) return ret + 1; } +#else +static inline int find_msb(unsigned int val) +{ + signed char index = 31; + + if(val == 0) { + return 0; + } + + do { + if(val & 0x80000000) { + break; + } + val <<= 1; + } while(--index >= 0); + + return index+1; +} + #endif static inline int gl_get_to_power_two(unsigned int val) |