[GRASS-SVN] r69243 - grass/branches/releasebranch_7_2/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 23 08:06:09 PDT 2016
Author: martinl
Date: 2016-08-23 08:06:09 -0700 (Tue, 23 Aug 2016)
New Revision: 69243
Modified:
grass/branches/releasebranch_7_2/lib/gis/lrand48.c
Log:
If GRASS_RANDOM_SEED is set, use it to seed the random generator when
G_srand48_auto is called. This helps makeing the build reproducible
(html/random.png)
Based on 04-srand48_auto-from-SOURCE_DATE_EPOCH.patch, see #3042
(merge r69217 from trunk)
Modified: grass/branches/releasebranch_7_2/lib/gis/lrand48.c
===================================================================
--- grass/branches/releasebranch_7_2/lib/gis/lrand48.c 2016-08-23 14:49:21 UTC (rev 69242)
+++ grass/branches/releasebranch_7_2/lib/gis/lrand48.c 2016-08-23 15:06:09 UTC (rev 69243)
@@ -70,7 +70,12 @@
long G_srand48_auto(void)
{
- unsigned long seed = (unsigned long) getpid();
+ unsigned long seed;
+ char *grass_random_seed = getenv("GRASS_RANDOM_SEED");
+ if(grass_random_seed) {
+ seed = strtoull(grass_random_seed, NULL, 10);
+ } else {
+ seed = (unsigned long) getpid();
#ifdef HAVE_GETTIMEOFDAY
{
@@ -86,6 +91,7 @@
seed += (unsigned long) t;
}
#endif
+ }
G_srand48((long) seed);
return (long) seed;
More information about the grass-commit
mailing list