This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to clear compile error when using rdrand64_step due to typedef'ing a 64-bit type?
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Jeffrey Walton <noloader at gmail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 1 Aug 2016 10:16:46 +0100
- Subject: Re: How to clear compile error when using rdrand64_step due to typedef'ing a 64-bit type?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8nB-rBT-YmWCv8-Di7hPhKYiOaxWib5k_Ms=33rRVX+SA@mail.gmail.com> <CAH6eHdReC5PY99B3daAe7KupbGwD6a4yOe6whM7UM3hAL0OtKg@mail.gmail.com> <CAH8yC8nMafHmEO=0v3_UU6Rm7gdzvfvG8+5J45Kony5W72h02Q@mail.gmail.com>
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?