From 8fc32c79e523790f3481348d95e535a9135f3508 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 2 Jan 2024 15:22:09 -0800 Subject: [PATCH] Rewrite liternal --- .../include/opentelemetry/exporters/etw/utils.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/exporters/etw/include/opentelemetry/exporters/etw/utils.h b/exporters/etw/include/opentelemetry/exporters/etw/utils.h index fbf1a2ad52..f3665efc80 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/utils.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/utils.h @@ -401,16 +401,14 @@ get_msgpack_eventtimeext(int32_t seconds = 0, int32_t nanoseconds = 0) } uint64_t timestamp = - ((static_cast(seconds / 100)) & ((1ull << 34) - 1)) | - ((static_cast(seconds % 100 * 1e7 + nanoseconds / 100) & ((1ull << 30) - 1)) << 34); + ((seconds / 100) & ((1ull << 34) - 1)) | + (((seconds % 100 * 10000000 + nanoseconds / 100) & ((1ull << 30) - 1)) << 34); nlohmann::byte_container_with_subtype> ts{std::vector(8)}; - for (int i = 0; i < 8; i++) - { - ts[i] = timestamp & 0xff; - timestamp >>= 8; - } + + *reinterpret_cast(ts.data()) = timestamp; ts.set_subtype(0x00); + return ts; } @@ -423,7 +421,7 @@ GetMsgPackEventTimeFromSystemTimestamp(opentelemetry::common::SystemTimestamp ti std::chrono::duration_cast(timestamp.time_since_epoch()).count()), // Add any remaining nanoseconds past the last whole second std::chrono::duration_cast(timestamp.time_since_epoch()).count() % - 1e9); + 1000000000); } #endif // defined(HAVE_MSGPACK)