hwint.h revision 90075
1/* HOST_WIDE_INT definitions for the GNU compiler. 2 Copyright (C) 1998 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#ifdef HAVE_LONG_LONG 19# define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG) 20#else 21#ifdef HAVE__INT64 22# define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF___INT64) 23#else 24/* If we're here and we're GCC, assume this is stage 2+ of a bootstrap 25 and 'long long' has the width of the *target*'s long long. */ 26# if GCC_VERSION > 3000 27# define HOST_BITS_PER_LONGLONG LONG_LONG_TYPE_SIZE 28# endif /* gcc */ 29#endif 30#endif /* no long long */ 31 32/* Find the largest host integer type and set its size and type. */ 33 34/* Use long long on the host if the target has a wider long type than 35 the host. */ 36 37#if ! defined HOST_BITS_PER_WIDE_INT \ 38 && defined HOST_BITS_PER_LONGLONG \ 39 && (HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG) \ 40 && (defined (LONG_LONG_MAX) || defined (LONGLONG_MAX) \ 41 || defined (LLONG_MAX) || defined (__GNUC__)) 42 43# ifdef MAX_LONG_TYPE_SIZE 44# if MAX_LONG_TYPE_SIZE > HOST_BITS_PER_LONG 45# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG 46# define HOST_WIDE_INT long long 47# endif 48# else 49# if LONG_TYPE_SIZE > HOST_BITS_PER_LONG 50# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG 51# define HOST_WIDE_INT long long 52# endif 53# endif 54 55#endif 56 57#ifndef HOST_BITS_PER_WIDE_INT 58 59# if HOST_BITS_PER_LONG > HOST_BITS_PER_INT 60# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG 61# define HOST_WIDE_INT long 62# else 63# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT 64# define HOST_WIDE_INT int 65# endif 66 67#endif /* ! HOST_BITS_PER_WIDE_INT */ 68 69/* Provide defaults for the way to print a HOST_WIDE_INT 70 in various manners. */ 71 72#ifndef HOST_WIDE_INT_PRINT_DEC 73# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 74# define HOST_WIDE_INT_PRINT_DEC "%d" 75# else 76# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 77# define HOST_WIDE_INT_PRINT_DEC "%ld" 78# else 79# define HOST_WIDE_INT_PRINT_DEC "%lld" 80# endif 81# endif 82#endif /* ! HOST_WIDE_INT_PRINT_DEC */ 83 84#ifndef HOST_WIDE_INT_PRINT_UNSIGNED 85# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 86# define HOST_WIDE_INT_PRINT_UNSIGNED "%u" 87# else 88# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 89# define HOST_WIDE_INT_PRINT_UNSIGNED "%lu" 90# else 91# define HOST_WIDE_INT_PRINT_UNSIGNED "%llu" 92# endif 93# endif 94#endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */ 95 96#ifndef HOST_WIDE_INT_PRINT_HEX 97# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 98# define HOST_WIDE_INT_PRINT_HEX "0x%x" 99# else 100# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 101# define HOST_WIDE_INT_PRINT_HEX "0x%lx" 102# else 103# define HOST_WIDE_INT_PRINT_HEX "0x%llx" 104# endif 105# endif 106#endif /* ! HOST_WIDE_INT_PRINT_HEX */ 107 108#ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX 109# if HOST_BITS_PER_WIDE_INT == 64 110# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 111# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x" 112# else 113# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 114# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx" 115# else 116# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx" 117# endif 118# endif 119# else 120# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 121# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x" 122# else 123# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 124# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx" 125# else 126# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx" 127# endif 128# endif 129# endif 130#endif /* ! HOST_WIDE_INT_PRINT_DOUBLE_HEX */ 131 132/* Find HOST_WIDEST_INT and set its bit size, type and print macros. 133 It will be the largest integer mode supported by the host which may 134 (or may not) be larger than HOST_WIDE_INT. */ 135 136#ifndef HOST_WIDEST_INT 137#if defined HOST_BITS_PER_LONGLONG \ 138 && HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG 139# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG 140# define HOST_WIDEST_INT long long 141# define HOST_WIDEST_INT_PRINT_DEC "%lld" 142# define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu" 143# define HOST_WIDEST_INT_PRINT_HEX "0x%llx" 144# else 145# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG 146# define HOST_WIDEST_INT long 147# define HOST_WIDEST_INT_PRINT_DEC "%ld" 148# define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu" 149# define HOST_WIDEST_INT_PRINT_HEX "0x%lx" 150# endif /* long long wider than long */ 151#endif /* ! HOST_WIDEST_INT */ 152 153#endif /* ! GCC_HWINT_H */ 154