aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-cppbuiltin.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-cppbuiltin.c')
-rw-r--r--gcc/c-cppbuiltin.c59
1 files changed, 7 insertions, 52 deletions
diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c
index 86c3f9c..2f2033d 100644
--- a/gcc/c-cppbuiltin.c
+++ b/gcc/c-cppbuiltin.c
@@ -48,8 +48,6 @@ along with GCC; see the file COPYING3. If not see
/* Non-static as some targets don't use it. */
void builtin_define_std (const char *) ATTRIBUTE_UNUSED;
-static void builtin_define_with_value_n (const char *, const char *,
- size_t);
static void builtin_define_with_int_value (const char *, HOST_WIDE_INT);
static void builtin_define_with_hex_fp_value (const char *, tree,
int, const char *,
@@ -375,40 +373,17 @@ builtin_define_fixed_point_constants (const char *name_prefix,
static void
define__GNUC__ (void)
{
- /* The format of the version string, enforced below, is
- ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? */
- const char *q, *v = version_string;
-
- while (*v && !ISDIGIT (*v))
- v++;
- gcc_assert (*v && (v <= version_string || v[-1] == '-'));
-
- q = v;
- while (ISDIGIT (*v))
- v++;
- builtin_define_with_value_n ("__GNUC__", q, v - q);
- if (c_dialect_cxx ())
- builtin_define_with_value_n ("__GNUG__", q, v - q);
-
- gcc_assert (*v == '.' && ISDIGIT (v[1]));
+ int major, minor, patchlevel;
- q = ++v;
- while (ISDIGIT (*v))
- v++;
- builtin_define_with_value_n ("__GNUC_MINOR__", q, v - q);
-
- if (*v == '.')
+ if (sscanf (BASEVER, "%d.%d.%d", &major, &minor, &patchlevel) != 3)
{
- gcc_assert (ISDIGIT (v[1]));
- q = ++v;
- while (ISDIGIT (*v))
- v++;
- builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", q, v - q);
+ sscanf (BASEVER, "%d.%d", &major, &minor);
+ patchlevel = 0;
}
- else
- builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", "0", 1);
+ 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);
- gcc_assert (!*v || *v == ' ' || *v == '-');
}
/* Define macros used by <stdint.h>. Currently only defines limits
@@ -684,9 +659,6 @@ c_cpp_builtins (cpp_reader *pfile)
if (flag_openmp)
cpp_define (pfile, "_OPENMP=200505");
- if (lang_fortran)
- cpp_define (pfile, "__GFORTRAN__=1");
-
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__",
@@ -799,23 +771,6 @@ builtin_define_with_value (const char *macro, const char *expansion, int is_str)
cpp_define (parse_in, buf);
}
-/* Pass an object-like macro and a value to define it to. The third
- parameter is the length of the expansion. */
-static void
-builtin_define_with_value_n (const char *macro, const char *expansion, size_t elen)
-{
- char *buf;
- size_t mlen = strlen (macro);
-
- /* Space for an = and a NUL. */
- buf = (char *) alloca (mlen + elen + 2);
- memcpy (buf, macro, mlen);
- buf[mlen] = '=';
- memcpy (buf + mlen + 1, expansion, elen);
- buf[mlen + elen + 1] = '\0';
-
- cpp_define (parse_in, buf);
-}
/* Pass an object-like macro and an integer value to define it to. */
static void