shithub: riscv

Download patch

ref: 93b475981e7326f53dee0369476344f8552f4e7b
parent: 711b69c0473d5dc962c7938c1cbbbf6c74cfba4d
author: Sigrid <ftrvxmtrx@gmail.com>
date: Fri Aug 7 13:08:49 EDT 2020

vmx: set xstart to either nsec or cycles depending on what is available

--- a/sys/src/cmd/vmx/nanosec.c
+++ b/sys/src/cmd/vmx/nanosec.c
@@ -6,9 +6,6 @@
  * nsec() is wallclock and can be adjusted by timesync
  * so need to use cycles() instead, but fall back to
  * nsec() in case we can't
- *
- * "fasthz" is how many ticks there are in a second
- * can be read from /dev/time
  */
 uvlong
 nanosec(void)
@@ -20,12 +17,14 @@
 		return nsec() - xstart;
 
 	if(fasthz == 0){
-		xstart = nsec();
 		if((fasthz = _tos->cyclefreq) == 0){
 			fasthz = ~0ULL;
+			xstart = nsec();
 			fprint(2, "cyclefreq not available, falling back to nsec()\n");
 			fprint(2, "you might want to disable aux/timesync\n");
 			return 0;
+		}else{
+			cycles(&xstart);
 		}
 	}
 	cycles(&x);