EAThread icon indicating copy to clipboard operation
EAThread copied to clipboard

Android arm64 build error

Open AlexRamallo opened this issue 5 years ago • 1 comments

When trying to build EAThread using the 64 bit compilers from the NDK, I get the following errors:

In file included from ../../library/eaoss/src/EAThread/eathread.cpp:89:
../../library/eaoss/src/EAThread/android/eathread_fake_atomic_64.cpp:37:26: error: cast from pointer to smaller type 'unsigned int' loses information
        pthread_mutex_t* lock = EAT_SWAP_LOCK(addr);
                                ^~~~~~~~~~~~~~~~~~~
../../library/eaoss/src/EAThread/android/eathread_fake_atomic_64.cpp:31:54: note: expanded from macro 'EAT_SWAP_LOCK'
#define EAT_SWAP_LOCK(addr) &sFakeAtomic64SwapLocks[((unsigned)(void*)(addr) >> 3U) % EAT_FAKE_ATOMIC_SWAP_LOCK_COUNT]
                                                     ^~~~~~~~~~~~~~~~~~~~~~~
../../library/eaoss/src/EAThread/android/eathread_fake_atomic_64.cpp:52:26: error: cast from pointer to smaller type 'unsigned int' loses information
        pthread_mutex_t* lock = EAT_SWAP_LOCK(addr);
                                ^~~~~~~~~~~~~~~~~~~
../../library/eaoss/src/EAThread/android/eathread_fake_atomic_64.cpp:31:54: note: expanded from macro 'EAT_SWAP_LOCK'
#define EAT_SWAP_LOCK(addr) &sFakeAtomic64SwapLocks[((unsigned)(void*)(addr) >> 3U) % EAT_FAKE_ATOMIC_SWAP_LOCK_COUNT]
                                                     ^~~~~~~~~~~~~~~~~~~~~~~
../../library/eaoss/src/EAThread/android/eathread_fake_atomic_64.cpp:73:26: error: cast from pointer to smaller type 'unsigned int' loses information
        pthread_mutex_t* lock = EAT_SWAP_LOCK(addr);
                                ^~~~~~~~~~~~~~~~~~~
../../library/eaoss/src/EAThread/android/eathread_fake_atomic_64.cpp:31:54: note: expanded from macro 'EAT_SWAP_LOCK'
#define EAT_SWAP_LOCK(addr) &sFakeAtomic64SwapLocks[((unsigned)(void*)(addr) >> 3U) % EAT_FAKE_ATOMIC_SWAP_LOCK_COUNT]
                                                     ^~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.

Changing that macro to use unsigned long for 64 bit builds eliminates the error, but I'm not sure if that will break functionality since it's not clear to me what that macro is doing.

AlexRamallo avatar Jul 19 '20 23:07 AlexRamallo

according to https://stackoverflow.com/a/27044460 - "I am using size_t here, because it is always having the same size as a pointer, no matter the platform. A long long would not work for 32bit systems and a long would not work for 64 bit Windows (while 64bit Unix and Unix-like systems like OS X use the LP64 data model, in which a long is 64bit, 64bit Windows uses the LLP64 data model, in which a long has a size of 32bit (http://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models))."

mgood7123 avatar Nov 24 '21 10:11 mgood7123