OSDN Git Service

e4ec51cba7ab3efa2e7f0b789209956830c133fc
[pf3gnuchains/gcc-fork.git] / gcc / hwint.h
1 /* HOST_WIDE_INT definitions for the GNU compiler.
2    Copyright (C) 1998 Free Software Foundation, Inc.
3
4    This file is part of GNU CC.
5
6    Provide definitions for macros which depend on HOST_BITS_PER_INT
7    and HOST_BITS_PER_LONG. */
8
9 #ifndef __HWINT_H__
10 #define __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 /* 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
25 # endif /* gcc */
26 #endif /* no long long */
27
28 /* Find the largest host integer type and set its size and type.  */
29
30 #ifndef HOST_BITS_PER_WIDE_INT
31
32 # if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
33 #  define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
34 #  define HOST_WIDE_INT long
35 # else
36 #  define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
37 #  define HOST_WIDE_INT int
38 # endif
39
40 #endif /* ! HOST_BITS_PER_WIDE_INT */
41
42 /* Provide defaults for the way to print a HOST_WIDE_INT
43    in various manners.  */
44
45 #ifndef HOST_WIDE_INT_PRINT_DEC
46 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
47 #  define HOST_WIDE_INT_PRINT_DEC "%d"
48 # else
49 #  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
50 #   define HOST_WIDE_INT_PRINT_DEC "%ld"
51 #  else
52 #   define HOST_WIDE_INT_PRINT_DEC "%lld"
53 #  endif
54 # endif
55 #endif /* ! HOST_WIDE_INT_PRINT_DEC */
56
57 #ifndef HOST_WIDE_INT_PRINT_UNSIGNED
58 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
59 #  define HOST_WIDE_INT_PRINT_UNSIGNED "%u"
60 # else
61 #  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
62 #   define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
63 #  else
64 #   define HOST_WIDE_INT_PRINT_UNSIGNED "%llu"
65 #  endif
66 # endif
67 #endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */
68
69 #ifndef HOST_WIDE_INT_PRINT_HEX
70 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
71 #  define HOST_WIDE_INT_PRINT_HEX "0x%x"
72 # else
73 #  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
74 #   define HOST_WIDE_INT_PRINT_HEX "0x%lx"
75 #  else
76 #   define HOST_WIDE_INT_PRINT_HEX "0x%llx"
77 #  endif
78 # endif
79 #endif /* ! HOST_WIDE_INT_PRINT_HEX */
80
81 #ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX
82 # if HOST_BITS_PER_WIDE_INT == 64
83 #  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
84 #   define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x"
85 #  else
86 #   if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
87 #    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
88 #   else
89 #    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
90 #   endif
91 #  endif
92 # else
93 #  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
94 #   define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x"
95 #  else
96 #   if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
97 #    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
98 #   else
99 #    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx"
100 #   endif
101 #  endif
102 # endif
103 #endif /* ! HOST_WIDE_INT_PRINT_DOUBLE_HEX */
104
105 /* Find HOST_WIDEST_INT and set its bit size, type and print macros.
106    It will be the largest integer mode supported by the host which may
107    (or may not) be larger than HOST_WIDE_INT.  */
108
109 #ifndef HOST_WIDEST_INT
110 #if defined HOST_BITS_PER_LONGLONG \
111     && HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG
112 #   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
113 #   define HOST_WIDEST_INT long long
114 #   define HOST_WIDEST_INT_PRINT_DEC "%lld"
115 #   define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu"
116 #   define HOST_WIDEST_INT_PRINT_HEX "0x%llx"
117 #  else
118 #   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
119 #   define HOST_WIDEST_INT long
120 #   define HOST_WIDEST_INT_PRINT_DEC "%ld"
121 #   define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
122 #   define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
123 # endif /* long long wider than long */
124 #endif /* ! HOST_WIDEST_INT */
125
126 #endif /* __HWINT_H__ */