This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __builtin_clzll and uintmax_t
- From: FX <fxcoudert at gmail dot com>
- To: gcc at gcc dot gnu dot org, marc dot glisse at inria dot fr
- Date: Sat, 5 Mar 2011 23:05:39 +0100
- Subject: Re: __builtin_clzll and uintmax_t
Salut Marc !
> We have a variable of type uintmax_t and want to count the leading zeros. Can we just call __builtin_clzll on it?
Yes.
> In particular, can uintmax_t be larger than unsigned long long in gcc?
uintmax_t is the largest of the standard unsigned C types, so it cannot be larger than unsigned long long. On x86_64, for example:
> #include <stdio.h>
> #include <stdint.h>
>
> int main (void)
> {
> printf ("%lu ", sizeof (uintmax_t));
> printf ("%lu ", sizeof (int));
> printf ("%lu ", sizeof (long int));
> printf ("%lu ", sizeof (long long int));
> printf ("%lu\n", sizeof (__int128));
> }
gives : 8 4 8 8 16
> Is __builtin_clzll available on all platforms?
Yes, we emit calls to this built-in unconditionally in the Fortran front-end, and it has caused no trouble.
FX