Commit b80f1d67 authored by nathan's avatar nathan
Browse files

* 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.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69005 138bc75d-0d04-0410-961f-82ee72b054a4
parent eac18265
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.
......
......@@ -463,6 +463,14 @@ int mem_report = 0;
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. */
......@@ -1560,6 +1568,43 @@ FILE *asm_out_file;
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.
......@@ -4394,13 +4439,10 @@ print_switch_values (FILE *file, int pos, int max,
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: "), "");
......@@ -4969,6 +5011,8 @@ toplev_main (unsigned int argc, const char **argv)
enough to default flags appropriately. */
decode_options (argc, argv);
randomize ();
/* Exit early if we can (e.g. -help). */
if (!exit_after_options)
do_compile ();
......
......@@ -104,6 +104,9 @@ extern void fnotice (FILE *, const char *, ...)
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;
......
......@@ -4464,38 +4464,6 @@ dump_tree_statistics (void)
#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
......@@ -4568,7 +4536,6 @@ get_file_function_name_long (const char *type)
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));
......
......@@ -2931,7 +2931,6 @@ extern void expand_start_case_dummy (void);
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. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment