1 #include "ns3/core-config.h"
2 #if !defined(INT64X64_CAIRO_H) && defined (INT64X64_USE_CAIRO) && !defined(PYTHON_SCAN)
3 #define INT64X64_CAIRO_H
12 #define noInt64x64_CAIRO_ASM 1
25 inline int64x64_t (
double value)
27 #define HPCAIRO_MAX_64 18446744073709551615.0
28 double fhi = std::floor (value);
29 int64_t hi = lround (fhi);
30 uint64_t lo = (uint64_t)((value - fhi) * HPCAIRO_MAX_64);
35 inline int64x64_t (
int v)
40 inline int64x64_t (
long int v)
45 inline int64x64_t (
long long int v)
50 inline int64x64_t (
unsigned int v)
55 inline int64x64_t (
unsigned long int v)
60 inline int64x64_t (
unsigned long long int v)
65 inline int64x64_t (int64_t hi, uint64_t lo)
71 inline int64x64_t (
const int64x64_t &o)
73 inline int64x64_t &operator = (
const int64x64_t &o)
79 inline double GetDouble (
void)
const
81 #define HPCAIRO_MAX_64 18446744073709551615.0
82 bool is_negative = IsNegative ();
84 double flo = value.
lo;
85 flo /= HPCAIRO_MAX_64;
86 double retval = value.
hi;
88 retval = is_negative ? -retval : retval;
92 inline int64_t GetHigh (
void)
const
94 return (int64_t)_v.hi;
96 inline uint64_t GetLow (
void)
const
101 void MulByInvert (
const int64x64_t &o);
103 static int64x64_t Invert (uint64_t v);
106 friend bool operator == (
const int64x64_t &lhs,
const int64x64_t &rhs);
107 friend bool operator != (
const int64x64_t &lhs,
const int64x64_t &rhs);
108 friend bool operator <= (
const int64x64_t &lhs,
const int64x64_t &rhs);
109 friend bool operator >= (
const int64x64_t &lhs,
const int64x64_t &rhs);
110 friend bool operator < (
const int64x64_t &lhs,
const int64x64_t &rhs);
111 friend bool operator > (
const int64x64_t &lhs,
const int64x64_t &rhs);
112 friend int64x64_t &
operator += (int64x64_t &lhs,
const int64x64_t &rhs);
113 friend int64x64_t &
operator -= (int64x64_t &lhs,
const int64x64_t &rhs);
114 friend int64x64_t &
operator *= (int64x64_t &lhs,
const int64x64_t &rhs);
115 friend int64x64_t &
operator /= (int64x64_t &lhs,
const int64x64_t &rhs);
116 friend int64x64_t
operator + (
const int64x64_t &lhs);
117 friend int64x64_t
operator - (
const int64x64_t &lhs);
118 friend int64x64_t
operator ! (
const int64x64_t &lhs);
119 void Mul (
const int64x64_t &o);
120 void Div (
const int64x64_t &o);
121 static cairo_uint128_t Umul (cairo_uint128_t a, cairo_uint128_t b);
122 static cairo_uint128_t Udiv (cairo_uint128_t a, cairo_uint128_t b);
123 static cairo_uint128_t UmulByInvert (cairo_uint128_t a, cairo_uint128_t b);
124 inline bool IsNegative (
void)
const
129 inline void Negate (
void)
138 inline int Compare (
const int64x64_t &o)
const
141 int64x64_t tmp = *
this;
143 status = (((int64_t)(tmp)._v.hi) < 0) ? -1 :
144 (((tmp)._v.hi == 0 && (tmp)._v.lo == 0)) ? 0 : 1;
150 inline bool operator == (
const int64x64_t &lhs,
const int64x64_t &rhs)
152 return lhs._v.hi == rhs._v.hi && lhs._v.lo == lhs._v.lo;
155 inline bool operator != (
const int64x64_t &lhs,
const int64x64_t &rhs)
157 return !(lhs == rhs);
160 inline bool operator < (
const int64x64_t &lhs,
const int64x64_t &rhs)
162 return lhs.Compare (rhs) < 0;
164 inline bool operator <= (
const int64x64_t &lhs,
const int64x64_t &rhs)
166 return lhs.Compare (rhs) <= 0;
169 inline bool operator >= (
const int64x64_t &lhs,
const int64x64_t &rhs)
171 return lhs.Compare (rhs) >= 0;
173 inline bool operator > (
const int64x64_t &lhs,
const int64x64_t &rhs)
175 return lhs.Compare (rhs) > 0;
177 inline int64x64_t &
operator += (int64x64_t &lhs,
const int64x64_t &rhs)
179 #if Int64x64_CAIRO_ASM
180 asm (
"mov 0(%1),%%eax\n\t"
181 "add %%eax,0(%0)\n\t"
182 "mov 4(%1),%%eax\n\t"
183 "adc %%eax,4(%0)\n\t"
184 "mov 8(%1),%%eax\n\t"
185 "adc %%eax,8(%0)\n\t"
186 "mov 12(%1),%%eax\n\t"
187 "adc %%eax,12(%0)\n\t"
189 :
"r" (&lhs._v),
"r" (&rhs._v)
192 lhs._v.hi += rhs._v.hi;
193 lhs._v.lo += rhs._v.lo;
194 if (lhs._v.lo < rhs._v.lo)
201 inline int64x64_t &
operator -= (int64x64_t &lhs,
const int64x64_t &rhs)
203 #if Int64x64_CAIRO_ASM
204 asm (
"mov 0(%1),%%eax\n\t"
205 "sub %%eax,0(%0)\n\t"
206 "mov 4(%1),%%eax\n\t"
207 "sbb %%eax,4(%0)\n\t"
208 "mov 8(%1),%%eax\n\t"
209 "sbb %%eax,8(%0)\n\t"
210 "mov 12(%1),%%eax\n\t"
211 "sbb %%eax,12(%0)\n\t"
213 :
"r" (&lhs._v),
"r" (&rhs._v)
216 lhs._v.hi -= rhs._v.hi;
217 lhs._v.lo -= rhs._v.lo;
218 if (lhs._v.lo > rhs._v.lo)
225 inline int64x64_t &
operator *= (int64x64_t &lhs,
const int64x64_t &rhs)
230 inline int64x64_t &
operator /= (int64x64_t &lhs,
const int64x64_t &rhs)
236 inline int64x64_t
operator + (
const int64x64_t &lhs)
241 inline int64x64_t
operator - (
const int64x64_t &lhs)
243 int64x64_t tmp = lhs;
248 inline int64x64_t
operator ! (
const int64x64_t &lhs)
250 return (lhs._v.hi == 0 && lhs._v.lo == 0) ? int64x64_t (1, 0) : int64x64_t ();
TracedValue< T > operator!(const TracedValue< T > &lhs)
cairo_int128_t _cairo_int128_negate(cairo_int128_t a)
bool operator>(const Time &lhs, const Time &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)
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)