Skip to content

Commit 4249001

Browse files
committed
all: Replaced int64_t with simtime_raw_t where appropriate.
This allows using __int128 for raw simtimes if needed.
1 parent ea97dda commit 4249001

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/inet/clock/common/ClockTime.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class INET_API ClockTime
4545
* Initialize simulation time from a double-precision number. This constructor
4646
* is recommended if the value is the result of some computation done in
4747
* <tt>double</tt>. For integer-based computations and time constants, the
48-
* <tt>ClockTime(int64_t x, int exponent)</tt> constructor is usually a better
48+
* <tt>ClockTime(simtime_raw_t x, int exponent)</tt> constructor is usually a better
4949
* choice, because it does not have rounding errors caused by double-to-integer
5050
* conversion.
5151
*/
@@ -74,7 +74,7 @@ class INET_API ClockTime
7474
* Simtime(-3, SIMTIME_S) -> -1s
7575
* Simtime(5, (SimTimeUnit)2) -> 500s;
7676
*/
77-
ClockTime(int64_t value, SimTimeUnit unit) : impl(value, unit) {}
77+
ClockTime(simtime_raw_t value, SimTimeUnit unit) : impl(value, unit) {}
7878

7979
/**
8080
* Copy constructor.
@@ -217,7 +217,7 @@ class INET_API ClockTime
217217
* -3.8ms in s --> -3;
218218
* 999ms in s --> 0
219219
*/
220-
int64_t inUnit(SimTimeUnit unit) const { return impl.inUnit(unit); }
220+
simtime_raw_t inUnit(SimTimeUnit unit) const { return impl.inUnit(unit); }
221221

222222
/**
223223
* Returns a new simulation time that is truncated (rounded towards zero)
@@ -247,7 +247,7 @@ class INET_API ClockTime
247247
* outRemainder = t.remainderForUnit(unit);
248248
* </pre>
249249
*/
250-
void split(SimTimeUnit unit, int64_t& outValue, ClockTime& outRemainder) const { impl.split(unit, outValue, outRemainder.impl); }
250+
void split(SimTimeUnit unit, simtime_raw_t& outValue, ClockTime& outRemainder) const { impl.split(unit, outValue, outRemainder.impl); }
251251

252252
/**
253253
* Converts the time to a numeric string. The number expresses the simulation
@@ -284,17 +284,17 @@ class INET_API ClockTime
284284
/**
285285
* Returns the underlying 64-bit integer.
286286
*/
287-
int64_t raw() const { return impl.raw(); }
287+
simtime_raw_t raw() const { return impl.raw(); }
288288

289289
/**
290290
* Creates a ClockTime by setting its underlying 64-bit integer.
291291
*/
292-
static ClockTime fromRaw(int64_t l) { ClockTime tmp; tmp.impl.setRaw(l); return tmp; }
292+
static ClockTime fromRaw(simtime_raw_t l) { ClockTime tmp; tmp.impl.setRaw(l); return tmp; }
293293

294294
/**
295295
* Directly sets the underlying 64-bit integer.
296296
*/
297-
const ClockTime& setRaw(int64_t l) { impl.setRaw(l); return *this; }
297+
const ClockTime& setRaw(simtime_raw_t l) { impl.setRaw(l); return *this; }
298298

299299
/**
300300
* Returns the largest simulation time that can be represented using the
@@ -306,7 +306,7 @@ class INET_API ClockTime
306306
* Returns the time resolution as the number of units per second,
307307
* e.g. for microsecond resolution it returns 1000000.
308308
*/
309-
static int64_t getScale() { return SimTime::getScale(); }
309+
static simtime_raw_t getScale() { return SimTime::getScale(); }
310310

311311
/**
312312
* Returns the scale exponent, which is an integer in the range -18..0.
@@ -341,7 +341,7 @@ class INET_API ClockTime
341341
* ATTENTION: For performance reasons, the returned pointer will point
342342
* *somewhere* into the buffer, but NOT necessarily at the beginning.
343343
*/
344-
static char *ttoa(char *buf, int64_t impl, int scaleexp, char *& endp) { return SimTime::ttoa(buf, impl, scaleexp, endp); }
344+
static char *ttoa(char *buf, simtime_raw_t impl, int scaleexp, char *& endp) { return SimTime::ttoa(buf, impl, scaleexp, endp); }
345345
//@}
346346
};
347347

src/inet/linklayer/ieee8021as/GptpPacketSerializer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ clocktime_t GptpPacketSerializer::readClock8(MemoryInputStream& stream) const
2828

2929
void GptpPacketSerializer::writeClock8(MemoryOutputStream& stream, const clocktime_t& clock) const
3030
{
31-
int64_t outValue;
31+
simtime_raw_t outValue;
3232
simtime_t outRemainder;
3333
simtime_t t = CLOCKTIME_AS_SIMTIME(clock);
3434
t.split(SIMTIME_NS, outValue, outRemainder);
@@ -51,7 +51,7 @@ void GptpPacketSerializer::writeTimestamp(MemoryOutputStream& stream, const cloc
5151
{
5252
// 10 bytes
5353
simtime_t t = CLOCKTIME_AS_SIMTIME(clock);
54-
int64_t outValue;
54+
simtime_raw_t outValue;
5555
t.split(SIMTIME_S, outValue, t);
5656
stream.writeUint48Be(outValue);
5757
t.split(SIMTIME_NS, outValue, t);
@@ -76,7 +76,7 @@ void GptpPacketSerializer::writeScaledNS(MemoryOutputStream& stream, const clock
7676
// The ScaledNs type represents signed values of time and time interval in units of 2^–16 ns.
7777
// 12 bytes
7878
simtime_t t = CLOCKTIME_AS_SIMTIME(clock);
79-
int64_t outValue;
79+
simtime_raw_t outValue;
8080
simtime_t outRemainder;
8181
t.split(SIMTIME_NS, outValue, outRemainder);
8282
outValue <<= 16;

0 commit comments

Comments
 (0)