소스 검색

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 https://trac.osgeo.org/grass/ticket/3042


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69217 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 8 년 전
부모
커밋
a099817b0d
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      lib/gis/lrand48.c

+ 7 - 1
lib/gis/lrand48.c

@@ -70,7 +70,12 @@ void G_srand48(long seedval)
 
 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 @@ long G_srand48_auto(void)
 	seed += (unsigned long) t;
     }
 #endif
+    }
 
     G_srand48((long) seed);
     return (long) seed;