Revision 052e87b0 include/qemu/int128.h

b/include/qemu/int128.h
34 34
    return (Int128) { 0, 1 };
35 35
}
36 36

  
37
static inline Int128 int128_and(Int128 a, Int128 b)
38
{
39
    return (Int128) { a.lo & b.lo, a.hi & b.hi };
40
}
41

  
42
static inline Int128 int128_rshift(Int128 a, int n)
43
{
44
    int64_t h;
45
    if (!n) {
46
        return a;
47
    }
48
    h = a.hi >> (n & 63);
49
    if (n >= 64) {
50
        return (Int128) { h, h >> 63 };
51
    } else {
52
        return (Int128) { (a.lo >> n) | (a.hi << (64 - n)), h };
53
    }
54
}
55

  
37 56
static inline Int128 int128_add(Int128 a, Int128 b)
38 57
{
39 58
    Int128 r = { a.lo + b.lo, a.hi + b.hi };

Also available in: Unified diff