/usr/include/ptlib/int64.h is in libpt-dev 2.10.11~dfsg-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | #ifndef PTLIB_INT64_H
#define PTLIB_INT64_H
///////////////////////////////////////////////////////////////////////////////
// Really big integer class for architectures without
#ifdef P_NEEDS_INT64
class PInt64__ {
public:
operator long() const { return (long)low; }
operator int() const { return (int)low; }
operator short() const { return (short)low; }
operator char() const { return (char)low; }
operator unsigned long() const { return (unsigned long)low; }
operator unsigned int() const { return (unsigned int)low; }
operator unsigned short() const { return (unsigned short)low; }
operator unsigned char() const { return (unsigned char)low; }
protected:
PInt64__() { }
PInt64__(unsigned long l) : low(l), high(0) { }
PInt64__(unsigned long l, unsigned long h) : low(l), high(h) { }
void operator=(const PInt64__ & v) { low = v.low; high = v.high; }
void Inc() { if (++low == 0) ++high; }
void Dec() { if (--low == 0) --high; }
void Or (long v) { low |= v; }
void And(long v) { low &= v; }
void Xor(long v) { low ^= v; }
void Add(const PInt64__ & v);
void Sub(const PInt64__ & v);
void Mul(const PInt64__ & v);
void Div(const PInt64__ & v);
void Mod(const PInt64__ & v);
void Or (const PInt64__ & v) { low |= v.low; high |= v.high; }
void And(const PInt64__ & v) { low &= v.low; high &= v.high; }
void Xor(const PInt64__ & v) { low ^= v.low; high ^= v.high; }
void ShiftLeft(int bits);
void ShiftRight(int bits);
PBoolean Eq(unsigned long v) const { return low == v && high == 0; }
PBoolean Ne(unsigned long v) const { return low != v || high != 0; }
PBoolean Eq(const PInt64__ & v) const { return low == v.low && high == v.high; }
PBoolean Ne(const PInt64__ & v) const { return low != v.low || high != v.high; }
unsigned long low, high;
};
#define DECL_OPS(cls, type) \
const cls & operator=(type v) { PInt64__::operator=(cls(v)); return *this; } \
cls operator+(type v) const { cls t = *this; t.Add(v); return t; } \
cls operator-(type v) const { cls t = *this; t.Sub(v); return t; } \
cls operator*(type v) const { cls t = *this; t.Mul(v); return t; } \
cls operator/(type v) const { cls t = *this; t.Div(v); return t; } \
cls operator%(type v) const { cls t = *this; t.Mod(v); return t; } \
cls operator|(type v) const { cls t = *this; t.Or (v); return t; } \
cls operator&(type v) const { cls t = *this; t.And(v); return t; } \
cls operator^(type v) const { cls t = *this; t.Xor(v); return t; } \
cls operator<<(type v) const { cls t = *this; t.ShiftLeft((int)v); return t; } \
cls operator>>(type v) const { cls t = *this; t.ShiftRight((int)v); return t; } \
const cls & operator+=(type v) { Add(v); return *this; } \
const cls & operator-=(type v) { Sub(v); return *this; } \
const cls & operator*=(type v) { Mul(v); return *this; } \
const cls & operator/=(type v) { Div(v); return *this; } \
const cls & operator|=(type v) { Or (v); return *this; } \
const cls & operator&=(type v) { And(v); return *this; } \
const cls & operator^=(type v) { Xor(v); return *this; } \
const cls & operator<<=(type v) { ShiftLeft((int)v); return *this; } \
const cls & operator>>=(type v) { ShiftRight((int)v); return *this; } \
PBoolean operator==(type v) const { return Eq(v); } \
PBoolean operator!=(type v) const { return Ne(v); } \
PBoolean operator< (type v) const { return Lt(v); } \
PBoolean operator> (type v) const { return Gt(v); } \
PBoolean operator>=(type v) const { return !Gt(v); } \
PBoolean operator<=(type v) const { return !Lt(v); } \
class PInt64 : public PInt64__ {
public:
PInt64() { }
PInt64(long l) : PInt64__(l, l < 0 ? -1 : 0) { }
PInt64(unsigned long l, long h) : PInt64__(l, h) { }
PInt64(const PInt64__ & v) : PInt64__(v) { }
PInt64 operator~() const { return PInt64(~low, ~high); }
PInt64 operator-() const { return operator~()+1; }
PInt64 operator++() { Inc(); return *this; }
PInt64 operator--() { Dec(); return *this; }
PInt64 operator++(int) { PInt64 t = *this; Inc(); return t; }
PInt64 operator--(int) { PInt64 t = *this; Dec(); return t; }
DECL_OPS(PInt64, char)
DECL_OPS(PInt64, unsigned char)
DECL_OPS(PInt64, short)
DECL_OPS(PInt64, unsigned short)
DECL_OPS(PInt64, int)
DECL_OPS(PInt64, unsigned int)
DECL_OPS(PInt64, long)
DECL_OPS(PInt64, unsigned long)
DECL_OPS(PInt64, const PInt64 &)
friend ostream & operator<<(ostream &, const PInt64 &);
friend istream & operator>>(istream &, PInt64 &);
protected:
void Add(long v) { Add(PInt64(v)); }
void Sub(long v) { Sub(PInt64(v)); }
void Mul(long v) { Mul(PInt64(v)); }
void Div(long v) { Div(PInt64(v)); }
void Mod(long v) { Mod(PInt64(v)); }
PBoolean Lt(long v) const { return Lt(PInt64(v)); }
PBoolean Gt(long v) const { return Gt(PInt64(v)); }
PBoolean Lt(const PInt64 &) const;
PBoolean Gt(const PInt64 &) const;
};
class PUInt64 : public PInt64__ {
public:
PUInt64() { }
PUInt64(unsigned long l) : PInt64__(l, 0) { }
PUInt64(unsigned long l, unsigned long h) : PInt64__(l, h) { }
PUInt64(const PInt64__ & v) : PInt64__(v) { }
PUInt64 operator~() const { return PUInt64(~low, ~high); }
const PUInt64 & operator++() { Inc(); return *this; }
const PUInt64 & operator--() { Dec(); return *this; }
PUInt64 operator++(int) { PUInt64 t = *this; Inc(); return t; }
PUInt64 operator--(int) { PUInt64 t = *this; Dec(); return t; }
DECL_OPS(PUInt64, char)
DECL_OPS(PUInt64, unsigned char)
DECL_OPS(PUInt64, short)
DECL_OPS(PUInt64, unsigned short)
DECL_OPS(PUInt64, int)
DECL_OPS(PUInt64, unsigned int)
DECL_OPS(PUInt64, long)
DECL_OPS(PUInt64, unsigned long)
DECL_OPS(PUInt64, const PUInt64 &)
friend ostream & operator<<(ostream &, const PUInt64 &);
friend istream & operator>>(istream &, PUInt64 &);
protected:
void Add(long v) { Add(PUInt64(v)); }
void Sub(long v) { Sub(PUInt64(v)); }
void Mul(long v) { Mul(PUInt64(v)); }
void Div(long v) { Div(PUInt64(v)); }
void Mod(long v) { Mod(PUInt64(v)); }
PBoolean Lt(long v) const { return Lt(PUInt64(v)); }
PBoolean Gt(long v) const { return Gt(PUInt64(v)); }
PBoolean Lt(const PUInt64 &) const;
PBoolean Gt(const PUInt64 &) const;
};
#undef DECL_OPS
#endif // P_NEEDS_INT64
#endif // PTLIB_INT64_H
// End Of File ///////////////////////////////////////////////////////////////
|