aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-cppbuiltin.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.c')
-rw-r--r--gcc/c-family/c-cppbuiltin.c95
1 files changed, 10 insertions, 85 deletions
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 7fe2993..f946dc2 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h" /* For TARGET_CPU_CPP_BUILTINS & friends. */
#include "target.h"
#include "cpp-id-data.h"
+#include "cppbuiltin.h"
#ifndef TARGET_OS_CPP_BUILTINS
# define TARGET_OS_CPP_BUILTINS()
@@ -57,20 +58,11 @@ static void builtin_define_stdint_macros (void);
static void builtin_define_constants (const char *, tree);
static void builtin_define_type_max (const char *, tree);
static void builtin_define_type_minmax (const char *, const char *, tree);
-static void builtin_define_type_precision (const char *, tree);
static void builtin_define_type_sizeof (const char *, tree);
static void builtin_define_float_constants (const char *,
const char *,
const char *,
tree);
-static void define__GNUC__ (void);
-
-/* Define NAME with value TYPE precision. */
-static void
-builtin_define_type_precision (const char *name, tree type)
-{
- builtin_define_with_int_value (name, TYPE_PRECISION (type));
-}
/* Define NAME with value TYPE size_unit. */
static void
@@ -389,25 +381,6 @@ builtin_define_fixed_point_constants (const char *name_prefix,
builtin_define_with_value (name, buf, 0);
}
-/* Define __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__. */
-static void
-define__GNUC__ (void)
-{
- int major, minor, patchlevel;
-
- if (sscanf (BASEVER, "%d.%d.%d", &major, &minor, &patchlevel) != 3)
- {
- sscanf (BASEVER, "%d.%d", &major, &minor);
- patchlevel = 0;
- }
- cpp_define_formatted (parse_in, "__GNUC__=%d", major);
- cpp_define_formatted (parse_in, "__GNUC_MINOR__=%d", minor);
- cpp_define_formatted (parse_in, "__GNUC_PATCHLEVEL__=%d", patchlevel);
-
- if (c_dialect_cxx ())
- cpp_define_formatted (parse_in, "__GNUG__=%d", major);
-}
-
/* Define macros used by <stdint.h>. */
static void
builtin_define_stdint_macros (void)
@@ -557,7 +530,14 @@ c_cpp_builtins (cpp_reader *pfile)
if (flag_undef)
return;
- define__GNUC__ ();
+ define_language_independent_builtin_macros (pfile);
+
+ if (c_dialect_cxx ())
+ {
+ int major;
+ parse_basever (&major, NULL, NULL);
+ cpp_define_formatted (pfile, "__GNUG__=%d", major);
+ }
/* For stddef.h. They require macros defined in c-common.c. */
c_stddef_cpp_builtins ();
@@ -616,13 +596,10 @@ c_cpp_builtins (cpp_reader *pfile)
builtin_define_type_max ("__PTRDIFF_MAX__", ptrdiff_type_node);
builtin_define_type_max ("__SIZE_MAX__", size_type_node);
- builtin_define_type_precision ("__CHAR_BIT__", char_type_node);
-
/* stdint.h and the testsuite need to know these. */
builtin_define_stdint_macros ();
- /* float.h needs to know these. */
-
+ /* float.h needs to know this. */
builtin_define_with_int_value ("__FLT_EVAL_METHOD__",
TARGET_FLT_EVAL_METHOD);
@@ -704,49 +681,13 @@ c_cpp_builtins (cpp_reader *pfile)
builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
/* Misc. */
- builtin_define_with_value ("__VERSION__", version_string, 1);
-
if (flag_gnu89_inline)
cpp_define (pfile, "__GNUC_GNU_INLINE__");
else
cpp_define (pfile, "__GNUC_STDC_INLINE__");
- /* Definitions for LP64 model. */
- if (TYPE_PRECISION (long_integer_type_node) == 64
- && POINTER_SIZE == 64
- && TYPE_PRECISION (integer_type_node) == 32)
- {
- cpp_define (pfile, "_LP64");
- cpp_define (pfile, "__LP64__");
- }
-
- /* Other target-independent built-ins determined by command-line
- options. */
- if (optimize_size)
- cpp_define (pfile, "__OPTIMIZE_SIZE__");
- if (optimize)
- cpp_define (pfile, "__OPTIMIZE__");
-
- if (fast_math_flags_set_p ())
- cpp_define (pfile, "__FAST_MATH__");
if (flag_no_inline)
cpp_define (pfile, "__NO_INLINE__");
- if (flag_signaling_nans)
- cpp_define (pfile, "__SUPPORT_SNAN__");
- if (flag_finite_math_only)
- cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
- else
- cpp_define (pfile, "__FINITE_MATH_ONLY__=0");
- if (flag_pic)
- {
- builtin_define_with_int_value ("__pic__", flag_pic);
- builtin_define_with_int_value ("__PIC__", flag_pic);
- }
- if (flag_pie)
- {
- builtin_define_with_int_value ("__pie__", flag_pie);
- builtin_define_with_int_value ("__PIE__", flag_pie);
- }
if (flag_iso)
cpp_define (pfile, "__STRICT_ANSI__");
@@ -810,26 +751,13 @@ c_cpp_builtins (cpp_reader *pfile)
if (flag_openmp)
cpp_define (pfile, "_OPENMP=200805");
- builtin_define_type_sizeof ("__SIZEOF_INT__", integer_type_node);
- builtin_define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node);
- builtin_define_type_sizeof ("__SIZEOF_LONG_LONG__",
- long_long_integer_type_node);
if (int128_integer_type_node != NULL_TREE)
builtin_define_type_sizeof ("__SIZEOF_INT128__",
int128_integer_type_node);
- builtin_define_type_sizeof ("__SIZEOF_SHORT__", short_integer_type_node);
- builtin_define_type_sizeof ("__SIZEOF_FLOAT__", float_type_node);
- builtin_define_type_sizeof ("__SIZEOF_DOUBLE__", double_type_node);
- builtin_define_type_sizeof ("__SIZEOF_LONG_DOUBLE__", long_double_type_node);
- builtin_define_type_sizeof ("__SIZEOF_SIZE_T__", size_type_node);
builtin_define_type_sizeof ("__SIZEOF_WCHAR_T__", wchar_type_node);
builtin_define_type_sizeof ("__SIZEOF_WINT_T__", wint_type_node);
builtin_define_type_sizeof ("__SIZEOF_PTRDIFF_T__",
unsigned_ptrdiff_type_node);
- /* ptr_type_node can't be used here since ptr_mode is only set when
- toplev calls backend_init which is not done with -E switch. */
- builtin_define_with_int_value ("__SIZEOF_POINTER__",
- POINTER_SIZE / BITS_PER_UNIT);
/* A straightforward target hook doesn't work, because of problems
linking that hook's body when part of non-C front ends. */
@@ -855,9 +783,6 @@ c_cpp_builtins (cpp_reader *pfile)
format. */
if (ENABLE_DECIMAL_FLOAT && ENABLE_DECIMAL_BID_FORMAT)
cpp_define (pfile, "__DECIMAL_BID_FORMAT__");
-
- builtin_define_with_int_value ("__BIGGEST_ALIGNMENT__",
- BIGGEST_ALIGNMENT / BITS_PER_UNIT);
}
/* Pass an object-like macro. If it doesn't lie in the user's