Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid WORDS_BIGENDIAN conflict with Python3 #295

Merged
merged 1 commit into from
Dec 22, 2024
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ cmake_dependent_option(
OFF
)

include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN)
add_definitions("-DHS_BIG_ENDIAN")
endif()

set(CMAKE_C_FLAGS_DEBUG "-DDEBUG ${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG ${CMAKE_CXX_FLAGS_DEBUG}")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR
Expand Down
8 changes: 4 additions & 4 deletions core/Stream/hsStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ uint16_t hsStream::readShort()
void hsStream::readShorts(size_t count, uint16_t* buf)
{
read(sizeof(uint16_t) * count, buf);
#ifdef WORDS_BIGENDIAN
#ifdef HS_BIG_ENDIAN
for (size_t i=0; i<count; i++)
buf[i] = LESWAP16(buf[i]);
#endif
Expand All @@ -70,7 +70,7 @@ uint32_t hsStream::readInt()
void hsStream::readInts(size_t count, uint32_t* buf)
{
read(sizeof(uint32_t) * count, buf);
#ifdef WORDS_BIGENDIAN
#ifdef HS_BIG_ENDIAN
for (size_t i=0; i<count; i++)
buf[i] = LESWAP32(buf[i]);
#endif
Expand Down Expand Up @@ -220,7 +220,7 @@ void hsStream::writeShort(uint16_t v)

void hsStream::writeShorts(size_t count, const uint16_t* buf)
{
#ifdef WORDS_BIGENDIAN
#ifdef HS_BIG_ENDIAN
uint16_t* swbuf = new uint16_t[count];
for (size_t i=0; i<count; i++)
swbuf[i] = LESWAP16(buf[i]);
Expand All @@ -239,7 +239,7 @@ void hsStream::writeInt(uint32_t v)

void hsStream::writeInts(size_t count, const uint32_t* buf)
{
#ifdef WORDS_BIGENDIAN
#ifdef HS_BIG_ENDIAN
uint32_t* swbuf = new uint32_t[count];
for (size_t i=0; i<count; i++)
swbuf[i] = LESWAP32(buf[i]);
Expand Down
6 changes: 1 addition & 5 deletions core/Sys/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ inline double ENDSWAPD(double val)
return conv.fv;
}

#if defined(MACOSX) && defined(__BIG_ENDIAN__)
#define WORDS_BIGENDIAN
#endif

#ifdef WORDS_BIGENDIAN
#ifdef HS_BIG_ENDIAN
#define LESWAP16(val) ENDSWAP16(val)
#define BESWAP16(val) (val)
#define LESWAP32(val) ENDSWAP32(val)
Expand Down
Loading