aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-07-06 14:40:49 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2003-07-06 14:40:49 +0000
commit2aab7ceb8b58b89e48e99c3e5af119cc2f50b81c (patch)
tree10b98969d0af1c81058c7434f9916ecc1e7ae73d /gcc
parent46c5ad278b15d1db509093032ea1eed00459b3a0 (diff)
downloadgcc-2aab7ceb8b58b89e48e99c3e5af119cc2f50b81c.zip
gcc-2aab7ceb8b58b89e48e99c3e5af119cc2f50b81c.tar.gz
gcc-2aab7ceb8b58b89e48e99c3e5af119cc2f50b81c.tar.bz2
tree.h (crc32_string): Declare.
* tree.h (crc32_string): Declare. * tree.c (append_random_chars): Remove. (crc32_string): New. (get_file_function_name_long): Use crc32_string here. From-SVN: r69004
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree.c73
-rw-r--r--gcc/tree.h1
3 files changed, 36 insertions, 45 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0247345..54bc84f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2003-07-06 Nathan Sidwell <nathan@codesourcery.com>
+
+ * tree.h (crc32_string): Declare.
+ * tree.c (append_random_chars): Remove.
+ (crc32_string): New.
+ (get_file_function_name_long): Use crc32_string here.
+
2003-07-06 Andreas Jaeger <aj@suse.de>
* gcc.c: Convert prototypes to ISO C90.
diff --git a/gcc/tree.c b/gcc/tree.c
index 9298247..a0f5414 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -119,7 +119,6 @@ static GTY ((if_marked ("type_hash_marked_p"), param_is (struct type_hash)))
htab_t type_hash_table;
static void set_type_quals (tree, int);
-static void append_random_chars (char *);
static int type_hash_eq (const void *, const void *);
static hashval_t type_hash_hash (const void *);
static void print_type_hash_statistics (void);
@@ -4497,44 +4496,27 @@ default_flag_random_seed (void)
flag_random_seed = new_random_seed;
}
-/* Appends 6 random characters to TEMPLATE to (hopefully) avoid name
- clashes in cases where we can't reliably choose a unique name.
+/* Generate a crc32 of a string. */
- Derived from mkstemp.c in libiberty. */
-
-static void
-append_random_chars (char *template)
+unsigned
+crc32_string (unsigned chksum, const char *string)
{
- static const char letters[]
- = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- unsigned HOST_WIDE_INT v;
- size_t i;
-
- default_flag_random_seed ();
-
- /* This isn't a very good hash, but it does guarantee no collisions
- when the random string is generated by the code above and the time
- delta is small. */
- v = 0;
- for (i = 0; i < strlen (flag_random_seed); i++)
- v = (v << 4) ^ (v >> (HOST_BITS_PER_WIDE_INT - 4)) ^ flag_random_seed[i];
-
- template += strlen (template);
-
- /* Fill in the random bits. */
- template[0] = letters[v % 62];
- v /= 62;
- template[1] = letters[v % 62];
- v /= 62;
- template[2] = letters[v % 62];
- v /= 62;
- template[3] = letters[v % 62];
- v /= 62;
- template[4] = letters[v % 62];
- v /= 62;
- template[5] = letters[v % 62];
-
- template[6] = '\0';
+ do
+ {
+ unsigned value = *string << 24;
+ unsigned ix;
+
+ for (ix = 8; ix--; value <<= 1)
+ {
+ unsigned feedback;
+
+ feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0;
+ chksum <<= 1;
+ chksum ^= feedback;
+ }
+ }
+ while (*string++);
+ return chksum;
}
/* P is a string that will be used in a symbol. Mask out any characters
@@ -4572,7 +4554,7 @@ get_file_function_name_long (const char *type)
{
/* We don't have anything that we know to be unique to this translation
unit, so use what we do have and throw in some randomness. */
-
+ unsigned len;
const char *name = weak_global_object_name;
const char *file = main_input_filename;
@@ -4581,10 +4563,15 @@ get_file_function_name_long (const char *type)
if (! file)
file = input_filename;
- q = (char *) alloca (7 + strlen (name) + strlen (file));
+ len = strlen (file);
+ q = (char *) alloca (9 * 2 + len);
+ memcpy (q, file, len + 1);
+ clean_symbol_name (q);
+
+ default_flag_random_seed ();
+ sprintf (q + len, "_%08X_%08X", crc32_string (0, name),
+ crc32_string (0, flag_random_seed));
- sprintf (q, "%s%s", name, file);
- append_random_chars (q);
p = q;
}
@@ -4597,10 +4584,6 @@ get_file_function_name_long (const char *type)
constraints). */
sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
- /* Don't need to pull weird characters out of global names. */
- if (p != first_global_object_name)
- clean_symbol_name (buf + 11);
-
return get_identifier (buf);
}
diff --git a/gcc/tree.h b/gcc/tree.h
index 2ca31dd..9be6532 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2640,6 +2640,7 @@ extern tree builtin_function (const char *, tree, int, enum built_in_class,
const char *, tree);
/* In tree.c */
+extern unsigned crc32_string (unsigned, const char *);
extern void clean_symbol_name (char *);
extern tree get_file_function_name_long (const char *);
extern tree get_set_constructor_bits (tree, char *, int);