Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmake/CompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function(set_project_options target_name)
endif()

if(HAVE_BACKTRACE OR HAVE_DLADDR)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
AND NOT APPLE
AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
target_compile_options(${target_name} PRIVATE -ggdb3)
endif()
target_compile_definitions(${target_name} PRIVATE -D_GNU_SOURCE=1)
Expand Down
3 changes: 1 addition & 2 deletions core/transactions/transactions_cleanup.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ parse_mutation_cas(const std::string& cas) -> std::uint64_t
if (cas.empty()) {
return 0;
}
return core::utils::byte_swap(static_cast<std::uint64_t>(std::stoull(cas, nullptr, 16))) /
1000000;
return core::utils::byte_swap(std::stoull(cas, nullptr, 16)) / 1000000;
}

// TODO(CXXCBC-549)
Expand Down
12 changes: 12 additions & 0 deletions core/utils/byteswap.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#pragma once

#include <cstdint>
#include <type_traits>

namespace couchbase::core::utils
{
Expand Down Expand Up @@ -46,4 +47,15 @@ byte_swap(std::uint64_t value) -> std::uint64_t
std::uint32_t lo = byte_swap(static_cast<std::uint32_t>(value >> 32));
return (hi << 32) | lo;
}

// when 'unsigned long long' is not the same as 'std::uint64_t'
template<typename Dummy = void>
static constexpr auto
byte_swap(unsigned long long value,
std::enable_if_t<!std::is_same_v<unsigned long long, std::uint64_t>, Dummy>* /* dummy */ =
nullptr) -> std::uint64_t
{
return byte_swap(static_cast<std::uint64_t>(value));
}

} // namespace couchbase::core::utils
Loading