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.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 9f993c4..42b7604 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -1277,29 +1277,39 @@ c_cpp_builtins (cpp_reader *pfile)
{
scalar_float_mode mode = mode_iter.require ();
const char *name = GET_MODE_NAME (mode);
+ const size_t name_len = strlen (name);
+ char float_h_prefix[16] = "";
char *macro_name
- = (char *) alloca (strlen (name)
- + sizeof ("__LIBGCC__MANT_DIG__"));
+ = XALLOCAVEC (char, name_len + sizeof ("__LIBGCC__MANT_DIG__"));
sprintf (macro_name, "__LIBGCC_%s_MANT_DIG__", name);
builtin_define_with_int_value (macro_name,
REAL_MODE_FORMAT (mode)->p);
if (!targetm.scalar_mode_supported_p (mode)
|| !targetm.libgcc_floating_mode_supported_p (mode))
continue;
- macro_name = (char *) alloca (strlen (name)
- + sizeof ("__LIBGCC_HAS__MODE__"));
+ macro_name = XALLOCAVEC (char, name_len
+ + sizeof ("__LIBGCC_HAS__MODE__"));
sprintf (macro_name, "__LIBGCC_HAS_%s_MODE__", name);
cpp_define (pfile, macro_name);
- macro_name = (char *) alloca (strlen (name)
- + sizeof ("__LIBGCC__FUNC_EXT__"));
+ macro_name = XALLOCAVEC (char, name_len
+ + sizeof ("__LIBGCC__FUNC_EXT__"));
sprintf (macro_name, "__LIBGCC_%s_FUNC_EXT__", name);
char suffix[20] = "";
if (mode == TYPE_MODE (double_type_node))
- ; /* Empty suffix correct. */
+ {
+ /* Empty suffix correct. */
+ memcpy (float_h_prefix, "DBL", 4);
+ }
else if (mode == TYPE_MODE (float_type_node))
- suffix[0] = 'f';
+ {
+ suffix[0] = 'f';
+ memcpy (float_h_prefix, "FLT", 4);
+ }
else if (mode == TYPE_MODE (long_double_type_node))
- suffix[0] = 'l';
+ {
+ suffix[0] = 'l';
+ memcpy (float_h_prefix, "LDBL", 5);
+ }
else
{
bool found_suffix = false;
@@ -1310,6 +1320,8 @@ c_cpp_builtins (cpp_reader *pfile)
sprintf (suffix, "f%d%s", floatn_nx_types[i].n,
floatn_nx_types[i].extended ? "x" : "");
found_suffix = true;
+ sprintf (float_h_prefix, "FLT%d%s", floatn_nx_types[i].n,
+ floatn_nx_types[i].extended ? "X" : "");
break;
}
gcc_assert (found_suffix);
@@ -1347,11 +1359,33 @@ c_cpp_builtins (cpp_reader *pfile)
default:
gcc_unreachable ();
}
- macro_name = (char *) alloca (strlen (name)
- + sizeof ("__LIBGCC__EXCESS_"
- "PRECISION__"));
+ macro_name = XALLOCAVEC (char, name_len
+ + sizeof ("__LIBGCC__EXCESS_PRECISION__"));
sprintf (macro_name, "__LIBGCC_%s_EXCESS_PRECISION__", name);
builtin_define_with_int_value (macro_name, excess_precision);
+
+ char val_name[64];
+
+ macro_name = XALLOCAVEC (char, name_len
+ + sizeof ("__LIBGCC__EPSILON__"));
+ sprintf (macro_name, "__LIBGCC_%s_EPSILON__", name);
+ sprintf (val_name, "__%s_EPSILON__", float_h_prefix);
+ builtin_define_with_value (macro_name, val_name, 0);
+
+ macro_name = XALLOCAVEC (char, name_len + sizeof ("__LIBGCC__MAX__"));
+ sprintf (macro_name, "__LIBGCC_%s_MAX__", name);
+ sprintf (val_name, "__%s_MAX__", float_h_prefix);
+ builtin_define_with_value (macro_name, val_name, 0);
+
+ macro_name = XALLOCAVEC (char, name_len + sizeof ("__LIBGCC__MIN__"));
+ sprintf (macro_name, "__LIBGCC_%s_MIN__", name);
+ sprintf (val_name, "__%s_MIN__", float_h_prefix);
+ builtin_define_with_value (macro_name, val_name, 0);
+
+#ifdef HAVE_adddf3
+ builtin_define_with_int_value ("__LIBGCC_HAVE_HWDBL__",
+ HAVE_adddf3);
+#endif
}
/* For libgcc crtstuff.c and libgcc2.c. */