]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/hwint.h
Merge basic-improvements-branch to trunk
[thirdparty/gcc.git] / gcc / hwint.h
CommitLineData
cce4a958 1/* HOST_WIDE_INT definitions for the GNU compiler.
964b104a 2 Copyright (C) 1998, 2002 Free Software Foundation, Inc.
cce4a958 3
1322177d 4 This file is part of GCC.
cce4a958
KG
5
6 Provide definitions for macros which depend on HOST_BITS_PER_INT
19eb1ad7 7 and HOST_BITS_PER_LONG. */
cce4a958 8
88657302
RH
9#ifndef GCC_HWINT_H
10#define GCC_HWINT_H
cce4a958 11
75e93faa
ZW
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
4977bab6
ZW
18/* If HAVE_LONG_LONG and SIZEOF_LONG_LONG aren't defined, but
19 GCC_VERSION >= 3000, assume this is the second or later stage of a
20 bootstrap, we do have long long, and it's 64 bits. (This is
21 required by C99; we do have some ports that violate that assumption
22 but they're all cross-compile-only.) Just in case, force a
23 constraint violation if that assumption is incorrect. */
24#if !defined HAVE_LONG_LONG
25# if GCC_VERSION >= 3000
26# define HAVE_LONG_LONG 1
27# define SIZEOF_LONG_LONG 8
28extern char sizeof_long_long_must_be_8[sizeof(long long) == 8 ? 1 : -1];
29# endif
30#endif
31
75e93faa
ZW
32#ifdef HAVE_LONG_LONG
33# define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG)
4977bab6 34#endif
964b104a 35#ifdef HAVE___INT64
4977bab6 36# define HOST_BITS_PER___INT64 (CHAR_BIT * SIZEOF___INT64)
6d08665a 37#endif
cce4a958 38
4977bab6
ZW
39/* Set HOST_WIDE_INT. This should be the widest efficient host
40 integer type. It can be 32 or 64 bits, except that if we are
41 targeting a machine with 64-bit size_t then it has to be 64 bits.
cce4a958 42
4977bab6
ZW
43 With a sane ABI, 'long' is the largest efficient host integer type.
44 Thus, we use that unless we have to use 'long long' or '__int64'
45 because we're targeting a 64-bit machine from a 32-bit host. */
4abe9f62 46
4977bab6
ZW
47#if HOST_BITS_PER_LONG >= 64 || !defined NEED_64BIT_HOST_WIDE_INT
48# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
49# define HOST_WIDE_INT long
50#else
51# if HOST_BITS_PER_LONGLONG >= 64
4abe9f62
AO
52# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
53# define HOST_WIDE_INT long long
cce4a958 54# else
4977bab6
ZW
55# if HOST_BITS_PER___INT64 >= 64
56# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER___INT64
57# define HOST_WIDE_INT __int64
cce4a958 58# else
4977bab6 59 #error "Unable to find a suitable type for HOST_WIDE_INT"
cce4a958
KG
60# endif
61# endif
4977bab6 62#endif
cce4a958 63
4977bab6
ZW
64/* Various printf format strings for HOST_WIDE_INT. */
65
66#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
67# define HOST_WIDE_INT_PRINT_DEC "%ld"
68# define HOST_WIDE_INT_PRINT_DEC_C "%ldL"
69# define HOST_WIDE_INT_PRINT_DEC_SPACE "% *ld"
70# define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
71# define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *lu"
72# define HOST_WIDE_INT_PRINT_HEX "0x%lx"
73 /* 'long' might be 32 or 64 bits, and the number of leading zeroes
74 must be tweaked accordingly. */
75# if HOST_BITS_PER_WIDE_INT == 64
76# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
cce4a958 77# else
4977bab6 78# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
cce4a958 79# endif
4977bab6
ZW
80#else
81# define HOST_WIDE_INT_PRINT_DEC "%lld"
82# define HOST_WIDE_INT_PRINT_DEC_C "%lldLL"
83# define HOST_WIDE_INT_PRINT_DEC_SPACE "% *lld"
84# define HOST_WIDE_INT_PRINT_UNSIGNED "%llu"
85# define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *llu"
86# define HOST_WIDE_INT_PRINT_HEX "0x%llx"
87 /* We can assume that 'long long' is at least 64 bits. */
88# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
89#endif
cce4a958 90
4977bab6
ZW
91/* Set HOST_WIDEST_INT. Unlike HOST_WIDE_INT, this must always be
92 at least 64 bits wide. */
93
94#if HOST_BITS_PER_WIDE_INT >= 64
95# define HOST_WIDEST_INT HOST_WIDE_INT
96# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_WIDE_INT
97# define HOST_WIDEST_INT_PRINT_DEC HOST_WIDE_INT_PRINT_DEC
98# define HOST_WIDEST_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC_C
99# define HOST_WIDEST_INT_PRINT_DEC_SPACE HOST_WIDE_INT_PRINT_DEC_SPACE
100# define HOST_WIDEST_INT_PRINT_UNSIGNED HOST_WIDE_INT_PRINT_UNSIGNED
101# define HOST_WIDEST_INT_PRINT_UNSIGNED_SPACE HOST_WIDE_INT_PRINT_UNSIGNED_SPACE
102# define HOST_WIDEST_INT_PRINT_HEX HOST_WIDE_INT_PRINT_HEX
103# define HOST_WIDEST_INT_PRINT_DOUBLE_HEX HOST_WIDE_INT_PRINT_DOUBLE_HEX
104#else
105# if HOST_BITS_PER_LONGLONG >= 64
106# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
107# define HOST_WIDEST_INT long long
cce4a958 108# else
4977bab6
ZW
109# if HOST_BITS_PER___INT64 >= 64
110# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER___INT64
111# define HOST_WIDEST_INT __int64
cce4a958 112# else
4977bab6 113 #error "Unable to find a suitable type for HOST_WIDEST_INT"
cce4a958
KG
114# endif
115# endif
4977bab6
ZW
116# define HOST_WIDEST_INT_PRINT_DEC "%lld"
117# define HOST_WIDEST_INT_PRINT_DEC_C "%lldLL"
118# define HOST_WIDEST_INT_PRINT_DEC_SPACE "% *lld"
119# define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu"
120# define HOST_WIDEST_INT_PRINT_UNSIGNED_SPACE "% *llu"
121# define HOST_WIDEST_INT_PRINT_HEX "0x%llx"
122# define HOST_WIDEST_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
123#endif
75e93faa 124
88657302 125#endif /* ! GCC_HWINT_H */