aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@codesourcery.com>2002-05-16 19:03:02 +0000
committerZack Weinberg <zack@gcc.gnu.org>2002-05-16 19:03:02 +0000
commit5279d7394efe3e6d39e9c5f0bbb066e63f4cf398 (patch)
tree7ba2394a66b4c75f323247f002ba280c373fb85a /gcc/c-common.c
parent62e6ca55bd6a235d9feccd4ac48c2b89e0bc32e5 (diff)
downloadgcc-5279d7394efe3e6d39e9c5f0bbb066e63f4cf398.zip
gcc-5279d7394efe3e6d39e9c5f0bbb066e63f4cf398.tar.gz
gcc-5279d7394efe3e6d39e9c5f0bbb066e63f4cf398.tar.bz2
c-common.c (STDC_0_IN_SYSTEM_HEADERS, [...]): Default-define here.
* c-common.c (STDC_0_IN_SYSTEM_HEADERS, REGISTER_PREFIX): Default-define here. (builtin_define_with_value): Can now wrap the expansion in quotation marks if such is wanted. (cb_register_builtins): Update calls to builtin_define_with_value. Define __REGISTER_PREFIX__, __USER_LABEL_PREFIX__, and __VERSION__ here. (c_common_init): Set options->stdc_0_in_system_headers. * c-lex.h: Update prototype of builtin_define_with_value. * cppdefault.h: Remove default definitions of USER_LABEL_PREFIX and REGISTER_PREFIX. * cppinit.c (VERS, ULP, C, X): Kill. (builtin_array): Remove entries for __VERSION__, __USER_LABEL_PREFIX__, __REGISTER_PREFIX__, and __HAVE_BUILTIN_SETJMP__. Make __STDC__ always a builtin, not a constant. (init_builtins): Kill off a bunch of now-dead code. (COMMAND_LINE_OPTIONS): Remove -fleading-underscore and -fno-leading-underscore. (cpp_handle_option): Remove code to set user_label_prefix. (cpp_post_options): Likewise. * cpplib.h (struct cpp_options): Remove user_label_prefix. (stdc_0_in_system_headers): New. * cppmacro.c (builtin_macro): Check CPP_OPTION (pfile, stdc_0_in_system_headers) too to decide the value of __STDC__. * tradcpp.c (user_label_prefix): Kill. (main): Remove code handling -f(no-)leading-underscore. (initialize_builtins): Don't define __REGISTER_PREFIX__ or __USER_LABEL_PREFIX__. (install_value): Wrap compound statement in dummy loop so the macro works properly in an if statement. From-SVN: r53525
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index f60a27f..81810dd 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -83,6 +83,14 @@ cpp_reader *parse_in; /* Declared in c-lex.h. */
: "long long unsigned int"))
#endif
+#ifndef STDC_0_IN_SYSTEM_HEADERS
+#define STDC_0_IN_SYSTEM_HEADERS 0
+#endif
+
+#ifndef REGISTER_PREFIX
+#define REGISTER_PREFIX ""
+#endif
+
/* The variant of the C language being processed. */
enum c_language_kind c_language;
@@ -4331,10 +4339,17 @@ cb_register_builtins (pfile)
cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");
/* stddef.h needs to know these. */
- builtin_define_with_value ("__SIZE_TYPE__", SIZE_TYPE);
- builtin_define_with_value ("__PTRDIFF_TYPE__", PTRDIFF_TYPE);
- builtin_define_with_value ("__WCHAR_TYPE__", MODIFIED_WCHAR_TYPE);
- builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE);
+ builtin_define_with_value ("__SIZE_TYPE__", SIZE_TYPE, 0);
+ builtin_define_with_value ("__PTRDIFF_TYPE__", PTRDIFF_TYPE, 0);
+ builtin_define_with_value ("__WCHAR_TYPE__", MODIFIED_WCHAR_TYPE, 0);
+ builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE, 0);
+
+ /* 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);
/* A straightforward target hook doesn't work, because of problems
linking that hook's body when part of non-C front ends. */
@@ -4385,23 +4400,28 @@ builtin_define_std (macro)
}
}
-/* Pass an object-like macro and a value to define it to. */
+/* 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 (macro, expansion)
+builtin_define_with_value (macro, expansion, is_str)
const char *macro;
const char *expansion;
+ int is_str;
{
- char *buf, *q;
+ char *buf;
size_t mlen = strlen (macro);
size_t elen = strlen (expansion);
+ size_t extra = 2; /* space for an = and a NUL */
- q = buf = alloca (mlen + elen + 2);
- memcpy (q, macro, mlen);
- q += mlen;
- *q++ = '=';
- memcpy (q, expansion, elen);
- q += elen;
- *q = '\0';
+ if (is_str)
+ extra += 2; /* space for two quote marks */
+
+ buf = 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);
}
@@ -4429,6 +4449,7 @@ c_common_init (filename)
options->unsigned_char = !flag_signed_char; */
options->warn_multichar = warn_multichar;
+ options->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
/* Register preprocessor built-ins before calls to
cpp_main_file. */