1/* HOST_WIDE_INT definitions for the GNU compiler. 2 Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc. 3 4 This file is part of GCC. 5 6 Provide definitions for macros which depend on HOST_BITS_PER_INT 7 and HOST_BITS_PER_LONG. */ 8 9#ifndef GCC_HWINT_H 10#define GCC_HWINT_H 11 12/* This describes the machine the compiler is hosted on. */ 13#define HOST_BITS_PER_CHAR CHAR_BIT 14#define HOST_BITS_PER_SHORT (CHAR_BIT * SIZEOF_SHORT) 15#define HOST_BITS_PER_INT (CHAR_BIT * SIZEOF_INT) 16#define HOST_BITS_PER_LONG (CHAR_BIT * SIZEOF_LONG) 17 18/* The string that should be inserted into a printf style format to 19 indicate a "long long" operand. */ 20#ifndef HOST_LONG_LONG_FORMAT 21#define HOST_LONG_LONG_FORMAT "ll" 22#endif 23 24/* If HAVE_LONG_LONG and SIZEOF_LONG_LONG aren't defined, but 25 GCC_VERSION >= 3000, assume this is the second or later stage of a 26 bootstrap, we do have long long, and it's 64 bits. (This is 27 required by C99; we do have some ports that violate that assumption 28 but they're all cross-compile-only.) Just in case, force a 29 constraint violation if that assumption is incorrect. */ 30#if !defined HAVE_LONG_LONG 31# if GCC_VERSION >= 3000 32# define HAVE_LONG_LONG 1 33# define SIZEOF_LONG_LONG 8 34extern char sizeof_long_long_must_be_8[sizeof(long long) == 8 ? 1 : -1]; 35# endif 36#endif 37 38#ifdef HAVE_LONG_LONG 39# define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG) 40#endif 41#ifdef HAVE___INT64 42# define HOST_BITS_PER___INT64 (CHAR_BIT * SIZEOF___INT64) 43#endif 44 45/* Set HOST_WIDE_INT. This should be the widest efficient host 46 integer type. It can be 32 or 64 bits, except that if we are 47 targeting a machine with 64-bit size_t then it has to be 64 bits. 48 49 With a sane ABI, 'long' is the largest efficient host integer type. 50 Thus, we use that unless we have to use 'long long' or '__int64' 51 because we're targeting a 64-bit machine from a 32-bit host. */ 52 53#if HOST_BITS_PER_LONG >= 64 || !defined NEED_64BIT_HOST_WIDE_INT 54# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG 55# define HOST_WIDE_INT long 56#else 57# if HOST_BITS_PER_LONGLONG >= 64 58# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG 59# define HOST_WIDE_INT long long 60# else 61# if HOST_BITS_PER___INT64 >= 64 62# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER___INT64 63# define HOST_WIDE_INT __int64 64# else 65 #error "Unable to find a suitable type for HOST_WIDE_INT" 66# endif 67# endif 68#endif 69 70/* Various printf format strings for HOST_WIDE_INT. */ 71 72#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 73# define HOST_WIDE_INT_PRINT "l" 74# define HOST_WIDE_INT_PRINT_C "L" 75# define HOST_WIDE_INT_CONSTANT(x) x ## L 76 /* 'long' might be 32 or 64 bits, and the number of leading zeroes 77 must be tweaked accordingly. */ 78# if HOST_BITS_PER_WIDE_INT == 64 79# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx" 80# else 81# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx" 82# endif 83#else 84# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT 85# define HOST_WIDE_INT_PRINT_C "LL" 86# define HOST_WIDE_INT_CONSTANT(x) x ## LL 87 /* We can assume that 'long long' is at least 64 bits. */ 88# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \ 89 "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x" 90#endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */ 91 92#define HOST_WIDE_INT_PRINT_DEC "%" HOST_WIDE_INT_PRINT "d" 93#define HOST_WIDE_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC HOST_WIDE_INT_PRINT_C 94#define HOST_WIDE_INT_PRINT_UNSIGNED "%" HOST_WIDE_INT_PRINT "u" 95#define HOST_WIDE_INT_PRINT_HEX "0x%" HOST_WIDE_INT_PRINT "x" 96 97/* Set HOST_WIDEST_INT. This is a 64-bit type unless the compiler 98 in use has no 64-bit type at all; in that case it's 32 bits. */ 99 100#if HOST_BITS_PER_WIDE_INT >= 64 \ 101 || (HOST_BITS_PER_LONGLONG < 64 && HOST_BITS_PER___INT64 < 64) 102# define HOST_WIDEST_INT HOST_WIDE_INT 103# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_WIDE_INT 104# define HOST_WIDEST_INT_PRINT_DEC HOST_WIDE_INT_PRINT_DEC 105# define HOST_WIDEST_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC_C 106# define HOST_WIDEST_INT_PRINT_UNSIGNED HOST_WIDE_INT_PRINT_UNSIGNED 107# define HOST_WIDEST_INT_PRINT_HEX HOST_WIDE_INT_PRINT_HEX 108# define HOST_WIDEST_INT_PRINT_DOUBLE_HEX HOST_WIDE_INT_PRINT_DOUBLE_HEX 109#else 110# if HOST_BITS_PER_LONGLONG >= 64 111# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG 112# define HOST_WIDEST_INT long long 113# else 114# if HOST_BITS_PER___INT64 >= 64 115# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER___INT64 116# define HOST_WIDEST_INT __int64 117# else 118 #error "This line should be impossible to reach" 119# endif 120# endif 121# define HOST_WIDEST_INT_PRINT_DEC "%" HOST_LONG_LONG_FORMAT "d" 122# define HOST_WIDEST_INT_PRINT_DEC_C "%" HOST_LONG_LONG_FORMAT "dLL" 123# define HOST_WIDEST_INT_PRINT_UNSIGNED "%" HOST_LONG_LONG_FORMAT "u" 124# define HOST_WIDEST_INT_PRINT_HEX "0x%" HOST_LONG_LONG_FORMAT "x" 125# define HOST_WIDEST_INT_PRINT_DOUBLE_HEX \ 126 "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x" 127#endif 128 129/* Define HOST_WIDEST_FAST_INT to the widest integer type supported 130 efficiently in hardware. (That is, the widest integer type that fits 131 in a hardware register.) Normally this is "long" but on some hosts it 132 should be "long long" or "__int64". This is no convenient way to 133 autodect this, so such systems must set a flag in config.host; see there 134 for details. */ 135 136#ifdef USE_LONG_LONG_FOR_WIDEST_FAST_INT 137# ifdef HAVE_LONG_LONG 138# define HOST_WIDEST_FAST_INT long long 139# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONGLONG 140# elif defined (HAVE___INT64) 141# define HOST_WIDEST_FAST_INT __int64 142# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER___INT64 143# else 144# error "Your host said it wantted to use long long or __int64 but neither" 145# error "exist" 146# endif 147#else 148# define HOST_WIDEST_FAST_INT long 149# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONG 150#endif 151 152#endif /* ! GCC_HWINT_H */ 153