cppbuiltin.c: New file.
gcc/ * cppbuiltin.c: New file. * cppbuiltin.h: New file. * Makefile.in: Take into account cppbuiltin.{h,c}. gcc/c-family/ * c-cppbuiltin.c (define__GNUC__, builtin_define_type_precision): Remove. (c_cpp_builtins): Call functions from cppbuiltin.c instead of duplicating code. gcc/fortran/ * cpp.c (cpp_define_builtins): Call functions from cppbuiltin.c instead of duplicating code. * Make-lang.in: Add dependency on cppbuiltin.h. Don't define BASEVER. From-SVN: r164917
This commit is contained in:
parent
f1e92a43e9
commit
82a1c2fe69
9 changed files with 242 additions and 158 deletions
|
@ -1,6 +1,12 @@
|
|||
2010-10-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
|
||||
|
||||
* cppbuiltin.c: New file.
|
||||
* cppbuiltin.h: New file.
|
||||
* Makefile.in: Take into account cppbuiltin.{h,c}.
|
||||
|
||||
2010-10-03 Andi Kleen <ak@linux.intel.com>
|
||||
|
||||
* lto-cgraph.c (input_cgraph): Check for missing sections.
|
||||
* lto-cgraph.c (input_cgraph): Check for missing sections.
|
||||
|
||||
2010-10-03 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
|
|
|
@ -1449,6 +1449,7 @@ OBJS-archive = \
|
|||
cgraph.o \
|
||||
cgraphbuild.o \
|
||||
cgraphunit.o \
|
||||
cppbuiltin.o \
|
||||
cppdefault.o \
|
||||
incpath.o \
|
||||
ipa-cp.o \
|
||||
|
@ -2093,9 +2094,9 @@ c-family/c-common.o : c-family/c-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
|||
c-family/c-cppbuiltin.o : c-family/c-cppbuiltin.c $(CONFIG_H) $(SYSTEM_H) \
|
||||
coretypes.h $(TM_H) $(TREE_H) version.h $(C_COMMON_H) $(C_PRAGMA_H) \
|
||||
$(FLAGS_H) $(TOPLEV_H) output.h $(TREE_H) $(TARGET_H) \
|
||||
$(TM_P_H) $(BASEVER) debug.h $(CPP_ID_DATA_H)
|
||||
$(TM_P_H) debug.h $(CPP_ID_DATA_H) cppbuiltin.h
|
||||
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
|
||||
-DBASEVER=$(BASEVER_s) $< $(OUTPUT_OPTION)
|
||||
$< $(OUTPUT_OPTION)
|
||||
|
||||
c-family/c-dump.o : c-family/c-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
||||
$(TM_H) $(TREE_H) $(TREE_DUMP_H)
|
||||
|
@ -3964,6 +3965,12 @@ PREPROCESSOR_DEFINES = \
|
|||
-DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
|
||||
@TARGET_SYSTEM_ROOT_DEFINE@
|
||||
|
||||
cppbuiltin.o: cppbuiltin.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
|
||||
cppbuiltin.h Makefile
|
||||
$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
|
||||
$(PREPROCESSOR_DEFINES) -DBASEVER=$(BASEVER_s) \
|
||||
-c $(srcdir)/cppbuiltin.c $(OUTPUT_OPTION)
|
||||
|
||||
cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
|
||||
cppdefault.h Makefile
|
||||
$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2010-10-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
|
||||
|
||||
* c-cppbuiltin.c (define__GNUC__, builtin_define_type_precision):
|
||||
Remove.
|
||||
(c_cpp_builtins): Call functions from cppbuiltin.c instead
|
||||
of duplicating code.
|
||||
|
||||
2010-09-30 Iain Sandoe <iains@gcc.gnu.org>
|
||||
|
||||
* c-common.c: Add two new entries for @optional
|
||||
|
|
|
@ -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
|
||||
|
|
157
gcc/cppbuiltin.c
Normal file
157
gcc/cppbuiltin.c
Normal file
|
@ -0,0 +1,157 @@
|
|||
/* Define builtin-in macros for all front ends that perform preprocessing
|
||||
Copyright (C) 2010
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 3, or (at your option) any later
|
||||
version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "tm.h"
|
||||
#include "tree.h"
|
||||
#include "version.h"
|
||||
#include "flags.h"
|
||||
#include "toplev.h"
|
||||
#include "cpp-id-data.h"
|
||||
#include "cppbuiltin.h"
|
||||
|
||||
|
||||
/* Parse a BASEVER version string of the format "major.minor.patchlevel"
|
||||
or "major.minor" to extract its components. */
|
||||
void
|
||||
parse_basever (int *major, int *minor, int *patchlevel)
|
||||
{
|
||||
static int s_major = -1, s_minor, s_patchlevel;
|
||||
|
||||
if (s_major == -1)
|
||||
if (sscanf (BASEVER, "%d.%d.%d", &s_major, &s_minor, &s_patchlevel) != 3)
|
||||
{
|
||||
sscanf (BASEVER, "%d.%d", &s_major, &s_minor);
|
||||
s_patchlevel = 0;
|
||||
}
|
||||
|
||||
if (major)
|
||||
*major = s_major;
|
||||
|
||||
if (minor)
|
||||
*minor = s_minor;
|
||||
|
||||
if (patchlevel)
|
||||
*patchlevel = s_patchlevel;
|
||||
}
|
||||
|
||||
|
||||
/* Define __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ and __VERSION__. */
|
||||
static void
|
||||
define__GNUC__ (cpp_reader *pfile)
|
||||
{
|
||||
int major, minor, patchlevel;
|
||||
|
||||
parse_basever (&major, &minor, &patchlevel);
|
||||
cpp_define_formatted (pfile, "__GNUC__=%d", major);
|
||||
cpp_define_formatted (pfile, "__GNUC_MINOR__=%d", minor);
|
||||
cpp_define_formatted (pfile, "__GNUC_PATCHLEVEL__=%d", patchlevel);
|
||||
cpp_define_formatted (pfile, "__VERSION__=\"%s\"", version_string);
|
||||
}
|
||||
|
||||
|
||||
/* Define various built-in CPP macros that depend on language-independent
|
||||
compilation flags. */
|
||||
static void
|
||||
define_builtin_macros_for_compilation_flags (cpp_reader *pfile)
|
||||
{
|
||||
if (flag_pic)
|
||||
{
|
||||
cpp_define_formatted (pfile, "__pic__=%d", flag_pic);
|
||||
cpp_define_formatted (pfile, "__PIC__=%d", flag_pic);
|
||||
}
|
||||
if (flag_pie)
|
||||
{
|
||||
cpp_define_formatted (pfile, "__pie__=%d", flag_pie);
|
||||
cpp_define_formatted (pfile, "__PIE__=%d", flag_pie);
|
||||
}
|
||||
|
||||
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_signaling_nans)
|
||||
cpp_define (pfile, "__SUPPORT_SNAN__");
|
||||
|
||||
cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d",
|
||||
flag_finite_math_only);
|
||||
}
|
||||
|
||||
|
||||
/* Define built-in macros for LP64 targets. */
|
||||
static void
|
||||
define_builtin_macros_for_lp64 (cpp_reader *pfile)
|
||||
{
|
||||
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__");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Define macros for size of basic C types. */
|
||||
static void
|
||||
define_builtin_macros_for_type_sizes (cpp_reader *pfile)
|
||||
{
|
||||
#define define_type_sizeof(NAME, TYPE) \
|
||||
cpp_define_formatted (pfile, NAME"="HOST_WIDE_INT_PRINT_DEC, \
|
||||
tree_low_cst (TYPE_SIZE_UNIT (TYPE), 1))
|
||||
|
||||
define_type_sizeof ("__SIZEOF_INT__", integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_LONG_LONG__", long_long_integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_SHORT__", short_integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_FLOAT__", float_type_node);
|
||||
define_type_sizeof ("__SIZEOF_DOUBLE__", double_type_node);
|
||||
define_type_sizeof ("__SIZEOF_LONG_DOUBLE__", long_double_type_node);
|
||||
define_type_sizeof ("__SIZEOF_SIZE_T__", size_type_node);
|
||||
|
||||
#undef define_type_sizeof
|
||||
|
||||
cpp_define_formatted (pfile, "__CHAR_BIT__=%u",
|
||||
TYPE_PRECISION (char_type_node));
|
||||
cpp_define_formatted (pfile, "__BIGGEST_ALIGNMENT__=%d",
|
||||
BIGGEST_ALIGNMENT / BITS_PER_UNIT);
|
||||
|
||||
/* 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. */
|
||||
cpp_define_formatted (pfile, "__SIZEOF_POINTER__=%d",
|
||||
POINTER_SIZE / BITS_PER_UNIT);
|
||||
}
|
||||
|
||||
|
||||
/* Define macros builtins common to all language performing CPP
|
||||
preprocessing. */
|
||||
void
|
||||
define_language_independent_builtin_macros (cpp_reader *pfile)
|
||||
{
|
||||
define__GNUC__ (pfile);
|
||||
define_builtin_macros_for_compilation_flags (pfile);
|
||||
define_builtin_macros_for_lp64 (pfile);
|
||||
define_builtin_macros_for_type_sizes (pfile);
|
||||
}
|
37
gcc/cppbuiltin.h
Normal file
37
gcc/cppbuiltin.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* Define builtin-in macros for all front ends that perform preprocessing
|
||||
Copyright (C) 2010
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 3, or (at your option) any later
|
||||
version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef GCC_CPPBUILTIN_H
|
||||
#define GCC_CPPBUILTIN_H
|
||||
|
||||
#include "coretypes.h"
|
||||
|
||||
|
||||
/* Parse a BASEVER version string of the format "major.minor.patchlevel"
|
||||
or "major.minor" to extract its components. */
|
||||
extern void parse_basever (int *, int *, int *);
|
||||
|
||||
/* Define macros builtins common to all language performing CPP
|
||||
preprocessing. */
|
||||
extern void define_language_independent_builtin_macros (cpp_reader *);
|
||||
|
||||
|
||||
#endif /* ! GCC_CPPBUILTIN_H */
|
||||
|
|
@ -1,3 +1,10 @@
|
|||
2010-10-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
|
||||
|
||||
* cpp.c (cpp_define_builtins): Call functions from cppbuiltin.c
|
||||
instead of duplicating code.
|
||||
* Make-lang.in: Add dependency on cppbuiltin.h. Don't define
|
||||
BASEVER.
|
||||
|
||||
2010-10-02 Janus Weil <janus@gcc.gnu.org>
|
||||
|
||||
PR fortran/45748
|
||||
|
|
|
@ -360,6 +360,6 @@ fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS) $(TARGET_H) $(RTL_H)
|
|||
fortran/resolve.o: fortran/dependency.h fortran/data.h fortran/target-memory.h
|
||||
fortran/data.o: fortran/data.h
|
||||
fortran/options.o: $(PARAMS_H) $(TARGET_H) fortran/cpp.h
|
||||
fortran/cpp.o: fortran/cpp.c $(BASEVER) incpath.h incpath.o
|
||||
fortran/cpp.o: fortran/cpp.c incpath.h incpath.o cppbuiltin.h
|
||||
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
|
||||
-DBASEVER=$(BASEVER_s) $< $(OUTPUT_OPTION)
|
||||
$< $(OUTPUT_OPTION)
|
||||
|
|
|
@ -35,8 +35,13 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "../../libcpp/internal.h"
|
||||
#include "cpp.h"
|
||||
#include "incpath.h"
|
||||
#include "cppbuiltin.h"
|
||||
#include "mkdeps.h"
|
||||
|
||||
#ifndef TARGET_CPU_CPP_BUILTINS
|
||||
# define TARGET_CPU_CPP_BUILTINS()
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_OS_CPP_BUILTINS
|
||||
# define TARGET_OS_CPP_BUILTINS()
|
||||
#endif
|
||||
|
@ -156,86 +161,19 @@ static void dump_queued_macros (cpp_reader *);
|
|||
static void
|
||||
cpp_define_builtins (cpp_reader *pfile)
|
||||
{
|
||||
int major, minor, patchlevel;
|
||||
|
||||
/* Initialize CPP built-ins; '1' corresponds to 'flag_hosted'
|
||||
in C, defines __STDC_HOSTED__?! */
|
||||
cpp_init_builtins (pfile, 0);
|
||||
|
||||
/* Initialize GFORTRAN specific builtins.
|
||||
These are documented. */
|
||||
if (sscanf (BASEVER, "%d.%d.%d", &major, &minor, &patchlevel) != 3)
|
||||
{
|
||||
sscanf (BASEVER, "%d.%d", &major, &minor);
|
||||
patchlevel = 0;
|
||||
}
|
||||
cpp_define_formatted (pfile, "__GNUC__=%d", major);
|
||||
cpp_define_formatted (pfile, "__GNUC_MINOR__=%d", minor);
|
||||
cpp_define_formatted (pfile, "__GNUC_PATCHLEVEL__=%d", patchlevel);
|
||||
|
||||
define_language_independent_builtin_macros (pfile);
|
||||
cpp_define (pfile, "__GFORTRAN__=1");
|
||||
cpp_define (pfile, "_LANGUAGE_FORTRAN=1");
|
||||
|
||||
if (gfc_option.gfc_flag_openmp)
|
||||
cpp_define (pfile, "_OPENMP=200805");
|
||||
|
||||
|
||||
/* More builtins that might be useful, but are not documented
|
||||
(in no particular order). */
|
||||
cpp_define_formatted (pfile, "__VERSION__=\"%s\"", version_string);
|
||||
|
||||
if (flag_pic)
|
||||
{
|
||||
cpp_define_formatted (pfile, "__pic__=%d", flag_pic);
|
||||
cpp_define_formatted (pfile, "__PIC__=%d", flag_pic);
|
||||
}
|
||||
if (flag_pie)
|
||||
{
|
||||
cpp_define_formatted (pfile, "__pie__=%d", flag_pie);
|
||||
cpp_define_formatted (pfile, "__PIE__=%d", flag_pie);
|
||||
}
|
||||
|
||||
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_signaling_nans)
|
||||
cpp_define (pfile, "__SUPPORT_SNAN__");
|
||||
|
||||
cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d", flag_finite_math_only);
|
||||
|
||||
/* 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__");
|
||||
}
|
||||
|
||||
/* Define NAME with value TYPE size_unit.
|
||||
The C-side also defines __SIZEOF_WCHAR_T__, __SIZEOF_WINT_T__
|
||||
__SIZEOF_PTRDIFF_T__, however, fortran seems to lack the
|
||||
appropriate type nodes. */
|
||||
|
||||
#define define_type_sizeof(NAME, TYPE) \
|
||||
cpp_define_formatted (pfile, NAME"="HOST_WIDE_INT_PRINT_DEC, \
|
||||
tree_low_cst (TYPE_SIZE_UNIT (TYPE), 1))
|
||||
|
||||
define_type_sizeof ("__SIZEOF_INT__", integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_LONG_LONG__", long_long_integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_SHORT__", short_integer_type_node);
|
||||
define_type_sizeof ("__SIZEOF_FLOAT__", float_type_node);
|
||||
define_type_sizeof ("__SIZEOF_DOUBLE__", double_type_node);
|
||||
define_type_sizeof ("__SIZEOF_LONG_DOUBLE__", long_double_type_node);
|
||||
define_type_sizeof ("__SIZEOF_SIZE_T__", size_type_node);
|
||||
|
||||
#undef define_type_sizeof
|
||||
|
||||
/* The defines below are necessary for the TARGET_* macros.
|
||||
|
||||
FIXME: Note that builtin_define_std() actually is a function
|
||||
|
|
Loading…
Add table
Reference in a new issue