This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __builtin_clzll and uintmax_t



Coucou FX,


On Sat, 5 Mar 2011, FX wrote:

uintmax_t is the largest of the standard unsigned C types, so it cannot be larger than unsigned long long.

That's a gcc property then. The C99 standard only guarantees that uintmax_t is at least as large as unsigned long long, but it is allowed to be some other larger type:


"The following type designates an unsigned integer type capable of representing any value of any unsigned integer type: uintmax_t"


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

I am not sure how legal that is. __int128 is an extended signed integer type, and thus the statement about intmax_t should apply to it as well. So gcc is just pretending that __int128 is not really there.


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.

Thank you, that's the best guarantee I could ask for about the existence of __builtin_clzll.


--
Marc Glisse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]