[GRASS-SVN] r69217 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 22 14:58:47 PDT 2016


Author: martinl
Date: 2016-08-22 14:58:47 -0700 (Mon, 22 Aug 2016)
New Revision: 69217

Modified:
   grass/trunk/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


Modified: grass/trunk/lib/gis/lrand48.c
===================================================================
--- grass/trunk/lib/gis/lrand48.c	2016-08-22 21:38:00 UTC (rev 69216)
+++ grass/trunk/lib/gis/lrand48.c	2016-08-22 21:58:47 UTC (rev 69217)
@@ -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