Skip to content

Commit

Permalink
[#519] Handle zserio runtime architecture without need of external de…
Browse files Browse the repository at this point in the history
…fine
  • Loading branch information
Mi-La committed Sep 5, 2023
1 parent d461106 commit 4451948
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions compiler/extensions/cpp/runtime/ClangTidySuppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/StringConvertUtil.h
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/StringConvertUtil.h:42
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/StringConvertUtil.h:52
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/StringConvertUtil.h:53
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/BitStreamReader.cpp:249
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/BitStreamReader.cpp:261
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/BitStreamReader.cpp:248
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/BitStreamReader.cpp:260
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/BitStreamWriter.cpp:146
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/BitStreamWriter.cpp:157
cppcoreguidelines-pro-bounds-constant-array-index:src/zserio/BitStreamWriter.cpp:168
Expand Down
6 changes: 0 additions & 6 deletions compiler/extensions/cpp/runtime/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ set(ZSERIO_CPP_RUNTIME_LIB_SRCS
zserio/ZserioTreeCreator.cpp
)

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# allows bit stream reader and var size util optimizations for 64bit platforms
set_property(SOURCE zserio/BitStreamReader.cpp zserio/SizeConvertUtil.cpp
APPEND PROPERTY COMPILE_DEFINITIONS ZSERIO_RUNTIME_64BIT)
endif ()

add_library(${PROJECT_NAME} STATIC ${ZSERIO_CPP_RUNTIME_LIB_SRCS})

set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "zserio/BitStreamReader.h"
#include "zserio/CppRuntimeException.h"
#include "zserio/FloatUtil.h"
#include "zserio/RuntimeArch.h"

namespace zserio
{
Expand All @@ -24,8 +25,6 @@ namespace
using BaseSignedType = int32_t;
#endif

static_assert(sizeof(uintptr_t) == sizeof(BaseType), "Unexpected uintptr_t sizeof!");

#ifdef ZSERIO_RUNTIME_64BIT
const std::array<BaseType, 65> MASK_TABLE =
{
Expand Down
14 changes: 14 additions & 0 deletions compiler/extensions/cpp/runtime/src/zserio/RuntimeArch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef ZSERIO_RUNTIME_ARCH_H_INC
#define ZSERIO_RUNTIME_ARCH_H_INC

#include "zserio/Types.h"

#if UINTPTR_MAX == UINT64_MAX
#define ZSERIO_RUNTIME_64BIT
#elif UINTPTR_MAX == UINT32_MAX
#define ZSERIO_RUNTIME_32BIT
#else
#error "Unexpected CPU architecture!"
#endif

#endif // ZSERIO_RUNTIME_ARCH_H_INC
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "zserio/CppRuntimeException.h"
#include "zserio/SizeConvertUtil.h"
#include "zserio/RuntimeArch.h"

namespace zserio
{
Expand Down
6 changes: 0 additions & 6 deletions compiler/extensions/cpp/runtime/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,6 @@ if (MSVC)
set_property(SOURCE zserio/ReflectableTest.cpp zserio/ArrayTest.cpp APPEND PROPERTY COMPILE_OPTIONS /bigobj)
endif ()

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# allows bit stream reader and var size util optimizations for 64bit platforms
set_property(SOURCE zserio/SizeConvertUtilTest.cpp
APPEND PROPERTY COMPILE_DEFINITIONS ZSERIO_RUNTIME_64BIT)
endif ()

add_executable(${PROJECT_NAME}
${TEST_OBJECT_SRCS}
${ZSERIO_CPP_RUNTIME_TEST_SRCS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "zserio/SizeConvertUtil.h"
#include "zserio/CppRuntimeException.h"
#include "zserio/RuntimeArch.h"

#include "gtest/gtest.h"

Expand Down
3 changes: 0 additions & 3 deletions compiler/extensions/python/runtime/src/zserio_cpp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ def finalize_options(self):
zserio_cpp.include_dirs.append(".")
zserio_cpp.include_dirs.append(self.cpp_runtime_dir)

if sys.maxsize > 2**32:
zserio_cpp.define_macros.append(('ZSERIO_RUNTIME_64BIT', None))

zserio_cpp.define_macros.append(('PYBIND11_DETAILED_ERROR_MESSAGES', None))

def build_extensions(self):
Expand Down

0 comments on commit 4451948

Please sign in to comment.