diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-09-08 09:37:50 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-10-05 17:49:45 -0700 |
| commit | f1cb2402734567b84e2b55129f98f9764167e13e (patch) | |
| tree | d65f9b676ec8e4f17ba7f0b5f5d952364e462a20 /CMakeLists.txt | |
| parent | 94c88335f9de5090846504dfa5fc1656092efacf (diff) | |
| download | nng-f1cb2402734567b84e2b55129f98f9764167e13e.tar.gz nng-f1cb2402734567b84e2b55129f98f9764167e13e.tar.bz2 nng-f1cb2402734567b84e2b55129f98f9764167e13e.zip | |
Endianness improvements.
This adds endian awareness at compile time, and defines some little
endian versions of some macros. We antiicpate making more use of
little endian in new protocols to reduce the "endian tax", as nearly
every modern system is little endian these days.
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dca028c..f859a7d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,6 +207,24 @@ if (NOT WIN32 AND NOT CYGWIN) endif () endif () +# Detect endianness -- this only handles little and big endian. +# PDP users, sorry, but you're out of luck.' +if (DEFINED CMAKE_LANG_C_BYTE_ORDER) + if (CMAKE_LANG_BYTE_ORDER EQUAL BIG_ENDIAN) + add_definitions(-DNNG_BIG_ENDIAN=1) + else() + add_definitions(-DNNG_LITTLE_ENDIAN=1) + endif() +else() + include(TestBigEndian) + test_big_endian(NNG_BIG_ENDIAN) + if (NNG_BIG_ENDIAN) + add_definitions(-DNNG_BIG_EDNDIAN=1) + else() + add_definitions(-DNNG_LITTLE_ENDIAN=1) + endif() +endif() + if (CMAKE_SYSTEM_NAME MATCHES "Linux") add_definitions(-DNNG_PLATFORM_POSIX) add_definitions(-DNNG_PLATFORM_LINUX) |
