1 #include "ns3/core-config.h"
2 #if !defined(INT64X64_128_H) && defined (INT64X64_USE_128) && !defined(PYTHON_SCAN)
5 #include "ns3/core-config.h"
9 #if defined(HAVE___UINT128_T) && !defined(HAVE_UINT128_T)
10 typedef __uint128_t uint128_t;
11 typedef __int128_t int128_t;
16 #define HP128_MAX_64 18446744073709551615.0
17 #define HP128_MASK_LO ((((int128_t)1)<<64)-1)
25 inline int64x64_t (
double value)
27 bool is_negative = value < 0;
28 value = is_negative ? -value : value;
29 double hi = std::floor (value);
30 double lo = (value - hi) * HP128_MAX_64;
34 _v = is_negative ? -_v : _v;
36 inline int64x64_t (
int v)
41 inline int64x64_t (
long int v)
46 inline int64x64_t (
long long int v)
51 inline int64x64_t (
unsigned int v)
56 inline int64x64_t (
unsigned long int v)
61 inline int64x64_t (
unsigned long long int v)
66 explicit inline int64x64_t (int64_t hi, uint64_t lo)
68 bool is_negative = hi<0;
69 _v = is_negative ? -hi : hi;
72 _v = is_negative ? -_v : _v;
75 inline int64x64_t (
const int64x64_t &o)
77 inline int64x64_t &operator = (
const int64x64_t &o)
83 inline double GetDouble (
void)
const
85 bool is_negative = _v < 0;
86 uint128_t value = is_negative ? -_v : _v;
87 uint64_t hi = value >> 64;
93 retval = is_negative ? -retval : retval;
96 inline int64_t GetHigh (
void)
const
98 bool negative = _v < 0;
99 int128_t v = negative ? -_v : _v;
102 return negative ? -retval : retval;
104 inline uint64_t GetLow (
void)
const
106 bool negative = _v < 0;
107 int128_t v = negative ? -_v : _v;
108 int128_t low = v & HP128_MASK_LO;
109 uint64_t retval = low;
115 void MulByInvert (
const int64x64_t &o);
117 static int64x64_t Invert (uint64_t v);
120 friend bool operator == (
const int64x64_t &lhs,
const int64x64_t &rhs);
121 friend bool operator != (
const int64x64_t &lhs,
const int64x64_t &rhs);
122 friend bool operator <= (
const int64x64_t &lhs,
const int64x64_t &rhs);
123 friend bool operator >= (
const int64x64_t &lhs,
const int64x64_t &rhs);
124 friend bool operator < (
const int64x64_t &lhs,
const int64x64_t &rhs);
125 friend bool operator > (
const int64x64_t &lhs,
const int64x64_t &rhs);
126 friend int64x64_t &
operator += (int64x64_t &lhs,
const int64x64_t &rhs);
127 friend int64x64_t &
operator -= (int64x64_t &lhs,
const int64x64_t &rhs);
128 friend int64x64_t &
operator *= (int64x64_t &lhs,
const int64x64_t &rhs);
129 friend int64x64_t &
operator /= (int64x64_t &lhs,
const int64x64_t &rhs);
130 friend int64x64_t
operator + (
const int64x64_t &lhs,
const int64x64_t &rhs);
131 friend int64x64_t
operator - (
const int64x64_t &lhs,
const int64x64_t &rhs);
132 friend int64x64_t
operator * (
const int64x64_t &lhs,
const int64x64_t &rhs);
133 friend int64x64_t
operator / (
const int64x64_t &lhs,
const int64x64_t &rhs);
134 friend int64x64_t
operator + (
const int64x64_t &lhs);
135 friend int64x64_t
operator - (
const int64x64_t &lhs);
136 friend int64x64_t
operator ! (
const int64x64_t &lhs);
137 void Mul (
const int64x64_t &o);
138 void Div (
const int64x64_t &o);
139 static uint128_t UmulByInvert (uint128_t a, uint128_t b);
140 static uint128_t Umul (uint128_t a, uint128_t b);
141 static uint128_t Divu (uint128_t a, uint128_t b);
142 inline int64x64_t (int128_t v)
148 inline bool operator == (
const int64x64_t &lhs,
const int64x64_t &rhs)
150 return lhs._v == rhs._v;
153 inline bool operator != (
const int64x64_t &lhs,
const int64x64_t &rhs)
155 return lhs._v != rhs._v;
158 inline bool operator < (
const int64x64_t &lhs,
const int64x64_t &rhs)
160 return lhs._v < rhs._v;
162 inline bool operator <= (
const int64x64_t &lhs,
const int64x64_t &rhs)
164 return lhs._v <= rhs._v;
167 inline bool operator >= (
const int64x64_t &lhs,
const int64x64_t &rhs)
169 return lhs._v >= rhs._v;
171 inline bool operator > (
const int64x64_t &lhs,
const int64x64_t &rhs)
173 return lhs._v > rhs._v;
175 inline int64x64_t &
operator += (int64x64_t &lhs,
const int64x64_t &rhs)
180 inline int64x64_t &
operator -= (int64x64_t &lhs,
const int64x64_t &rhs)
185 inline int64x64_t &
operator *= (int64x64_t &lhs,
const int64x64_t &rhs)
190 inline int64x64_t &
operator /= (int64x64_t &lhs,
const int64x64_t &rhs)
196 inline int64x64_t
operator + (
const int64x64_t &lhs)
201 inline int64x64_t
operator - (
const int64x64_t &lhs)
203 return int64x64_t (-lhs._v);
206 inline int64x64_t
operator ! (
const int64x64_t &lhs)
208 return int64x64_t (!lhs._v);
TracedValue< T > operator!(const TracedValue< T > &lhs)
bool operator>(const Time &lhs, const Time &rhs)
TracedValue< T > operator*(const TracedValue< T > &lhs, const TracedValue< U > &rhs)
bool operator<(const Room &a, const Room &b)
Time & operator+=(Time &lhs, const Time &rhs)
TracedValue< T > & operator*=(TracedValue< T > &lhs, const U &rhs)
Time operator+(const Time &lhs, const Time &rhs)
TracedValue< T > operator/(const TracedValue< T > &lhs, const TracedValue< U > &rhs)
bool operator<=(const Time &lhs, const Time &rhs)
Time & operator-=(Time &lhs, const Time &rhs)
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
bool operator>=(const Time &lhs, const Time &rhs)
Time operator-(const Time &lhs, const Time &rhs)
TracedValue< T > & operator/=(TracedValue< T > &lhs, const U &rhs)
bool operator==(const EventId &a, const EventId &b)