void ix86_target_macros (void) { /* 32/64-bit won't change with target specific options, so do the assert and builtin_define_std calls here. */ if (TARGET_64BIT) { cpp_assert (parse_in, "cpu=x86_64"); cpp_assert (parse_in, "machine=x86_64"); cpp_define (parse_in, "__amd64"); cpp_define (parse_in, "__amd64__"); cpp_define (parse_in, "__x86_64"); cpp_define (parse_in, "__x86_64__"); } else { cpp_assert (parse_in, "cpu=i386"); cpp_assert (parse_in, "machine=i386"); builtin_define_std ("i386"); } ix86_target_macros_internal (ix86_isa_flags, ix86_arch, ix86_tune, ix86_fpmath, cpp_define); }
/* Pass an object-like macro. If it doesn't lie in the user's namespace, defines it unconditionally. Otherwise define a version with two leading underscores, and another version with two leading and trailing underscores, and define the original only if an ISO standard was not nominated. e.g. passing "unix" defines "__unix", "__unix__" and possibly "unix". Passing "_mips" defines "__mips", "__mips__" and possibly "_mips". */ void builtin_define_std (const char *macro) { size_t len = strlen (macro); char *buff = (char *) alloca (len + 5); char *p = buff + 2; char *q = p + len; /* prepend __ (or maybe just _) if in user's namespace. */ memcpy (p, macro, len + 1); if (!( *p == '_' && (p[1] == '_' || ISUPPER (p[1])))) { if (*p != '_') *--p = '_'; if (p[1] != '_') *--p = '_'; } cpp_define (parse_in, p); /* If it was in user's namespace... */ if (p != buff + 2) { /* Define the macro with leading and following __. */ if (q[-1] != '_') *q++ = '_'; if (q[-2] != '_') *q++ = '_'; *q = '\0'; cpp_define (parse_in, p); /* Finally, define the original macro if permitted. */ if (!flag_iso) cpp_define (parse_in, macro); } }
/* 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 (&global_options)) 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); }
void spu_cpu_cpp_builtins (struct cpp_reader *pfile) { builtin_define_std ("__SPU__"); cpp_assert (pfile, "cpu=spu"); cpp_assert (pfile, "machine=spu"); if (spu_arch == PROCESSOR_CELLEDP) builtin_define_std ("__SPU_EDP__"); builtin_define_std ("__vector=__attribute__((__spu_vector__))"); if (!flag_iso) { /* Define this when supporting context-sensitive keywords. */ cpp_define (pfile, "__VECTOR_KEYWORD_SUPPORTED__"); cpp_define (pfile, "vector=vector"); /* Initialize vector keywords. */ __vector_keyword = get_identifier ("__vector"); C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL; vector_keyword = get_identifier ("vector"); C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL; /* Enable context-sensitive macros. */ cpp_get_callbacks (pfile)->macro_to_expand = spu_macro_to_expand; } }
/* 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__"); } }
static void builtin_define_type_minmax (const char *min_macro, const char *max_macro, tree type) { static const char *const values[] = { "127", "255", "32767", "65535", "2147483647", "4294967295", "9223372036854775807", "18446744073709551615", "170141183460469231731687303715884105727", "340282366920938463463374607431768211455" }; const char *value, *suffix; char *buf; size_t idx; /* Pre-rendering the values mean we don't have to futz with printing a multi-word decimal value. There are also a very limited number of precisions that we support, so it's really a waste of time. */ switch (TYPE_PRECISION (type)) { case 8: idx = 0; break; case 16: idx = 2; break; case 32: idx = 4; break; case 64: idx = 6; break; case 128: idx = 8; break; default: gcc_unreachable (); } value = values[idx + TYPE_UNSIGNED (type)]; suffix = type_suffix (type); buf = (char *) alloca (strlen (max_macro) + 1 + strlen (value) + strlen (suffix) + 1); sprintf (buf, "%s=%s%s", max_macro, value, suffix); cpp_define (parse_in, buf); if (min_macro) { if (TYPE_UNSIGNED (type)) { buf = (char *) alloca (strlen (min_macro) + 2 + strlen (suffix) + 1); sprintf (buf, "%s=0%s", min_macro, suffix); } else { buf = (char *) alloca (strlen (min_macro) + 3 + strlen (max_macro) + 6); sprintf (buf, "%s=(-%s - 1)", min_macro, max_macro); } cpp_define (parse_in, buf); } }
/* 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_to_uhwi (TYPE_SIZE_UNIT (TYPE))) 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); /* Define constants useful for implementing endian.h. */ cpp_define (pfile, "__ORDER_LITTLE_ENDIAN__=1234"); cpp_define (pfile, "__ORDER_BIG_ENDIAN__=4321"); cpp_define (pfile, "__ORDER_PDP_ENDIAN__=3412"); if (WORDS_BIG_ENDIAN == BYTES_BIG_ENDIAN) cpp_define_formatted (pfile, "__BYTE_ORDER__=%s", (WORDS_BIG_ENDIAN ? "__ORDER_BIG_ENDIAN__" : "__ORDER_LITTLE_ENDIAN__")); else { /* Assert that we're only dealing with the PDP11 case. */ gcc_assert (!BYTES_BIG_ENDIAN); gcc_assert (WORDS_BIG_ENDIAN); cpp_define (pfile, "__BYTE_ORDER__=__ORDER_PDP_ENDIAN__"); } cpp_define_formatted (pfile, "__FLOAT_WORD_ORDER__=%s", (targetm.float_words_big_endian () ? "__ORDER_BIG_ENDIAN__" : "__ORDER_LITTLE_ENDIAN__")); /* 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", 1 << ceil_log2 ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)); }
static PyObject* gcc_python_define_macro(PyObject *self, PyObject *args, PyObject *kwargs) { const char *macro; char *keywords[] = {"macro", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:define_preprocessor_name", keywords, ¯o)) { return NULL; } if (0) { fprintf(stderr, "gcc.define_macro(\"%s\")\n", macro); } if (!parse_in) { return PyErr_Format(PyExc_ValueError, "gcc.define_macro(\"%s\") called without a compilation unit", macro); } if (!gcc_python_is_within_event(NULL)) { return PyErr_Format(PyExc_ValueError, "gcc.define_macro(\"%s\") called from outside an event callback", macro); } cpp_define (parse_in, macro); Py_RETURN_NONE; }
/* Pass an object-like macro a hexadecimal floating-point value. */ static void builtin_define_with_hex_fp_value (const char *macro, tree type ATTRIBUTE_UNUSED, int digits, const char *hex_str, const char *fp_suffix, const char *fp_cast) { REAL_VALUE_TYPE real; char dec_str[64], buf1[256], buf2[256]; /* Hex values are really cool and convenient, except that they're not supported in strict ISO C90 mode. First, the "p-" sequence is not valid as part of a preprocessor number. Second, we get a pedwarn from the preprocessor, which has no context, so we can't suppress the warning with __extension__. So instead what we do is construct the number in hex (because it's easy to get the exact correct value), parse it as a real, then print it back out as decimal. */ real_from_string (&real, hex_str); real_to_decimal (dec_str, &real, sizeof (dec_str), digits, 0); /* Assemble the macro in the following fashion macro = fp_cast [dec_str fp_suffix] */ sprintf (buf1, "%s%s", dec_str, fp_suffix); sprintf (buf2, fp_cast, buf1); sprintf (buf1, "%s=%s", macro, buf2); cpp_define (parse_in, buf1); }
static void def_or_undef_macro(struct cpp_reader* pfile, const char *name, bool def_p) { if (def_p) cpp_define (pfile, name); else cpp_undef (pfile, name); }
/* Define platform dependent macros. */ void s390_cpu_cpp_builtins (cpp_reader *pfile) { struct cl_target_option opts; cpp_assert (pfile, "cpu=s390"); cpp_assert (pfile, "machine=s390"); cpp_define (pfile, "__s390__"); if (TARGET_ZARCH) cpp_define (pfile, "__zarch__"); if (TARGET_64BIT) cpp_define (pfile, "__s390x__"); if (TARGET_LONG_DOUBLE_128) cpp_define (pfile, "__LONG_DOUBLE_128__"); cl_target_option_save (&opts, &global_options); s390_cpu_cpp_builtins_internal (pfile, &opts, NULL); }
static void aarch64_def_or_undef (bool def_p, const char *macro, cpp_reader *pfile) { if (def_p) cpp_define (pfile, macro); else cpp_undef (pfile, macro); }
static void cci_attribute(void *pfile_v,const char *keyword, const char *target, int varargs, int n) { struct cpp_reader *pfile = (struct cpp_reader *)pfile_v; int params_specified = 0; char *buffer,*c; int size; int i; if (n) { for (c = target; *c; c++) { if ((*c == 'P') && (c[1] >= '0') && (c[1] <= '9')) { params_specified=1; break; } } } size = strlen(keyword)+sizeof("__attribute__(())")+strlen(target)+1; if (n) { if (params_specified == 0) { size += 8 * n; /* up to 99 params: Pnn, */ } } if (varargs) size += strlen("=()(),...__VA_ARGS__"); buffer = (char *)xmalloc(size); c = buffer; c += sprintf(c,"%s",keyword); if (n || varargs) { *c++ = '('; for (i = 1; i <= n; i++) { c += sprintf(c, "P%d", i); if (i < n) *c += ','; } if (varargs) { if (n) *c++=','; c += sprintf(c, "..."); } *c++ = ')'; } c += sprintf(c, "=__attribute__((%s", target); if ((n || varargs) && !params_specified) { *c++ = '('; for (i = 1; i <= n; i++) { c += sprintf(c, "P%d", i); if (i < n) *c += ','; } if (varargs) { if (n) *c++=','; c += sprintf(c, "__VA_ARGS__"); } *c++ = ')'; } *c++ = ')'; *c++ = ')'; *c++ = 0; cpp_define(pfile, buffer); free(buffer); }
/* Internal function to either define or undef the appropriate system macros. */ static void s390_cpu_cpp_builtins_internal (cpp_reader *pfile, struct cl_target_option *opts, const struct cl_target_option *old_opts) { s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts, "__HTM__", "__HTM__"); s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts, "__VX__", "__VX__"); s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, "__VEC__=10302", "__VEC__"); s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, "__vector=__attribute__((vector_size(16)))", "__vector__"); s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, "__bool=__attribute__((s390_vector_bool)) unsigned", "__bool"); { char macro_def[64]; gcc_assert (s390_arch != PROCESSOR_NATIVE); sprintf (macro_def, "__ARCH__=%d", processor_table[s390_arch].arch_level); cpp_undef (pfile, "__ARCH__"); cpp_define (pfile, macro_def); } if (!flag_iso) { s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, "__VECTOR_KEYWORD_SUPPORTED__", "__VECTOR_KEYWORD_SUPPORTED__"); s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, "vector=vector", "vector"); s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, "bool=bool", "bool"); if (TARGET_ZVECTOR_P (opts->x_target_flags) && __vector_keyword == NULL) { __vector_keyword = get_identifier ("__vector"); C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL; vector_keyword = get_identifier ("vector"); C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL; __bool_keyword = get_identifier ("__bool"); C_CPP_HASHNODE (__bool_keyword)->flags |= NODE_CONDITIONAL; bool_keyword = get_identifier ("bool"); C_CPP_HASHNODE (bool_keyword)->flags |= NODE_CONDITIONAL; _Bool_keyword = get_identifier ("_Bool"); C_CPP_HASHNODE (_Bool_keyword)->flags |= NODE_CONDITIONAL; /* Enable context-sensitive macros. */ cpp_get_callbacks (pfile)->macro_to_expand = s390_macro_to_expand; } } }
void ix86_target_macros (void) { /* 32/64-bit won't change with target specific options, so do the assert and builtin_define_std calls here. */ if (TARGET_64BIT) { cpp_assert (parse_in, "cpu=x86_64"); cpp_assert (parse_in, "machine=x86_64"); cpp_define (parse_in, "__amd64"); cpp_define (parse_in, "__amd64__"); cpp_define (parse_in, "__x86_64"); cpp_define (parse_in, "__x86_64__"); if (TARGET_X32) { cpp_define (parse_in, "_ILP32"); cpp_define (parse_in, "__ILP32__"); } } else { cpp_assert (parse_in, "cpu=i386"); cpp_assert (parse_in, "machine=i386"); builtin_define_std ("i386"); } cpp_define_formatted (parse_in, "__ATOMIC_HLE_ACQUIRE=%d", IX86_HLE_ACQUIRE); cpp_define_formatted (parse_in, "__ATOMIC_HLE_RELEASE=%d", IX86_HLE_RELEASE); ix86_target_macros_internal (ix86_isa_flags, ix86_arch, ix86_tune, ix86_fpmath, cpp_define); }
void sparc_target_macros (void) { builtin_define_std ("sparc"); if (TARGET_64BIT) { cpp_assert (parse_in, "cpu=sparc64"); cpp_assert (parse_in, "machine=sparc64"); } else { cpp_assert (parse_in, "cpu=sparc"); cpp_assert (parse_in, "machine=sparc"); } if (TARGET_VIS3) { cpp_define (parse_in, "__VIS__=0x300"); cpp_define (parse_in, "__VIS=0x300"); } else if (TARGET_VIS2) { cpp_define (parse_in, "__VIS__=0x200"); cpp_define (parse_in, "__VIS=0x200"); } else if (TARGET_VIS) { cpp_define (parse_in, "__VIS__=0x100"); cpp_define (parse_in, "__VIS=0x100"); } }
/* Pass an object-like macro and an integer value to define it to. */ static void builtin_define_with_int_value (const char *macro, HOST_WIDE_INT value) { char *buf; size_t mlen = strlen (macro); size_t vlen = 18; size_t extra = 2; /* space for = and NUL. */ buf = (char *) alloca (mlen + vlen + extra); memcpy (buf, macro, mlen); buf[mlen] = '='; sprintf (buf + mlen + 1, HOST_WIDE_INT_PRINT_DEC, value); 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); }
int main(int argc, char *argv[]) { int ofd = 1; int i = 1; char *s1, *s2; int len = 0; char *cbuf; int clen; while (i < argc && argv[i][0] == '-') { if (argv[i][1] == 'I') cpp_addpath(argv[i][2] ? argv[i] + 2 : argv[++i]); if (argv[i][1] == 'D') { char *name = argv[i] + 2; char *def = ""; char *eq = strchr(name, '='); if (eq) { *eq = '\0'; def = eq + 1; } cpp_define(name, def); } i++; } if (i + 1 >= argc) { printf("usage: npp [-I idir] [-D define] input output\n"); return 0; } if (cpp_init(argv[i++])) die("npp: cannot open <%s>\n", argv[i - 1]); ofd = open(argv[i++], O_WRONLY | O_TRUNC | O_CREAT, 0600); if (ofd < 0) die("npp: cannot open <%s>\n", argv[i - 1]); s1 = malloc(OBUFSZ); s2 = malloc(OBUFSZ); if (!s1 || !s2) die("npp: cannot allocate enough memory\n"); while (!cpp_read(&cbuf, &clen)) { memcpy(s1 + len, cbuf, clen); len += clen; } len = rmcomments(s2, s1, len); xwrite(ofd, s2, len); close(ofd); return 0; }
static void cci_define(void *pfile_v, const char *keyword, const char *target) { struct cpp_reader *pfile = (struct cpp_reader *)pfile_v; char *buffer; if (target) { buffer = (char *)xmalloc(strlen(keyword) + strlen(target) + 6); sprintf(buffer,"%s=%s", keyword, target); } else { buffer = (char *)xmalloc(strlen(keyword) + strlen("=") + 6); sprintf(buffer,"%s=", keyword); } cpp_define(pfile, buffer); free(buffer); return; }
/* Pass an object-like macro and a value to define it to. The third parameter says whether or not to turn the value into a string constant. */ void builtin_define_with_value (const char *macro, const char *expansion, int is_str) { char *buf; size_t mlen = strlen (macro); size_t elen = strlen (expansion); size_t extra = 2; /* space for an = and a NUL */ if (is_str) extra += 2; /* space for two quote marks */ buf = (char *) alloca (mlen + elen + extra); if (is_str) sprintf (buf, "%s=\"%s\"", macro, expansion); else sprintf (buf, "%s=%s", macro, expansion); cpp_define (parse_in, buf); }
/* Helper function that defines or undefines macros. If SET is true, the macro MACRO_DEF is defined. If SET is false, the macro MACRO_UNDEF is undefined. Nothing is done if SET and WAS_SET have the same value. */ static void s390_def_or_undef_macro (cpp_reader *pfile, unsigned int mask, const struct cl_target_option *old_opts, const struct cl_target_option *new_opts, const char *macro_def, const char *macro_undef) { bool was_set; bool set; was_set = (!old_opts) ? false : old_opts->x_target_flags & mask; set = new_opts->x_target_flags & mask; if (was_set == set) return; if (set) cpp_define (pfile, macro_def); else cpp_undef (pfile, macro_undef); }
/* Adjust the optimization macros when a #pragma GCC optimization is done to reflect the current level. */ void c_cpp_builtins_optimize_pragma (cpp_reader *pfile, tree prev_tree, tree cur_tree) { struct cl_optimization *prev = TREE_OPTIMIZATION (prev_tree); struct cl_optimization *cur = TREE_OPTIMIZATION (cur_tree); bool prev_fast_math; bool cur_fast_math; /* -undef turns off target-specific built-ins. */ if (flag_undef) return; /* Other target-independent built-ins determined by command-line options. */ if (!prev->x_optimize_size && cur->x_optimize_size) cpp_define (pfile, "__OPTIMIZE_SIZE__"); else if (prev->x_optimize_size && !cur->x_optimize_size) cpp_undef (pfile, "__OPTIMIZE_SIZE__"); if (!prev->x_optimize && cur->x_optimize) cpp_define (pfile, "__OPTIMIZE__"); else if (prev->x_optimize && !cur->x_optimize) cpp_undef (pfile, "__OPTIMIZE__"); prev_fast_math = fast_math_flags_struct_set_p (prev); cur_fast_math = fast_math_flags_struct_set_p (cur); if (!prev_fast_math && cur_fast_math) cpp_define (pfile, "__FAST_MATH__"); else if (prev_fast_math && !cur_fast_math) cpp_undef (pfile, "__FAST_MATH__"); if (!prev->x_flag_signaling_nans && cur->x_flag_signaling_nans) cpp_define (pfile, "__SUPPORT_SNAN__"); else if (prev->x_flag_signaling_nans && !cur->x_flag_signaling_nans) cpp_undef (pfile, "__SUPPORT_SNAN__"); if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only) { cpp_undef (pfile, "__FINITE_MATH_ONLY__"); cpp_define (pfile, "__FINITE_MATH_ONLY__=1"); } else if (prev->x_flag_finite_math_only && !cur->x_flag_finite_math_only) { cpp_undef (pfile, "__FINITE_MATH_ONLY__"); cpp_define (pfile, "__FINITE_MATH_ONLY__=0"); } }
/* Define MACRO as a <stdint.h> constant-suffix macro for TYPE. */ static void builtin_define_constants (const char *macro, tree type) { const char *suffix; char *buf; suffix = type_suffix (type); if (suffix[0] == 0) { buf = (char *) alloca (strlen (macro) + 6); sprintf (buf, "%s(c)=c", macro); } else { buf = (char *) alloca (strlen (macro) + 9 + strlen (suffix) + 1); sprintf (buf, "%s(c)=c ## %s", macro, suffix); } cpp_define (parse_in, buf); }
/* 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 (flag_sanitize & SANITIZE_ADDRESS) cpp_define (pfile, "__SANITIZE_ADDRESS__"); if (optimize_size) cpp_define (pfile, "__OPTIMIZE_SIZE__"); if (optimize) cpp_define (pfile, "__OPTIMIZE__"); if (fast_math_flags_set_p (&global_options)) cpp_define (pfile, "__FAST_MATH__"); if (flag_signaling_nans) cpp_define (pfile, "__SUPPORT_SNAN__"); if (!flag_errno_math) cpp_define (pfile, "__NO_MATH_ERRNO__"); cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d", flag_finite_math_only); if (flag_cilkplus) cpp_define (pfile, "__cilk=200"); if (flag_check_pointer_bounds) cpp_define (pfile, "__CHKP__"); }
void spu_cpu_cpp_builtins (struct cpp_reader *pfile) { cpp_define (pfile, "__SPU__"); cpp_assert (pfile, "cpu=spu"); cpp_assert (pfile, "machine=spu"); if (spu_arch == PROCESSOR_CELLEDP) cpp_define (pfile, "__SPU_EDP__"); if (cpp_get_options (pfile)->lang != CLK_ASM) cpp_define (pfile, "__vector=__attribute__((__spu_vector__))"); switch (spu_ea_model) { case 32: cpp_define (pfile, "__EA32__"); break; case 64: cpp_define (pfile, "__EA64__"); break; default: gcc_unreachable (); } if (!flag_iso && cpp_get_options (pfile)->lang != CLK_ASM) { /* Define this when supporting context-sensitive keywords. */ cpp_define (pfile, "__VECTOR_KEYWORD_SUPPORTED__"); cpp_define (pfile, "vector=vector"); /* Initialize vector keywords. */ __vector_keyword = get_identifier ("__vector"); C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL; vector_keyword = get_identifier ("vector"); C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL; /* Enable context-sensitive macros. */ cpp_get_callbacks (pfile)->macro_to_expand = spu_macro_to_expand; } }
/* Hook that registers front end and target-specific built-ins. */ void c_cpp_builtins (cpp_reader *pfile) { /* -undef turns off target-specific built-ins. */ if (flag_undef) return; 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 (); /* Set include test macros for all C/C++ (not for just C++11 etc.) the builtins __has_include__ and __has_include_next__ are defined in libcpp. */ cpp_define (pfile, "__has_include(STR)=__has_include__(STR)"); cpp_define (pfile, "__has_include_next(STR)=__has_include_next__(STR)"); if (c_dialect_cxx ()) { if (flag_weak && SUPPORTS_ONE_ONLY) cpp_define (pfile, "__GXX_WEAK__=1"); else cpp_define (pfile, "__GXX_WEAK__=0"); if (warn_deprecated) cpp_define (pfile, "__DEPRECATED"); if (flag_rtti) cpp_define (pfile, "__GXX_RTTI"); if (cxx_dialect >= cxx11) cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__"); /* Binary literals have been allowed in g++ before C++11 and were standardized for C++14. */ if (!pedantic || cxx_dialect > cxx11) cpp_define (pfile, "__cpp_binary_literals=201304"); if (cxx_dialect >= cxx11) { /* Set feature test macros for C++11 */ cpp_define (pfile, "__cpp_unicode_characters=200704"); cpp_define (pfile, "__cpp_raw_strings=200710"); cpp_define (pfile, "__cpp_unicode_literals=200710"); cpp_define (pfile, "__cpp_user_defined_literals=200809"); cpp_define (pfile, "__cpp_lambdas=200907"); cpp_define (pfile, "__cpp_constexpr=200704"); cpp_define (pfile, "__cpp_static_assert=200410"); cpp_define (pfile, "__cpp_decltype=200707"); cpp_define (pfile, "__cpp_attributes=200809"); cpp_define (pfile, "__cpp_rvalue_reference=200610"); cpp_define (pfile, "__cpp_variadic_templates=200704"); cpp_define (pfile, "__cpp_alias_templates=200704"); } if (cxx_dialect > cxx11) { /* Set feature test macros for C++14 */ cpp_define (pfile, "__cpp_return_type_deduction=201304"); cpp_define (pfile, "__cpp_init_captures=201304"); cpp_define (pfile, "__cpp_generic_lambdas=201304"); //cpp_undef (pfile, "__cpp_constexpr"); //cpp_define (pfile, "__cpp_constexpr=201304"); cpp_define (pfile, "__cpp_decltype_auto=201304"); //cpp_define (pfile, "__cpp_aggregate_nsdmi=201304"); //cpp_define (pfile, "__cpp_variable_templates=201304"); cpp_define (pfile, "__cpp_digit_separators=201309"); cpp_define (pfile, "__cpp_attribute_deprecated=201309"); //cpp_define (pfile, "__cpp_sized_deallocation=201309"); /* We'll have to see where runtime arrays wind up. Let's put it in C++14 for now. */ cpp_define (pfile, "__cpp_runtime_arrays=201304"); } } /* Note that we define this for C as well, so that we know if __attribute__((cleanup)) will interface with EH. */ if (flag_exceptions) cpp_define (pfile, "__EXCEPTIONS"); /* Represents the C++ ABI version, always defined so it can be used while preprocessing C and assembler. */ if (flag_abi_version == 0) /* Use a very large value so that: #if __GXX_ABI_VERSION >= <value for version X> will work whether the user explicitly says "-fabi-version=x" or "-fabi-version=0". Do not use INT_MAX because that will be different from system to system. */ builtin_define_with_int_value ("__GXX_ABI_VERSION", 999999); else if (flag_abi_version == 1) /* Due to a historical accident, this version had the value "102". */ builtin_define_with_int_value ("__GXX_ABI_VERSION", 102); else /* Newer versions have values 1002, 1003, .... */ builtin_define_with_int_value ("__GXX_ABI_VERSION", 1000 + flag_abi_version); /* libgcc needs to know this. */ if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ) cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__"); /* limits.h and stdint.h need to know these. */ builtin_define_type_max ("__SCHAR_MAX__", signed_char_type_node); builtin_define_type_max ("__SHRT_MAX__", short_integer_type_node); builtin_define_type_max ("__INT_MAX__", integer_type_node); builtin_define_type_max ("__LONG_MAX__", long_integer_type_node); builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node); builtin_define_type_minmax ("__WCHAR_MIN__", "__WCHAR_MAX__", underlying_wchar_type_node); builtin_define_type_minmax ("__WINT_MIN__", "__WINT_MAX__", wint_type_node); builtin_define_type_max ("__PTRDIFF_MAX__", ptrdiff_type_node); builtin_define_type_max ("__SIZE_MAX__", size_type_node); /* stdint.h and the testsuite need to know these. */ builtin_define_stdint_macros (); /* Provide information for library headers to determine whether to define macros such as __STDC_IEC_559__ and __STDC_IEC_559_COMPLEX__. */ builtin_define_with_int_value ("__GCC_IEC_559", cpp_iec_559_value ()); builtin_define_with_int_value ("__GCC_IEC_559_COMPLEX", cpp_iec_559_complex_value ()); /* float.h needs to know this. */ builtin_define_with_int_value ("__FLT_EVAL_METHOD__", TARGET_FLT_EVAL_METHOD); /* And decfloat.h needs this. */ builtin_define_with_int_value ("__DEC_EVAL_METHOD__", TARGET_DEC_EVAL_METHOD); builtin_define_float_constants ("FLT", "F", "%s", "F", float_type_node); /* Cast the double precision constants. This is needed when single precision constants are specified or when pragma FLOAT_CONST_DECIMAL64 is used. The correct result is computed by the compiler when using macros that include a cast. We use a different cast for C++ to avoid problems with -Wold-style-cast. */ builtin_define_float_constants ("DBL", "L", (c_dialect_cxx () ? "double(%s)" : "((double)%s)"), "", double_type_node); builtin_define_float_constants ("LDBL", "L", "%s", "L", long_double_type_node); /* For decfloat.h. */ builtin_define_decimal_float_constants ("DEC32", "DF", dfloat32_type_node); builtin_define_decimal_float_constants ("DEC64", "DD", dfloat64_type_node); builtin_define_decimal_float_constants ("DEC128", "DL", dfloat128_type_node); /* For fixed-point fibt, ibit, max, min, and epsilon. */ if (targetm.fixed_point_supported_p ()) { builtin_define_fixed_point_constants ("SFRACT", "HR", short_fract_type_node); builtin_define_fixed_point_constants ("USFRACT", "UHR", unsigned_short_fract_type_node); builtin_define_fixed_point_constants ("FRACT", "R", fract_type_node); builtin_define_fixed_point_constants ("UFRACT", "UR", unsigned_fract_type_node); builtin_define_fixed_point_constants ("LFRACT", "LR", long_fract_type_node); builtin_define_fixed_point_constants ("ULFRACT", "ULR", unsigned_long_fract_type_node); builtin_define_fixed_point_constants ("LLFRACT", "LLR", long_long_fract_type_node); builtin_define_fixed_point_constants ("ULLFRACT", "ULLR", unsigned_long_long_fract_type_node); builtin_define_fixed_point_constants ("SACCUM", "HK", short_accum_type_node); builtin_define_fixed_point_constants ("USACCUM", "UHK", unsigned_short_accum_type_node); builtin_define_fixed_point_constants ("ACCUM", "K", accum_type_node); builtin_define_fixed_point_constants ("UACCUM", "UK", unsigned_accum_type_node); builtin_define_fixed_point_constants ("LACCUM", "LK", long_accum_type_node); builtin_define_fixed_point_constants ("ULACCUM", "ULK", unsigned_long_accum_type_node); builtin_define_fixed_point_constants ("LLACCUM", "LLK", long_long_accum_type_node); builtin_define_fixed_point_constants ("ULLACCUM", "ULLK", unsigned_long_long_accum_type_node); builtin_define_fixed_point_constants ("QQ", "", qq_type_node); builtin_define_fixed_point_constants ("HQ", "", hq_type_node); builtin_define_fixed_point_constants ("SQ", "", sq_type_node); builtin_define_fixed_point_constants ("DQ", "", dq_type_node); builtin_define_fixed_point_constants ("TQ", "", tq_type_node); builtin_define_fixed_point_constants ("UQQ", "", uqq_type_node); builtin_define_fixed_point_constants ("UHQ", "", uhq_type_node); builtin_define_fixed_point_constants ("USQ", "", usq_type_node); builtin_define_fixed_point_constants ("UDQ", "", udq_type_node); builtin_define_fixed_point_constants ("UTQ", "", utq_type_node); builtin_define_fixed_point_constants ("HA", "", ha_type_node); builtin_define_fixed_point_constants ("SA", "", sa_type_node); builtin_define_fixed_point_constants ("DA", "", da_type_node); builtin_define_fixed_point_constants ("TA", "", ta_type_node); builtin_define_fixed_point_constants ("UHA", "", uha_type_node); builtin_define_fixed_point_constants ("USA", "", usa_type_node); builtin_define_fixed_point_constants ("UDA", "", uda_type_node); builtin_define_fixed_point_constants ("UTA", "", uta_type_node); } /* For libgcc-internal use only. */ if (flag_building_libgcc) /* For libgcc enable-execute-stack.c. */ builtin_define_with_int_value ("__LIBGCC_TRAMPOLINE_SIZE__", TRAMPOLINE_SIZE); /* For use in assembly language. */ builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); /* Misc. */ if (flag_gnu89_inline) cpp_define (pfile, "__GNUC_GNU_INLINE__"); else cpp_define (pfile, "__GNUC_STDC_INLINE__"); if (flag_no_inline) cpp_define (pfile, "__NO_INLINE__"); if (flag_iso) cpp_define (pfile, "__STRICT_ANSI__"); if (!flag_signed_char) cpp_define (pfile, "__CHAR_UNSIGNED__"); if (c_dialect_cxx () && TYPE_UNSIGNED (wchar_type_node)) cpp_define (pfile, "__WCHAR_UNSIGNED__"); /* Tell source code if the compiler makes sync_compare_and_swap builtins available. */ #ifdef HAVE_sync_compare_and_swapqi if (HAVE_sync_compare_and_swapqi) cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); #endif #ifdef HAVE_sync_compare_and_swaphi if (HAVE_sync_compare_and_swaphi) cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); #endif #ifdef HAVE_sync_compare_and_swapsi if (HAVE_sync_compare_and_swapsi) cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"); #endif #ifdef HAVE_sync_compare_and_swapdi if (HAVE_sync_compare_and_swapdi) cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); #endif #ifdef HAVE_sync_compare_and_swapti if (HAVE_sync_compare_and_swapti) cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16"); #endif cpp_atomic_builtins (pfile); #ifdef DWARF2_UNWIND_INFO if (dwarf2out_do_cfi_asm ()) cpp_define (pfile, "__GCC_HAVE_DWARF2_CFI_ASM"); #endif /* Make the choice of ObjC runtime visible to source code. */ if (c_dialect_objc () && flag_next_runtime) cpp_define (pfile, "__NEXT_RUNTIME__"); /* Show the availability of some target pragmas. */ cpp_define (pfile, "__PRAGMA_REDEFINE_EXTNAME"); /* Make the choice of the stack protector runtime visible to source code. The macro names and values here were chosen for compatibility with an earlier implementation, i.e. ProPolice. */ if (flag_stack_protect == 3) cpp_define (pfile, "__SSP_STRONG__=3"); if (flag_stack_protect == 2) cpp_define (pfile, "__SSP_ALL__=2"); else if (flag_stack_protect == 1) cpp_define (pfile, "__SSP__=1"); if (flag_openmp) cpp_define (pfile, "_OPENMP=201307"); if (int128_integer_type_node != NULL_TREE) builtin_define_type_sizeof ("__SIZEOF_INT128__", int128_integer_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); /* A straightforward target hook doesn't work, because of problems linking that hook's body when part of non-C front ends. */ # define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM) # define preprocessing_trad_p() (cpp_get_options (pfile)->traditional) # define builtin_define(TXT) cpp_define (pfile, TXT) # define builtin_assert(TXT) cpp_assert (pfile, TXT) TARGET_CPU_CPP_BUILTINS (); TARGET_OS_CPP_BUILTINS (); TARGET_OBJFMT_CPP_BUILTINS (); /* Support the __declspec keyword by turning them into attributes. Note that the current way we do this may result in a collision with predefined attributes later on. This can be solved by using one attribute, say __declspec__, and passing args to it. The problem with that approach is that args are not accumulated: each new appearance would clobber any existing args. */ if (TARGET_DECLSPEC) builtin_define ("__declspec(x)=__attribute__((x))"); /* If decimal floating point is supported, tell the user if the alternate format (BID) is used instead of the standard (DPD) format. */ if (ENABLE_DECIMAL_FLOAT && ENABLE_DECIMAL_BID_FORMAT) cpp_define (pfile, "__DECIMAL_BID_FORMAT__"); if (c_dialect_cxx () && flag_sized_delete) cpp_define (pfile, "__GXX_DELETE_WITH_SIZE__"); }
void avr_cpu_cpp_builtins (struct cpp_reader *pfile) { int i; builtin_define_std ("AVR"); if (avr_current_arch->macro) cpp_define_formatted (pfile, "__AVR_ARCH__=%s", avr_current_arch->macro); if (avr_current_device->macro) { cpp_define (pfile, avr_current_device->macro); cpp_define_formatted (pfile, "__AVR_DEVICE_NAME__=%s", avr_current_device->name); } if (AVR_HAVE_RAMPD) cpp_define (pfile, "__AVR_HAVE_RAMPD__"); if (AVR_HAVE_RAMPX) cpp_define (pfile, "__AVR_HAVE_RAMPX__"); if (AVR_HAVE_RAMPY) cpp_define (pfile, "__AVR_HAVE_RAMPY__"); if (AVR_HAVE_RAMPZ) cpp_define (pfile, "__AVR_HAVE_RAMPZ__"); if (AVR_HAVE_ELPM) cpp_define (pfile, "__AVR_HAVE_ELPM__"); if (AVR_HAVE_ELPMX) cpp_define (pfile, "__AVR_HAVE_ELPMX__"); if (AVR_HAVE_MOVW) cpp_define (pfile, "__AVR_HAVE_MOVW__"); if (AVR_HAVE_LPMX) cpp_define (pfile, "__AVR_HAVE_LPMX__"); if (avr_current_arch->asm_only) cpp_define (pfile, "__AVR_ASM_ONLY__"); if (AVR_HAVE_MUL) { cpp_define (pfile, "__AVR_ENHANCED__"); cpp_define (pfile, "__AVR_HAVE_MUL__"); } if (avr_current_arch->have_jmp_call) { cpp_define (pfile, "__AVR_MEGA__"); cpp_define (pfile, "__AVR_HAVE_JMP_CALL__"); } if (AVR_XMEGA) cpp_define (pfile, "__AVR_XMEGA__"); if (avr_current_arch->have_eijmp_eicall) { cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__"); cpp_define (pfile, "__AVR_3_BYTE_PC__"); } else { cpp_define (pfile, "__AVR_2_BYTE_PC__"); } if (AVR_HAVE_8BIT_SP) cpp_define (pfile, "__AVR_HAVE_8BIT_SP__"); else cpp_define (pfile, "__AVR_HAVE_16BIT_SP__"); if (avr_sp8) cpp_define (pfile, "__AVR_SP8__"); if (AVR_HAVE_SPH) cpp_define (pfile, "__AVR_HAVE_SPH__"); if (TARGET_NO_INTERRUPTS) cpp_define (pfile, "__NO_INTERRUPTS__"); if (avr_current_device->dev_attribute & AVR_ERRATA_SKIP) { cpp_define (pfile, "__AVR_ERRATA_SKIP__"); if (avr_current_arch->have_jmp_call) cpp_define (pfile, "__AVR_ERRATA_SKIP_JMP_CALL__"); } if (avr_current_device->dev_attribute & AVR_ISA_RMW) cpp_define (pfile, "__AVR_ISA_RMW__"); cpp_define_formatted (pfile, "__AVR_SFR_OFFSET__=0x%x", avr_current_arch->sfr_offset); #ifdef WITH_AVRLIBC cpp_define (pfile, "__WITH_AVRLIBC__"); #endif /* WITH_AVRLIBC */ /* Define builtin macros so that the user can easily query whether non-generic address spaces (and which) are supported or not. This is only supported for C. For C++, a language extension is needed (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not implemented in GCC up to now. */ if (!strcmp (lang_hooks.name, "GNU C")) { for (i = 0; i < ADDR_SPACE_COUNT; i++) if (!ADDR_SPACE_GENERIC_P (i) /* Only supply __FLASH<n> macro if the address space is reasonable for this target. The address space qualifier itself is still supported, but using it will throw an error. */ && avr_addrspace[i].segment < avr_current_device->n_flash) { const char *name = avr_addrspace[i].name; char *Name = (char*) alloca (1 + strlen (name)); cpp_define (pfile, avr_toupper (Name, name)); } } /* Define builtin macros so that the user can easily query whether or not a specific builtin is available. */ #define DEF_BUILTIN(NAME, N_ARGS, TYPE, CODE, LIBNAME) \ cpp_define (pfile, "__BUILTIN_AVR_" #NAME); #include "builtins.def" #undef DEF_BUILTIN /* Builtin macros for the __int24 and __uint24 type. */ cpp_define_formatted (pfile, "__INT24_MAX__=8388607%s", INT_TYPE_SIZE == 8 ? "LL" : "L"); cpp_define (pfile, "__INT24_MIN__=(-__INT24_MAX__-1)"); cpp_define_formatted (pfile, "__UINT24_MAX__=16777215%s", INT_TYPE_SIZE == 8 ? "ULL" : "UL"); }
void avr_cpu_cpp_builtins (struct cpp_reader *pfile) { builtin_define_std ("AVR"); if (avr_current_arch->macro) cpp_define (pfile, avr_current_arch->macro); if (avr_extra_arch_macro) cpp_define (pfile, avr_extra_arch_macro); if (avr_current_arch->have_elpm) cpp_define (pfile, "__AVR_HAVE_RAMPZ__"); if (avr_current_arch->have_elpm) cpp_define (pfile, "__AVR_HAVE_ELPM__"); if (avr_current_arch->have_elpmx) cpp_define (pfile, "__AVR_HAVE_ELPMX__"); if (avr_current_arch->have_movw_lpmx) { cpp_define (pfile, "__AVR_HAVE_MOVW__"); cpp_define (pfile, "__AVR_HAVE_LPMX__"); } if (avr_current_arch->asm_only) cpp_define (pfile, "__AVR_ASM_ONLY__"); if (avr_current_arch->have_mul) { cpp_define (pfile, "__AVR_ENHANCED__"); cpp_define (pfile, "__AVR_HAVE_MUL__"); } if (avr_current_arch->have_jmp_call) { cpp_define (pfile, "__AVR_MEGA__"); cpp_define (pfile, "__AVR_HAVE_JMP_CALL__"); } if (avr_current_arch->have_eijmp_eicall) { cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__"); cpp_define (pfile, "__AVR_3_BYTE_PC__"); } else { cpp_define (pfile, "__AVR_2_BYTE_PC__"); } if (avr_current_device->short_sp) cpp_define (pfile, "__AVR_HAVE_8BIT_SP__"); else cpp_define (pfile, "__AVR_HAVE_16BIT_SP__"); if (TARGET_NO_INTERRUPTS) cpp_define (pfile, "__NO_INTERRUPTS__"); }
/* Hook that registers front end and target-specific built-ins. */ void c_cpp_builtins (cpp_reader *pfile) { /* -undef turns off target-specific built-ins. */ if (flag_undef) return; define__GNUC__ (); /* For stddef.h. They require macros defined in c-common.c. */ c_stddef_cpp_builtins (); if (c_dialect_cxx ()) { if (flag_weak && SUPPORTS_ONE_ONLY) cpp_define (pfile, "__GXX_WEAK__=1"); else cpp_define (pfile, "__GXX_WEAK__=0"); if (warn_deprecated) cpp_define (pfile, "__DEPRECATED"); } /* Note that we define this for C as well, so that we know if __attribute__((cleanup)) will interface with EH. */ if (flag_exceptions) cpp_define (pfile, "__EXCEPTIONS"); /* Represents the C++ ABI version, always defined so it can be used while preprocessing C and assembler. */ if (flag_abi_version == 0) /* Use a very large value so that: #if __GXX_ABI_VERSION >= <value for version X> will work whether the user explicitly says "-fabi-version=x" or "-fabi-version=0". Do not use INT_MAX because that will be different from system to system. */ builtin_define_with_int_value ("__GXX_ABI_VERSION", 999999); else if (flag_abi_version == 1) /* Due to a historical accident, this version had the value "102". */ builtin_define_with_int_value ("__GXX_ABI_VERSION", 102); else /* Newer versions have values 1002, 1003, .... */ builtin_define_with_int_value ("__GXX_ABI_VERSION", 1000 + flag_abi_version); /* libgcc needs to know this. */ if (USING_SJLJ_EXCEPTIONS) cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__"); /* limits.h needs to know these. */ builtin_define_type_max ("__SCHAR_MAX__", signed_char_type_node, 0); builtin_define_type_max ("__SHRT_MAX__", short_integer_type_node, 0); builtin_define_type_max ("__INT_MAX__", integer_type_node, 0); builtin_define_type_max ("__LONG_MAX__", long_integer_type_node, 1); builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node, 2); builtin_define_type_max ("__WCHAR_MAX__", wchar_type_node, 0); builtin_define_type_precision ("__CHAR_BIT__", char_type_node); /* stdint.h (eventually) and the testsuite need to know these. */ builtin_define_stdint_macros (); /* float.h needs to know these. */ builtin_define_with_int_value ("__FLT_EVAL_METHOD__", TARGET_FLT_EVAL_METHOD); /* And decfloat.h needs this. */ builtin_define_with_int_value ("__DEC_EVAL_METHOD__", TARGET_DEC_EVAL_METHOD); builtin_define_float_constants ("FLT", "F", "%s", float_type_node); /* Cast the double precision constants when single precision constants are specified. The correct result is computed by the compiler when using macros that include a cast. This has the side-effect of making the value unusable in const expressions. */ if (flag_single_precision_constant) builtin_define_float_constants ("DBL", "L", "((double)%s)", double_type_node); else builtin_define_float_constants ("DBL", "", "%s", double_type_node); builtin_define_float_constants ("LDBL", "L", "%s", long_double_type_node); /* For decfloat.h. */ builtin_define_decimal_float_constants ("DEC32", "DF", dfloat32_type_node); builtin_define_decimal_float_constants ("DEC64", "DD", dfloat64_type_node); builtin_define_decimal_float_constants ("DEC128", "DL", dfloat128_type_node); /* For use in assembly language. */ builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); /* Misc. */ builtin_define_with_value ("__VERSION__", version_string, 1); cpp_define (pfile, "__GNUC_GNU_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_really_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_iso) cpp_define (pfile, "__STRICT_ANSI__"); if (!flag_signed_char) cpp_define (pfile, "__CHAR_UNSIGNED__"); if (c_dialect_cxx () && TYPE_UNSIGNED (wchar_type_node)) cpp_define (pfile, "__WCHAR_UNSIGNED__"); /* Make the choice of ObjC runtime visible to source code. */ if (c_dialect_objc () && flag_next_runtime) cpp_define (pfile, "__NEXT_RUNTIME__"); /* Show the availability of some target pragmas. */ if (flag_mudflap || targetm.handle_pragma_redefine_extname) cpp_define (pfile, "__PRAGMA_REDEFINE_EXTNAME"); if (targetm.handle_pragma_extern_prefix) cpp_define (pfile, "__PRAGMA_EXTERN_PREFIX"); /* Make the choice of the stack protector runtime visible to source code. The macro names and values here were chosen for compatibility with an earlier implementation, i.e. ProPolice. */ if (flag_stack_protect == 2) cpp_define (pfile, "__SSP_ALL__=2"); else if (flag_stack_protect == 1) cpp_define (pfile, "__SSP__=1"); if (flag_openmp) cpp_define (pfile, "_OPENMP=200505"); /* A straightforward target hook doesn't work, because of problems linking that hook's body when part of non-C front ends. */ # define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM) # define preprocessing_trad_p() (cpp_get_options (pfile)->traditional) # define builtin_define(TXT) cpp_define (pfile, TXT) # define builtin_assert(TXT) cpp_assert (pfile, TXT) TARGET_CPU_CPP_BUILTINS (); TARGET_OS_CPP_BUILTINS (); TARGET_OBJFMT_CPP_BUILTINS (); /* Support the __declspec keyword by turning them into attributes. Note that the current way we do this may result in a collision with predefined attributes later on. This can be solved by using one attribute, say __declspec__, and passing args to it. The problem with that approach is that args are not accumulated: each new appearance would clobber any existing args. */ if (TARGET_DECLSPEC) builtin_define ("__declspec(x)=__attribute__((x))"); }