From 2f49203c954527dd85631fee9041ac5eaac37cee Mon Sep 17 00:00:00 2001 From: David Li Date: Thu, 24 Jun 2021 14:14:44 -0400 Subject: [PATCH] Rename bswap_64 to otel_bswap_64 to avoid clash with macro (#875) --- .../opentelemetry/exporters/jaeger/recordable.h | 4 ++-- exporters/jaeger/src/recordable.cc | 8 ++++---- exporters/jaeger/test/jaeger_recordable_test.cc | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h b/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h index c5ce57c3c4..01a4bb0d79 100644 --- a/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h +++ b/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h @@ -29,13 +29,13 @@ namespace jaeger # if defined(__clang__) || \ (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ >= 5)) -inline uint64_t bswap_64(uint64_t host_int) +inline uint64_t otel_bswap_64(uint64_t host_int) { return __builtin_bswap64(host_int); } # elif defined(_MSC_VER) -inline uint64_t bswap_64(uint64_t host_int) +inline uint64_t otel_bswap_64(uint64_t host_int) { return _byteswap_uint64(host_int); } diff --git a/exporters/jaeger/src/recordable.cc b/exporters/jaeger/src/recordable.cc index 3e3661623e..c9425b963b 100644 --- a/exporters/jaeger/src/recordable.cc +++ b/exporters/jaeger/src/recordable.cc @@ -46,13 +46,13 @@ void Recordable::SetIdentity(const trace::SpanContext &span_context, // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk_exporters/jaeger.md#ids #if JAEGER_IS_LITTLE_ENDIAN == 1 span_->__set_traceIdHigh( - bswap_64(*(reinterpret_cast(span_context.trace_id().Id().data())))); + otel_bswap_64(*(reinterpret_cast(span_context.trace_id().Id().data())))); span_->__set_traceIdLow( - bswap_64(*(reinterpret_cast(span_context.trace_id().Id().data()) + 1))); + otel_bswap_64(*(reinterpret_cast(span_context.trace_id().Id().data()) + 1))); span_->__set_spanId( - bswap_64(*(reinterpret_cast(span_context.span_id().Id().data())))); + otel_bswap_64(*(reinterpret_cast(span_context.span_id().Id().data())))); span_->__set_parentSpanId( - bswap_64(*(reinterpret_cast(parent_span_id.Id().data())))); + otel_bswap_64(*(reinterpret_cast(parent_span_id.Id().data())))); #else span_->__set_traceIdLow( *(reinterpret_cast(span_context.trace_id().Id().data()))); diff --git a/exporters/jaeger/test/jaeger_recordable_test.cc b/exporters/jaeger/test/jaeger_recordable_test.cc index 2692096213..2289a53ab9 100644 --- a/exporters/jaeger/test/jaeger_recordable_test.cc +++ b/exporters/jaeger/test/jaeger_recordable_test.cc @@ -43,10 +43,10 @@ TEST(JaegerSpanRecordable, SetIdentity) std::unique_ptr span{rec.Span()}; #if JAEGER_IS_LITTLE_ENDIAN == 1 - EXPECT_EQ(span->traceIdLow, opentelemetry::exporter::jaeger::bswap_64(trace_id_val[1])); - EXPECT_EQ(span->traceIdHigh, opentelemetry::exporter::jaeger::bswap_64(trace_id_val[0])); - EXPECT_EQ(span->spanId, opentelemetry::exporter::jaeger::bswap_64(span_id_val)); - EXPECT_EQ(span->parentSpanId, opentelemetry::exporter::jaeger::bswap_64(parent_span_id_val)); + EXPECT_EQ(span->traceIdLow, opentelemetry::exporter::jaeger::otel_bswap_64(trace_id_val[1])); + EXPECT_EQ(span->traceIdHigh, opentelemetry::exporter::jaeger::otel_bswap_64(trace_id_val[0])); + EXPECT_EQ(span->spanId, opentelemetry::exporter::jaeger::otel_bswap_64(span_id_val)); + EXPECT_EQ(span->parentSpanId, opentelemetry::exporter::jaeger::otel_bswap_64(parent_span_id_val)); #else EXPECT_EQ(span->traceIdLow, trace_id_val[0]); EXPECT_EQ(span->traceIdHigh, trace_id_val[1]); @@ -143,4 +143,4 @@ TEST(JaegerSpanRecordable, SetInstrumentationLibrary) EXPECT_EQ(tags[1].key, "otel.library.version"); EXPECT_EQ(tags[1].vType, thrift::TagType::STRING); EXPECT_EQ(tags[1].vStr, library_version); -} \ No newline at end of file +}