Endianness Detection


#1

I’ve been working on building Couchbase 3.0.3 for RHEL 7 on a big-endian machine, and have been seeing some issues getting the build to correctly recognize the system’s endianness. Most of the offending code makes use of the macro WORDS_BIGENDIAN to select the appropriate code segments, but this macro seems to be going undefined in my builds. I’ve examined the codebase in hopes of troubleshooting whatever endianness detection is used, but haven’t been able to determine where this macro is supposed to be defined in the first place. Is anyone familiar with how Couchbase determines endianness while building?


Detecting machine endianness for s390x
#2

I believe the checks was lost as part of dropping automake and moving over to CMake (the fact that we only supported x86 builds it wasn’t put that high up on the list :wink: ) You could just edit

tlm/cmake/Modules/CouchbaseDefinitions.cmake 

and add

ADD_DEFINITIONS(-DWORDS_BIGENDIAN=1)

#3

Thank you for the info, that’s fair enough. I was going to look into coming up with a more elegant fix, but I see that you’ve gone ahead and added in a check already. On the topic of contributing, do you know if there are separate CLAs for individuals and corporate contributors? Thus far I’ve only been commenting here with regards to solving a few build issues, but I am working on behalf of a large company which may wish to contribute back once things get further along.

Getting back to the endianness issue, making sure that WORDS_BIGENDIAN is defined seems to deal with most of the issues I’ve been seeing, but to be sure, do you know if there were any other similar macros in different modules that now go undefined? Looking through the codebase I see a lot of different endianness-related macros, but most of them seem to be defined based on WORDS_BIGENDIAN.

If I can bother you a little further, I was also curious about one of your commits, which appears to have first been used in membase/moxi/config_static.h:

#if defined(WORDS_BIGENDIAN) && WORDS_BIGENDIAN > 1
#define ENDIAN_BIG 1       
#else
#define ENDIAN_LITTLE 1
#endif

Why the check to see if it’s greater than one? Is there some additional convention to the value beyond simply defining the macro?

Thank you very much for your insight.


#4

Hi,

I have no idea about the legal stuff regarding CLAs for individuals and corporate contributions.

When it comes to the other macros I am sad to tell you that I don’t have a list over things we “dropped” while moving away from automake (and I don’t think I’ve ever run Couchbase on my sparc boxes in my basement since the early membase days…)

I’m sort of tempted to say that you can ignore moxi :wink: because you would always be WAY better of by using one of the couchbase clients directly rather than using an old “memcached” client and go through moxi. There is a lot of features you can’t use when you’re using moxi.

Cheers,

Trond


#5

Okay, thanks. I just wanted to cover everything, as that bit with the greater-then-one comparison was carried into Couchbase (the membase file just seems to be where it was first introduced).