The epoch isn't far that away and we need to prepare OpenBSD for it.
I had a little free time, so I wrote a diff to simulate the behaviour
so that we can test how parts of OpenBSD cope with it.
Index: sys/sysctl.h
===================================================================
RCS file: /cvs/src/sys/sys/sysctl.h,v
retrieving revision 1.121
diff -u -p -u -r1.121 sysctl.h
--- sys/sysctl.h 23 Mar 2012 15:51:26 -0000 1.121
+++ sys/sysctl.h 1 Apr 2012 04:27:45 -0000
@@ -184,7 +184,8 @@ struct ctlname {
#define KERN_NETLIVELOCKS 76 /* int: number of network
livelocks */
#define KERN_POOL_DEBUG 77 /* int: enable pool_debug */
#define KERN_PROC_CWD 78 /* node: proc cwd */
-#define KERN_MAXID 79 /* number of valid kern ids */
+#define KERN_EMULATEMAYANPROPHESY 79 /* int: prevent the first epoch
*/
+#define KERN_MAXID 80 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
@@ -266,6 +267,7 @@ struct ctlname {
{ "netlivelocks", CTLTYPE_INT }, \
{ "pool_debug", CTLTYPE_INT }, \
{ "proc_cwd", CTLTYPE_NODE }, \
+ { "emulatemayanprophesy", CTLTYPE_INT }, \
}
/*
Index: sys/time.h
===================================================================
RCS file: /cvs/src/sys/sys/time.h,v
retrieving revision 1.26
diff -u -p -u -r1.26 time.h
--- sys/time.h 27 Nov 2009 19:45:54 -0000 1.26
+++ sys/time.h 1 Apr 2012 06:32:21 -0000
@@ -270,6 +270,17 @@ extern volatile time_t time_second; /* S
extern volatile time_t time_uptime; /* Seconds since reboot. */
/*
+ * Wikipedia: "The current (13th) b'ak'tun will end, or be completed, on
+ * 13.0.0.0.0 (December 21, 2012 using the GMT correlation". GMT or
+ * Mexico/General? What's 6 hours between Mayans friends.. let's follow
+ * 'Mexican time' rules. You might get 6 more hours of reading your
+ * mail, but don't count on it.
+ */
+#define END_13BAKTUN 1356069600
+extern int emulatemayanprophecy; /* End time before the Mayans do */
+
+
+/*
* Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
*
* Functions without the "get" prefix returns the best timestamp
Index: kern/kern_clock.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_clock.c,v
retrieving revision 1.73
diff -u -p -u -r1.73 kern_clock.c
--- kern/kern_clock.c 23 Mar 2012 15:51:26 -0000 1.73
+++ kern/kern_clock.c 1 Apr 2012 06:21:53 -0000
@@ -108,6 +108,8 @@ int psratio; /* ratio: prof / stat */
long cp_time[CPUSTATES];
+int emulatemayanprophecy; /* sysctl: stop time at end of 13th b'ak'tun */
+
#ifndef __HAVE_TIMECOUNTER
int tickfix, tickfixinterval; /* used if tick not really integral */
static int tickfixcnt; /* accumulated fractional error */
@@ -292,8 +294,16 @@ hardclock(struct clockframe *frame)
BUMPTIME(&time, delta);
BUMPTIME(&mono_time, delta);
- time_second = time.tv_sec;
- time_uptime = mono_time.tv_sec;
+ if (emulatemayanprophecy) {
+ if (time.tv_sec < END_13BAKTUN) {
+ time_second = time.tv_sec;
+ time_uptime = mono_time.tv_sec;
+ }
+ } else {
+ time_second = time.tv_sec;
+ time_uptime = mono_time.tv_sec;
+ }
+
#else
tc_ticktock();
#endif
Index: kern/kern_sysctl.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.218
diff -u -p -u -r1.218 kern_sysctl.c
--- kern/kern_sysctl.c 28 Mar 2012 16:01:30 -0000 1.218
+++ kern/kern_sysctl.c 1 Apr 2012 04:27:45 -0000
@@ -55,6 +55,7 @@
#include <sys/tty.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
+#include <sys/time.h>
#include <uvm/uvm_extern.h>
#include <sys/sysctl.h>
#include <sys/msgbuf.h>
@@ -607,6 +608,9 @@ kern_sysctl(int *name, u_int namelen, vo
pool_reclaim_all();
return (error);
}
+ case KERN_EMULATEMAYANPROPHESY:
+ return (sysctl_int(oldp, oldlenp, newp, newlen,
+ &emulatemayanprophecy));
default:
return (EOPNOTSUPP);
}
Index: kern/kern_tc.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_tc.c,v
retrieving revision 1.16
diff -u -p -u -r1.16 kern_tc.c
--- kern/kern_tc.c 24 Sep 2010 07:29:30 -0000 1.16
+++ kern/kern_tc.c 1 Apr 2012 06:49:06 -0000
@@ -16,6 +16,7 @@
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
+#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/malloc.h>
#include <dev/rndvar.h>
@@ -381,6 +382,14 @@ tc_windup(void)
i = 2;
for (; i > 0; i--)
ntp_update_second(&th->th_adjustment, &bt.sec);
+
+ if (emulatemayanprophecy) {
+ struct timeval tv;
+
+ bintime2timeval(&bt, &tv);
+ if (tv.tv_sec >= END_13BAKTUN)
+ return;
+ }
/* Update the UTC timestamps used by the get*() functions. */
/* XXX shouldn't do this here. Should force non-`get' versions. */