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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1 August 2016 at 09:06, Jeffrey Walton wrote:
>>> $ 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).

The functions takes a pointer to an unsigned 64-bit type, not
necessarily unsigned long.

long is 32-bits on IA-32, 64 bits on x86_64.

> It looks like
> 'unsigned long long' is 64-bits too (other wise, GCC would not be
> using it).

long long is 64-bits on IA-32 and x86_64. That's probably why GCC uses
unsigned long long. So you should not be using a different type for
IA-32 and x86_64.

> Is it safe to cast a pointer of type 'unsigned long' to a pointer of
> 'unsigned long long' when using this particular function?

No, they are distinct types.

> Does UL and
> ULL provide the same alignment guarantees?



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux