2
0
Эх сурвалжийг харах

added -D HL_DEBUG_REPRO for some more reproducible output (when tracking gc bugs for instance)

Nicolas Cannasse 5 жил өмнө
parent
commit
a30209ef50
2 өөрчлөгдсөн 13 нэмэгдсэн , 0 устгасан
  1. 5 0
      src/std/random.c
  2. 8 0
      src/std/sys.c

+ 5 - 0
src/std/random.c

@@ -77,6 +77,11 @@ HL_PRIM rnd *hl_rnd_init_system() {
 	struct timeval t;
 	gettimeofday(&t,NULL);
 	time = t.tv_sec * 1000000 + t.tv_usec;
+#endif
+#ifdef HL_DEBUG_REPRO
+	// fixed random seed
+	time = 4644546;
+	pid = 0;
 #endif
 	hl_rnd_set_seed(r,time ^ (pid | (pid << 16)));
 	return r;

+ 8 - 0
src/std/sys.c

@@ -181,7 +181,15 @@ HL_PRIM void hl_sys_exit( int code ) {
 	exit(code);
 }
 
+#ifdef HL_DEBUG_REPRO
+static double CURT = 0;
+#endif
+
 HL_PRIM double hl_sys_time() {
+#ifdef HL_DEBUG_REPRO
+	CURT += 0.001;
+	return CURT;
+#endif
 #ifdef HL_WIN
 	#define EPOCH_DIFF	(134774*24*60*60.0)
 	static double time_diff = 0.;