* tree.h (default_flag_random_seed): Remove.
* toplev.h (local_tick): Declare.
* tree.c (flag_random_seed, default_flag_random_seed): Move to
toplev.c.
(append_random_chars): Don't call default_flag_random_seed.
* toplev.c (flag_random_seed): Define here. Set local_tick.
(local_tick): Define.
(randomize): New, moved from tree.c.
(print_switch_values): Adjust.
(toplev_main): Call randomize.
From-SVN: r69005
+2003-07-06 Nathan Sidwell <nathan@codesourcery.com>
+
+ * tree.h (default_flag_random_seed): Remove.
+ * toplev.h (local_tick): Declare.
+ * tree.c (flag_random_seed, default_flag_random_seed): Move to
+ toplev.c.
+ (append_random_chars): Don't call default_flag_random_seed.
+ * toplev.c (flag_random_seed): Define here. Set local_tick.
+ (local_tick): Define.
+ (randomize): New, moved from tree.c.
+ (print_switch_values): Adjust.
+ (toplev_main): Call randomize.
+
2003-07-06 Nathan Sidwell <nathan@codesourcery.com>
* tree.h (crc32_string): Declare.
and to print them when we are done. */
int flag_detailed_statistics = 0;
+/* A random sequence of characters, unless overridden by user. */
+const char *flag_random_seed;
+
+/* A local time stamp derived from the time of compilation. It will be
+ zero if the system cannot provide a time. It will be -1u, if the
+ user has specified a particular random seed. */
+unsigned local_tick;
+
/* -f flags. */
/* Nonzero means `char' should be signed. */
FILE *aux_info_file;
FILE *rtl_dump_file = NULL;
+/* Set up a default flag_random_seed and local_tick, unless the user
+ already specified one. */
+
+static void
+randomize (void)
+{
+ if (!flag_random_seed)
+ {
+ unsigned HOST_WIDE_INT value;
+ static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
+
+ /* Get some more or less random data. */
+#ifdef HAVE_GETTIMEOFDAY
+ {
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ }
+#else
+ {
+ time_t now = time ();
+
+ if (now != (time_t)-1)
+ local_tick = (unsigned) now;
+ }
+#endif
+ value = local_tick ^ getpid ();
+
+ sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
+ flag_random_seed = random_seed;
+ }
+ else
+ local_tick = -1;
+}
+
+
/* Decode the string P as an integral parameter.
If the string is indeed an integer return its numeric value else
issue an Invalid Option error for the option PNAME and return DEFVAL.
const char **p;
/* Fill in the -frandom-seed option, if the user didn't pass it, so
- that it can be printed below. This helps reproducibility. Of
- course, the string may never be used, but we can't tell that at
- this point in the compile. */
- default_flag_random_seed ();
+ that it can be printed below. This helps reproducibility. */
+ randomize ();
/* Print the options as passed. */
-
pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
_("options passed: "), "");
enough to default flags appropriately. */
decode_options (argc, argv);
+ randomize ();
+
/* Exit early if we can (e.g. -help). */
if (!exit_after_options)
do_compile ();
extern int wrapup_global_declarations (union tree_node **, int);
extern void check_global_declarations (union tree_node **, int);
+/* A unique local time stamp, might be zero if none is available. */
+extern unsigned local_tick;
+
extern const char *progname;
extern const char *dump_base_name;
extern const char *aux_base_name;
\f
#define FILE_FUNCTION_FORMAT "_GLOBAL__%s_%s"
-const char *flag_random_seed;
-
-/* Set up a default flag_random_seed value, if there wasn't one already. */
-
-void
-default_flag_random_seed (void)
-{
- unsigned HOST_WIDE_INT value;
- char *new_random_seed;
-
- if (flag_random_seed != NULL)
- return;
-
- /* Get some more or less random data. */
-#ifdef HAVE_GETTIMEOFDAY
- {
- struct timeval tv;
-
- gettimeofday (&tv, NULL);
- value = (((unsigned HOST_WIDE_INT) tv.tv_usec << 16)
- ^ tv.tv_sec ^ getpid ());
- }
-#else
- value = getpid ();
-#endif
-
- /* This slightly overestimates the space required. */
- new_random_seed = xmalloc (HOST_BITS_PER_WIDE_INT / 3 + 2);
- sprintf (new_random_seed, HOST_WIDE_INT_PRINT_UNSIGNED, value);
- flag_random_seed = new_random_seed;
-}
-
/* Generate a crc32 of a string. */
unsigned
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));
extern HOST_WIDE_INT all_cases_count (tree, int *);
extern void check_for_full_enumeration_handling (tree);
extern void declare_nonlocal_label (tree);
-extern void default_flag_random_seed (void);
/* If KIND=='I', return a suitable global initializer (constructor) name.
If KIND=='D', return a suitable global clean-up (destructor) name. */