1 /* HOST_WIDE_INT definitions for the GNU compiler.
2 Copyright (C) 1998 Free Software Foundation, Inc.
4 This file is part of GCC.
6 Provide definitions for macros which depend on HOST_BITS_PER_INT
7 and HOST_BITS_PER_LONG. */
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)
19 # define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG)
21 /* If we're here and we're GCC, assume this is stage 2+ of a bootstrap
22 and 'long long' has the width of the *target*'s long long. */
23 # if GCC_VERSION > 3000
24 # define HOST_BITS_PER_LONGLONG LONG_LONG_TYPE_SIZE
26 #endif /* no long long */
28 /* Find the largest host integer type and set its size and type. */
30 /* Use long long on the host if the target has a wider long type than
33 #if ! defined HOST_BITS_PER_WIDE_INT \
34 && defined HOST_BITS_PER_LONGLONG \
35 && (HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG) \
36 && (defined (LONG_LONG_MAX) || defined (LONGLONG_MAX) \
37 || defined (LLONG_MAX) || defined (__GNUC__))
39 # ifdef MAX_LONG_TYPE_SIZE
40 # if MAX_LONG_TYPE_SIZE > HOST_BITS_PER_LONG
41 # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
42 # define HOST_WIDE_INT long long
45 # if LONG_TYPE_SIZE > HOST_BITS_PER_LONG
46 # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
47 # define HOST_WIDE_INT long long
53 #ifndef HOST_BITS_PER_WIDE_INT
55 # if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
56 # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
57 # define HOST_WIDE_INT long
59 # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
60 # define HOST_WIDE_INT int
63 #endif /* ! HOST_BITS_PER_WIDE_INT */
65 /* Provide defaults for the way to print a HOST_WIDE_INT
66 in various manners. */
68 #ifndef HOST_WIDE_INT_PRINT_DEC
69 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
70 # define HOST_WIDE_INT_PRINT_DEC "%d"
72 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
73 # define HOST_WIDE_INT_PRINT_DEC "%ld"
75 # define HOST_WIDE_INT_PRINT_DEC "%lld"
78 #endif /* ! HOST_WIDE_INT_PRINT_DEC */
80 #ifndef HOST_WIDE_INT_PRINT_UNSIGNED
81 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
82 # define HOST_WIDE_INT_PRINT_UNSIGNED "%u"
84 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
85 # define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
87 # define HOST_WIDE_INT_PRINT_UNSIGNED "%llu"
90 #endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */
92 #ifndef HOST_WIDE_INT_PRINT_HEX
93 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
94 # define HOST_WIDE_INT_PRINT_HEX "0x%x"
96 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
97 # define HOST_WIDE_INT_PRINT_HEX "0x%lx"
99 # define HOST_WIDE_INT_PRINT_HEX "0x%llx"
102 #endif /* ! HOST_WIDE_INT_PRINT_HEX */
104 #ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX
105 # if HOST_BITS_PER_WIDE_INT == 64
106 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
107 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x"
109 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
110 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
112 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
116 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
117 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x"
119 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
120 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
122 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx"
126 #endif /* ! HOST_WIDE_INT_PRINT_DOUBLE_HEX */
128 /* Find HOST_WIDEST_INT and set its bit size, type and print macros.
129 It will be the largest integer mode supported by the host which may
130 (or may not) be larger than HOST_WIDE_INT. */
132 #ifndef HOST_WIDEST_INT
133 #if defined HOST_BITS_PER_LONGLONG \
134 && HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG
135 # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
136 # define HOST_WIDEST_INT long long
137 # define HOST_WIDEST_INT_PRINT_DEC "%lld"
138 # define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu"
139 # define HOST_WIDEST_INT_PRINT_HEX "0x%llx"
141 # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
142 # define HOST_WIDEST_INT long
143 # define HOST_WIDEST_INT_PRINT_DEC "%ld"
144 # define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
145 # define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
146 # endif /* long long wider than long */
147 #endif /* ! HOST_WIDEST_INT */
149 #endif /* ! GCC_HWINT_H */