On 30 July 2016 at 23:04, Jeffrey Walton wrote: > I'm catching a compile error when using rdrand64_step on x86_64. If I > change the typedef to use 'unsigned long long', then I catch a compile > error under AArch64 when using NEON intrinsics. > > How should I clear the compile error in a way that does not lead to > additional breaks? > > Thanks in advance. > > Jeff > > ********** > > $ cat test.cc > #include <x86intrin.h> > > #if _LP64 || __LP64__ > typedef unsigned long my_u64; > #else > typedef unsigned long long my_u64; > #endif The definition doesn't depend on ILP32 or LP64: ../gcc/config/i386/immintrin.h:_rdrand64_step (unsigned long long *__P) Looks like you want unsigned long long for Intel. If that doesn't work for Neon then use the preprocessor to check for that, not for LP64. > > int main(int argc, char* argv[]) > { > my_u64 val; > _rdrand64_step(&val); > > return 0; > } > > $ gcc -mrdrnd test.cc -o test.exe > test.cc: In function ‘int main(int, char**)’: > test.cc:12:22: error: invalid conversion from ‘my_u64* {aka long > unsigned int*}’ to ‘long long unsigned int*’ [-fpermissive] > _rdrand64_step(&val); > ^ > In file included from > /usr/lib/gcc/x86_64-linux-gnu/4.9/include/x86intrin.h:46:0, > from test.cc:1: > /usr/lib/gcc/x86_64-linux-gnu/4.9/include/immintrin.h:166:1: note: > initializing argument 1 of ‘int _rdrand64_step(long long unsigned > int*)’ > _rdrand64_step (unsigned long long *__P) > ^ > > ********** > > Intel's declaration is (http://software.intel.com/en-us/node/523864): > > extern int _rdrand64_step(unsigned __int64 *random_val); But that's not what the GCC header says, as shown above. > ********** > > $ grep -R 'unsigned __int64' /usr/lib/gcc/x86_64-linux-gnu/4.9/include > | grep typedef > /usr/lib/gcc/x86_64-linux-gnu/4.9/include/cilk/common.h: > typedef unsigned __int64 uint64_t; To track down that definition shouldn't you be searching for __int64, not "unsigned __int64"? Searching for uint64_t will show where that's used, not how it's defined. You already know how it's defined above, what you're missing is how __int64 is defined. This doesn't help answer that: > $ grep -R 'uint64_t' /usr/lib/gcc/x86_64-linux-gnu/4.9/include | grep typedef > /usr/lib/gcc/x86_64-linux-gnu/4.9/include/stdint-gcc.h:typedef > __UINT64_TYPE__ uint64_t; > /usr/lib/gcc/x86_64-linux-gnu/4.9/include/cilk/common.h: > typedef unsigned __int64 uint64_t; However looking for how it's defined in the cilk headers isn't very relevant, what matters is the declaration of _rdrand64_step in the relevant header, which simply uses unsigned long long. > The trail ends at __UINT64_TYPE__. I can't find what its defined as. It's defined by the compiler: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html