How to clear compile error when using rdrand64_step due to typedef'ing a 64-bit type?

Jeffrey Walton noloader@gmail.com
Mon Aug 1 08:06:00 GMT 2016


>> $ 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.

Thanks.

Forgive my ignorance... 'unsigned long' is 64 bits, which is what that
interface needs (if I am reading the docs correctly). It looks like
'unsigned long long' is 64-bits too (other wise, GCC would not be
using it).

Is it safe to cast a pointer of type 'unsigned long' to a pointer of
'unsigned long long' when using this particular function? Does UL and
ULL provide the same alignment guarantees?

Jeff



More information about the Gcc-help mailing list