~ubuntu-branches/debian/stretch/spice/stretch

« back to all changes in this revision

Viewing changes to common/gl_utils.h

  • Committer: Package Import Robot
  • Author(s): Liang Guo, Liang Guo, Michael Tokarev
  • Date: 2011-11-29 14:37:08 UTC
  • mfrom: (0.5.1) (0.2.2)
  • mto: (2.2.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: package-import@ubuntu.com-20111129143708-ovrce9zj5l6rwi1m
[ Liang Guo ]
* New upstream release (Closes: #651262)
* Refresh debian/copyright
* Remove fix-typo-in-cmd_line_parser-cpp.patch, applied upstream
* Remove fix-typo-in-record-cpp.patch, applied upstream
* Remove use-requires-private-for-libspice-pkgconfig.patch, applied upstream
* Change Build-Depends on libspice-protocol-dev to (>= 0.9.1~)
* Refresh libspice-server1.symbols
* Update debian/rules clean target
* Ignore common/win/my_getopt-1.5/Makefile change when building package
* debian/control: set DMUA

[ Michael Tokarev ]
* use `rm -f' instead of `-rm' in debian/rules clean targets
* remove python_modules/*.pyc in clean target

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#define GLC_ERROR_TEST_FINISH ;
50
50
#endif
51
51
 
52
 
#ifdef WIN32
53
 
static inline int find_msb(uint32_t val)
54
 
{
55
 
    uint32_t r;
56
 
    __asm {
57
 
        bsr eax, val
58
 
        jnz found
59
 
        mov eax, -1
60
 
 
61
 
found:
62
 
        mov r, eax
63
 
    }
64
 
    return r + 1;
65
 
}
66
 
 
67
 
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
68
 
static inline int find_msb(unsigned int val)
69
 
{
70
 
    int ret;
71
 
 
72
 
    asm ("bsrl %1,%0\n\t"
73
 
         "jnz 1f\n\t"
74
 
         "movl $-1,%0\n"
75
 
         "1:"
76
 
         : "=r"(ret) : "r"(val));
77
 
    return ret + 1;
78
 
}
79
 
 
80
 
#else
81
 
static inline int find_msb(unsigned int val)
82
 
{
83
 
    signed char index = 31;
84
 
 
85
 
    if(val == 0) {
86
 
        return 0;
87
 
    }
88
 
 
89
 
    do {
90
 
        if(val & 0x80000000) {
91
 
            break;
92
 
        }
93
 
        val <<= 1;
94
 
    } while(--index >= 0);
95
 
 
96
 
    return index+1;
97
 
}
98
 
 
99
 
#endif
100
 
 
101
 
static inline int gl_get_to_power_two(unsigned int val)
102
 
{
103
 
    if ((val & (val - 1)) == 0) {
104
 
        return val;
105
 
    }
106
 
    return 1 << find_msb(val);
107
 
}
 
52
#include "bitops.h"
 
53
 
 
54
#define find_msb spice_bit_find_msb
 
55
#define gl_get_to_power_two spice_bit_next_pow2
108
56
 
109
57
#ifdef __cplusplus
110
58
}