A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
int64x64.h
1 #ifndef INT64X64_H
2 #define INT64X64_H
3 
4 #include "ns3/core-config.h"
5 
6 #if defined (INT64X64_USE_DOUBLE) || defined (PYTHON_SCAN)
7 #include "int64x64-double.h"
8 #elif defined (INT64X64_USE_CAIRO)
9 #include "int64x64-cairo.h"
10 #elif defined (INT64X64_USE_128)
11 #include "int64x64-128.h"
12 #endif
13 
14 #include <iostream>
15 
16 namespace ns3 {
17 
18 #define INT64X64_OP_ARITH_TYPE(op,type) \
19  inline int64x64_t operator op (const int64x64_t &lhs, const type rhs) \
20  { \
21  int64x64_t tmp = lhs; \
22  tmp op ## = int64x64_t (rhs); \
23  return tmp; \
24  } \
25  inline int64x64_t operator op (const type lhs, const int64x64_t &rhs) \
26  { \
27  int64x64_t tmp = int64x64_t (lhs); \
28  tmp op ## = rhs; \
29  return tmp; \
30  }
31 
32 #define INT64X64_OP_ARITH(op) \
33  inline int64x64_t operator op (const int64x64_t &lhs, const int64x64_t &rhs) \
34  { \
35  int64x64_t tmp = lhs; \
36  tmp op ## = rhs; \
37  return tmp; \
38  } \
39  INT64X64_OP_ARITH_TYPE (op,double) \
40  INT64X64_OP_ARITH_TYPE (op,signed char) \
41  INT64X64_OP_ARITH_TYPE (op,signed short) \
42  INT64X64_OP_ARITH_TYPE (op,signed int) \
43  INT64X64_OP_ARITH_TYPE (op,signed long int) \
44  INT64X64_OP_ARITH_TYPE (op,signed long long int) \
45  INT64X64_OP_ARITH_TYPE (op,unsigned char) \
46  INT64X64_OP_ARITH_TYPE (op,unsigned short) \
47  INT64X64_OP_ARITH_TYPE (op,unsigned int) \
48  INT64X64_OP_ARITH_TYPE (op,unsigned long int) \
49  INT64X64_OP_ARITH_TYPE (op,unsigned long long int)
50 
51 #define INT64X64_OP_CMP_TYPE(op,type) \
52  inline bool operator op (const int64x64_t &lhs, const type &rhs) \
53  { \
54  return lhs op int64x64_t (rhs); \
55  } \
56  inline bool operator op (const type &lhs, const int64x64_t &rhs) \
57  { \
58  return int64x64_t (lhs) op rhs; \
59  }
60 
61 #define INT64X64_OP_CMP(op) \
62  INT64X64_OP_CMP_TYPE (op,double) \
63  INT64X64_OP_CMP_TYPE (op,signed int) \
64  INT64X64_OP_CMP_TYPE (op,signed long int) \
65  INT64X64_OP_CMP_TYPE (op,signed long long int) \
66  INT64X64_OP_CMP_TYPE (op,unsigned int) \
67  INT64X64_OP_CMP_TYPE (op,unsigned long int) \
68  INT64X64_OP_CMP_TYPE (op,unsigned long long int)
69 
70 
71 INT64X64_OP_ARITH (+)
72 INT64X64_OP_ARITH (-)
73 INT64X64_OP_ARITH (*)
74 INT64X64_OP_ARITH (/)
75 INT64X64_OP_CMP (==)
76 INT64X64_OP_CMP (!=)
77 INT64X64_OP_CMP (<)
78 INT64X64_OP_CMP (<=)
79 INT64X64_OP_CMP (>)
80 INT64X64_OP_CMP (>=)
81 
82 std::ostream &operator << (std::ostream &os, const int64x64_t &val);
83 std::istream &operator >> (std::istream &is, int64x64_t &val);
84 
85 inline int64x64_t Abs (const int64x64_t &value)
86 {
87  return (value < 0) ? -value : value;
88 }
89 
90 inline int64x64_t Min (const int64x64_t &a, const int64x64_t &b)
91 {
92  return (a < b) ? a : b;
93 }
94 
95 inline int64x64_t Max (const int64x64_t &a, const int64x64_t &b)
96 {
97  return (a > b) ? a : b;
98 }
99 
100 } // namespace ns3
101 
102 #endif /* INT64X64_H */