aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Bothner <bothner@gcc.gnu.org>1993-08-11 19:43:49 -0700
committerPer Bothner <bothner@gcc.gnu.org>1993-08-11 19:43:49 -0700
commitbb28827839783bec6c40cbded51a65c0faa1eee3 (patch)
treea6d1a4cf78fbdbf29f58250d0201a856924c5868
parenta2f541382982d674825d853512b77ecfbe329c28 (diff)
downloadgcc-bb28827839783bec6c40cbded51a65c0faa1eee3.zip
gcc-bb28827839783bec6c40cbded51a65c0faa1eee3.tar.gz
gcc-bb28827839783bec6c40cbded51a65c0faa1eee3.tar.bz2
(get_file_function_name): New function.
From-SVN: r5136
-rw-r--r--gcc/tree.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 84198bd..317e8ad 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3352,3 +3352,68 @@ dump_tree_statistics ()
#endif
print_lang_statistics ();
}
+
+#define FILE_FUNCTION_PREFIX_LEN 9
+
+#ifndef NO_DOLLAR_IN_LABEL
+#define FILE_FUNCTION_FORMAT "_GLOBAL_$D$%s"
+#else /* NO_DOLLAR_IN_LABEL */
+#ifndef NO_DOT_IN_LABEL
+#define FILE_FUNCTION_FORMAT "_GLOBAL_.D.%s"
+#else /* NO_DOT_IN_LABEL */
+#define FILE_FUNCTION_FORMAT "__GLOBAL_D_%s"
+#endif /* NO_DOT_IN_LABEL */
+#endif /* NO_DOLLAR_IN_LABEL */
+
+extern char * first_global_object_name;
+
+/* If KIND=='I', return a suitable global initializer (constructor) name.
+ If KIND=='D', return a suitable global clean-up (destructor) name. */
+
+tree
+get_file_function_name (kind)
+ int kind;
+{
+ char *buf;
+ register char *p;
+
+ if (first_global_object_name)
+ p = first_global_object_name;
+ else if (main_input_filename)
+ p = main_input_filename;
+ else
+ p = input_filename;
+
+ buf = (char *) alloca (sizeof (FILE_FUNCTION_FORMAT) + strlen (p));
+
+ /* Set up the name of the file-level functions we may need. */
+ /* Use a global object (which is already required to be unique over
+ the program) rather than the file name (which imposes extra
+ constraints). -- Raeburn@MIT.EDU, 10 Jan 1990. */
+ sprintf (buf, FILE_FUNCTION_FORMAT, p);
+
+ /* Don't need to pull wierd characters out of global names. */
+ if (p != first_global_object_name)
+ {
+ for (p = buf+11; *p; p++)
+ if (! ((*p >= '0' && *p <= '9')
+#if 0 /* we always want labels, which are valid C++ identifiers (+ `$') */
+#ifndef ASM_IDENTIFY_GCC /* this is required if `.' is invalid -- k. raeburn */
+ || *p == '.'
+#endif
+#endif
+#ifndef NO_DOLLAR_IN_LABEL /* this for `$'; unlikely, but... -- kr */
+ || *p == '$'
+#endif
+#ifndef NO_DOT_IN_LABEL /* this for `.'; unlikely, but... */
+ || *p == '.'
+#endif
+ || (*p >= 'A' && *p <= 'Z')
+ || (*p >= 'a' && *p <= 'z')))
+ *p = '_';
+ }
+
+ buf[FILE_FUNCTION_PREFIX_LEN] = kind;
+
+ return get_identifier (buf);
+}