Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / include / cmp.h
1 #ifndef __CEPH_CMP_H
2 #define __CEPH_CMP_H
3
4 /*
5  * macros to define comparison operators for classes with small numbers of members.
6  */
7
8 #define WRITE_EQ_OPERATORS_1(type, a)                                   \
9   inline bool operator==(const type &l, const type &r) {                \
10     return l.a == r.a;                                                  \
11   }                                                                     \
12   inline bool operator!=(const type &l, const type &r) {                \
13     return l.a != r.a;                                                  \
14   }
15
16 #define WRITE_CMP_OPERATORS_1(type, a)                                  \
17   inline bool operator>(const type &l, const type &r) {                 \
18     return l.a > r.a;                                                   \
19   }                                                                     \
20   inline bool operator<(const type &l, const type &r) {                 \
21     return l.a < r.a;                                                   \
22   }                                                                     \
23   inline bool operator>=(const type &l, const type &r) {                \
24     return l.a >= r.a;                                                  \
25   }                                                                     \
26   inline bool operator<=(const type &l, const type &r) {                \
27     return l.a <= r.a;                                                  \
28   }
29
30 #define WRITE_EQ_OPERATORS_2(type, a, b)                                \
31   inline bool operator==(const type &l, const type &r) {                \
32     return l.a == r.a && l.b == r.b;                                    \
33   }                                                                     \
34   inline bool operator!=(const type &l, const type &r) {                \
35     return l.a != r.a || l.b != r.b;                                    \
36   }
37
38 #define WRITE_CMP_OPERATORS_2(type, a, b)                       \
39   inline bool operator>(const type &l, const type &r) {                 \
40     return l.a > r.a ||                                                 \
41       (l.a == r.a && (l.b > r.b));                                      \
42   }                                                                     \
43   inline bool operator<(const type &l, const type &r) {                 \
44     return l.a < r.a ||                                                 \
45       (l.a == r.a && (l.b < r.b));                                      \
46   }                                                                     \
47   inline bool operator>=(const type &l, const type &r) {                \
48     return l.a > r.a ||                                                 \
49       (l.a == r.a && (l.b >= r.b));                                     \
50   }                                                                     \
51   inline bool operator<=(const type &l, const type &r) {                \
52     return l.a < r.a ||                                                 \
53       (l.a == r.a && (l.b <= r.b));                                     \
54   }
55
56
57 #define WRITE_EQ_OPERATORS_3(type, a, b, c)                             \
58   inline bool operator==(const type &l, const type &r) {                \
59     return l.a == r.a && l.b == r.b && l.c == r.c;                      \
60   }                                                                     \
61   inline bool operator!=(const type &l, const type &r) {                \
62     return l.a != r.a || l.b != r.b || l.c != r.c;                      \
63   }
64
65 #define WRITE_CMP_OPERATORS_3(type, a, b, c)                            \
66   inline bool operator>(const type &l, const type &r) {                 \
67     return l.a > r.a ||                                                 \
68       (l.a == r.a && (l.b > r.b ||                                      \
69                       (l.b == r.b && (l.c > r.c))));                    \
70   }                                                                     \
71   inline bool operator<(const type &l, const type &r) {                 \
72     return l.a < r.a ||                                                 \
73       (l.a == r.a && (l.b < r.b ||                                      \
74                       (l.b == r.b && (l.c < r.c))));                    \
75   }                                                                     \
76   inline bool operator>=(const type &l, const type &r) {                \
77     return l.a > r.a ||                                                 \
78       (l.a == r.a && (l.b > r.b ||                                      \
79                       (l.b == r.b && (l.c >= r.c))));                   \
80   }                                                                     \
81   inline bool operator<=(const type &l, const type &r) {                \
82     return l.a < r.a ||                                                 \
83       (l.a == r.a && (l.b < r.b ||                                      \
84                       (l.b == r.b && (l.c <= r.c))));                   \
85   }
86
87 #define WRITE_EQ_OPERATORS_4(type, a, b, c, d)                          \
88   inline bool operator==(const type &l, const type &r) {                \
89     return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d;        \
90   }                                                                     \
91   inline bool operator!=(const type &l, const type &r) {                \
92     return l.a != r.a || l.b != r.b || l.c != r.c || l.d != r.d;        \
93   }
94
95 #define WRITE_CMP_OPERATORS_4(type, a, b, c, d)                         \
96   inline bool operator>(const type &l, const type &r) {                 \
97     return l.a > r.a ||                                                 \
98       (l.a == r.a && (l.b > r.b ||                                      \
99                       (l.b == r.b && (l.c > r.c ||                      \
100                                       (l.c == r.c && (l.d > r.d))))));  \
101   }                                                                     \
102   inline bool operator<(const type &l, const type &r) {                 \
103     return l.a < r.a ||                                                 \
104       (l.a == r.a && (l.b < r.b ||                                      \
105                       (l.b == r.b && (l.c < r.c ||                      \
106                                       (l.c == r.c && (l.d < r.d))))));  \
107   }                                                                     \
108   inline bool operator>=(const type &l, const type &r) {                \
109     return l.a > r.a ||                                                 \
110       (l.a == r.a && (l.b > r.b ||                                      \
111                       (l.b == r.b && (l.c > r.c ||                      \
112                                       (l.c == r.c && (l.d >= r.d)))))); \
113   }                                                                     \
114   inline bool operator<=(const type &l, const type &r) {                \
115     return l.a < r.a ||                                                 \
116       (l.a == r.a && (l.b < r.b ||                                      \
117                       (l.b == r.b && (l.c < r.c ||                      \
118                                       (l.c == r.c && (l.d <= r.d)))))); \
119   }
120
121
122
123 #define WRITE_EQ_OPERATORS_5(type, a, b, c, d, e)                       \
124   inline bool operator==(const type &l, const type &r) {                \
125     return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d && l.e == r.e; \
126   }                                                                     \
127   inline bool operator!=(const type &l, const type &r) {                \
128     return l.a != r.a || l.b != r.b || l.c != r.c || l.d != r.d || l.e != r.e; \
129   }
130
131 #define WRITE_CMP_OPERATORS_5(type, a, b, c, d, e)                      \
132   inline bool operator>(const type &l, const type &r) {                 \
133     return l.a > r.a ||                                                 \
134       (l.a == r.a && (l.b > r.b ||                                      \
135                       (l.b == r.b && (l.c > r.c ||                      \
136                                       (l.c == r.c && (l.d > r.d ||      \
137                                                       (l.d == r.d && l.e > r.e))))))); \
138   }                                                                     \
139   inline bool operator<(const type &l, const type &r) {                 \
140     return l.a < r.a ||                                                 \
141       (l.a == r.a && (l.b < r.b ||                                      \
142                       (l.b == r.b && (l.c < r.c ||                      \
143                                       (l.c == r.c && (l.d < r.d ||      \
144                                                       (l.d == r.d && (l.e < r.e)))))))); \
145   }                                                                     \
146   inline bool operator>=(const type &l, const type &r) {                \
147     return l.a > r.a ||                                                 \
148       (l.a == r.a && (l.b > r.b ||                                      \
149                       (l.b == r.b && (l.c > r.c ||                      \
150                                       (l.c == r.c && (l.d > r.d ||      \
151                                                       (l.d == r.d && l.e >= r.e))))))); \
152   }                                                                     \
153   inline bool operator<=(const type &l, const type &r) {                \
154     return l.a < r.a ||                                                 \
155       (l.a == r.a && (l.b < r.b ||                                      \
156                       (l.b == r.b && (l.c < r.c ||                      \
157                                       (l.c == r.c && (l.d < r.d ||      \
158                                                       (l.d == r.d && l.e <= r.e))))))); \
159   }
160
161 #define WRITE_EQ_OPERATORS_7(type, a, b, c, d, e, f, g)                 \
162   inline bool operator==(const type &l, const type &r) {                \
163     return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d && l.e == r.e && l.f == r.f && l.g == r.g; \
164   }                                                                     \
165   inline bool operator!=(const type &l, const type &r) {                \
166     return l.a != r.a || l.b != r.b || l.c != r.c || l.d != r.d || l.e != r.e || l.f != r.f || l.g != r.g; \
167   }
168 #define WRITE_CMP_OPERATORS_7(type, a, b, c, d, e, f, g)                \
169   inline bool operator<=(const type &l, const type &r) {                \
170     return l.a < r.a ||                                                 \
171       (l.a == r.a && (l.b < r.b ||                                      \
172                       (l.b == r.b && (l.c < r.c ||                      \
173                                       (l.c == r.c && (l.d < r.d ||      \
174                                                       (l.d == r.d && (l.e < r.e || \
175                                                                       (l.e == r.e && (l.f < r.f || \
176                                                                                       (l.f == r.f && l.g <= r.g))))))))))); \
177   }                                                                     \
178   inline bool operator>=(const type &l, const type &r) {                \
179     return l.a > r.a ||                                                 \
180       (l.a == r.a && (l.b > r.b ||                                      \
181                       (l.b == r.b && (l.c > r.c ||                      \
182                                       (l.c == r.c && (l.d > r.d ||      \
183                                                       (l.d == r.d && (l.e > r.e || \
184                                                                       (l.e == r.e && (l.f > r.f || \
185                                                                                       (l.f == r.f && l.g >= r.g))))))))))); \
186   }                                                                     \
187   inline bool operator>(const type &l, const type &r) {                 \
188     return l.a > r.a ||                                                 \
189       (l.a == r.a && (l.b > r.b ||                                      \
190                       (l.b == r.b && (l.c > r.c ||                      \
191                                       (l.c == r.c && (l.d > r.d ||      \
192                                                       (l.d == r.d && (l.e > r.e || \
193                                                                       (l.e == r.e && (l.f > r.f || \
194                                                                                       (l.f == r.f && l.g > r.g))))))))))); \
195   }                                                                     \
196   inline bool operator<(const type &l, const type &r) {                 \
197     return l.a < r.a ||                                                 \
198       (l.a == r.a && (l.b < r.b ||                                      \
199                       (l.b == r.b && (l.c < r.c ||                      \
200                                       (l.c == r.c && (l.d < r.d ||      \
201                                                       (l.d == r.d && (l.e < r.e || \
202                                                                       (l.e == r.e && (l.f < r.f || \
203                                                                                       (l.f == r.f && l.g < r.g))))))))))); \
204   }
205 #endif