Skip to content

Commit 8d6ded7

Browse files
committed
Bug#36040942 router build on 32bit linux fails
On Linux 32bit, make all fails with: router/src/harness/tests/linux_timestamping.cc:156:5: error: missing binary operator before token "(" 156 | #if SO_TIMESTAMP == SO_TIMESTAMP_NEW | ^~~~~~~~~~~~ That's caused by SO_TIMESTAMP being defined as: #define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW) (in /usr/include/asm-generic/socket.h). But ?: isn't allowed in an "#if". Change ====== - use std::conditional_t<> instead of ifdef to select the right type. Change-Id: I3243812ab04eae509baeec259572e42a03aa36d1
1 parent 2fff6a3 commit 8d6ded7

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

router/src/harness/tests/linux_timestamping.cc

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <string>
3333
#include <string_view>
3434
#include <thread>
35+
#include <type_traits>
3536
#include <vector>
3637

3738
#include "hexify.h"
@@ -151,17 +152,16 @@ using SocketTimestampOld =
151152

152153
#ifdef SO_TIMESTAMP
153154
// linux + freebsd
154-
using SocketTimestamp = SocketTimestampBase<SOL_SOCKET, SO_TIMESTAMP,
155+
using SocketTimestamp =
156+
SocketTimestampBase<SOL_SOCKET, SO_TIMESTAMP,
155157
#ifdef SO_TIMESTAMP_NEW
156-
#if SO_TIMESTAMP == SO_TIMESTAMP_NEW
157-
SocketTimestampNew::value_type
158+
std::conditional_t<SO_TIMESTAMP == SO_TIMESTAMP_NEW,
159+
SocketTimestampNew::value_type,
160+
SocketTimestampOld::value_type>
158161
#else
159-
SocketTimestampOld::value_type
162+
timeval
160163
#endif
161-
#else
162-
timeval
163-
#endif
164-
>;
164+
>;
165165
#endif
166166

167167
template <int Lvl, int Type, class V>
@@ -205,18 +205,16 @@ using SocketTimestampNanosecondOld =
205205
#endif
206206

207207
#ifdef SO_TIMESTAMPNS
208-
using SocketTimestampNanosecond =
209-
SocketTimestampNanosecondBase<SOL_SOCKET, SO_TIMESTAMPNS,
208+
using SocketTimestampNanosecond = SocketTimestampNanosecondBase<
209+
SOL_SOCKET, SO_TIMESTAMPNS,
210210
#ifdef SO_TIMESTAMPNS_NEW
211-
#if SO_TIMESTAMPNS == SO_TIMESTAMPNS_NEW
212-
SocketTimestampNanosecondNew::value_type
213-
#else
214-
SocketTimestampNanosecondOld::value_type
215-
#endif
211+
std::conditional_t<SO_TIMESTAMPNS == SO_TIMESTAMPNS_NEW,
212+
SocketTimestampNanosecondNew::value_type,
213+
SocketTimestampNanosecondOld::value_type>
216214
#else
217-
timespec
215+
timespec
218216
#endif
219-
>;
217+
>;
220218
#endif
221219

222220
template <int Lvl, int Type, class V>
@@ -290,20 +288,17 @@ using SocketTimestampingOld =
290288
#endif
291289

292290
#ifdef SO_TIMESTAMPING
293-
using SocketTimestamping =
294-
SocketTimestampingBase<SOL_SOCKET, SO_TIMESTAMPING,
291+
using SocketTimestamping = SocketTimestampingBase<
292+
SOL_SOCKET, SO_TIMESTAMPING,
295293
#ifdef SO_TIMESTAMPING_NEW
296-
#if SO_TIMESTAMPING == SO_TIMESTAMPING_NEW
297-
SocketTimestampingNew::value_type
298-
#else
299-
SocketTimestampingOld::value_type
300-
#endif
294+
std::conditional_t<SO_TIMESTAMPING == SO_TIMESTAMPING_NEW,
295+
SocketTimestampingNew::value_type,
296+
SocketTimestampingOld::value_type>
301297
#else
302-
std::conditional_t<
303-
is_type_complete_v<struct scm_timestamping>,
304-
scm_timestamping, fallback::scm_timestamping>
298+
std::conditional_t<is_type_complete_v<struct scm_timestamping>,
299+
scm_timestamping, fallback::scm_timestamping>
305300
#endif
306-
>;
301+
>;
307302
#endif
308303

309304
// if they are defined, check they have the expected value.

0 commit comments

Comments
 (0)