ref: 6aa83c4d6c919b4f958ebc20d8f9e06653c3aab9
parent: b1fc24bed0a7a676d7f5927cd860724425189dbe
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Mar 1 18:45:59 EST 2020
plan9: add -n option to force use of nsec() instead of relying on RDTSC: apparently 9front's clock may run absolutely crazy under some hypervizors
--- a/orca.man
+++ b/orca.man
@@ -18,6 +18,8 @@
] [
.I -l undo_limit
] [
+.I -n
+] [
.I file
]
.SH DESCRIPTION
@@ -66,6 +68,11 @@
.TP
.B -l
Sets the maximum number of undo steps. Default is 100.
+.TP
+.B -n
+Forces the use of
+.I nsec()
+instead of relying on RDTSC.
.PP
.SH KEYS
.TP
--- a/plan9.c
+++ b/plan9.c
@@ -92,6 +92,7 @@
static int mode = Minsert;
static long framedev; /* frame deviation in ms */
static char *shellcmd;
+static bool usensec;
static Snap *snaps;
static int numsnaps, nextsnap;
@@ -651,6 +652,9 @@
if (fasthz == 0) {
fasthz = ~0ULL;
+ xstart = nsec();
+ if (usensec)
+ return 0;
if ((f = open("/dev/time", OREAD)) >= 0 && (n = read(f, tmp, sizeof(tmp)-1)) > 2) {
tmp[n] = 0;
e = tmp;
@@ -665,7 +669,6 @@
if (fasthz == ~0ULL) {
fprint(2, "couldn't get fasthz, falling back to nsec()\n");
fprint(2, "you might want to disable aux/timesync\n");
- xstart = nsec();
return 0;
}
}
@@ -1190,7 +1193,7 @@
static void
usage(void)
{
- print("usage: %s [-p] [-b bpm] [-c cursor] [-l undo_limit] [-s WxH] [-r random_seed] [-i ip_address] [-u udp_port] [-m midi_path] [file]\n", argv0);
+ print("usage: %s [-p] [-n] [-b bpm] [-c cursor] [-l undo_limit] [-s WxH] [-r random_seed] [-i ip_address] [-u udp_port] [-m midi_path] [file]\n", argv0);
threadexitsall("usage");
}
@@ -1224,6 +1227,9 @@
ARGBEGIN{
case 'p':
pause = true;
+ break;
+ case 'n':
+ usensec = true;
break;
case 'b':
bpm = atoi(EARGF(usage()));