Commit 403d4851 by Alexandre Oliva Committed by Alexandre Oliva

flags.h (flag_random_seed): Remove declaration, in favor of...

gcc/ChangeLog:
* flags.h (flag_random_seed): Remove declaration, in favor of...
* toplev.h (get_random_seed, set_random_seed): ... these.
* tree.c (get_file_function_name): Use the former.
* opts.c (common_handle_option): Use the latter.
* toplev.c
gcc/cp/ChangeLog:
* cp/repo.c (init_repo): Initialize random_seed saved options.
(finish_repo): Adjust.

From-SVN: r122901
parent 481e0a49
2007-03-13 Alexandre Oliva <aoliva@redhat.com>
* flags.h (flag_random_seed): Remove declaration, in favor of...
* toplev.h (get_random_seed, set_random_seed): ... these.
* tree.c (get_file_function_name): Use the former.
* opts.c (common_handle_option): Use the latter.
* toplev.c
2007-03-13 Steven Bosscher <steven@gcc.gnu.org> 2007-03-13 Steven Bosscher <steven@gcc.gnu.org>
PR middle-end/31127 PR middle-end/31127
......
2007-03-13 Alexandre Oliva <aoliva@redhat.com>
* cp/repo.c (init_repo): Initialize random_seed saved options.
(finish_repo): Adjust.
2007-03-13 Mark Mitchell <mark@codesourcery.com> 2007-03-13 Mark Mitchell <mark@codesourcery.com>
PR bootstrap/30899 PR bootstrap/30899
......
/* Code to maintain a C++ template repository. /* Code to maintain a C++ template repository.
Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
Free Software Foundation, Inc. 2006, 2007 Free Software Foundation, Inc.
Contributed by Jason Merrill (jason@cygnus.com) Contributed by Jason Merrill (jason@cygnus.com)
This file is part of GCC. This file is part of GCC.
...@@ -203,6 +203,10 @@ init_repo (void) ...@@ -203,6 +203,10 @@ init_repo (void)
obstack_free (&temporary_obstack, buf); obstack_free (&temporary_obstack, buf);
} }
fclose (repo_file); fclose (repo_file);
if (old_args && !get_random_seed (true)
&& (buf = strstr (old_args, "'-frandom-seed=")))
set_random_seed (extract_string (&buf) + strlen ("-frandom-seed="));
} }
static FILE * static FILE *
...@@ -250,7 +254,7 @@ finish_repo (void) ...@@ -250,7 +254,7 @@ finish_repo (void)
anonymous namespaces will get the same mangling when this anonymous namespaces will get the same mangling when this
file is recompiled. */ file is recompiled. */
if (!strstr (args, "'-frandom-seed=")) if (!strstr (args, "'-frandom-seed="))
fprintf (repo_file, " '-frandom-seed=%s'", flag_random_seed); fprintf (repo_file, " '-frandom-seed=%s'", get_random_seed (false));
fprintf (repo_file, "\n"); fprintf (repo_file, "\n");
} }
......
...@@ -251,11 +251,6 @@ extern int flag_var_tracking; ...@@ -251,11 +251,6 @@ extern int flag_var_tracking;
warning message in case flag was set by -fprofile-{generate,use}. */ warning message in case flag was set by -fprofile-{generate,use}. */
extern bool flag_speculative_prefetching_set; extern bool flag_speculative_prefetching_set;
/* A string that's used when a random name is required. NULL means
to make it really random. */
extern const char *flag_random_seed;
/* Returns TRUE if generated code should match ABI version N or /* Returns TRUE if generated code should match ABI version N or
greater is in use. */ greater is in use. */
......
...@@ -1268,11 +1268,11 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1268,11 +1268,11 @@ common_handle_option (size_t scode, const char *arg, int value,
/* The real switch is -fno-random-seed. */ /* The real switch is -fno-random-seed. */
if (value) if (value)
return 0; return 0;
flag_random_seed = NULL; set_random_seed (NULL);
break; break;
case OPT_frandom_seed_: case OPT_frandom_seed_:
flag_random_seed = arg; set_random_seed (arg);
break; break;
case OPT_fsched_verbose_: case OPT_fsched_verbose_:
......
/* Top level of GCC compilers (cc1, cc1plus, etc.) /* Top level of GCC compilers (cc1, cc1plus, etc.)
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -239,7 +239,7 @@ int in_system_header = 0; ...@@ -239,7 +239,7 @@ int in_system_header = 0;
int flag_detailed_statistics = 0; int flag_detailed_statistics = 0;
/* A random sequence of characters, unless overridden by user. */ /* A random sequence of characters, unless overridden by user. */
const char *flag_random_seed; static const char *flag_random_seed;
/* A local time stamp derived from the time of compilation. It will be /* 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 zero if the system cannot provide a time. It will be -1u, if the
...@@ -451,17 +451,14 @@ announce_function (tree decl) ...@@ -451,17 +451,14 @@ announce_function (tree decl)
} }
} }
/* Set up a default flag_random_seed and local_tick, unless the user /* Initialize local_tick with the time of day, or -1 if
already specified one. */ flag_random_seed is set. */
static void static void
randomize (void) init_local_tick (void)
{ {
if (!flag_random_seed) 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. */ /* Get some more or less random data. */
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
{ {
...@@ -478,15 +475,47 @@ randomize (void) ...@@ -478,15 +475,47 @@ randomize (void)
local_tick = (unsigned) now; local_tick = (unsigned) now;
} }
#endif #endif
}
else
local_tick = -1;
}
/* Set up a default flag_random_seed and local_tick, unless the user
already specified one. Must be called after init_local_tick. */
static void
init_random_seed (void)
{
unsigned HOST_WIDE_INT value;
static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
value = local_tick ^ getpid (); value = local_tick ^ getpid ();
sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value); sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
flag_random_seed = random_seed; flag_random_seed = random_seed;
}
else if (!local_tick)
local_tick = -1;
} }
/* Obtain the random_seed string. Unless NOINIT, initialize it if
it's not provided in the command line. */
const char *
get_random_seed (bool noinit)
{
if (!flag_random_seed && !noinit)
init_random_seed ();
return flag_random_seed;
}
/* Modify the random_seed string to VAL. Return its previous
value. */
const char *
set_random_seed (const char *val)
{
const char *old = flag_random_seed;
flag_random_seed = val;
return old;
}
/* Decode the string P as an integral parameter. /* Decode the string P as an integral parameter.
If the string is indeed an integer return its numeric value else If the string is indeed an integer return its numeric value else
...@@ -1277,7 +1306,8 @@ print_switch_values (print_switch_fn_type print_fn) ...@@ -1277,7 +1306,8 @@ print_switch_values (print_switch_fn_type print_fn)
/* Fill in the -frandom-seed option, if the user didn't pass it, so /* Fill in the -frandom-seed option, if the user didn't pass it, so
that it can be printed below. This helps reproducibility. */ that it can be printed below. This helps reproducibility. */
randomize (); if (!flag_random_seed)
init_random_seed ();
/* Print the options as passed. */ /* Print the options as passed. */
pos = print_single_switch (print_fn, pos, pos = print_single_switch (print_fn, pos,
...@@ -2119,7 +2149,7 @@ toplev_main (unsigned int argc, const char **argv) ...@@ -2119,7 +2149,7 @@ toplev_main (unsigned int argc, const char **argv)
enough to default flags appropriately. */ enough to default flags appropriately. */
decode_options (argc, argv); decode_options (argc, argv);
randomize (); init_local_tick ();
/* Exit early if we can (e.g. -help). */ /* Exit early if we can (e.g. -help). */
if (!exit_after_options) if (!exit_after_options)
......
/* toplev.h - Various declarations for functions found in toplev.c /* toplev.h - Various declarations for functions found in toplev.c
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005 Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -191,4 +191,9 @@ exact_log2 (unsigned HOST_WIDE_INT x) ...@@ -191,4 +191,9 @@ exact_log2 (unsigned HOST_WIDE_INT x)
extern const char *get_src_pwd (void); extern const char *get_src_pwd (void);
extern bool set_src_pwd (const char *); extern bool set_src_pwd (const char *);
/* Functions used to manipulate the random seed. */
extern const char *get_random_seed (bool);
extern const char *set_random_seed (const char *);
#endif /* ! GCC_TOPLEV_H */ #endif /* ! GCC_TOPLEV_H */
...@@ -6497,7 +6497,7 @@ get_file_function_name (const char *type) ...@@ -6497,7 +6497,7 @@ get_file_function_name (const char *type)
clean_symbol_name (q); clean_symbol_name (q);
sprintf (q + len, "_%08X_%08X", crc32_string (0, name), sprintf (q + len, "_%08X_%08X", crc32_string (0, name),
crc32_string (0, flag_random_seed)); crc32_string (0, get_random_seed (false)));
p = q; p = q;
} }
......
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