Index: world
===================================================================
--- world	(revision 0)
+++ world	(revision 781)
@@ -0,0 +1 @@
+make buildworld KERNCONF=DIMETRODON -DNO_KERNELCLEAN NOCLEAN=1
Index: test-inst
===================================================================
--- test-inst	(revision 0)
+++ test-inst	(revision 781)
@@ -0,0 +1,3 @@
+make installkernel KERNCONF=DIMETRODON KODIR=/boot/testkernel
+        nextboot -k testkernel	
+
Index: gdb-dump
===================================================================
--- gdb-dump	(revision 0)
+++ gdb-dump	(revision 781)
@@ -0,0 +1,2 @@
+kgdb /usr/obj/usr/dimetrodon/bsd/sys/DIMETRODON/kernel.debug /var/crash/vmcore.2
+
Index: boot-test
===================================================================
--- boot-test	(revision 0)
+++ boot-test	(revision 781)
@@ -0,0 +1 @@
+nextboot -k testkernel
Index: build
===================================================================
--- build	(revision 0)
+++ build	(revision 781)
@@ -0,0 +1 @@
+make buildkernel -j 5 KERNCONF=DIMETRODON -DNO_KERNELCLEAN
Index: install
===================================================================
--- install	(revision 0)
+++ install	(revision 781)
@@ -0,0 +1 @@
+make installkernel KERNCONF=DIMETRODON
Index: sys/conf/files
===================================================================
--- sys/conf/files	(revision 379)
+++ sys/conf/files	(revision 781)
@@ -1578,6 +1578,10 @@
 fs/cd9660/cd9660_vfsops.c	optional cd9660
 fs/cd9660/cd9660_vnops.c	optional cd9660
 fs/cd9660/cd9660_iconv.c	optional cd9660_iconv
+
+# dimetrodon
+kern/sched_heuristics.c		standard
+
 kern/bus_if.m			standard
 kern/clock_if.m			optional genclock
 kern/cpufreq_if.m		standard
Index: sys/kern/kern_thread.c
===================================================================
--- sys/kern/kern_thread.c	(revision 379)
+++ sys/kern/kern_thread.c	(revision 781)
@@ -494,10 +494,14 @@
 		}
 	} 
 	PROC_UNLOCK(p);
+
 	thread_lock(td);
 	/* Save our tick information with both the thread and proc locked */
 	ruxagg(&p->p_rux, td);
 	PROC_SUNLOCK(p);
+
+	KASSERT(td->is_preempted == 0, "Preempted thread is exiting!?!?!");
+
 	td->td_state = TDS_INACTIVE;
 	CTR1(KTR_PROC, "thread_exit: cpu_throw() thread %p", td);
 	sched_throw(td);
Index: sys/kern/kern_switch.c
===================================================================
--- sys/kern/kern_switch.c	(revision 379)
+++ sys/kern/kern_switch.c	(revision 781)
@@ -348,8 +348,9 @@
 	return (-1);
 }
 
+
 static __inline int
-runq_findbit_from(struct runq *rq, u_char pri)
+runq_findbit_from_doagain(struct runq *rq, u_char pri, int doagain)
 {
 	struct rqbits *rqb;
 	rqb_word_t mask;
@@ -376,10 +377,22 @@
 	 * Wrap back around to the beginning of the list just once so we
 	 * scan the whole thing.
 	 */
-	pri = 0;
-	goto again;
+	if(doagain)
+	{
+	    pri = 0;
+	    goto again;
+	}
+
+	return (-1);
 }
 
+static __inline int
+runq_findbit_from(struct runq *rq, u_char pri)
+{
+    return runq_findbit_from_doagain(rq, pri, 1);
+}
+
+
 /*
  * Set the status bit of the queue corresponding to priority level pri,
  * indicating that it is non-empty.
@@ -398,6 +411,19 @@
 }
 
 /*
+ * Move thread to the back of its current runq.  This could be optimized!
+ */
+
+void
+runq_move_to_back(struct runq *rq, struct td_sched *ts)
+{
+	CTR3(KTR_RUNQ, "runq_move_to_back: moving ts %p (%s) to back of rq %p",
+	     ts, ts->ts_thread->td_proc->p_comm, rq);
+	runq_remove(rq, ts);
+	runq_add(rq, ts, (int) NULL);
+}
+
+/*
  * Add the thread to the queue specified by its priority, and set the
  * corresponding status bit.
  */
@@ -407,6 +433,8 @@
 	struct rqhead *rqh;
 	int pri;
 
+	KASSERT(!ts->ts_thread->is_preempted, "adding preempted thread to rq!");
+
 	pri = ts->ts_thread->td_priority / RQ_PPQ;
 	ts->ts_rqindex = pri;
 	runq_setbit(rq, pri);
@@ -415,8 +443,10 @@
 	    ts->ts_thread, ts, ts->ts_thread->td_priority, pri, rqh);
 	if (flags & SRQ_PREEMPTED) {
 		TAILQ_INSERT_HEAD(rqh, ts, ts_procq);
+		CTR0(KTR_RUNQ, "runq_add: at head!");
 	} else {
 		TAILQ_INSERT_TAIL(rqh, ts, ts_procq);
+		CTR0(KTR_RUNQ, "runq_add: at tail!");
 	}
 }
 
@@ -460,6 +490,78 @@
 	return (0);
 }
 
+/*
+ * Return true if there are runnable anointed processes of any priority on the run
+ * queue, false otherwise.  Has no side effects, does not modify the run
+ * queue structure.
+ */
+int
+runq_check_dimetrodon_anointed(struct runq *rq)
+{
+	struct rqhead *rqh;
+	int pri = 0;
+
+	while ((pri = runq_findbit_from_doagain(rq, (u_char) pri, 0)) != -1) {
+		rqh = &rq->rq_queues[pri];
+		struct td_sched *ts;
+		ts = TAILQ_FIRST(rqh);
+
+		while (ts) {
+		    if (ts->ts_thread->td_proc->is_dimetrodon_anointed &&
+			!ts->ts_thread->is_preempted)
+		    {
+			CTR2(KTR_RUNQ, "runq_check_anointed: found proc at pri %d (%s)",
+			     pri, ts->ts_thread->td_proc->p_comm);
+			return (1);
+		    }
+		    
+		    ts = TAILQ_NEXT(ts, ts_procq);
+		}
+		++pri;
+	}
+	
+	CTR0(KTR_RUNQ, "runq_check_anointed: empty");
+
+	return (0);
+}
+
+
+/*
+ * Return true if there are runnable anointed processes of any priority on the run
+ * queue, false otherwise.  Has no side effects, does not modify the run
+ * queue structure.
+ */
+struct td_sched *
+runq_get_dimetrodon_anointed(struct runq *rq)
+{
+	struct rqhead *rqh;
+	int pri = 0;
+
+	while ((pri = runq_findbit_from_doagain(rq, (u_char) pri, 0)) != -1) {
+		rqh = &rq->rq_queues[pri];
+		struct td_sched *ts;
+		ts = TAILQ_FIRST(rqh);
+
+		while (ts) {
+		    if (ts->ts_thread->td_proc->is_dimetrodon_anointed &&
+			!ts->ts_thread->is_preempted)
+		    {
+			CTR2(KTR_RUNQ, "runq_get_anointed: found proc at pri %d (%s)",
+			     pri, ts->ts_thread->td_proc->p_comm);
+			return ts;
+		    }
+		    
+		    ts = TAILQ_NEXT(ts, ts_procq);
+		}
+		++pri;
+	}
+	
+	CTR0(KTR_RUNQ, "runq_check_anointed: empty");
+
+	return NULL;
+}
+
+
 #if defined(SMP) && defined(SCHED_4BSD)
 int runq_fuzz = 1;
 SYSCTL_INT(_kern_sched, OID_AUTO, runq_fuzz, CTLFLAG_RW, &runq_fuzz, 0, "");
@@ -473,9 +575,9 @@
 {
 	struct rqhead *rqh;
 	struct td_sched *ts;
-	int pri;
+	int pri = 0;
 
-	while ((pri = runq_findbit(rq)) != -1) {
+	while ((pri = runq_findbit_from_doagain(rq, (u_char) pri, 0)) != -1) {
 		rqh = &rq->rq_queues[pri];
 #if defined(SMP) && defined(SCHED_4BSD)
 		/* fuzz == 1 is normal.. 0 or less are ignored */
@@ -487,10 +589,10 @@
 			int count = runq_fuzz;
 			int cpu = PCPU_GET(cpuid);
 			struct td_sched *ts2;
-			ts2 = ts = TAILQ_FIRST(rqh);
+			ts2 = TAILQ_FIRST(rqh);
 
 			while (count-- && ts2) {
-				if (ts2->ts_thread->td_lastcpu == cpu) {
+				if (ts2->ts_thread->td_lastcpu == cpu && !ts2->ts_thread->is_preempted) {
 					ts = ts2;
 					break;
 				}
@@ -498,16 +600,44 @@
 			}
 		} else
 #endif
-			ts = TAILQ_FIRST(rqh);
-		KASSERT(ts != NULL, ("runq_choose: no proc on busy queue"));
-		CTR3(KTR_RUNQ,
-		    "runq_choose: pri=%d td_sched=%p rqh=%p", pri, ts, rqh);
-		return (ts);
+		{
+			struct td_sched *ts2;
+			ts2 = TAILQ_FIRST(rqh);
+
+			while (ts2) {
+				if (!ts2->ts_thread->is_preempted) {
+					ts = ts2;
+					break;
+				}
+				ts2 = TAILQ_NEXT(ts2, ts_procq);
+			}
+		}
+
+		/*
+		  If we found a non-preempted thread...
+		 */
+		if(ts)
+		{
+			KASSERT(!ts->ts_thread->is_preempted, "chose a preempted thread!");
+			CTR5(KTR_RUNQ,
+			     "runq_choose: at pri=%d td_sched=%p (pri=%d) rqh=%p, name=%s",
+			     pri, ts, ts->ts_thread->td_priority, rqh, ts->ts_thread->td_proc->p_comm);
+			
+			return (ts);
+		}
+
+		/*
+		  Go to the next priority.
+		*/
+		++pri;
 	}
 	CTR1(KTR_RUNQ, "runq_choose: idleproc pri=%d", pri);
 
 	return (NULL);
 }
+/*
+  Note: THIS IS UNUSED, BUT NEEDS TO BE FIXED IF WE ARE TO USE IT!
+ */
 
 struct td_sched *
 runq_choose_from(struct runq *rq, u_char idx)
Index: sys/kern/kern_idle.c
===================================================================
--- sys/kern/kern_idle.c	(revision 379)
+++ sys/kern/kern_idle.c	(revision 781)
@@ -78,6 +78,7 @@
 		TD_SET_CAN_RUN(td);
 		td->td_flags |= TDF_IDLETD;
 		sched_class(td, PRI_IDLE);
+		td->dimetrodon_idle = 0;
 		sched_prio(td, PRI_MAX_IDLE);
 		thread_unlock(td);
 		PROC_UNLOCK(p);
Index: sys/kern/kern_synch.c
===================================================================
--- sys/kern/kern_synch.c	(revision 379)
+++ sys/kern/kern_synch.c	(revision 781)
@@ -57,6 +57,7 @@
 #include <sys/sysctl.h>
 #include <sys/sysproto.h>
 #include <sys/vmmeter.h>
+#include <sys/sched_heuristics.h>
 #ifdef KTRACE
 #include <sys/uio.h>
 #include <sys/ktrace.h>
@@ -371,7 +372,7 @@
 void
 mi_switch(int flags, struct thread *newtd)
 {
-	uint64_t runtime, new_switchtime;
+        uint64_t runtime, new_switchtime;
 	struct thread *td;
 	struct proc *p;
 
@@ -408,20 +409,50 @@
 	 * Compute the amount of time during which the current
 	 * thread was running, and add that to its total so far.
 	 */
+
+	//set dimetrodon recent ticktimes here--for now, just do 2
+	td->td_recenttick_old = td->td_recenttick_new;
+	td->td_recenttick_new = td->td_currenttick;
+
+	CTR4(KTR_SCHED, "mi_switch ticks: %p(%s) old: %d, new: %d",
+	     td, td->td_proc->p_comm, td->td_recenttick_old,
+	     td->td_recenttick_new);
+
 	new_switchtime = cpu_ticks();
 	runtime = new_switchtime - PCPU_GET(switchtime);
 	td->td_runtime += runtime;
 	td->td_incruntime += runtime;
+
+	/*
+	  For whatever reason, locking the proc causes a deadlock even if we
+	  do ugly reentrant-type locking.
+
+	  We instead use a spinlock for these variables.
+	  Context switching is already expensive...
+	 */
+
+	if(p)
+	{
+		//mtx_lock_spin(&p->tick_lock);
+		p->proc_ticks += td->td_currenttick;
+		p->proc_numquanta++;
+		//mtx_unlock_spin(&p->tick_lock);
+	}
+
 	PCPU_SET(switchtime, new_switchtime);
 	td->td_generation++;	/* bump preempt-detect counter */
 	PCPU_INC(cnt.v_swtch);
+
 	PCPU_SET(switchticks, ticks);
 	CTR4(KTR_PROC, "mi_switch: old thread %ld (kse %p, pid %ld, %s)",
 	    td->td_tid, td->td_sched, p->p_pid, p->p_comm);
 #if (KTR_COMPILE & KTR_SCHED) != 0
-	if (TD_IS_IDLETHREAD(td))
-		CTR3(KTR_SCHED, "mi_switch: %p(%s) prio %d idle",
+	if (TD_IS_IDLETHREAD(td) && !td->dimetrodon_idle)
+		CTR3(KTR_SCHED, "mi_switch from idle: %p(%s) prio %d idle",
 		    td, td->td_proc->p_comm, td->td_priority);
+	else if (TD_IS_IDLETHREAD(td) && td->dimetrodon_idle)
+		CTR3(KTR_SCHED, "mi_switch from dimetrodon idle: %p(%s) prio %d idle",
+		    td, td->td_proc->p_comm, td->td_priority);
 	else if (newtd != NULL)
 		CTR5(KTR_SCHED,
 		    "mi_switch: %p(%s) prio %d preempted by %p(%s)",
@@ -445,8 +476,8 @@
 	CTR3(KTR_SCHED, "mi_switch: running %p(%s) prio %d",
 	    td, td->td_proc->p_comm, td->td_priority);
 
-	CTR4(KTR_PROC, "mi_switch: new thread %ld (kse %p, pid %ld, %s)",
-	    td->td_tid, td->td_sched, p->p_pid, p->p_comm);
+	CTR5(KTR_PROC, "mi_switch: new thread %ld (kse %p, pid %ld, %s, dimetrodon: %d)",
+	     td->td_tid, td->td_sched, p->p_pid, p->p_comm, td->dimetrodon_idle);
 
 	/* 
 	 * If the last thread was exiting, finish cleaning it up.
@@ -484,6 +515,8 @@
 	case TDS_CAN_RUN:
 		break;
 	default:
+		if(td->is_preempted)
+			break;
 		printf("state is 0x%x", td->td_state);
 		panic("setrunnable(2)");
 	}
Index: sys/kern/init_main.c
===================================================================
--- sys/kern/init_main.c	(revision 379)
+++ sys/kern/init_main.c	(revision 781)
@@ -393,6 +393,8 @@
 	 * Add scheduler specific parts to proc, thread as needed.
 	 */
 	schedinit();	/* scheduler gets its house in order */
+	mtx_init(&p->tick_lock, "proc tick lock", NULL, MTX_SPIN);
+
 	/*
 	 * Initialize sleep queue hash table
 	 */
Index: sys/kern/kern_clock.c
===================================================================
--- sys/kern/kern_clock.c	(revision 379)
+++ sys/kern/kern_clock.c	(revision 781)
@@ -264,6 +264,13 @@
 	struct thread *td = curthread;
 	struct proc *p = td->td_proc;
 	int flags;
+	
+	CTR5(KTR_SCHED,
+	     "hardclock_cpu: td %p(%s) %d ticks, needresched(%d) dimetrodon:%d",
+	     td, td->td_proc->p_comm, ticks-PCPU_GET(switchticks),
+	     td->td_flags & TDF_NEEDRESCHED, td->dimetrodon_idle);
+	
+	td->td_currenttick = ticks-PCPU_GET(switchticks);
 
 	/*
 	 * Run current process's virtual and profile time, as needed.
@@ -527,8 +534,9 @@
 	rss = pgtok(vmspace_resident_count(vm));
 	if (ru->ru_maxrss < rss)
 		ru->ru_maxrss = rss;
-	CTR4(KTR_SCHED, "statclock: %p(%s) prio %d stathz %d",
-	    td, td->td_proc->p_comm, td->td_priority, (stathz)?stathz:hz);
+//	CTR4(KTR_SCHED, "statclock: %p(%s) prio %d stathz %d",
+//	    td, td->td_proc->p_comm, td->td_priority, (stathz)?stathz:hz);
+
 	thread_lock_flags(td, MTX_QUIET);
 	sched_clock(td);
 	thread_unlock(td);
Index: sys/kern/kern_proc.c
===================================================================
--- sys/kern/kern_proc.c	(revision 379)
+++ sys/kern/kern_proc.c	(revision 781)
@@ -283,7 +283,7 @@
 pfind(pid)
 	register pid_t pid;
 {
-	register struct proc *p;
+	register struct proc *p = NULL;
 
 	sx_slock(&allproc_lock);
 	LIST_FOREACH(p, PIDHASH(pid), p_hash)
Index: sys/kern/sched_4bsd.c
===================================================================
--- sys/kern/sched_4bsd.c	(revision 379)
+++ sys/kern/sched_4bsd.c	(revision 781)
@@ -1,5 +1,4 @@
-/*-
- * Copyright (c) 1982, 1986, 1990, 1991, 1993
+/*- * Copyright (c) 1982, 1986, 1990, 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
  * (c) UNIX System Laboratories, Inc.
  * All or some portions of this file are derived from material licensed
@@ -54,6 +53,7 @@
 #include <sys/sx.h>
 #include <sys/turnstile.h>
 #include <sys/umtx.h>
+#include <sys/sched_heuristics.h>
 #include <machine/pcb.h>
 #include <machine/smp.h>
 
@@ -259,10 +259,19 @@
 static void
 maybe_resched(struct thread *td)
 {
+        if(TD_IS_IDLETHREAD(curthread) && curthread->dimetrodon_idle)
+            return;
 
 	THREAD_LOCK_ASSERT(td, MA_OWNED);
 	if (td->td_priority < curthread->td_priority)
+	{
+		CTR5(KTR_SCHED,
+		     "maybe_resched: td %p(%s) %d ticks, %d quantum, needresched(%d)",
+		     td, td->td_proc->p_comm, ticks-PCPU_GET(switchticks), sched_quantum,
+		     td->td_flags & TDF_NEEDRESCHED);
+
 		curthread->td_flags |= TDF_NEEDRESCHED;
+ 	}
 }
 
 /*
@@ -459,7 +468,6 @@
 static void
 schedcpu_thread(void)
 {
-
 	for (;;) {
 		schedcpu();
 		pause("-", hz);
@@ -524,7 +532,8 @@
 		return;
 
 	/* XXX the whole needresched thing is broken, but not silly. */
-	maybe_resched(td);
+	if(!(TD_IS_IDLETHREAD(curthread) && curthread->dimetrodon_idle))
+		maybe_resched(td);
 
 	sched_prio(td, td->td_user_pri);
 }
@@ -574,6 +583,16 @@
 #endif
 }
 
+static int sched_runnable_dimetrodon_anointed(void)
+{
+#ifdef SMP
+	return runq_check_dimetrodon_anointed(&runq) + 
+		runq_check_dimetrodon_anointed(&runq_pcpu[PCPU_GET(cpuid)]);
+#else
+	return runq_check_dimetrodon_anointed(&runq);
+#endif
+}
+
 int
 sched_rr_interval(void)
 {
@@ -599,50 +618,105 @@
 void
 sched_clock(struct thread *td)
 {
-	struct td_sched *ts;
+	struct td_sched *ts, *actualts;
+	struct thread *actualtd;
+	int isidlethread;
+	int tickssofar;
 
+	isidlethread = TD_IS_IDLETHREAD(td);
+
 	THREAD_LOCK_ASSERT(td, MA_OWNED);
 	ts = td->td_sched;
 
-	ts->ts_cpticks++;
-	td->td_estcpu = ESTCPULIM(td->td_estcpu + 1);
-	if ((td->td_estcpu % INVERSE_ESTCPU_WEIGHT) == 0) {
-		resetpriority(td);
-		resetpriority_thread(td);
+	if(!td->dimetrodon_idle)
+	{
+		actualts = ts;
+		actualtd = curthread;
 	}
+	else
+	{
+		actualtd = td->dimetrodon_wouldrun;
+		actualts = actualtd->td_sched;
+	}
+		
+	actualts->ts_cpticks++;
+	actualtd->td_estcpu = ESTCPULIM(actualtd->td_estcpu + 1);
+	
+	if ((actualtd->td_estcpu % INVERSE_ESTCPU_WEIGHT) == 0) {
+		resetpriority(actualtd);
+		resetpriority_thread(actualtd);
+	}
 
+
 	/*
 	 * Force a context switch if the current thread has used up a full
 	 * quantum (default quantum is 100ms).
 	 */
-	if (!TD_IS_IDLETHREAD(td) &&
-	    ticks - PCPU_GET(switchticks) >= sched_quantum)
+
+	//dimetrodon: don't context switch in idle thread, like normal, but
+	//if we're idling in dimetrodon, we actually do want to switch at quantum
+	//depletion
+
+	tickssofar = ticks-PCPU_GET(switchticks);
+
+	if ((td->dimetrodon_idle <= tickssofar && td->dimetrodon_idle > 0 && isidlethread)
+	    ||
+	    ((!(isidlethread || td->dimetrodon_idle))
+	     &&
+	     tickssofar >= sched_quantum))
+	{
+		if(td->dimetrodon_idle)
+			CTR5(KTR_SCHED,
+			     "sched_clock dimetrodon: td %p(%s) %d ticks, %d dimetrodon, needresched(%d)",
+			     td, td->td_proc->p_comm, ticks-PCPU_GET(switchticks), td->dimetrodon_idle,
+			     td->td_flags & TDF_NEEDRESCHED);
+		else
+			CTR5(KTR_SCHED,
+			     "sched_clock: td %p(%s) %d ticks, %d quantum, needresched(%d)",
+			     td, td->td_proc->p_comm, ticks-PCPU_GET(switchticks), sched_quantum,
+			     td->td_flags & TDF_NEEDRESCHED);
+	
+		if(td->dimetrodon_idle)
+			increment_idle_count();
+		else
+			increment_real_count_cond();
+
+		td->td_currenttick = tickssofar;
+
 		td->td_flags |= TDF_NEEDRESCHED;
+	}
 }
 
+
 /*
  * Charge child's scheduling CPU usage to parent.
  */
 void
 sched_exit(struct proc *p, struct thread *td)
 {
-
 	CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d",
 	    td, td->td_proc->p_comm, td->td_priority);
 	PROC_SLOCK_ASSERT(p, MA_OWNED);
+
 	sched_exit_thread(FIRST_THREAD_IN_PROC(p), td);
 }
 
 void
 sched_exit_thread(struct thread *td, struct thread *child)
 {
-
 	CTR3(KTR_SCHED, "sched_exit_thread: %p(%s) prio %d",
 	    child, child->td_proc->p_comm, child->td_priority);
+
 	thread_lock(td);
 	td->td_estcpu = ESTCPULIM(td->td_estcpu + child->td_estcpu);
 	thread_unlock(td);
+
 	mtx_lock_spin(&sched_lock);
+	if(child->is_preempted)
+	{
+	    child->preempting_thread->dimetrodon_wouldrun = 0;
+	    child->is_preempted = 0;
+	}
 	if ((child->td_proc->p_flag & P_NOLOAD) == 0)
 		sched_load_rem();
 	mtx_unlock_spin(&sched_lock);
@@ -651,6 +725,8 @@
 void
 sched_fork(struct thread *td, struct thread *childtd)
 {
+	//blessed are the children of the anointed
+	childtd->td_proc->is_dimetrodon_anointed = td->td_proc->is_dimetrodon_anointed;
 	sched_fork_thread(td, childtd);
 }
 
@@ -660,7 +736,18 @@
 	childtd->td_estcpu = td->td_estcpu;
 	childtd->td_lock = &sched_lock;
 	childtd->td_cpuset = cpuset_ref(td->td_cpuset);
+	
+	childtd->td_recenttick_new = td->td_recenttick_new;
+	childtd->td_recenttick_old = td->td_recenttick_old;
+	childtd->td_currenttick = 0;
+
 	sched_newthread(childtd);
+	childtd->is_preempted = 0;
+	childtd->preempting_thread = NULL;
+	if(childtd->td_proc && td->td_proc)
+	{
+		childtd->td_proc->dimetrodon_always_preempt = td->td_proc->dimetrodon_always_preempt;
+	}
 	childtd->td_sched->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY);
 }
 
@@ -693,6 +780,9 @@
 static void
 sched_priority(struct thread *td, u_char prio)
 {
+	if(td->dimetrodon_idle)
+		return;
+
 	CTR6(KTR_SCHED, "sched_prio: %p(%s) prio %d newprio %d by %p(%s)",
 	    td, td->td_proc->p_comm, td->td_priority, prio, curthread,
 	    curthread->td_proc->p_comm);
@@ -748,6 +838,9 @@
 void
 sched_prio(struct thread *td, u_char prio)
 {
+	if(td->dimetrodon_idle)
+		return;
+
 	u_char oldprio;
 
 	/* First, update the base priority. */
@@ -824,7 +917,7 @@
 void
 sched_switch(struct thread *td, struct thread *newtd, int flags)
 {
-	struct td_sched *ts;
+        struct td_sched *ts;
 	struct proc *p;
 
 	ts = td->td_sched;
@@ -859,9 +952,12 @@
 	 * threads on the run queue, however.
 	 */
 	if (td->td_flags & TDF_IDLETD) {
-		TD_SET_CAN_RUN(td);
+		if(!td->dimetrodon_idle)
+			TD_SET_CAN_RUN(td);
+
 #ifdef SMP
-		idle_cpus_mask &= ~PCPU_GET(cpumask);
+		if (!td->dimetrodon_idle)
+			idle_cpus_mask &= ~PCPU_GET(cpumask);
 #endif
 	} else {
 		if (TD_IS_RUNNING(td)) {
@@ -871,6 +967,8 @@
 			    SRQ_OURSELF|SRQ_YIELDING);
 		}
 	}
+
+
 	if (newtd) {
 		/*
 		 * The thread we are about to run needs to be counted
@@ -931,7 +1029,7 @@
 	}
 
 #ifdef SMP
-	if (td->td_flags & TDF_IDLETD)
+	if (td->td_flags & TDF_IDLETD && !td->dimetrodon_idle)
 		idle_cpus_mask |= PCPU_GET(cpumask);
 #endif
 	sched_lock.mtx_lock = (uintptr_t)td;
@@ -1132,7 +1230,6 @@
 		thread_lock_set(td, &sched_lock);
 	}
 	TD_SET_RUNQ(td);
-
 	if (td->td_pinned != 0) {
 		cpu = td->td_lastcpu;
 		ts->ts_runq = &runq_pcpu[cpu];
@@ -1272,8 +1369,23 @@
 sched_choose(void)
 {
 	struct td_sched *ts;
+	struct thread *td, *wouldrun;
 	struct runq *rq;
 
+	if(curthread->dimetrodon_wouldrun)
+	{
+		curthread->dimetrodon_wouldrun->preempting_thread = NULL;
+		curthread->dimetrodon_wouldrun->is_preempted = 0;
+
+		KASSERT((curtd->dimetrodon_wouldrun->
+			 td_sched->ts_runq != NULL),
+			("preempted thread has null runq!"));
+		runq_move_to_back(curthread->dimetrodon_wouldrun->td_sched->ts_runq,
+				  curthread->dimetrodon_wouldrun->td_sched);
+	}
+
+	curthread->dimetrodon_idle = 0;
+
 	mtx_assert(&sched_lock,  MA_OWNED);
 #ifdef SMP
 	struct td_sched *kecpu;
@@ -1282,15 +1394,39 @@
 	ts = runq_choose(&runq);
 	kecpu = runq_choose(&runq_pcpu[PCPU_GET(cpuid)]);
 
+	if(ts != NULL && kecpu != NULL && ts->ts_thread && kecpu->ts_thread && ts->ts_thread->td_proc && kecpu->ts_thread->td_proc)
+	{
+	    CTR4(KTR_RUNQ, "got td_scheds for %s(pri:%d) and %s(pri:%d)", 
+		 kecpu->ts_thread->td_proc->p_comm,
+		 kecpu->ts_thread->td_priority,
+		 ts->ts_thread->td_proc->p_comm,
+		 ts->ts_thread->td_priority);
+	}
+	else if(ts == NULL)
+	    CTR0(KTR_RUNQ, "ts == NULL runq_choose");
+
+
 	if (ts == NULL ||
 	    (kecpu != NULL &&
 	     kecpu->ts_thread->td_priority < ts->ts_thread->td_priority)) {
-		CTR2(KTR_RUNQ, "choosing td_sched %p from pcpu runq %d", kecpu,
+/*
+	    if(kecpu->ts_thread && kecpu->ts_thread->td_proc)
+		CTR3(KTR_RUNQ, "sched_choose: choosing td_sched %p(%s) from pcpu runq %d", kecpu,
+		     kecpu->ts_thread->td_proc->p_comm, PCPU_GET(cpuid));
+	    else
+		CTR2(KTR_RUNQ, "sched_choose: choosing td_sched %p(%s) from pcpu runq %d", kecpu,
 		     PCPU_GET(cpuid));
-		ts = kecpu;
-		rq = &runq_pcpu[PCPU_GET(cpuid)];
+*/
+	    ts = kecpu;
+	    rq = &runq_pcpu[PCPU_GET(cpuid)];
 	} else {
-		CTR1(KTR_RUNQ, "choosing td_sched %p from main runq", ts);
+/*
+	    if(ts && ts->ts_thread && ts->ts_thread->td_proc)
+		CTR2(KTR_RUNQ, "sched_choose: choosing td_sched %p(%s) from main runq", ts,
+		     ts->ts_thread->td_proc->p_comm);
+	    else
+		CTR1(KTR_RUNQ, "sched_choose: choosing td_sched %p(%s) from main runq", ts);
+*/
 	}
 
 #else
@@ -1299,18 +1435,104 @@
 #endif
 
 	if (ts) {
+		wouldrun = ts->ts_thread;
+
+		//DIMETRODON HACK
+		if(do_schedule_now(wouldrun) == 0)
+		{
+
+			/*
+			rq = &runq;
+			anointed = runq_get_dimetrodon_anointed(&runq);
 #ifdef SMP
+			kecpu = runq_get_dimetrodon_anointed(&runq_pcpu[PCPU_GET(cpuid)]);
+
+			if (anointed == NULL ||
+			    (kecpu != NULL &&
+			     kecpu->ts_thread->td_priority < ts->ts_thread->td_priority)) {
+				anointed = kecpu;
+				rq = &runq_pcpu[PCPU_GET(cpuid)];
+			}
+#endif
+
+			if(anointed != NULL)
+			{
+#ifdef SMP
+				if (ts == kecpu)
+					runq_length[PCPU_GET(cpuid)]--;
+#endif
+				runq_remove(rq, ts);
+				ts->ts_thread->td_flags |= TDF_DIDRUN;
+
+				CTR5(KTR_SCHED, "sched_choose: returning anointed %p(%s) prio %d by %p(%s)",
+				     ts->ts_thread, ts->ts_thread->td_proc->p_comm, ts->ts_thread->td_priority, curthread,
+				     curthread->td_proc->p_comm);			
+
+				return ts->ts_thread;
+			}
+			 
+			*/
+#ifdef SMP
+		        if (ts == kecpu)
+			        runq_length[PCPU_GET(cpuid)]--;
+#endif
+
+			td = PCPU_GET(idlethread);
+			//this is probably overkill, but let's just copy
+			//the real version below
+			td->td_flags |= TDF_DIDRUN;
+
+			wouldrun->is_preempted = 1;
+			wouldrun->preempting_thread = td;
+			td->dimetrodon_wouldrun = wouldrun;
+
+			//run for a fixed amount
+			if(dimetrodon_chosen_idletime_kind == IDLETIME_SET_TICKS)
+			{
+			        td->dimetrodon_idle = dimetrodon_idle_ticks;
+			}
+			//run for the amount of time that the thread would have run.
+			else
+			{
+			        td->dimetrodon_idle = MIN(
+				  MAX_IDLETIME,
+				  MAX(((wouldrun->td_recenttick_old + 
+					wouldrun->td_recenttick_new)/2),
+				      dimetrodon_min_idle_ticks));
+			}
+
+			CTR6(KTR_SCHED, "sched_choose: returning dimetrodon %p(%s) dimetrodon %d by %p(%s) instead of %s",
+			     td, td->td_proc->p_comm, td->dimetrodon_idle, curthread,
+			     curthread->td_proc->p_comm, wouldrun->td_proc->p_comm);
+
+			return td;
+		}
+
+#ifdef SMP
 		if (ts == kecpu)
 			runq_length[PCPU_GET(cpuid)]--;
 #endif
 		runq_remove(rq, ts);
 		ts->ts_thread->td_flags |= TDF_DIDRUN;
 
+		td = ts->ts_thread;
+
+		KASSERT(!td->is_preempted, "got a preempted thread!?!");
+
+		CTR5(KTR_SCHED, "sched_choose: returning other %p(%s) prio %d by %p(%s)",
+		     td, td->td_proc->p_comm, td->td_priority, curthread,
+		     curthread->td_proc->p_comm);
+
 		KASSERT(ts->ts_thread->td_flags & TDF_INMEM,
 		    ("sched_choose: thread swapped out"));
 		return (ts->ts_thread);
 	}
-	return (PCPU_GET(idlethread));
+
+	//return idle thread, but make sure we don't do the dimetrodon idle
+	td = PCPU_GET(idlethread);
+	td->dimetrodon_wouldrun = NULL;
+	td->dimetrodon_idle = 0;
+	return td;
 }
 
 void
@@ -1409,6 +1631,26 @@
 void
 sched_tick(void)
 {
+	/*
+	 * Stathz is 133 hz by default, which means it will get checked every
+	 * 7.5 milliseconds, or 7.5 ticks.  In order to allow finer-grained idle
+	 * cycle lengths, we want better resolution than this, so check every
+	 * tick if we need to preempt Dimetrodon threads.
+	 */
+
+	if (curthread->dimetrodon_idle
+	    && TD_IS_IDLETHREAD(curthread)
+	    && (curthread->dimetrodon_idle <= ticks-PCPU_GET(switchticks)))
+	{
+		CTR5(KTR_SCHED,
+		     "sched_tick dimetrodon: td %p(%s) %d ticks, %d dimetrodon, needresched(%d)",
+		     curthread, curthread->td_proc->p_comm, ticks-PCPU_GET(switchticks), curthread->dimetrodon_idle,
+		     curthread->td_flags & TDF_NEEDRESCHED);
+
+		increment_idle_count();
+
+		curthread->td_flags |= TDF_NEEDRESCHED;
+	}
 }
 
 /*
@@ -1419,15 +1661,52 @@
 {
 	struct proc *p;
 	struct thread *td;
+	int hadanointed = 0;
 
 	td = curthread;
+	//initialize this to false, just in case!
+	td->dimetrodon_idle = 0;
+
 	p = td->td_proc;
 	for (;;) {
 		mtx_assert(&Giant, MA_NOTOWNED);
 
-		while (sched_runnable() == 0)
+		/*
+		  dimetrodon
+
+		  break out of idle loop in two conditions:
+
+		  if we're not the dimetrodon idle process (we're just idling by choice,
+		  and not because we were idled by dimetrodon in sched_choose, then
+		  break once another thread becomes runnable
+
+		  if we are the dimetrodon idle process, run until we get rescheduled
+		*/
+
+		while (((td->dimetrodon_idle == 0) && (sched_runnable() == 0))
+		       ||
+		       ((td->dimetrodon_idle != 0) &&
+			(!(td->td_flags & TDF_NEEDRESCHED)) &&
+			((hadanointed = sched_runnable_dimetrodon_anointed()) == 0)))
+		{
+			CTR2(KTR_SCHED,
+			     "idletd: dimetrodon %d, ticks %d",
+			     curthread->dimetrodon_idle, ticks-PCPU_GET(switchticks));
 			cpu_idle();
+		}
 
+		if(td->dimetrodon_idle != 0)
+		{
+		    if(td->td_flags & TDF_NEEDRESCHED)
+		    {
+			CTR0(KTR_RUNQ, "idle: dime neededresched");
+		    }
+		    if(hadanointed == 1)
+		    {
+			CTR0(KTR_RUNQ, "idle: hadanointed");
+		    }
+		}
+
 		mtx_lock_spin(&sched_lock);
 		mi_switch(SW_VOL, NULL);
 		mtx_unlock_spin(&sched_lock);
@@ -1441,7 +1720,7 @@
 sched_throw(struct thread *td)
 {
 	/*
-	 * Correct spinlock nesting.  The idle thread context that we are
+	 * Correct spinlock nesting.  the idle thread context that we are
 	 * borrowing was created so that it would start out with a single
 	 * spin lock (sched_lock) held in fork_trampoline().  Since we've
 	 * explicitly acquired locks in this function, the nesting count
@@ -1482,6 +1761,9 @@
 	struct td_sched *ts;
 	int cpu;
 
+        if(curthread->dimetrodon_idle && td == curthread->dimetrodon_wouldrun)
+	        return;
+
 	THREAD_LOCK_ASSERT(td, MA_OWNED);	
 
 	/*
Index: sys/kern/kern_cpu.c
===================================================================
--- sys/kern/kern_cpu.c	(revision 379)
+++ sys/kern/kern_cpu.c	(revision 781)
@@ -131,12 +131,16 @@
 DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0);
 
 static int		cf_lowest_freq;
+static int		cf_highest_freq;
 static int		cf_verbose;
 TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq);
+TUNABLE_INT("debug.cpufreq.highest", &cf_highest_freq);
 TUNABLE_INT("debug.cpufreq.verbose", &cf_verbose);
 SYSCTL_NODE(_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL, "cpufreq debugging");
 SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW, &cf_lowest_freq, 1,
     "Don't provide levels below this frequency.");
+SYSCTL_INT(_debug_cpufreq, OID_AUTO, highest, CTLFLAG_RW, &cf_highest_freq, 1,
+    "Don't provide levels above this frequency.");
 SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RW, &cf_verbose, 1,
     "Print verbose debugging messages");
 
@@ -302,6 +306,14 @@
 		goto out;
 	}
 
+	/* Reject levels that are above our specified threshold. */
+	if (cf_highest_freq > 0 && level->total_set.freq > cf_highest_freq) {
+		CF_DEBUG("rejecting freq %d, greater than %d limit\n",
+		    level->total_set.freq, cf_highest_freq);
+		error = EINVAL;
+		goto out;
+	}
+
 	/* If already at this level, just return. */
 	if (CPUFREQ_CMP(sc->curr_level.total_set.freq, level->total_set.freq)) {
 		CF_DEBUG("skipping freq %d, same as current level %d\n",
@@ -624,8 +636,13 @@
 			continue;
 		}
 
-		/* Skip levels that have a frequency that is too low. */
-		if (lev->total_set.freq < cf_lowest_freq) {
+		/*
+		 * Skip levels that have a frequency that is too low or too
+		 * high.
+		 */
+		if (lev->total_set.freq < cf_lowest_freq ||
+		    (cf_highest_freq > 0 &&
+		     lev->total_set.freq > cf_highest_freq)) {
 			sc->all_count--;
 			continue;
 		}
Index: sys/kern/subr_turnstile.c
===================================================================
--- sys/kern/subr_turnstile.c	(revision 379)
+++ sys/kern/subr_turnstile.c	(revision 781)
@@ -240,7 +240,7 @@
 		 * If lock holder is actually running or on the run queue
 		 * then we are done.
 		 */
-		if (TD_IS_RUNNING(td) || TD_ON_RUNQ(td)) {
+		if (TD_IS_RUNNING(td) || TD_ON_RUNQ(td) || td->is_preempted) {
 			MPASS(td->td_blocked == NULL);
 			thread_unlock(td);
 			return;
Index: sys/kern/init_sysent.c
===================================================================
--- sys/kern/init_sysent.c	(revision 379)
+++ sys/kern/init_sysent.c	(revision 781)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/kern/syscalls.master 180808 2008-07-25 17:46:01Z jhb 
+ * created from FreeBSD
  */
 
 #include "opt_compat.h"
@@ -517,4 +517,21 @@
 	{ AS(cpuset_getid_args), (sy_call_t *)cpuset_getid, AUE_NULL, NULL, 0, 0 },	/* 486 = cpuset_getid */
 	{ AS(cpuset_getaffinity_args), (sy_call_t *)cpuset_getaffinity, AUE_NULL, NULL, 0, 0 },	/* 487 = cpuset_getaffinity */
 	{ AS(cpuset_setaffinity_args), (sy_call_t *)cpuset_setaffinity, AUE_NULL, NULL, 0, 0 },	/* 488 = cpuset_setaffinity */
+	{ AS(sys_set_dimetrodon_constant_args), (sy_call_t *)sys_set_dimetrodon_constant, AUE_NULL, NULL, 0, 0 },	/* 489 = sys_set_dimetrodon_constant */
+	{ AS(sys_dimetrodon_set_idle_ticks_args), (sy_call_t *)sys_dimetrodon_set_idle_ticks, AUE_NULL, NULL, 0, 0 },	/* 490 = sys_dimetrodon_set_idle_ticks */
+	{ AS(sys_dimetrodon_set_min_preempt_args), (sy_call_t *)sys_dimetrodon_set_min_preempt, AUE_NULL, NULL, 0, 0 },	/* 491 = sys_dimetrodon_set_min_preempt */
+	{ AS(sys_dimetrodon_set_heuristic_args), (sy_call_t *)sys_dimetrodon_set_heuristic, AUE_NULL, NULL, 0, 0 },	/* 492 = sys_dimetrodon_set_heuristic */
+	{ AS(sys_dimetrodon_get_stats_args), (sy_call_t *)sys_dimetrodon_get_stats, AUE_NULL, NULL, 0, 0 },	/* 493 = sys_dimetrodon_get_stats */
+	{ 0, (sy_call_t *)sys_dimetrodon_set_nopreempt, AUE_NULL, NULL, 0, 0 },	/* 494 = sys_dimetrodon_set_nopreempt */
+	{ 0, (sy_call_t *)sys_dimetrodon_set_dopreempt, AUE_NULL, NULL, 0, 0 },	/* 495 = sys_dimetrodon_set_dopreempt */
+	{ 0, (sy_call_t *)sys_dimetrodon_set_doregular, AUE_NULL, NULL, 0, 0 },	/* 496 = sys_dimetrodon_set_doregular */
+	{ AS(sys_dimetrodon_set_nopreempt_specify_args), (sy_call_t *)sys_dimetrodon_set_nopreempt_specify, AUE_NULL, NULL, 0, 0 },	/* 497 = sys_dimetrodon_set_nopreempt_specify */
+	{ AS(sys_dimetrodon_set_dopreempt_specify_args), (sy_call_t *)sys_dimetrodon_set_dopreempt_specify, AUE_NULL, NULL, 0, 0 },	/* 498 = sys_dimetrodon_set_dopreempt_specify */
+	{ AS(sys_dimetrodon_set_idletime_kind_args), (sy_call_t *)sys_dimetrodon_set_idletime_kind, AUE_NULL, NULL, 0, 0 },	/* 499 = sys_dimetrodon_set_idletime_kind */
+	{ AS(sys_dimetrodon_set_min_idle_ticks_args), (sy_call_t *)sys_dimetrodon_set_min_idle_ticks, AUE_NULL, NULL, 0, 0 },	/* 500 = sys_dimetrodon_set_min_idle_ticks */
+	{ AS(sys_dimetrodon_get_avg_quanta_args), (sy_call_t *)sys_dimetrodon_get_avg_quanta, AUE_NULL, NULL, 0, 0 },	/* 501 = sys_dimetrodon_get_avg_quanta */
+	{ AS(sys_dimetrodon_reset_quanta_count_args), (sy_call_t *)sys_dimetrodon_reset_quanta_count, AUE_NULL, NULL, 0, 0 },	/* 502 = sys_dimetrodon_reset_quanta_count */
+	{ AS(sys_dimetrodon_anoint_thread_specify_args), (sy_call_t *)sys_dimetrodon_anoint_thread_specify, AUE_NULL, NULL, 0, 0 },	/* 503 = sys_dimetrodon_anoint_thread_specify */
+	{ AS(sys_dimetrodon_unanoint_thread_specify_args), (sy_call_t *)sys_dimetrodon_unanoint_thread_specify, AUE_NULL, NULL, 0, 0 },	/* 504 = sys_dimetrodon_unanoint_thread_specify */
+	{ AS(sys_dimetrodon_is_thread_anointed_args), (sy_call_t *)sys_dimetrodon_is_thread_anointed, AUE_NULL, NULL, 0, 0 },	/* 505 = sys_dimetrodon_is_thread_anointed */
 };
Index: sys/kern/kern_fork.c
===================================================================
--- sys/kern/kern_fork.c	(revision 379)
+++ sys/kern/kern_fork.c	(revision 781)
@@ -429,6 +429,8 @@
 	LIST_INSERT_HEAD(&allproc, p2, p_list);
 	LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash);
 
+	mtx_init(&p2->tick_lock, "proc tick lock", NULL, MTX_SPIN);
+
 	PROC_LOCK(p2);
 	PROC_LOCK(p1);
 
Index: sys/kern/syscalls.c
===================================================================
--- sys/kern/syscalls.c	(revision 379)
+++ sys/kern/syscalls.c	(revision 781)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/kern/syscalls.master 180808 2008-07-25 17:46:01Z jhb 
+ * created from FreeBSD
  */
 
 const char *syscallnames[] = {
@@ -496,4 +496,21 @@
 	"cpuset_getid",			/* 486 = cpuset_getid */
 	"cpuset_getaffinity",			/* 487 = cpuset_getaffinity */
 	"cpuset_setaffinity",			/* 488 = cpuset_setaffinity */
+	"sys_set_dimetrodon_constant",			/* 489 = sys_set_dimetrodon_constant */
+	"sys_dimetrodon_set_idle_ticks",			/* 490 = sys_dimetrodon_set_idle_ticks */
+	"sys_dimetrodon_set_min_preempt",			/* 491 = sys_dimetrodon_set_min_preempt */
+	"sys_dimetrodon_set_heuristic",			/* 492 = sys_dimetrodon_set_heuristic */
+	"sys_dimetrodon_get_stats",			/* 493 = sys_dimetrodon_get_stats */
+	"sys_dimetrodon_set_nopreempt",			/* 494 = sys_dimetrodon_set_nopreempt */
+	"sys_dimetrodon_set_dopreempt",			/* 495 = sys_dimetrodon_set_dopreempt */
+	"sys_dimetrodon_set_doregular",			/* 496 = sys_dimetrodon_set_doregular */
+	"sys_dimetrodon_set_nopreempt_specify",			/* 497 = sys_dimetrodon_set_nopreempt_specify */
+	"sys_dimetrodon_set_dopreempt_specify",			/* 498 = sys_dimetrodon_set_dopreempt_specify */
+	"sys_dimetrodon_set_idletime_kind",			/* 499 = sys_dimetrodon_set_idletime_kind */
+	"sys_dimetrodon_set_min_idle_ticks",			/* 500 = sys_dimetrodon_set_min_idle_ticks */
+	"sys_dimetrodon_get_avg_quanta",			/* 501 = sys_dimetrodon_get_avg_quanta */
+	"sys_dimetrodon_reset_quanta_count",			/* 502 = sys_dimetrodon_reset_quanta_count */
+	"sys_dimetrodon_anoint_thread_specify",			/* 503 = sys_dimetrodon_anoint_thread_specify */
+	"sys_dimetrodon_unanoint_thread_specify",			/* 504 = sys_dimetrodon_unanoint_thread_specify */
+	"sys_dimetrodon_is_thread_anointed",			/* 505 = sys_dimetrodon_is_thread_anointed */
 };
Index: sys/kern/syscalls.master
===================================================================
--- sys/kern/syscalls.master	(revision 379)
+++ sys/kern/syscalls.master	(revision 781)
@@ -870,6 +870,22 @@
 488	AUE_NULL	STD	{ int cpuset_setaffinity(cpulevel_t level, \
 				    cpuwhich_t which, id_t id, size_t cpusetsize, \
 				    const cpuset_t *mask); }
-
+489     AUE_NULL        STD     { int sys_set_dimetrodon_constant(int value); }
+490	AUE_NULL	STD	{ int sys_dimetrodon_set_idle_ticks(int ticks); }
+491     AUE_NULL        STD     { int sys_dimetrodon_set_min_preempt(int min); }
+492	AUE_NULL	STD	{ int sys_dimetrodon_set_heuristic(int which); }
+493	AUE_NULL	STD	{ u_long sys_dimetrodon_get_stats(int which); }
+494	AUE_NULL	STD	{ int sys_dimetrodon_set_nopreempt(void); }
+495	AUE_NULL	STD	{ int sys_dimetrodon_set_dopreempt(void); }
+496	AUE_NULL	STD	{ int sys_dimetrodon_set_doregular(void); }
+497	AUE_NULL	STD	{ int sys_dimetrodon_set_nopreempt_specify(int which); }
+498	AUE_NULL	STD	{ int sys_dimetrodon_set_dopreempt_specify(int which); }
+499	AUE_NULL	STD	{ int sys_dimetrodon_set_idletime_kind(int which); }
+500	AUE_NULL	STD	{ int sys_dimetrodon_set_min_idle_ticks(int which); }
+501	AUE_NULL	STD	{ int sys_dimetrodon_get_avg_quanta(int which); }
+502	AUE_NULL	STD	{ int sys_dimetrodon_reset_quanta_count(int which); }
+503	AUE_NULL	STD	{ int sys_dimetrodon_anoint_thread_specify(int which); }
+504	AUE_NULL	STD	{ int sys_dimetrodon_unanoint_thread_specify(int which); }
+505	AUE_NULL	STD	{ int sys_dimetrodon_is_thread_anointed(int which); }
 ; Please copy any additions and changes to the following compatability tables:
 ; sys/compat/freebsd32/syscalls.master
Index: sys/kern/systrace_args.c
===================================================================
--- sys/kern/systrace_args.c	(revision 379)
+++ sys/kern/systrace_args.c	(revision 781)
@@ -2936,6 +2936,119 @@
 		*n_args = 5;
 		break;
 	}
+	/* sys_set_dimetrodon_constant */
+	case 489: {
+		struct sys_set_dimetrodon_constant_args *p = params;
+		iarg[0] = p->value; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_set_idle_ticks */
+	case 490: {
+		struct sys_dimetrodon_set_idle_ticks_args *p = params;
+		iarg[0] = p->ticks; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_set_min_preempt */
+	case 491: {
+		struct sys_dimetrodon_set_min_preempt_args *p = params;
+		iarg[0] = p->min; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_set_heuristic */
+	case 492: {
+		struct sys_dimetrodon_set_heuristic_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_get_stats */
+	case 493: {
+		struct sys_dimetrodon_get_stats_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_set_nopreempt */
+	case 494: {
+		*n_args = 0;
+		break;
+	}
+	/* sys_dimetrodon_set_dopreempt */
+	case 495: {
+		*n_args = 0;
+		break;
+	}
+	/* sys_dimetrodon_set_doregular */
+	case 496: {
+		*n_args = 0;
+		break;
+	}
+	/* sys_dimetrodon_set_nopreempt_specify */
+	case 497: {
+		struct sys_dimetrodon_set_nopreempt_specify_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_set_dopreempt_specify */
+	case 498: {
+		struct sys_dimetrodon_set_dopreempt_specify_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_set_idletime_kind */
+	case 499: {
+		struct sys_dimetrodon_set_idletime_kind_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_set_min_idle_ticks */
+	case 500: {
+		struct sys_dimetrodon_set_min_idle_ticks_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_get_avg_quanta */
+	case 501: {
+		struct sys_dimetrodon_get_avg_quanta_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_reset_quanta_count */
+	case 502: {
+		struct sys_dimetrodon_reset_quanta_count_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_anoint_thread_specify */
+	case 503: {
+		struct sys_dimetrodon_anoint_thread_specify_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_unanoint_thread_specify */
+	case 504: {
+		struct sys_dimetrodon_unanoint_thread_specify_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
+	/* sys_dimetrodon_is_thread_anointed */
+	case 505: {
+		struct sys_dimetrodon_is_thread_anointed_args *p = params;
+		iarg[0] = p->which; /* int */
+		*n_args = 1;
+		break;
+	}
 	default:
 		*n_args = 0;
 		break;
@@ -4489,6 +4602,16 @@
 			break;
 		};
 		break;
+	/* setfib */
+	case 175:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
 	/* ntp_adjtime */
 	case 176:
 		switch(ndx) {
@@ -7652,6 +7775,244 @@
 			break;
 		};
 		break;
+	/* cpuset */
+	case 484:
+		switch(ndx) {
+		case 0:
+			p = "cpusetid_t *";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* cpuset_setid */
+	case 485:
+		switch(ndx) {
+		case 0:
+			p = "cpuwhich_t";
+			break;
+		case 1:
+			p = "id_t";
+			break;
+		case 2:
+			p = "cpusetid_t";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* cpuset_getid */
+	case 486:
+		switch(ndx) {
+		case 0:
+			p = "cpulevel_t";
+			break;
+		case 1:
+			p = "cpuwhich_t";
+			break;
+		case 2:
+			p = "id_t";
+			break;
+		case 3:
+			p = "cpusetid_t *";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* cpuset_getaffinity */
+	case 487:
+		switch(ndx) {
+		case 0:
+			p = "cpulevel_t";
+			break;
+		case 1:
+			p = "cpuwhich_t";
+			break;
+		case 2:
+			p = "id_t";
+			break;
+		case 3:
+			p = "size_t";
+			break;
+		case 4:
+			p = "cpuset_t *";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* cpuset_setaffinity */
+	case 488:
+		switch(ndx) {
+		case 0:
+			p = "cpulevel_t";
+			break;
+		case 1:
+			p = "cpuwhich_t";
+			break;
+		case 2:
+			p = "id_t";
+			break;
+		case 3:
+			p = "size_t";
+			break;
+		case 4:
+			p = "const cpuset_t *";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_set_dimetrodon_constant */
+	case 489:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_set_idle_ticks */
+	case 490:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_set_min_preempt */
+	case 491:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_set_heuristic */
+	case 492:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_get_stats */
+	case 493:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_set_nopreempt */
+	case 494:
+		break;
+	/* sys_dimetrodon_set_dopreempt */
+	case 495:
+		break;
+	/* sys_dimetrodon_set_doregular */
+	case 496:
+		break;
+	/* sys_dimetrodon_set_nopreempt_specify */
+	case 497:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_set_dopreempt_specify */
+	case 498:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_set_idletime_kind */
+	case 499:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_set_min_idle_ticks */
+	case 500:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_get_avg_quanta */
+	case 501:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_reset_quanta_count */
+	case 502:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_anoint_thread_specify */
+	case 503:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_unanoint_thread_specify */
+	case 504:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
+	/* sys_dimetrodon_is_thread_anointed */
+	case 505:
+		switch(ndx) {
+		case 0:
+			p = "int";
+			break;
+		default:
+			break;
+		};
+		break;
 	default:
 		break;
 	};
Index: sys/kern/sched_heuristics.c
===================================================================
--- sys/kern/sched_heuristics.c	(revision 0)
+++ sys/kern/sched_heuristics.c	(revision 781)
@@ -0,0 +1,391 @@
+ /*
+ * Power-Conserving Interactive-User-Sensitive Scheduling (DIMETRODON) Heuristics
+ *
+ *  Copyright (C) 2009 Peter Bailis, Sanjay Gandhi.
+ */
+
+/*
+These includes are indeed overkill, but it appears that BSD is a bit more picky
+about include order, etc, than linux, and makekernel is going nuts over
+includes, so we're going to copy sched_4bsd.h and add some...
+
+Eventually, these should be pruned down, but for now, leave them.
+ */
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/cpuset.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/kthread.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/sysproto.h>
+#include <sys/syscall.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/sx.h>
+#include <sys/umtx.h>
+#include <sys/libkern.h>
+#include <sys/sched_heuristics.h>
+#include <machine/smp.h>
+
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif
+
+unsigned idle_count = 0;
+unsigned real_count = 0;
+
+static unsigned heuristic_constant = MAX_HEURISTIC_CONSTANT;
+static int ticks_to_preempt = DEFAULT_MIN_TICKS_TO_PREEMPT*2;
+
+int dimetrodon_idle_ticks = DEFAULT_DIMETRODON_IDLE_TICKS;
+
+int chosen_heuristic = SIMPLE_CONSTANT_WITH_MINTICKS;
+
+int dimetrodon_min_idle_ticks = DEFAULT_MIN_IDLETIME;
+int dimetrodon_chosen_idletime_kind = IDLETIME_SET_TICKS;
+
+static int calculate_heuristic(struct thread *td);
+
+void increment_idle_count(void)
+{
+	++idle_count;
+}
+
+void increment_real_count_cond(void)
+{
+	++real_count;
+}
+
+int sys_dimetrodon_get_stats(struct thread *td, struct sys_dimetrodon_get_stats_args *pa)
+{
+	if(pa->which <= 0)
+		td->td_retval[0] = idle_count;
+	else
+	{
+		td->td_retval[0] = real_count;
+	}
+
+	return 0;
+}
+
+int sys_dimetrodon_set_min_preempt(struct thread *td,
+			       struct sys_dimetrodon_set_min_preempt_args *pa)
+{
+	int newmin = pa->min;
+
+	if(newmin < 0)
+		return -1;
+
+	td->td_retval[0] = newmin;
+	ticks_to_preempt = newmin*2;
+
+	return 0;
+}
+
+int sys_dimetrodon_set_heuristic(struct thread *td,
+			     struct sys_dimetrodon_set_heuristic_args *pa)
+{
+	if(pa->which < 0 || pa->which > MAX_HEURISTIC)
+		return -1;
+
+	chosen_heuristic = pa->which;
+
+	return 0;
+}
+
+int sys_dimetrodon_set_idletime_kind(struct thread *td,
+				     struct sys_dimetrodon_set_idletime_kind_args *pa)
+{
+	if(pa->which != IDLETIME_RECENT_TIME && pa->which != IDLETIME_SET_TICKS)
+		return -1;
+
+	dimetrodon_chosen_idletime_kind = pa->which;
+
+	return 0;
+}
+
+
+int sys_dimetrodon_set_nopreempt(struct thread *td, struct sys_dimetrodon_set_nopreempt_args *pa)
+{
+	td->td_proc->dimetrodon_always_preempt = -1;
+
+	return 0;
+}
+
+int sys_dimetrodon_set_dopreempt(struct thread *td, struct sys_dimetrodon_set_dopreempt_args *pa)
+{
+	td->td_proc->dimetrodon_always_preempt = 1;
+
+	return 0;
+}
+
+int sys_dimetrodon_set_nopreempt_specify(struct thread *td, struct sys_dimetrodon_set_nopreempt_specify_args *pa)
+{
+        struct proc *current = pfind(pa->which);
+
+        if(current == 0)
+        {
+                return -1;
+        }
+
+        current->dimetrodon_always_preempt = -1;
+
+        PROC_UNLOCK(current);
+
+	td->td_retval[0] = pa->which;
+
+        return 0;
+}
+
+int sys_dimetrodon_set_dopreempt_specify(struct thread *td, struct sys_dimetrodon_set_dopreempt_specify_args *pa)
+{
+        struct proc *current = pfind(pa->which);
+
+        if(current == 0)
+        {
+                return -1;
+        }
+
+        current->dimetrodon_always_preempt = 1;
+
+        PROC_UNLOCK(current);
+
+	td->td_retval[0] = pa->which;
+
+        return 0;
+}
+
+int sys_dimetrodon_anoint_thread_specify(struct thread *td, struct sys_dimetrodon_anoint_thread_specify_args *pa)
+{
+        struct proc *current = pfind(pa->which);
+
+        if(current == 0)
+        {
+                return -1;
+        }
+
+        current->is_dimetrodon_anointed = 1;
+
+        PROC_UNLOCK(current);
+
+	td->td_retval[0] = pa->which;
+
+        return 0;
+}
+
+int sys_dimetrodon_unanoint_thread_specify(struct thread *td, struct sys_dimetrodon_unanoint_thread_specify_args *pa)
+{
+        struct proc *current = pfind(pa->which);
+
+        if(current == 0)
+        {
+                return -1;
+        }
+
+        current->is_dimetrodon_anointed = 0;
+
+        PROC_UNLOCK(current);
+
+	td->td_retval[0] = pa->which;
+
+        return 0;
+}
+
+int sys_dimetrodon_is_thread_anointed(struct thread *td, struct sys_dimetrodon_is_thread_anointed_args *pa)
+{
+        struct proc *current = pfind(pa->which);
+
+        if(current == 0)
+        {
+                return -1;
+        }
+
+        if(current->is_dimetrodon_anointed)
+	{
+		td->td_retval[0] = 1;
+	}
+	else
+	{
+		td->td_retval[0] = -1;
+	}
+
+        PROC_UNLOCK(current);
+
+        return 0;
+}
+
+int sys_dimetrodon_get_avg_quanta(struct thread *td, struct sys_dimetrodon_get_avg_quanta_args *pa)
+{
+        struct proc *current = pfind(pa->which);
+        if(current == 0)
+        {
+                return -1;
+        }
+
+	mtx_lock_spin(&current->tick_lock);
+
+	if(current->proc_numquanta == 0)
+	{
+	    td->td_retval[0] = -1;
+	}
+	else
+	{
+	    td->td_retval[0] = (current->proc_ticks)/
+	      (current->proc_numquanta);
+	}
+
+	mtx_unlock_spin(&current->tick_lock);
+
+        PROC_UNLOCK(current);
+
+
+        return 0;
+}
+
+int sys_dimetrodon_reset_quanta_count(struct thread *td, struct sys_dimetrodon_reset_quanta_count_args *pa)
+{
+        struct proc *current = pfind(pa->which);
+        if(current == 0)
+        {
+                return -1;
+        }
+
+	mtx_lock_spin(&current->tick_lock);
+
+	current->proc_ticks = 0;
+	current->proc_numquanta = 0;
+
+	mtx_unlock_spin(&current->tick_lock);
+
+        PROC_UNLOCK(current);
+
+	td->td_retval[0] = pa->which;
+
+        return 0;
+}
+
+int sys_dimetrodon_set_doregular(struct thread *td, struct sys_dimetrodon_set_doregular_args *pa)
+{
+	td->td_proc->dimetrodon_always_preempt = 0;
+	return 0;
+}
+
+int sys_dimetrodon_set_idle_ticks(struct thread *td,
+			      struct sys_dimetrodon_set_idle_ticks_args *pa)
+{
+	int newticks = pa->ticks;
+
+	if(newticks < 0)
+		return -1;
+
+	td->td_retval[0] = newticks;
+	dimetrodon_idle_ticks = newticks;
+
+	return 0;
+}
+
+int sys_dimetrodon_set_min_idle_ticks(struct thread *td,
+				      struct sys_dimetrodon_set_min_idle_ticks_args *pa)
+{
+	int newticks = pa->which;
+
+	if(newticks < 0)
+		return -1;
+
+	td->td_retval[0] = newticks;
+	dimetrodon_min_idle_ticks = newticks;
+
+	return 0;
+}
+
+
+int sys_set_dimetrodon_constant(struct thread *td,
+			    struct sys_set_dimetrodon_constant_args *pa)
+{
+	set_heuristic_constant(pa->value);
+	td->td_retval[0] = heuristic_constant;	
+	
+	return 0;
+}
+
+//technically we should synchronize this, but it doesn't really matter
+int set_heuristic_constant(int new)
+{
+	new *= 10;
+
+	if(new < 0 || new > MAX_HEURISTIC_CONSTANT)
+	{
+		return -1;
+	}
+
+	CTR1(KTR_SCHED, "set_heuristic_constant: setting constant to %u",
+	     new);
+
+	heuristic_constant = new;
+
+	return new;
+}
+
+static int thread_has_minticks(struct thread *td)
+{
+	//make sure we aren't going to preempt a short-running process
+	if((td->td_recenttick_old + td->td_recenttick_new) < ticks_to_preempt)
+	{
+		CTR4(KTR_SCHED, "do_schedule_now: %p(%s) too few recentticks: %d (min %d)",
+		     td, td->td_proc->p_comm, (td->td_recenttick_old+td->td_recenttick_new)/2, ticks_to_preempt);
+
+		return 0;
+	}
+
+	return 1;
+}
+
+static int simple_constant_heuristic(struct thread *td)
+{
+	return heuristic_constant;
+}
+
+static int calculate_heuristic(struct thread *td)
+{
+	if(td->td_proc->dimetrodon_always_preempt == -1)
+		return MAX_HEURISTIC_CONSTANT;
+	else if(td->td_proc->dimetrodon_always_preempt == 1)
+		return heuristic_constant;
+
+	switch(chosen_heuristic)
+	{
+	case SIMPLE_CONSTANT:
+		return simple_constant_heuristic(td);
+	case SIMPLE_CONSTANT_WITH_MINTICKS:
+		return thread_has_minticks(td) ? simple_constant_heuristic(td)
+			: MAX_HEURISTIC_CONSTANT;
+	case NONE:
+	default:
+		return MAX_HEURISTIC_CONSTANT;
+	}
+}
+
+int do_schedule_now(struct thread *td)
+{
+	KASSERT(!TD_IS_IDLETHREAD(td), "do_schedule_now idlethread?");
+
+	//don't preempt kernel threads
+	if(td->td_priority < PRI_MIN_TIMESHARE)
+	{
+		return 1;
+	}
+
+	int heuristic_value = calculate_heuristic(td);
+
+	if(heuristic_value >= MAX_HEURISTIC_CONSTANT)
+		return 1;
+
+	return ((random() % MAX_HEURISTIC_VALUE) < heuristic_value) ? 1 : 0;
+}
+
Index: sys/dev/acpica/acpi_cpu.c
===================================================================
--- sys/dev/acpica/acpi_cpu.c	(revision 379)
+++ sys/dev/acpica/acpi_cpu.c	(revision 781)
@@ -40,7 +40,7 @@
 #include <sys/proc.h>
 #include <sys/sbuf.h>
 #include <sys/smp.h>
-
+#include <sys/sched_heuristics.h>
 #include <dev/pci/pcivar.h>
 #include <machine/atomic.h>
 #include <machine/bus.h>
@@ -164,6 +164,8 @@
 static int	acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc, int val);
 static int	acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS);
 static int	acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS);
+static void acpi_cpu_c2(void);
+static uint32_t get_trans_lat(unsigned num);
 
 static device_method_t acpi_cpu_methods[] = {
     /* Device interface */
@@ -1191,3 +1193,24 @@
 
     return (0);
 }
+
+static void acpi_cpu_c2(void)
+{
+	struct acpi_cpu_softc *sc;
+	sc = cpu_softc[PCPU_GET(cpuid)];
+	
+	CPU_GET_REG(sc->cpu_cx_states[2].p_lvlx, 1);	
+}
+
+static uint32_t get_trans_lat(unsigned num)
+{
+	struct acpi_cpu_softc *sc;
+
+	if(num >= MAX_CX_STATES)
+	{
+		return 0;
+	}
+	
+	sc = cpu_softc[PCPU_GET(cpuid)];
+	return sc->cpu_cx_states[num].trans_lat;
+}
Index: sys/compat/freebsd32/syscalls.master
===================================================================
--- sys/compat/freebsd32/syscalls.master	(revision 379)
+++ sys/compat/freebsd32/syscalls.master	(revision 781)
@@ -1,11 +1,10 @@
  $FreeBSD$
 ;	from: @(#)syscalls.master	8.2 (Berkeley) 1/13/94
-;	from: src/sys/kern/syscalls.master 1.107
 ;
 ; System call name/number master file.
 ; Processed to created init_sysent.c, syscalls.c and syscall.h.
 
-; Columns: number audit type nargs name alt{name,tag,rtyp}/comments
+; Columns: number audit type name alt{name,tag,rtyp}/comments
 ;	number	system call number, must be in order
 ;	audit	the audit event associated with the system call
 ;		A value of AUE_NULL means no auditing, but it also means that
@@ -39,15 +38,15 @@
 ;		function prototype in sys/sysproto.h.  Does add a
 ;		definition to syscall.h besides adding a sysent.
 
+;
+; Please copy any additions and changes to the following compatability tables:
+; sys/compat/freebsd32/syscalls.master
+
 ; #ifdef's, etc. may be included, and are copied to the output files.
 
 #include <sys/param.h>
 #include <sys/sysent.h>
 #include <sys/sysproto.h>
-#include <sys/mount.h>
-#include <sys/socket.h>
-#include <compat/freebsd32/freebsd32.h>
-#include <compat/freebsd32/freebsd32_proto.h>
 
 ; Reserved/unimplemented system calls in the range 0-150 inclusive
 ; are reserved for use in future Berkeley releases.
@@ -55,224 +54,249 @@
 ; redistributions should be placed in the reserved range at the end
 ; of the current calls.
 
-0	AUE_NULL	NOPROTO	{ int nosys(void); } syscall nosys_args int
-1	AUE_EXIT	NOPROTO	{ void sys_exit(int rval); } exit \
+0	AUE_NULL	STD	{ int nosys(void); } syscall nosys_args int
+1	AUE_EXIT	STD	{ void sys_exit(int rval); } exit \
 				    sys_exit_args void
-2	AUE_FORK	NOPROTO	{ int fork(void); }
-3	AUE_READ	NOPROTO	{ ssize_t read(int fd, void *buf, \
+2	AUE_FORK	STD	{ int fork(void); }
+3	AUE_NULL	STD	{ ssize_t read(int fd, void *buf, \
 				    size_t nbyte); }
-4	AUE_WRITE	NOPROTO	{ ssize_t write(int fd, const void *buf, \
+4	AUE_NULL	STD	{ ssize_t write(int fd, const void *buf, \
 				    size_t nbyte); }
-5	AUE_OPEN_RWTC	NOPROTO	{ int open(char *path, int flags, \
-				    int mode); }
-6	AUE_CLOSE	NOPROTO	{ int close(int fd); }
-7	AUE_WAIT4	STD	{ int freebsd32_wait4(int pid, int *status, \
-				    int options, struct rusage32 *rusage); }
-8	AUE_CREAT	OBSOL	old creat
-9	AUE_LINK	NOPROTO	{ int link(char *path, char *link); }
-10	AUE_UNLINK	NOPROTO	{ int unlink(char *path); }
+5	AUE_OPEN_RWTC	STD	{ int open(char *path, int flags, int mode); }
+; XXX should be		{ int open(const char *path, int flags, ...); }
+; but we're not ready for `const' or varargs.
+; XXX man page says `mode_t mode'.
+6	AUE_CLOSE	STD	{ int close(int fd); }
+7	AUE_WAIT4	STD	{ int wait4(int pid, int *status, \
+				    int options, struct rusage *rusage); } \
+				    wait4 wait_args int
+8	AUE_CREAT	COMPAT	{ int creat(char *path, int mode); }
+9	AUE_LINK	STD	{ int link(char *path, char *link); }
+10	AUE_UNLINK	STD	{ int unlink(char *path); }
 11	AUE_NULL	OBSOL	execv
-12	AUE_CHDIR	NOPROTO	{ int chdir(char *path); }
-13	AUE_FCHDIR	NOPROTO	{ int fchdir(int fd); }
-14	AUE_MKNOD	NOPROTO	{ int mknod(char *path, int mode, int dev); }
-15	AUE_CHMOD	NOPROTO	{ int chmod(char *path, int mode); }
-16	AUE_CHOWN	NOPROTO	{ int chown(char *path, int uid, int gid); }
-17	AUE_NULL	NOPROTO	{ int obreak(char *nsize); } break \
+12	AUE_CHDIR	STD	{ int chdir(char *path); }
+13	AUE_FCHDIR	STD	{ int fchdir(int fd); }
+14	AUE_MKNOD	STD	{ int mknod(char *path, int mode, int dev); }
+15	AUE_CHMOD	STD	{ int chmod(char *path, int mode); }
+16	AUE_CHOWN	STD	{ int chown(char *path, int uid, int gid); }
+17	AUE_NULL	STD	{ int obreak(char *nsize); } break \
 				    obreak_args int
-18	AUE_GETFSSTAT	COMPAT4	{ int freebsd32_getfsstat( \
-				    struct statfs32 *buf, long bufsize, \
-				    int flags); }
-19	AUE_LSEEK	OBSOL	olseek
-20	AUE_GETPID	NOPROTO	{ pid_t getpid(void); }
-21	AUE_MOUNT	NOPROTO	{ int mount(char *type, char *path, \
+18	AUE_GETFSSTAT	COMPAT4	{ int getfsstat(struct ostatfs *buf, \
+				    long bufsize, int flags); }
+19	AUE_LSEEK	COMPAT	{ long lseek(int fd, long offset, \
+				    int whence); }
+20	AUE_GETPID	STD	{ pid_t getpid(void); }
+21	AUE_MOUNT	STD	{ int mount(char *type, char *path, \
 				    int flags, caddr_t data); }
-22	AUE_UMOUNT	NOPROTO	{ int unmount(char *path, int flags); }
-23	AUE_SETUID	NOPROTO	{ int setuid(uid_t uid); }
-24	AUE_GETUID	NOPROTO	{ uid_t getuid(void); }
-25	AUE_GETEUID	NOPROTO	{ uid_t geteuid(void); }
-26	AUE_PTRACE	NOPROTO	{ int ptrace(int req, pid_t pid, \
+; XXX `path' should have type `const char *' but we're not ready for that.
+22	AUE_UMOUNT	STD	{ int unmount(char *path, int flags); }
+23	AUE_SETUID	STD	{ int setuid(uid_t uid); }
+24	AUE_GETUID	STD	{ uid_t getuid(void); }
+25	AUE_GETEUID	STD	{ uid_t geteuid(void); }
+26	AUE_PTRACE	STD	{ int ptrace(int req, pid_t pid, \
 				    caddr_t addr, int data); }
-27	AUE_RECVMSG	STD	{ int freebsd32_recvmsg(int s, struct msghdr32 *msg, \
+27	AUE_RECVMSG	STD	{ int recvmsg(int s, struct msghdr *msg, \
 				    int flags); }
-28	AUE_SENDMSG	STD	{ int freebsd32_sendmsg(int s, struct msghdr32 *msg, \
+28	AUE_SENDMSG	STD	{ int sendmsg(int s, struct msghdr *msg, \
 				    int flags); }
-29	AUE_RECVFROM	STD	{ int freebsd32_recvfrom(int s, u_int32_t buf, \
-				    u_int32_t len, int flags, u_int32_t from, \
-				    u_int32_t fromlenaddr); }
-30	AUE_ACCEPT	NOPROTO	{ int accept(int s, caddr_t name, \
-				    int *anamelen); }
-31	AUE_GETPEERNAME	NOPROTO	{ int getpeername(int fdes, caddr_t asa, \
-				    int *alen); }
-32	AUE_GETSOCKNAME	NOPROTO	{ int getsockname(int fdes, caddr_t asa, \
-				    int *alen); }
-33	AUE_ACCESS	NOPROTO	{ int access(char *path, int flags); }
-34	AUE_CHFLAGS	NOPROTO	{ int chflags(char *path, int flags); }
-35	AUE_FCHFLAGS	NOPROTO	{ int fchflags(int fd, int flags); }
-36	AUE_SYNC	NOPROTO	{ int sync(void); }
-37	AUE_KILL	NOPROTO	{ int kill(int pid, int signum); }
-38	AUE_STAT	UNIMPL	ostat
-39	AUE_GETPPID	NOPROTO	{ pid_t getppid(void); }
-40	AUE_LSTAT	UNIMPL	olstat
-41	AUE_DUP		NOPROTO	{ int dup(u_int fd); }
-42	AUE_PIPE	NOPROTO	{ int pipe(void); }
-43	AUE_GETEGID	NOPROTO	{ gid_t getegid(void); }
-44	AUE_PROFILE	NOPROTO	{ int profil(caddr_t samples, size_t size, \
+29	AUE_RECVFROM	STD	{ int recvfrom(int s, caddr_t buf, \
+				    size_t len, int flags, \
+				    struct sockaddr * __restrict from, \
+				    __socklen_t * __restrict fromlenaddr); }
+30	AUE_ACCEPT	STD	{ int accept(int s, \
+				    struct sockaddr * __restrict name, \
+				    __socklen_t * __restrict anamelen); }
+31	AUE_GETPEERNAME	STD	{ int getpeername(int fdes, \
+				    struct sockaddr * __restrict asa, \
+				    __socklen_t * __restrict alen); }
+32	AUE_GETSOCKNAME	STD	{ int getsockname(int fdes, \
+				    struct sockaddr * __restrict asa, \
+				    __socklen_t * __restrict alen); }
+33	AUE_ACCESS	STD	{ int access(char *path, int flags); }
+34	AUE_CHFLAGS	STD	{ int chflags(char *path, int flags); }
+35	AUE_FCHFLAGS	STD	{ int fchflags(int fd, int flags); }
+36	AUE_SYNC	STD	{ int sync(void); }
+37	AUE_KILL	STD	{ int kill(int pid, int signum); }
+38	AUE_STAT	COMPAT	{ int stat(char *path, struct ostat *ub); }
+39	AUE_GETPPID	STD	{ pid_t getppid(void); }
+40	AUE_LSTAT	COMPAT	{ int lstat(char *path, struct ostat *ub); }
+41	AUE_DUP		STD	{ int dup(u_int fd); }
+42	AUE_PIPE	STD	{ int pipe(void); }
+43	AUE_GETEGID	STD	{ gid_t getegid(void); }
+44	AUE_PROFILE	STD	{ int profil(caddr_t samples, size_t size, \
 				    size_t offset, u_int scale); }
-45	AUE_KTRACE	NOPROTO	{ int ktrace(const char *fname, int ops, \
+45	AUE_KTRACE	STD	{ int ktrace(const char *fname, int ops, \
 				    int facs, int pid); }
-46	AUE_SIGACTION	COMPAT	{ int freebsd32_sigaction( int signum, \
-				   struct osigaction32 *nsa, \
-				   struct osigaction32 *osa); }
-47	AUE_GETGID	NOPROTO	{ gid_t getgid(void); }
-48	AUE_SIGPROCMASK	COMPAT	{ int freebsd32_sigprocmask(int how, \
-				   osigset_t mask); }
-49	AUE_GETLOGIN	NOPROTO	{ int getlogin(char *namebuf, \
-				    u_int namelen); }
-50	AUE_SETLOGIN	NOPROTO	{ int setlogin(char *namebuf); }
-51	AUE_ACCT	NOPROTO	{ int acct(char *path); }
-52	AUE_SIGPENDING	COMPAT	{ int freebsd32_sigpending(void); }
-53	AUE_SIGALTSTACK	STD	{ int freebsd32_sigaltstack( \
-				    struct sigaltstack32 *ss, \
-				    struct sigaltstack32 *oss); }
-54	AUE_NULL	STD	{ int freebsd32_ioctl(int fd, uint32_t com, \
-				    struct md_ioctl32 *data); }
-55	AUE_REBOOT	NOPROTO	{ int reboot(int opt); }
-56	AUE_REVOKE	NOPROTO	{ int revoke(char *path); }
-57	AUE_SYMLINK	NOPROTO	{ int symlink(char *path, char *link); }
-58	AUE_READLINK	NOPROTO	{ int readlink(char *path, char *buf, \
+46	AUE_SIGACTION	COMPAT	{ int sigaction(int signum, \
+				    struct osigaction *nsa, \
+				    struct osigaction *osa); }
+47	AUE_GETGID	STD	{ gid_t getgid(void); }
+48	AUE_SIGPROCMASK	COMPAT	{ int sigprocmask(int how, osigset_t mask); }
+; XXX note nonstandard (bogus) calling convention - the libc stub passes
+; us the mask, not a pointer to it, and we return the old mask as the
+; (int) return value.
+49	AUE_GETLOGIN	STD	{ int getlogin(char *namebuf, u_int \
+				    namelen); }
+50	AUE_SETLOGIN	STD	{ int setlogin(char *namebuf); }
+51	AUE_ACCT	STD	{ int acct(char *path); }
+52	AUE_SIGPENDING	COMPAT	{ int sigpending(void); }
+53	AUE_SIGALTSTACK	STD	{ int sigaltstack(stack_t *ss, \
+				    stack_t *oss); }
+54	AUE_IOCTL	STD	{ int ioctl(int fd, u_long com, \
+				    caddr_t data); }
+55	AUE_REBOOT	STD	{ int reboot(int opt); }
+56	AUE_REVOKE	STD	{ int revoke(char *path); }
+57	AUE_SYMLINK	STD	{ int symlink(char *path, char *link); }
+58	AUE_READLINK	STD	{ int readlink(char *path, char *buf, \
 				    int count); }
-59	AUE_EXECVE	STD	{ int freebsd32_execve(char *fname, \
-				    u_int32_t *argv, u_int32_t *envv); }
-60	AUE_UMASK	NOPROTO	{ int umask(int newmask); } umask \
-				    umask_args int
-61	AUE_CHROOT	NOPROTO	{ int chroot(char *path); }
-62	AUE_FSTAT	OBSOL	ofstat
-63	AUE_NULL	OBSOL	ogetkerninfo
-64	AUE_NULL	OBSOL	ogetpagesize
-65	AUE_MSYNC	NOPROTO	{ int msync(void *addr, size_t len, \
+59	AUE_EXECVE	STD	{ int execve(char *fname, char **argv, \
+				    char **envv); }
+60	AUE_UMASK	STD	{ int umask(int newmask); } umask umask_args \
+				    int
+61	AUE_CHROOT	STD	{ int chroot(char *path); }
+62	AUE_FSTAT	COMPAT	{ int fstat(int fd, struct ostat *sb); }
+63	AUE_NULL	COMPAT	{ int getkerninfo(int op, char *where, \
+				    size_t *size, int arg); } getkerninfo \
+				    getkerninfo_args int
+64	AUE_NULL	COMPAT	{ int getpagesize(void); } getpagesize \
+				    getpagesize_args int
+65	AUE_MSYNC	STD	{ int msync(void *addr, size_t len, \
 				    int flags); }
-66	AUE_VFORK	NOPROTO	{ int vfork(void); }
+66	AUE_VFORK	STD	{ int vfork(void); }
 67	AUE_NULL	OBSOL	vread
 68	AUE_NULL	OBSOL	vwrite
-69	AUE_SBRK	NOPROTO	{ int sbrk(int incr); }
-70	AUE_SSTK	NOPROTO	{ int sstk(int incr); }
-71	AUE_MMAP	OBSOL	ommap
-72	AUE_O_VADVISE	NOPROTO	{ int ovadvise(int anom); } vadvise \
+69	AUE_SBRK	STD	{ int sbrk(int incr); }
+70	AUE_SSTK	STD	{ int sstk(int incr); }
+71	AUE_MMAP	COMPAT	{ int mmap(void *addr, int len, int prot, \
+				    int flags, int fd, long pos); }
+72	AUE_O_VADVISE	STD	{ int ovadvise(int anom); } vadvise \
 				    ovadvise_args int
-73	AUE_MUNMAP	NOPROTO	{ int munmap(void *addr, size_t len); }
-74	AUE_MPROTECT	NOPROTO	{ int mprotect(const void *addr, \
-				    size_t len, int prot); }
-75	AUE_MADVISE	NOPROTO	{ int madvise(void *addr, size_t len, \
+73	AUE_MUNMAP	STD	{ int munmap(void *addr, size_t len); }
+74	AUE_MPROTECT	STD	{ int mprotect(const void *addr, size_t len, \
+				    int prot); }
+75	AUE_MADVISE	STD	{ int madvise(void *addr, size_t len, \
 				    int behav); }
 76	AUE_NULL	OBSOL	vhangup
 77	AUE_NULL	OBSOL	vlimit
-78	AUE_MINCORE	NOPROTO	{ int mincore(const void *addr, size_t len, \
+78	AUE_MINCORE	STD	{ int mincore(const void *addr, size_t len, \
 				    char *vec); }
-79	AUE_GETGROUPS	NOPROTO	{ int getgroups(u_int gidsetsize, \
+79	AUE_GETGROUPS	STD	{ int getgroups(u_int gidsetsize, \
 				    gid_t *gidset); }
-80	AUE_SETGROUPS	NOPROTO	{ int setgroups(u_int gidsetsize, \
+80	AUE_SETGROUPS	STD	{ int setgroups(u_int gidsetsize, \
 				    gid_t *gidset); }
-81	AUE_GETPGRP	NOPROTO	{ int getpgrp(void); }
-82	AUE_SETPGRP	NOPROTO	{ int setpgid(int pid, int pgid); }
-83	AUE_SETITIMER	STD	{ int freebsd32_setitimer(u_int which, \
-				    struct itimerval32 *itv, \
-				    struct itimerval32 *oitv); }
-84	AUE_NULL	OBSOL	owait
-; XXX implement
-85	AUE_SWAPON	NOPROTO	{ int swapon(char *name); }
-86	AUE_GETITIMER	STD	{ int freebsd32_getitimer(u_int which, \
-				    struct itimerval32 *itv); }
-87	AUE_O_GETHOSTNAME	OBSOL	ogethostname
-88	AUE_O_SETHOSTNAME	OBSOL	osethostname
-89	AUE_GETDTABLESIZE	NOPROTO	{ int getdtablesize(void); }
-90	AUE_DUP2	NOPROTO	{ int dup2(u_int from, u_int to); }
+81	AUE_GETPGRP	STD	{ int getpgrp(void); }
+82	AUE_SETPGRP	STD	{ int setpgid(int pid, int pgid); }
+83	AUE_SETITIMER	STD	{ int setitimer(u_int which, struct \
+				    itimerval *itv, struct itimerval *oitv); }
+84	AUE_WAIT4	COMPAT	{ int wait(void); }
+85	AUE_SWAPON	STD	{ int swapon(char *name); }
+86	AUE_GETITIMER	STD	{ int getitimer(u_int which, \
+				    struct itimerval *itv); }
+87	AUE_SYSCTL	COMPAT	{ int gethostname(char *hostname, \
+				    u_int len); } gethostname \
+				    gethostname_args int
+88	AUE_SYSCTL	COMPAT	{ int sethostname(char *hostname, \
+				    u_int len); } sethostname \
+				    sethostname_args int
+89	AUE_GETDTABLESIZE	STD	{ int getdtablesize(void); }
+90	AUE_DUP2	STD	{ int dup2(u_int from, u_int to); }
 91	AUE_NULL	UNIMPL	getdopt
-92	AUE_FCNTL	NOPROTO	{ int fcntl(int fd, int cmd, long arg); }
-93	AUE_SELECT	STD	{ int freebsd32_select(int nd, fd_set *in, \
-				    fd_set *ou, fd_set *ex, \
-				    struct timeval32 *tv); }
-; XXX need to override for big-endian - little-endian should work fine.
+92	AUE_FCNTL	STD	{ int fcntl(int fd, int cmd, long arg); }
+; XXX should be	{ int fcntl(int fd, int cmd, ...); }
+; but we're not ready for varargs.
+93	AUE_SELECT	STD	{ int select(int nd, fd_set *in, fd_set *ou, \
+				    fd_set *ex, struct timeval *tv); }
 94	AUE_NULL	UNIMPL	setdopt
-95	AUE_FSYNC	NOPROTO	{ int fsync(int fd); }
-96	AUE_SETPRIORITY	NOPROTO	{ int setpriority(int which, int who, \
+95	AUE_FSYNC	STD	{ int fsync(int fd); }
+96	AUE_SETPRIORITY	STD	{ int setpriority(int which, int who, \
 				    int prio); }
-97	AUE_SOCKET	NOPROTO	{ int socket(int domain, int type, \
+97	AUE_SOCKET	STD	{ int socket(int domain, int type, \
 				    int protocol); }
-98	AUE_CONNECT	NOPROTO	{ int connect(int s, caddr_t name, \
+98	AUE_CONNECT	STD	{ int connect(int s, caddr_t name, \
 				    int namelen); }
-99	AUE_NULL	OBSOL	oaccept
-100	AUE_GETPRIORITY	NOPROTO	{ int getpriority(int which, int who); }
-101	AUE_NULL	OBSOL	osend
-102	AUE_NULL	OBSOL	orecv
-103	AUE_NULL	OBSOL	osigreturn
-104	AUE_BIND	NOPROTO	{ int bind(int s, caddr_t name, \
+99	AUE_ACCEPT	CPT_NOA	{ int accept(int s, caddr_t name, \
+				    int *anamelen); } accept accept_args int
+100	AUE_GETPRIORITY	STD	{ int getpriority(int which, int who); }
+101	AUE_SEND	COMPAT	{ int send(int s, caddr_t buf, int len, \
+				    int flags); }
+102	AUE_RECV	COMPAT	{ int recv(int s, caddr_t buf, int len, \
+				    int flags); }
+103	AUE_SIGRETURN	COMPAT	{ int sigreturn( \
+				    struct osigcontext *sigcntxp); }
+104	AUE_BIND	STD	{ int bind(int s, caddr_t name, \
 				    int namelen); }
-105	AUE_SETSOCKOPT	NOPROTO	{ int setsockopt(int s, int level, \
-				    int name, caddr_t val, int valsize); }
-106	AUE_LISTEN	NOPROTO	{ int listen(int s, int backlog); }
+105	AUE_SETSOCKOPT	STD	{ int setsockopt(int s, int level, int name, \
+				    caddr_t val, int valsize); }
+106	AUE_LISTEN	STD	{ int listen(int s, int backlog); }
 107	AUE_NULL	OBSOL	vtimes
-108	AUE_O_SIGVEC	COMPAT	{ int freebsd32_sigvec(int signum, \
-				     struct sigvec32 *nsv, \
-				     struct sigvec32 *osv); }
-109	AUE_O_SIGBLOCK	COMPAT	{ int freebsd32_sigblock(int mask); }
-110	AUE_O_SIGSETMASK	COMPAT	{ int freebsd32_sigsetmask( int mask); }
-111	AUE_SIGSUSPEND	COMPAT	{ int freebsd32_sigsuspend( int mask); }
-112	AUE_O_SIGSTACK	COMPAT	{ int freebsd32_sigstack( \
-				     struct sigstack32 *nss, \
-				     struct sigstack32 *oss); }
-113	AUE_NULL	OBSOL	orecvmsg
-114	AUE_NULL	OBSOL	osendmsg
+108	AUE_NULL	COMPAT	{ int sigvec(int signum, struct sigvec *nsv, \
+				    struct sigvec *osv); }
+109	AUE_NULL	COMPAT	{ int sigblock(int mask); }
+110	AUE_NULL	COMPAT	{ int sigsetmask(int mask); }
+111	AUE_NULL	COMPAT	{ int sigsuspend(osigset_t mask); }
+; XXX note nonstandard (bogus) calling convention - the libc stub passes
+; us the mask, not a pointer to it.
+112	AUE_NULL	COMPAT	{ int sigstack(struct sigstack *nss, \
+				    struct sigstack *oss); }
+113	AUE_RECVMSG	COMPAT	{ int recvmsg(int s, struct omsghdr *msg, \
+				    int flags); }
+114	AUE_SENDMSG	COMPAT	{ int sendmsg(int s, caddr_t msg, \
+				    int flags); }
 115	AUE_NULL	OBSOL	vtrace
-116	AUE_GETTIMEOFDAY	STD	{ int freebsd32_gettimeofday( \
-				    struct timeval32 *tp, \
+116	AUE_GETTIMEOFDAY	STD	{ int gettimeofday(struct timeval *tp, \
 				    struct timezone *tzp); }
-117	AUE_GETRUSAGE	STD	{ int freebsd32_getrusage(int who, \
-				    struct rusage32 *rusage); }
-118	AUE_GETSOCKOPT	NOPROTO	{ int getsockopt(int s, int level, \
-				    int name, caddr_t val, int *avalsize); }
+117	AUE_GETRUSAGE	STD	{ int getrusage(int who, \
+				    struct rusage *rusage); }
+118	AUE_GETSOCKOPT	STD	{ int getsockopt(int s, int level, int name, \
+				    caddr_t val, int *avalsize); }
 119	AUE_NULL	UNIMPL	resuba (BSD/OS 2.x)
-120	AUE_READV	STD	{ int freebsd32_readv(int fd, \
-				    struct iovec32 *iovp, u_int iovcnt); }
-121	AUE_WRITEV	STD	{ int freebsd32_writev(int fd, \
-				    struct iovec32 *iovp, u_int iovcnt); }
-122	AUE_SETTIMEOFDAY	STD	{ int freebsd32_settimeofday( \
-				    struct timeval32 *tv, \
+120	AUE_READV	STD	{ int readv(int fd, struct iovec *iovp, \
+				    u_int iovcnt); }
+121	AUE_WRITEV	STD	{ int writev(int fd, struct iovec *iovp, \
+				    u_int iovcnt); }
+122	AUE_SETTIMEOFDAY	STD	{ int settimeofday(struct timeval *tv, \
 				    struct timezone *tzp); }
-123	AUE_FCHOWN	NOPROTO	{ int fchown(int fd, int uid, int gid); }
-124	AUE_FCHMOD	NOPROTO	{ int fchmod(int fd, int mode); }
-125	AUE_RECVFROM	OBSOL	orecvfrom
-126	AUE_SETREUID	NOPROTO	{ int setreuid(int ruid, int euid); }
-127	AUE_SETREGID	NOPROTO	{ int setregid(int rgid, int egid); }
-128	AUE_RENAME	NOPROTO	{ int rename(char *from, char *to); }
-129	AUE_TRUNCATE	OBSOL	otruncate
-130	AUE_FTRUNCATE	OBSOL	ftruncate
-131	AUE_FLOCK	NOPROTO	{ int flock(int fd, int how); }
-132	AUE_MKFIFO	NOPROTO	{ int mkfifo(char *path, int mode); }
-133	AUE_SENDTO	NOPROTO	{ int sendto(int s, caddr_t buf, \
-				    size_t len, int flags, caddr_t to, \
-				    int tolen); }
-134	AUE_SHUTDOWN	NOPROTO	{ int shutdown(int s, int how); }
-135	AUE_SOCKETPAIR	NOPROTO	{ int socketpair(int domain, int type, \
+123	AUE_FCHOWN	STD	{ int fchown(int fd, int uid, int gid); }
+124	AUE_FCHMOD	STD	{ int fchmod(int fd, int mode); }
+125	AUE_RECVFROM	CPT_NOA	{ int recvfrom(int s, caddr_t buf, \
+				    size_t len, int flags, caddr_t from, int \
+				    *fromlenaddr); } recvfrom recvfrom_args \
+				    int
+126	AUE_SETREUID	STD	{ int setreuid(int ruid, int euid); }
+127	AUE_SETREGID	STD	{ int setregid(int rgid, int egid); }
+128	AUE_RENAME	STD	{ int rename(char *from, char *to); }
+129	AUE_TRUNCATE	COMPAT	{ int truncate(char *path, long length); }
+130	AUE_FTRUNCATE	COMPAT	{ int ftruncate(int fd, long length); }
+131	AUE_FLOCK	STD	{ int flock(int fd, int how); }
+132	AUE_MKFIFO	STD	{ int mkfifo(char *path, int mode); }
+133	AUE_SENDTO	STD	{ int sendto(int s, caddr_t buf, size_t len, \
+				    int flags, caddr_t to, int tolen); }
+134	AUE_SHUTDOWN	STD	{ int shutdown(int s, int how); }
+135	AUE_SOCKETPAIR	STD	{ int socketpair(int domain, int type, \
 				    int protocol, int *rsv); }
-136	AUE_MKDIR	NOPROTO	{ int mkdir(char *path, int mode); }
-137	AUE_RMDIR	NOPROTO	{ int rmdir(char *path); }
-138	AUE_UTIMES	STD	{ int freebsd32_utimes(char *path, \
-				    struct timeval32 *tptr); }
+136	AUE_MKDIR	STD	{ int mkdir(char *path, int mode); }
+137	AUE_RMDIR	STD	{ int rmdir(char *path); }
+138	AUE_UTIMES	STD	{ int utimes(char *path, \
+				    struct timeval *tptr); }
 139	AUE_NULL	OBSOL	4.2 sigreturn
-140	AUE_ADJTIME	STD	{ int freebsd32_adjtime( \
-				    struct timeval32 *delta, \
-				    struct timeval32 *olddelta); }
-141	AUE_GETPEERNAME	OBSOL	ogetpeername
-142	AUE_SYSCTL	OBSOL	ogethostid
-143	AUE_SYSCTL	OBSOL	sethostid
-144	AUE_GETRLIMIT	OBSOL	getrlimit
-145	AUE_SETRLIMIT	OBSOL	setrlimit
-146	AUE_KILLPG	OBSOL	killpg
-147	AUE_SETSID	NOPROTO	{ int setsid(void); }
-148	AUE_QUOTACTL	NOPROTO	{ int quotactl(char *path, int cmd, int uid, \
+140	AUE_ADJTIME	STD	{ int adjtime(struct timeval *delta, \
+				    struct timeval *olddelta); }
+141	AUE_GETPEERNAME	COMPAT	{ int getpeername(int fdes, caddr_t asa, \
+				    int *alen); }
+142	AUE_SYSCTL	COMPAT	{ long gethostid(void); }
+143	AUE_SYSCTL	COMPAT	{ int sethostid(long hostid); }
+144	AUE_GETRLIMIT	COMPAT	{ int getrlimit(u_int which, struct \
+				    orlimit *rlp); }
+145	AUE_SETRLIMIT	COMPAT	{ int setrlimit(u_int which, \
+				    struct orlimit *rlp); }
+146	AUE_KILLPG	COMPAT	{ int killpg(int pgid, int signum); }
+147	AUE_SETSID	STD	{ int setsid(void); }
+148	AUE_QUOTACTL	STD	{ int quotactl(char *path, int cmd, int uid, \
 				    caddr_t arg); }
-149	AUE_O_QUOTA	OBSOL oquota
-150	AUE_GETSOCKNAME	OBSOL ogetsockname
+149	AUE_O_QUOTA	COMPAT	{ int quota(void); }
+150	AUE_GETSOCKNAME	CPT_NOA	{ int getsockname(int fdec, \
+				    caddr_t asa, int *alen); } getsockname \
+				    getsockname_args int
 
 ; Syscalls 151-180 inclusive are reserved for vendor-specific
 ; system calls.  (This includes various calls added for compatibity
@@ -282,163 +306,156 @@
 152	AUE_NULL	UNIMPL	sem_wakeup (BSD/OS 2.x)
 153	AUE_NULL	UNIMPL	asyncdaemon (BSD/OS 2.x)
 ; 154 is initialised by the NLM code, if present.
-154	AUE_NULL	UNIMPL	nlm_syscall
+154	AUE_NULL	NOSTD	{ int nlm_syscall(int debug_level, int grace_period, int addr_count, char **addrs); }
 ; 155 is initialized by the NFS code, if present.
-; XXX this is a problem!!!
-155	AUE_NFS_SVC	UNIMPL	nfssvc
-156	AUE_GETDIRENTRIES	OBSOL	ogetdirentries
-157	AUE_STATFS	COMPAT4	{ int freebsd32_statfs(char *path, \
-				    struct statfs32 *buf); }
-158	AUE_FSTATFS	COMPAT4	{ int freebsd32_fstatfs(int fd, \
-				    struct statfs32 *buf); }
+155	AUE_NFS_SVC	NOSTD	{ int nfssvc(int flag, caddr_t argp); }
+156	AUE_GETDIRENTRIES	COMPAT	{ int getdirentries(int fd, char *buf, \
+				    u_int count, long *basep); }
+157	AUE_STATFS	COMPAT4	{ int statfs(char *path, \
+				    struct ostatfs *buf); }
+158	AUE_FSTATFS	COMPAT4	{ int fstatfs(int fd, \
+				    struct ostatfs *buf); }
 159	AUE_NULL	UNIMPL	nosys
-160	AUE_LGETFH	UNIMPL	lgetfh
-161	AUE_NFS_GETFH	NOPROTO	{ int getfh(char *fname, \
+160	AUE_LGETFH	STD	{ int lgetfh(char *fname, \
 				    struct fhandle *fhp); }
-162	AUE_SYSCTL	NOPROTO	{ int getdomainname(char *domainname, \
+161	AUE_NFS_GETFH	STD	{ int getfh(char *fname, \
+				    struct fhandle *fhp); }
+162	AUE_SYSCTL	STD	{ int getdomainname(char *domainname, \
 				    int len); }
-163	AUE_SYSCTL	NOPROTO	{ int setdomainname(char *domainname, \
+163	AUE_SYSCTL	STD	{ int setdomainname(char *domainname, \
 				    int len); }
-164	AUE_NULL	NOPROTO	{ int uname(struct utsname *name); }
-165	AUE_SYSARCH	NOPROTO	{ int sysarch(int op, char *parms); }
-166	AUE_RTPRIO	NOPROTO	{ int rtprio(int function, pid_t pid, \
+164	AUE_NULL	STD	{ int uname(struct utsname *name); }
+165	AUE_SYSARCH	STD	{ int sysarch(int op, char *parms); }
+166	AUE_RTPRIO	STD	{ int rtprio(int function, pid_t pid, \
 				    struct rtprio *rtp); }
 167	AUE_NULL	UNIMPL	nosys
 168	AUE_NULL	UNIMPL	nosys
-169	AUE_SEMSYS	STD	{ int freebsd32_semsys(int which, int a2, \
-				    int a3, int a4, int a5); }
-170	AUE_MSGSYS	STD	{ int freebsd32_msgsys(int which, int a2, \
-				    int a3, int a4, int a5, int a6); }
-171	AUE_SHMSYS	STD	{ int freebsd32_shmsys(uint32_t which, uint32_t a2, \
-				    uint32_t a3, uint32_t a4); }
+; 169 is initialized by the SYSVSEM code if present or loaded
+169	AUE_SEMSYS	NOSTD	{ int semsys(int which, int a2, int a3, \
+				    int a4, int a5); }
+; 169 is initialized by the SYSVMSG code if present or loaded
+; XXX should be	{ int semsys(int which, ...); }
+170	AUE_MSGSYS	NOSTD	{ int msgsys(int which, int a2, int a3, \
+				    int a4, int a5, int a6); }
+; 169 is initialized by the SYSVSHM code if present or loaded
+; XXX should be	{ int msgsys(int which, ...); }
+171	AUE_SHMSYS	NOSTD	{ int shmsys(int which, int a2, int a3, \
+				    int a4); }
+; XXX should be	{ int shmsys(int which, ...); }
 172	AUE_NULL	UNIMPL	nosys
-173	AUE_PREAD	COMPAT6	{ ssize_t freebsd32_pread(int fd, void *buf, \
-				    size_t nbyte, int pad, \
-				    u_int32_t offsetlo, u_int32_t offsethi); }
-; XXX note - bigendian is different
-174	AUE_PWRITE	COMPAT6	{ ssize_t freebsd32_pwrite(int fd, \
-				    const void *buf, size_t nbyte, int pad, \
-				    u_int32_t offsetlo, u_int32_t offsethi); }
-; XXX note - bigendian is different
-175	AUE_NULL	UNIMPL	nosys
-176	AUE_NTP_ADJTIME	NOPROTO	{ int ntp_adjtime(struct timex *tp); }
+173	AUE_PREAD	STD	{ ssize_t freebsd6_pread(int fd, void *buf, \
+				    size_t nbyte, int pad, off_t offset); }
+174	AUE_PWRITE	STD	{ ssize_t freebsd6_pwrite(int fd, \
+				    const void *buf, \
+				    size_t nbyte, int pad, off_t offset); }
+175	AUE_NULL	STD	{ int setfib(int fibnum); }
+176	AUE_NTP_ADJTIME	STD	{ int ntp_adjtime(struct timex *tp); }
 177	AUE_NULL	UNIMPL	sfork (BSD/OS 2.x)
 178	AUE_NULL	UNIMPL	getdescriptor (BSD/OS 2.x)
 179	AUE_NULL	UNIMPL	setdescriptor (BSD/OS 2.x)
 180	AUE_NULL	UNIMPL	nosys
 
 ; Syscalls 181-199 are used by/reserved for BSD
-181	AUE_SETGID	NOPROTO	{ int setgid(gid_t gid); }
-182	AUE_SETEGID	NOPROTO	{ int setegid(gid_t egid); }
-183	AUE_SETEUID	NOPROTO	{ int seteuid(uid_t euid); }
+181	AUE_SETGID	STD	{ int setgid(gid_t gid); }
+182	AUE_SETEGID	STD	{ int setegid(gid_t egid); }
+183	AUE_SETEUID	STD	{ int seteuid(uid_t euid); }
 184	AUE_NULL	UNIMPL	lfs_bmapv
 185	AUE_NULL	UNIMPL	lfs_markv
 186	AUE_NULL	UNIMPL	lfs_segclean
 187	AUE_NULL	UNIMPL	lfs_segwait
-188	AUE_STAT	STD	{ int freebsd32_stat(char *path, \
-				    struct stat32 *ub); }
-189	AUE_FSTAT	STD	{ int freebsd32_fstat(int fd, \
-				    struct stat32 *ub); }
-190	AUE_LSTAT	STD	{ int freebsd32_lstat(char *path, \
-				    struct stat32 *ub); }
-191	AUE_PATHCONF	NOPROTO	{ int pathconf(char *path, int name); }
-192	AUE_FPATHCONF	NOPROTO	{ int fpathconf(int fd, int name); }
+188	AUE_STAT	STD	{ int stat(char *path, struct stat *ub); }
+189	AUE_FSTAT	STD	{ int fstat(int fd, struct stat *sb); }
+190	AUE_LSTAT	STD	{ int lstat(char *path, struct stat *ub); }
+191	AUE_PATHCONF	STD	{ int pathconf(char *path, int name); }
+192	AUE_FPATHCONF	STD	{ int fpathconf(int fd, int name); }
 193	AUE_NULL	UNIMPL	nosys
-194	AUE_GETRLIMIT	NOPROTO	{ int getrlimit(u_int which, \
+194	AUE_GETRLIMIT	STD	{ int getrlimit(u_int which, \
 				    struct rlimit *rlp); } getrlimit \
 				    __getrlimit_args int
-195	AUE_SETRLIMIT	NOPROTO	{ int setrlimit(u_int which, \
+195	AUE_SETRLIMIT	STD	{ int setrlimit(u_int which, \
 				    struct rlimit *rlp); } setrlimit \
 				    __setrlimit_args int
-196	AUE_GETDIRENTRIES	STD	{ int freebsd32_getdirentries(int fd, \
-				    char *buf, u_int count, int32_t *basep); }
-197	AUE_MMAP	COMPAT6	{ caddr_t freebsd32_mmap(caddr_t addr, \
+196	AUE_GETDIRENTRIES	STD	{ int getdirentries(int fd, char *buf, \
+				    u_int count, long *basep); }
+197	AUE_MMAP	STD	{ caddr_t freebsd6_mmap(caddr_t addr, \
 				    size_t len, int prot, int flags, int fd, \
-				    int pad, u_int32_t poslo, \
-				    u_int32_t poshi); }
-198	AUE_NULL	NOPROTO	{ int nosys(void); } __syscall \
+				    int pad, off_t pos); }
+198	AUE_NULL	STD	{ int nosys(void); } __syscall \
 				    __syscall_args int
-; XXX note - bigendian is different
-199	AUE_LSEEK	COMPAT6	{ off_t freebsd32_lseek(int fd, int pad, \
-				    u_int32_t offsetlo, u_int32_t offsethi, \
-				    int whence); }
-; XXX note - bigendian is different
-200	AUE_TRUNCATE	COMPAT6	{ int freebsd32_truncate(char *path, \
-				    int pad, u_int32_t lengthlo, \
-				    u_int32_t lengthhi); }
-; XXX note - bigendian is different
-201	AUE_FTRUNCATE	COMPAT6	{ int freebsd32_ftruncate(int fd, int pad, \
-				    u_int32_t lengthlo, u_int32_t lengthhi); }
-202	AUE_SYSCTL	STD	{ int freebsd32_sysctl(int *name, \
-				    u_int namelen, void *old, \
-				    u_int32_t *oldlenp, void *new, \
-				    u_int32_t newlen); }
-203	AUE_MLOCK	NOPROTO	{ int mlock(const void *addr, \
-				    size_t len); }
-204	AUE_MUNLOCK	NOPROTO	{ int munlock(const void *addr, \
-				    size_t len); }
-205	AUE_UNDELETE	NOPROTO	{ int undelete(char *path); }
-206	AUE_FUTIMES	STD	{ int freebsd32_futimes(int fd, \
-				    struct timeval32 *tptr); }
-207	AUE_GETPGID	NOPROTO	{ int getpgid(pid_t pid); }
+199	AUE_LSEEK	STD	{ off_t freebsd6_lseek(int fd, int pad, \
+				    off_t offset, int whence); }
+200	AUE_TRUNCATE	STD	{ int freebsd6_truncate(char *path, int pad, \
+				    off_t length); }
+201	AUE_FTRUNCATE	STD	{ int freebsd6_ftruncate(int fd, int pad, \
+				    off_t length); }
+202	AUE_SYSCTL	STD	{ int __sysctl(int *name, u_int namelen, \
+				    void *old, size_t *oldlenp, void *new, \
+				    size_t newlen); } __sysctl sysctl_args int
+203	AUE_MLOCK	STD	{ int mlock(const void *addr, size_t len); }
+204	AUE_MUNLOCK	STD	{ int munlock(const void *addr, size_t len); }
+205	AUE_UNDELETE	STD	{ int undelete(char *path); }
+206	AUE_FUTIMES	STD	{ int futimes(int fd, struct timeval *tptr); }
+207	AUE_GETPGID	STD	{ int getpgid(pid_t pid); }
 208	AUE_NULL	UNIMPL	newreboot (NetBSD)
-209	AUE_POLL	NOPROTO	{ int poll(struct pollfd *fds, u_int nfds, \
+209	AUE_POLL	STD	{ int poll(struct pollfd *fds, u_int nfds, \
 				    int timeout); }
 
 ;
 ; The following are reserved for loadable syscalls
 ;
-210	AUE_NULL	UNIMPL
-211	AUE_NULL	UNIMPL
-212	AUE_NULL	UNIMPL
-213	AUE_NULL	UNIMPL
-214	AUE_NULL	UNIMPL
-215	AUE_NULL	UNIMPL
-216	AUE_NULL	UNIMPL
-217	AUE_NULL	UNIMPL
-218	AUE_NULL	UNIMPL
-219	AUE_NULL	UNIMPL
+210	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+211	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+212	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+213	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+214	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+215	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+216	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+217	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+218	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
+219	AUE_NULL	NODEF	lkmnosys lkmnosys nosys_args int
 
 ;
 ; The following were introduced with NetBSD/4.4Lite-2
-; They are initialized by thier respective modules/sysinits
-; XXX PROBLEM!!
-220	AUE_SEMCTL	STD	{ int freebsd32_semctl(int semid, int semnum, \
-				    int cmd, union semun32 *arg); }
-221	AUE_SEMGET	NOPROTO	{ int semget(key_t key, int nsems, \
+220	AUE_SEMCTL	NOSTD	{ int __semctl(int semid, int semnum, \
+				    int cmd, union semun *arg); }
+221	AUE_SEMGET	NOSTD	{ int semget(key_t key, int nsems, \
 				    int semflg); }
-222	AUE_SEMOP	NOPROTO	{ int semop(int semid, struct sembuf *sops, \
-				    u_int nsops); }
+222	AUE_SEMOP	NOSTD	{ int semop(int semid, struct sembuf *sops, \
+				    size_t nsops); }
 223	AUE_NULL	UNIMPL	semconfig
-224	AUE_MSGCTL	STD	{ int freebsd32_msgctl(int msqid, int cmd, \
-				    struct msqid_ds32 *buf); }
-225	AUE_MSGGET	NOPROTO	{ int msgget(key_t key, int msgflg); }
-226	AUE_MSGSND	STD	{ int freebsd32_msgsnd(int msqid, void *msgp, \
+224	AUE_MSGCTL	NOSTD	{ int msgctl(int msqid, int cmd, \
+				    struct msqid_ds *buf); }
+225	AUE_MSGGET	NOSTD	{ int msgget(key_t key, int msgflg); }
+226	AUE_MSGSND	NOSTD	{ int msgsnd(int msqid, const void *msgp, \
 				    size_t msgsz, int msgflg); }
-227	AUE_MSGRCV	STD	{ int freebsd32_msgrcv(int msqid, void *msgp, \
+227	AUE_MSGRCV	NOSTD	{ int msgrcv(int msqid, void *msgp, \
 				    size_t msgsz, long msgtyp, int msgflg); }
-228	AUE_SHMAT	NOPROTO	{ int shmat(int shmid, void *shmaddr, \
+228	AUE_SHMAT	NOSTD	{ int shmat(int shmid, const void *shmaddr, \
 				    int shmflg); }
-229	AUE_SHMCTL	STD	{ int freebsd32_shmctl(int shmid, int cmd, \
+229	AUE_SHMCTL	NOSTD	{ int shmctl(int shmid, int cmd, \
 				    struct shmid_ds *buf); }
-230	AUE_SHMDT	NOPROTO	{ int shmdt(void *shmaddr); }
-231	AUE_SHMGET	NOPROTO	{ int shmget(key_t key, int size, \
+230	AUE_SHMDT	NOSTD	{ int shmdt(const void *shmaddr); }
+231	AUE_SHMGET	NOSTD	{ int shmget(key_t key, size_t size, \
 				    int shmflg); }
 ;
-232	AUE_NULL	STD 	{ int freebsd32_clock_gettime(clockid_t clock_id, \
-				    struct timespec32 *tp); }
-233	AUE_CLOCK_SETTIME	STD	{ int freebsd32_clock_settime(clockid_t clock_id, \
-				    const struct timespec32 *tp); }
-234	AUE_NULL	STD	{ int freebsd32_clock_getres(clockid_t clock_id, \
-				    struct timespec32 *tp); }
-235	AUE_NULL	UNIMPL	timer_create
-236	AUE_NULL	UNIMPL	timer_delete
-237	AUE_NULL	UNIMPL	timer_settime
-238	AUE_NULL	UNIMPL	timer_gettime
-239	AUE_NULL	UNIMPL	timer_getoverrun
-240	AUE_NULL	STD	{ int freebsd32_nanosleep( \
-				    const struct timespec32 *rqtp, \
-				    struct timespec32 *rmtp); }
+232	AUE_NULL	STD	{ int clock_gettime(clockid_t clock_id, \
+				    struct timespec *tp); }
+233	AUE_CLOCK_SETTIME	STD	{ int clock_settime( \
+				    clockid_t clock_id, \
+				    const struct timespec *tp); }
+234	AUE_NULL	STD	{ int clock_getres(clockid_t clock_id, \
+				    struct timespec *tp); }
+235	AUE_NULL	STD	{ int ktimer_create(clockid_t clock_id, \
+				    struct sigevent *evp, int *timerid); }
+236	AUE_NULL	STD	{ int ktimer_delete(int timerid); }
+237	AUE_NULL	STD	{ int ktimer_settime(int timerid, int flags, \
+				    const struct itimerspec *value, \
+				    struct itimerspec *ovalue); }
+238	AUE_NULL	STD	{ int ktimer_gettime(int timerid, struct \
+				    itimerspec *value); }
+239	AUE_NULL	STD	{ int ktimer_getoverrun(int timerid); }
+240	AUE_NULL	STD	{ int nanosleep(const struct timespec *rqtp, \
+				    struct timespec *rmtp); }
 241	AUE_NULL	UNIMPL	nosys
 242	AUE_NULL	UNIMPL	nosys
 243	AUE_NULL	UNIMPL	nosys
@@ -446,22 +463,20 @@
 245	AUE_NULL	UNIMPL	nosys
 246	AUE_NULL	UNIMPL	nosys
 247	AUE_NULL	UNIMPL	nosys
-248	AUE_NULL	UNIMPL	ntp_gettime
+248	AUE_NULL	STD	{ int ntp_gettime(struct ntptimeval *ntvp); }
 249	AUE_NULL	UNIMPL	nosys
 ; syscall numbers initially used in OpenBSD
-250	AUE_MINHERIT	NOPROTO	{ int minherit(void *addr, size_t len, \
+250	AUE_MINHERIT	STD	{ int minherit(void *addr, size_t len, \
 				    int inherit); }
-251	AUE_RFORK	NOPROTO	{ int rfork(int flags); }
-252	AUE_POLL	NOPROTO	{ int openbsd_poll(struct pollfd *fds, \
+251	AUE_RFORK	STD	{ int rfork(int flags); }
+252	AUE_POLL	STD	{ int openbsd_poll(struct pollfd *fds, \
 				    u_int nfds, int timeout); }
-253	AUE_ISSETUGID	NOPROTO	{ int issetugid(void); }
-254	AUE_LCHOWN	NOPROTO	{ int lchown(char *path, int uid, int gid); }
-255	AUE_NULL	NOSTD	{ int freebsd32_aio_read( \
-				    struct aiocb32 *aiocbp); }
-256	AUE_NULL	NOSTD	{ int freebsd32_aio_write( \
-				    struct aiocb32 *aiocbp); }
-257	AUE_NULL	NOSTD	{ int freebsd32_lio_listio(int mode, \
-				    struct aiocb32 * const *acb_list, \
+253	AUE_ISSETUGID	STD	{ int issetugid(void); }
+254	AUE_LCHOWN	STD	{ int lchown(char *path, int uid, int gid); }
+255	AUE_NULL	NOSTD	{ int aio_read(struct aiocb *aiocbp); }
+256	AUE_NULL	NOSTD	{ int aio_write(struct aiocb *aiocbp); }
+257	AUE_NULL	NOSTD	{ int lio_listio(int mode, \
+				    struct aiocb * const *acb_list, \
 				    int nent, struct sigevent *sig); }
 258	AUE_NULL	UNIMPL	nosys
 259	AUE_NULL	UNIMPL	nosys
@@ -477,20 +492,20 @@
 269	AUE_NULL	UNIMPL	nosys
 270	AUE_NULL	UNIMPL	nosys
 271	AUE_NULL	UNIMPL	nosys
-272	AUE_O_GETDENTS	NOPROTO	{ int getdents(int fd, char *buf, \
+272	AUE_O_GETDENTS	STD	{ int getdents(int fd, char *buf, \
 				    size_t count); }
 273	AUE_NULL	UNIMPL	nosys
-274	AUE_LCHMOD	NOPROTO	{ int lchmod(char *path, mode_t mode); }
+274	AUE_LCHMOD	STD	{ int lchmod(char *path, mode_t mode); }
 275	AUE_LCHOWN	NOPROTO	{ int lchown(char *path, uid_t uid, \
-				    gid_t gid); } netbsd_lchown \
-				    lchown_args int
-276	AUE_LUTIMES	STD	{ int freebsd32_lutimes(char *path, \
-				    struct timeval32 *tptr); }
+				    gid_t gid); } netbsd_lchown lchown_args \
+				    int
+276	AUE_LUTIMES	STD	{ int lutimes(char *path, \
+				    struct timeval *tptr); }
 277	AUE_MSYNC	NOPROTO	{ int msync(void *addr, size_t len, \
 				    int flags); } netbsd_msync msync_args int
-278	AUE_STAT	NOPROTO	{ int nstat(char *path, struct nstat *ub); }
-279	AUE_FSTAT	NOPROTO	{ int nfstat(int fd, struct nstat *sb); }
-280	AUE_LSTAT	NOPROTO	{ int nlstat(char *path, struct nstat *ub); }
+278	AUE_STAT	STD	{ int nstat(char *path, struct nstat *ub); }
+279	AUE_FSTAT	STD	{ int nfstat(int fd, struct nstat *sb); }
+280	AUE_LSTAT	STD	{ int nlstat(char *path, struct nstat *ub); }
 281	AUE_NULL	UNIMPL	nosys
 282	AUE_NULL	UNIMPL	nosys
 283	AUE_NULL	UNIMPL	nosys
@@ -500,14 +515,10 @@
 287	AUE_NULL	UNIMPL	nosys
 288	AUE_NULL	UNIMPL	nosys
 ; 289 and 290 from NetBSD (OpenBSD: 267 and 268)
-289	AUE_PREADV	STD	{ ssize_t freebsd32_preadv(int fd, \
-					struct iovec32 *iovp, \
+289	AUE_PREADV	STD	{ ssize_t preadv(int fd, struct iovec *iovp, \
 					u_int iovcnt, off_t offset); }
-; XXX note - bigendian is different
-290	AUE_PWRITEV	STD	{ ssize_t freebsd32_pwritev(int fd, \
-					struct iovec32 *iovp, \
+290	AUE_PWRITEV	STD	{ ssize_t pwritev(int fd, struct iovec *iovp, \
 					u_int iovcnt, off_t offset); }
-; XXX note - bigendian is different
 291	AUE_NULL	UNIMPL	nosys
 292	AUE_NULL	UNIMPL	nosys
 293	AUE_NULL	UNIMPL	nosys
@@ -515,328 +526,363 @@
 295	AUE_NULL	UNIMPL	nosys
 296	AUE_NULL	UNIMPL	nosys
 ; XXX 297 is 300 in NetBSD 
-297	AUE_FHSTATFS	COMPAT4	{ int freebsd32_fhstatfs( \
+297	AUE_FHSTATFS	COMPAT4	{ int fhstatfs( \
 				    const struct fhandle *u_fhp, \
-				    struct statfs32 *buf); }
-298	AUE_FHOPEN	NOPROTO	{ int fhopen(const struct fhandle *u_fhp, \
-			 	    int flags); }
-299	AUE_FHSTAT	NOPROTO	{ int fhstat(const struct fhandle *u_fhp, \
+				    struct ostatfs *buf); }
+298	AUE_FHOPEN	STD	{ int fhopen(const struct fhandle *u_fhp, \
+				    int flags); }
+299	AUE_FHSTAT	STD	{ int fhstat(const struct fhandle *u_fhp, \
 				    struct stat *sb); }
 ; syscall numbers for FreeBSD
-300	AUE_NULL	NOPROTO	{ int modnext(int modid); }
-301	AUE_NULL	STD	{ int freebsd32_modstat(int modid, \
-				    struct module_stat32* stat); }
-302	AUE_NULL	NOPROTO	{ int modfnext(int modid); }
-303	AUE_NULL	NOPROTO	{ int modfind(const char *name); }
-304	AUE_MODLOAD	NOPROTO	{ int kldload(const char *file); }
-305	AUE_MODUNLOAD	NOPROTO	{ int kldunload(int fileid); }
-306	AUE_NULL	NOPROTO	{ int kldfind(const char *file); }
-307	AUE_NULL	NOPROTO	{ int kldnext(int fileid); }
-308	AUE_NULL	NOPROTO	{ int kldstat(int fileid, \
-				    struct kld_file_stat* stat); }
-309	AUE_NULL	NOPROTO	{ int kldfirstmod(int fileid); }
-310	AUE_GETSID	NOPROTO	{ int getsid(pid_t pid); }
-311	AUE_SETRESUID	NOPROTO	{ int setresuid(uid_t ruid, uid_t euid, \
+300	AUE_NULL	STD	{ int modnext(int modid); }
+301	AUE_NULL	STD	{ int modstat(int modid, \
+				    struct module_stat *stat); }
+302	AUE_NULL	STD	{ int modfnext(int modid); }
+303	AUE_NULL	STD	{ int modfind(const char *name); }
+304	AUE_MODLOAD	STD	{ int kldload(const char *file); }
+305	AUE_MODUNLOAD	STD	{ int kldunload(int fileid); }
+306	AUE_NULL	STD	{ int kldfind(const char *file); }
+307	AUE_NULL	STD	{ int kldnext(int fileid); }
+308	AUE_NULL	STD	{ int kldstat(int fileid, struct \
+				    kld_file_stat* stat); }
+309	AUE_NULL	STD	{ int kldfirstmod(int fileid); }
+310	AUE_GETSID	STD	{ int getsid(pid_t pid); }
+311	AUE_SETRESUID	STD	{ int setresuid(uid_t ruid, uid_t euid, \
 				    uid_t suid); }
-312	AUE_SETRESGID	NOPROTO	{ int setresgid(gid_t rgid, gid_t egid, \
+312	AUE_SETRESGID	STD	{ int setresgid(gid_t rgid, gid_t egid, \
 				    gid_t sgid); }
 313	AUE_NULL	OBSOL	signanosleep
-314	AUE_NULL	NOSTD	{ int freebsd32_aio_return( \
-				    struct aiocb32 *aiocbp); }
-315	AUE_NULL	NOSTD	{ int freebsd32_aio_suspend( \
-				    struct aiocb32 * const * aiocbp, int nent, \
-				    const struct timespec32 *timeout); }
-316	AUE_NULL	NOSTD	{ int freebsd32_aio_cancel(int fd, \
-				    struct aiocb32 *aiocbp); }
-317	AUE_NULL	NOSTD	{ int freebsd32_aio_error( \
-				    struct aiocb32 *aiocbp); }
-318	AUE_NULL	NOSTD	{ int freebsd32_oaio_read( \
-				    struct oaiocb32 *aiocbp); }
-319	AUE_NULL	NOSTD	{ int freebsd32_oaio_write( \
-				    struct oaiocb32 *aiocbp); }
-320	AUE_NULL	NOSTD	{ int freebsd32_olio_listio(int mode, \
-				    struct oaiocb32 * const *acb_list, \
-				    int nent, struct osigevent32 *sig); }
-321	AUE_NULL	NOPROTO	{ int yield(void); }
+314	AUE_NULL	NOSTD	{ int aio_return(struct aiocb *aiocbp); }
+315	AUE_NULL	NOSTD	{ int aio_suspend( \
+				    struct aiocb * const * aiocbp, int nent, \
+				    const struct timespec *timeout); }
+316	AUE_NULL	NOSTD	{ int aio_cancel(int fd, \
+				    struct aiocb *aiocbp); }
+317	AUE_NULL	NOSTD	{ int aio_error(struct aiocb *aiocbp); }
+318	AUE_NULL	NOSTD	{ int oaio_read(struct oaiocb *aiocbp); }
+319	AUE_NULL	NOSTD	{ int oaio_write(struct oaiocb *aiocbp); }
+320	AUE_NULL	NOSTD	{ int olio_listio(int mode, \
+				    struct oaiocb * const *acb_list, \
+				    int nent, struct osigevent *sig); }
+321	AUE_NULL	STD	{ int yield(void); }
 322	AUE_NULL	OBSOL	thr_sleep
 323	AUE_NULL	OBSOL	thr_wakeup
-324	AUE_MLOCKALL	NOPROTO	{ int mlockall(int how); }
-325	AUE_MUNLOCKALL	NOPROTO	{ int munlockall(void); }
-326	AUE_GETCWD	NOPROTO	{ int __getcwd(u_char *buf, u_int buflen); }
+324	AUE_MLOCKALL	STD	{ int mlockall(int how); }
+325	AUE_MUNLOCKALL	STD	{ int munlockall(void); }
+326	AUE_GETCWD	STD	{ int __getcwd(u_char *buf, u_int buflen); }
 
-327	AUE_NULL	NOPROTO	{ int sched_setparam (pid_t pid, \
+327	AUE_NULL	STD	{ int sched_setparam (pid_t pid, \
 				    const struct sched_param *param); }
-328	AUE_NULL	NOPROTO	{ int sched_getparam (pid_t pid, \
-				    struct sched_param *param); }
+328	AUE_NULL	STD	{ int sched_getparam (pid_t pid, struct \
+				    sched_param *param); }
 
-329	AUE_NULL	NOPROTO	{ int sched_setscheduler (pid_t pid, \
-				    int policy, \
-				    const struct sched_param *param); }
-330	AUE_NULL	NOPROTO	{ int sched_getscheduler (pid_t pid); }
+329	AUE_NULL	STD	{ int sched_setscheduler (pid_t pid, int \
+				    policy, const struct sched_param \
+				    *param); }
+330	AUE_NULL	STD	{ int sched_getscheduler (pid_t pid); }
 
-331	AUE_NULL	NOPROTO	{ int sched_yield (void); }
-332	AUE_NULL	NOPROTO	{ int sched_get_priority_max (int policy); }
-333	AUE_NULL	NOPROTO	{ int sched_get_priority_min (int policy); }
-334	AUE_NULL	NOPROTO	{ int sched_rr_get_interval (pid_t pid, \
+331	AUE_NULL	STD	{ int sched_yield (void); }
+332	AUE_NULL	STD	{ int sched_get_priority_max (int policy); }
+333	AUE_NULL	STD	{ int sched_get_priority_min (int policy); }
+334	AUE_NULL	STD	{ int sched_rr_get_interval (pid_t pid, \
 				    struct timespec *interval); }
-335	AUE_NULL	NOPROTO	{ int utrace(const void *addr, size_t len); }
-; XXX note - bigendian is different
-336	AUE_SENDFILE	COMPAT4	{ int freebsd32_sendfile(int fd, int s, \
-				    u_int32_t offsetlo, u_int32_t offsethi, \
-				    size_t nbytes, struct sf_hdtr32 *hdtr, \
-				    off_t *sbytes, int flags); }
-337	AUE_NULL	NOPROTO	{ int kldsym(int fileid, int cmd, \
+335	AUE_NULL	STD	{ int utrace(const void *addr, size_t len); }
+336	AUE_SENDFILE	COMPAT4	{ int sendfile(int fd, int s, \
+				    off_t offset, size_t nbytes, \
+				    struct sf_hdtr *hdtr, off_t *sbytes, \
+				    int flags); }
+337	AUE_NULL	STD	{ int kldsym(int fileid, int cmd, \
 				    void *data); }
-338	AUE_JAIL	STD	{ int freebsd32_jail(struct jail32 *jail); }
+338	AUE_JAIL	STD	{ int jail(struct jail *jail); }
 339	AUE_NULL	UNIMPL	pioctl
-340	AUE_SIGPROCMASK	NOPROTO	{ int sigprocmask(int how, \
+340	AUE_SIGPROCMASK	STD	{ int sigprocmask(int how, \
 				    const sigset_t *set, sigset_t *oset); }
-341	AUE_SIGSUSPEND	NOPROTO	{ int sigsuspend(const sigset_t *sigmask); }
-342	AUE_SIGACTION	COMPAT4	{ int freebsd32_sigaction(int sig, \
-				    struct sigaction32 *act, \
-				    struct sigaction32 *oact); }
-343	AUE_SIGPENDING	NOPROTO	{ int sigpending(sigset_t *set); }
-344	AUE_SIGRETURN	COMPAT4	{ int freebsd32_sigreturn( \
-		    const struct freebsd4_freebsd32_ucontext *sigcntxp); }
-345	AUE_SIGWAIT	STD	{ int freebsd32_sigtimedwait(const sigset_t *set, \
+341	AUE_SIGSUSPEND	STD	{ int sigsuspend(const sigset_t *sigmask); }
+342	AUE_SIGACTION	COMPAT4	{ int sigaction(int sig, const \
+				    struct sigaction *act, \
+				    struct sigaction *oact); }
+343	AUE_SIGPENDING	STD	{ int sigpending(sigset_t *set); }
+344	AUE_SIGRETURN	COMPAT4	{ int sigreturn( \
+				    const struct ucontext4 *sigcntxp); }
+345	AUE_SIGWAIT	STD	{ int sigtimedwait(const sigset_t *set, \
 				    siginfo_t *info, \
 				    const struct timespec *timeout); }
-346	AUE_NULL	STD	{ int freebsd32_sigwaitinfo(const sigset_t *set, \
+346	AUE_NULL	STD	{ int sigwaitinfo(const sigset_t *set, \
 				    siginfo_t *info); }
-347	AUE_NULL	NOPROTO	{ int __acl_get_file(const char *path, \
+347	AUE_NULL	STD	{ int __acl_get_file(const char *path, \
 				    acl_type_t type, struct acl *aclp); }
-348	AUE_NULL	NOPROTO	{ int __acl_set_file(const char *path, \
+348	AUE_NULL	STD	{ int __acl_set_file(const char *path, \
 				    acl_type_t type, struct acl *aclp); }
-349	AUE_NULL	NOPROTO	{ int __acl_get_fd(int filedes, \
+349	AUE_NULL	STD	{ int __acl_get_fd(int filedes, \
 				    acl_type_t type, struct acl *aclp); }
-350	AUE_NULL	NOPROTO	{ int __acl_set_fd(int filedes, \
+350	AUE_NULL	STD	{ int __acl_set_fd(int filedes, \
 				    acl_type_t type, struct acl *aclp); }
-351	AUE_NULL	NOPROTO	{ int __acl_delete_file(const char *path, \
+351	AUE_NULL	STD	{ int __acl_delete_file(const char *path, \
 				    acl_type_t type); }
-352	AUE_NULL	NOPROTO	{ int __acl_delete_fd(int filedes, \
+352	AUE_NULL	STD	{ int __acl_delete_fd(int filedes, \
 				    acl_type_t type); }
-353	AUE_NULL	NOPROTO	{ int __acl_aclcheck_file(const char *path, \
+353	AUE_NULL	STD	{ int __acl_aclcheck_file(const char *path, \
 				    acl_type_t type, struct acl *aclp); }
-354	AUE_NULL	NOPROTO	{ int __acl_aclcheck_fd(int filedes, \
+354	AUE_NULL	STD	{ int __acl_aclcheck_fd(int filedes, \
 				    acl_type_t type, struct acl *aclp); }
-355	AUE_EXTATTRCTL	NOPROTO	{ int extattrctl(const char *path, int cmd, \
+355	AUE_EXTATTRCTL	STD	{ int extattrctl(const char *path, int cmd, \
 				    const char *filename, int attrnamespace, \
 				    const char *attrname); }
-356	AUE_EXTATTR_SET_FILE	NOPROTO	{ int extattr_set_file( \
+356	AUE_EXTATTR_SET_FILE	STD	{ int extattr_set_file( \
 				    const char *path, int attrnamespace, \
 				    const char *attrname, void *data, \
 				    size_t nbytes); }
-357	AUE_EXTATTR_GET_FILE	NOPROTO	{ ssize_t extattr_get_file( \
+357	AUE_EXTATTR_GET_FILE	STD	{ ssize_t extattr_get_file( \
 				    const char *path, int attrnamespace, \
 				    const char *attrname, void *data, \
 				    size_t nbytes); }
-358	AUE_EXTATTR_DELETE_FILE	NOPROTO	{ int extattr_delete_file( \
-				    const char *path, int attrnamespace, \
+358	AUE_EXTATTR_DELETE_FILE	STD	{ int extattr_delete_file(const char *path, \
+				    int attrnamespace, \
 				    const char *attrname); }
-359	AUE_NULL	NOSTD	{ int freebsd32_aio_waitcomplete( \
-				    struct aiocb32 **aiocbp, \
-				    struct timespec32 *timeout); }
-360	AUE_GETRESUID	NOPROTO	{ int getresuid(uid_t *ruid, uid_t *euid, \
+359	AUE_NULL	NOSTD	{ int aio_waitcomplete( \
+				    struct aiocb **aiocbp, \
+				    struct timespec *timeout); }
+360	AUE_GETRESUID	STD	{ int getresuid(uid_t *ruid, uid_t *euid, \
 				    uid_t *suid); }
-361	AUE_GETRESGID	NOPROTO	{ int getresgid(gid_t *rgid, gid_t *egid, \
+361	AUE_GETRESGID	STD	{ int getresgid(gid_t *rgid, gid_t *egid, \
 				    gid_t *sgid); }
-362	AUE_KQUEUE	NOPROTO	{ int kqueue(void); }
-363	AUE_NULL	STD	{ int freebsd32_kevent(int fd, \
-				    const struct kevent32 *changelist, \
-				    int nchanges, \
-				    struct kevent32 *eventlist, int nevents, \
-				    const struct timespec32 *timeout); }
+362	AUE_KQUEUE	STD	{ int kqueue(void); }
+363	AUE_NULL	STD	{ int kevent(int fd, \
+				    struct kevent *changelist, int nchanges, \
+				    struct kevent *eventlist, int nevents, \
+				    const struct timespec *timeout); }
 364	AUE_NULL	UNIMPL	__cap_get_proc
 365	AUE_NULL	UNIMPL	__cap_set_proc
 366	AUE_NULL	UNIMPL	__cap_get_fd
 367	AUE_NULL	UNIMPL	__cap_get_file
 368	AUE_NULL	UNIMPL	__cap_set_fd
 369	AUE_NULL	UNIMPL	__cap_set_file
-370	AUE_NULL	UNIMPL	lkmressys
-371	AUE_EXTATTR_SET_FD	NOPROTO	{ int extattr_set_fd(int fd, \
+370	AUE_NULL	NODEF	lkmressys lkmressys nosys_args int
+371	AUE_EXTATTR_SET_FD	STD	{ int extattr_set_fd(int fd, \
 				    int attrnamespace, const char *attrname, \
 				    void *data, size_t nbytes); }
-372	AUE_EXTATTR_GET_FD	NOPROTO	{ ssize_t extattr_get_fd(int fd, \
+372	AUE_EXTATTR_GET_FD	STD	{ ssize_t extattr_get_fd(int fd, \
 				    int attrnamespace, const char *attrname, \
 				    void *data, size_t nbytes); }
-373	AUE_EXTATTR_DELETE_FD	NOPROTO	{ int extattr_delete_fd(int fd, \
+373	AUE_EXTATTR_DELETE_FD	STD	{ int extattr_delete_fd(int fd, \
 				    int attrnamespace, \
 				    const char *attrname); }
-374	AUE_NULL	NOPROTO	{ int __setugid(int flag); }
-375	AUE_NULL	UNIMPL	nfsclnt
-376	AUE_EACCESS	NOPROTO	{ int eaccess(char *path, int flags); }
+374	AUE_NULL	STD	{ int __setugid(int flag); }
+375	AUE_NULL	NOIMPL	{ int nfsclnt(int flag, caddr_t argp); }
+376	AUE_EACCESS	STD	{ int eaccess(char *path, int flags); }
 377	AUE_NULL	UNIMPL	afs_syscall
-378	AUE_NMOUNT	STD	{ int freebsd32_nmount(struct iovec32 *iovp, \
+378	AUE_NMOUNT	STD	{ int nmount(struct iovec *iovp, \
 				    unsigned int iovcnt, int flags); }
-379	AUE_NULL	NOPROTO	{ int kse_exit(void); }
-380	AUE_NULL	NOPROTO	{ int kse_wakeup(struct kse_mailbox *mbx); }
-381	AUE_NULL	NOPROTO	{ int kse_create(struct kse_mailbox *mbx, \
+379	AUE_NULL	STD	{ int kse_exit(void); }
+380	AUE_NULL	STD	{ int kse_wakeup(struct kse_mailbox *mbx); }
+381	AUE_NULL	STD	{ int kse_create(struct kse_mailbox *mbx, \
 				    int newgroup); }
-382	AUE_NULL	NOPROTO	{ int kse_thr_interrupt( \
-				    struct kse_thr_mailbox *tmbx); }
-383	AUE_NULL	NOPROTO	{ int kse_release(void); }
-384	AUE_NULL	UNIMPL	__mac_get_proc
-385	AUE_NULL	UNIMPL	__mac_set_proc
-386	AUE_NULL	UNIMPL	__mac_get_fd
-387	AUE_NULL	UNIMPL	__mac_get_file
-388	AUE_NULL	UNIMPL	__mac_set_fd
-389	AUE_NULL	UNIMPL	__mac_set_file
-390	AUE_NULL	NOPROTO	{ int kenv(int what, const char *name, \
+382	AUE_NULL	STD	{ int kse_thr_interrupt( \
+				    struct kse_thr_mailbox *tmbx, int cmd, \
+				    long data); }
+383	AUE_NULL	STD	{ int kse_release(struct timespec *timeout); }
+384	AUE_NULL	STD	{ int __mac_get_proc(struct mac *mac_p); }
+385	AUE_NULL	STD	{ int __mac_set_proc(struct mac *mac_p); }
+386	AUE_NULL	STD	{ int __mac_get_fd(int fd, \
+				    struct mac *mac_p); }
+387	AUE_NULL	STD	{ int __mac_get_file(const char *path_p, \
+				    struct mac *mac_p); }
+388	AUE_NULL	STD	{ int __mac_set_fd(int fd, \
+				    struct mac *mac_p); }
+389	AUE_NULL	STD	{ int __mac_set_file(const char *path_p, \
+				    struct mac *mac_p); }
+390	AUE_NULL	STD	{ int kenv(int what, const char *name, \
 				    char *value, int len); }
-391	AUE_LCHFLAGS	NOPROTO	{ int lchflags(const char *path, int flags); }
-392	AUE_NULL	NOPROTO	{ int uuidgen(struct uuid *store, \
+391	AUE_LCHFLAGS	STD	{ int lchflags(const char *path, int flags); }
+392	AUE_NULL	STD	{ int uuidgen(struct uuid *store, \
 				    int count); }
-393	AUE_SENDFILE	STD	{ int freebsd32_sendfile(int fd, int s, \
-				    u_int32_t offsetlo, u_int32_t offsethi, \
-				    size_t nbytes, struct sf_hdtr32 *hdtr, \
+393	AUE_SENDFILE	STD	{ int sendfile(int fd, int s, off_t offset, \
+				    size_t nbytes, struct sf_hdtr *hdtr, \
 				    off_t *sbytes, int flags); }
-394	AUE_NULL	UNIMPL	mac_syscall
-395	AUE_GETFSSTAT	NOPROTO	{ int getfsstat(struct statfs *buf, \
+394	AUE_NULL	STD	{ int mac_syscall(const char *policy, \
+				    int call, void *arg); }
+395	AUE_GETFSSTAT	STD	{ int getfsstat(struct statfs *buf, \
 				    long bufsize, int flags); }
-396	AUE_STATFS	NOPROTO	{ int statfs(char *path, \
+396	AUE_STATFS	STD	{ int statfs(char *path, \
 				    struct statfs *buf); }
-397	AUE_FSTATFS	NOPROTO	{ int fstatfs(int fd, struct statfs *buf); }
-398	AUE_FHSTATFS	NOPROTO	{ int fhstatfs(const struct fhandle *u_fhp, \
+397	AUE_FSTATFS	STD	{ int fstatfs(int fd, struct statfs *buf); }
+398	AUE_FHSTATFS	STD	{ int fhstatfs(const struct fhandle *u_fhp, \
 				    struct statfs *buf); }
 399	AUE_NULL	UNIMPL	nosys
-; XXX implement these?
-400	AUE_NULL	UNIMPL	ksem_close
-401	AUE_NULL	UNIMPL	ksem_post
-402	AUE_NULL	UNIMPL	ksem_wait
-403	AUE_NULL	UNIMPL	ksem_trywait
-404	AUE_NULL	UNIMPL	ksem_init
-405	AUE_NULL	UNIMPL	ksem_open
-406	AUE_NULL	UNIMPL	ksem_unlink
-407	AUE_NULL	UNIMPL	ksem_getvalue
-408	AUE_NULL	UNIMPL	ksem_destroy
-409	AUE_NULL	UNIMPL	__mac_get_pid
-410	AUE_NULL	UNIMPL	__mac_get_link
-411	AUE_NULL	UNIMPL	__mac_set_link
-412	AUE_EXTATTR_SET_LINK	UNIMPL	extattr_set_link
-413	AUE_EXTATTR_GET_LINK	UNIMPL	extattr_get_link
-414	AUE_EXTATTR_DELETE_LINK	UNIMPL	extattr_delete_link
-415	AUE_NULL	UNIMPL	__mac_execve
-416	AUE_SIGACTION	STD	{ int freebsd32_sigaction(int sig, \
-				    struct sigaction32 *act, \
-				    struct sigaction32 *oact); }
-417	AUE_SIGRETURN	STD	{ int freebsd32_sigreturn( \
-		    const struct freebsd32_ucontext *sigcntxp); }
+400	AUE_NULL	NOSTD	{ int ksem_close(semid_t id); }
+401	AUE_NULL	NOSTD	{ int ksem_post(semid_t id); }
+402	AUE_NULL	NOSTD	{ int ksem_wait(semid_t id); }
+403	AUE_NULL	NOSTD	{ int ksem_trywait(semid_t id); }
+404	AUE_NULL	NOSTD	{ int ksem_init(semid_t *idp, \
+				    unsigned int value); }
+405	AUE_NULL	NOSTD	{ int ksem_open(semid_t *idp, \
+				    const char *name, int oflag, \
+				    mode_t mode, unsigned int value); }
+406	AUE_NULL	NOSTD	{ int ksem_unlink(const char *name); }
+407	AUE_NULL	NOSTD	{ int ksem_getvalue(semid_t id, int *val); }
+408	AUE_NULL	NOSTD	{ int ksem_destroy(semid_t id); }
+409	AUE_NULL	STD	{ int __mac_get_pid(pid_t pid, \
+				    struct mac *mac_p); }
+410	AUE_NULL	STD	{ int __mac_get_link(const char *path_p, \
+				    struct mac *mac_p); }
+411	AUE_NULL	STD	{ int __mac_set_link(const char *path_p, \
+				    struct mac *mac_p); }
+412	AUE_EXTATTR_SET_LINK	STD	{ int extattr_set_link( \
+				    const char *path, int attrnamespace, \
+				    const char *attrname, void *data, \
+				    size_t nbytes); }
+413	AUE_EXTATTR_GET_LINK	STD	{ ssize_t extattr_get_link( \
+				    const char *path, int attrnamespace, \
+				    const char *attrname, void *data, \
+				    size_t nbytes); }
+414	AUE_EXTATTR_DELETE_LINK	STD	{ int extattr_delete_link( \
+				    const char *path, int attrnamespace, \
+				    const char *attrname); }
+415	AUE_NULL	STD	{ int __mac_execve(char *fname, char **argv, \
+				    char **envv, struct mac *mac_p); }
+416	AUE_SIGACTION	STD	{ int sigaction(int sig, \
+				    const struct sigaction *act, \
+				    struct sigaction *oact); }
+417	AUE_SIGRETURN	STD	{ int sigreturn( \
+				    const struct __ucontext *sigcntxp); }
 418	AUE_NULL	UNIMPL	__xstat
 419	AUE_NULL	UNIMPL	__xfstat
 420	AUE_NULL	UNIMPL	__xlstat
-421	AUE_NULL	STD	{ int freebsd32_getcontext( \
-				    struct freebsd32_ucontext *ucp); }
-422	AUE_NULL	STD	{ int freebsd32_setcontext( \
-				    const struct freebsd32_ucontext *ucp); }
-423	AUE_NULL	STD	{ int freebsd32_swapcontext( \
-				    struct freebsd32_ucontext *oucp, \
-				    const struct freebsd32_ucontext *ucp); }
-424	AUE_SWAPOFF	UNIMPL	swapoff
-425	AUE_NULL	UNIMPL	__acl_get_link
-426	AUE_NULL	UNIMPL	__acl_set_link
-427	AUE_NULL	UNIMPL	__acl_delete_link
-428	AUE_NULL	UNIMPL	__acl_aclcheck_link
-429	AUE_SIGWAIT	NOPROTO	{ int sigwait(const sigset_t *set, \
+421	AUE_NULL	STD	{ int getcontext(struct __ucontext *ucp); }
+422	AUE_NULL	STD	{ int setcontext( \
+				    const struct __ucontext *ucp); }
+423	AUE_NULL	STD	{ int swapcontext(struct __ucontext *oucp, \
+				    const struct __ucontext *ucp); }
+424	AUE_SWAPOFF	STD	{ int swapoff(const char *name); }
+425	AUE_NULL	STD	{ int __acl_get_link(const char *path, \
+				    acl_type_t type, struct acl *aclp); }
+426	AUE_NULL	STD	{ int __acl_set_link(const char *path, \
+				    acl_type_t type, struct acl *aclp); }
+427	AUE_NULL	STD	{ int __acl_delete_link(const char *path, \
+				    acl_type_t type); }
+428	AUE_NULL	STD	{ int __acl_aclcheck_link(const char *path, \
+				    acl_type_t type, struct acl *aclp); }
+429	AUE_SIGWAIT	STD	{ int sigwait(const sigset_t *set, \
 				    int *sig); }
-430	AUE_NULL	UNIMPL	thr_create;
-431	AUE_NULL	NOPROTO	{ void thr_exit(long *state); }
-432	AUE_NULL	NOPROTO	{ int thr_self(long *id); }
-433	AUE_NULL	NOPROTO	{ int thr_kill(long id, int sig); }
-434	AUE_NULL	STD	{ int freebsd32_umtx_lock(struct umtx *umtx); }
-435	AUE_NULL	STD	{ int freebsd32_umtx_unlock(struct umtx *umtx); }
-436	AUE_NULL	NOPROTO	{ int jail_attach(int jid); }
-437	AUE_EXTATTR_LIST_FD	UNIMPL	extattr_list_fd
-438	AUE_EXTATTR_LIST_FILE	UNIMPL	extattr_list_file
-439	AUE_EXTATTR_LIST_LINK	UNIMPL	extattr_list_link
-440	AUE_NULL	UNIMPL	kse_switchin
-441	AUE_NULL	UNIMPL	ksem_timedwait
-442	AUE_NULL	STD	{ int freebsd32_thr_suspend( \
-				    const struct timespec32 *timeout); }
-443	AUE_NULL	NOPROTO	{ int thr_wake(long id); }
-444	AUE_MODUNLOAD	NOPROTO	{ int kldunloadf(int fileid, int flags); }
-445	AUE_AUDIT	NOPROTO	{ int audit(const void *record, \
+430	AUE_NULL	STD	{ int thr_create(ucontext_t *ctx, long *id, \
+				    int flags); }
+431	AUE_NULL	STD	{ void thr_exit(long *state); }
+432	AUE_NULL	STD	{ int thr_self(long *id); }
+433	AUE_NULL	STD	{ int thr_kill(long id, int sig); }
+434	AUE_NULL	STD	{ int _umtx_lock(struct umtx *umtx); }
+435	AUE_NULL	STD	{ int _umtx_unlock(struct umtx *umtx); }
+436	AUE_NULL	STD	{ int jail_attach(int jid); }
+437	AUE_EXTATTR_LIST_FD	STD	{ ssize_t extattr_list_fd(int fd, \
+				    int attrnamespace, void *data, \
+				    size_t nbytes); }
+438	AUE_EXTATTR_LIST_FILE	STD	{ ssize_t extattr_list_file( \
+				    const char *path, int attrnamespace, \
+				    void *data, size_t nbytes); }
+439	AUE_EXTATTR_LIST_LINK	STD	{ ssize_t extattr_list_link( \
+				    const char *path, int attrnamespace, \
+				    void *data, size_t nbytes); }
+440	AUE_NULL	STD	{ int kse_switchin( \
+				    struct kse_thr_mailbox *tmbx, \
+				    int flags); }
+441	AUE_NULL	NOSTD	{ int ksem_timedwait(semid_t id, \
+				    const struct timespec *abstime); }
+442	AUE_NULL	STD	{ int thr_suspend( \
+				    const struct timespec *timeout); }
+443	AUE_NULL	STD	{ int thr_wake(long id); }
+444	AUE_MODUNLOAD	STD	{ int kldunloadf(int fileid, int flags); }
+445	AUE_AUDIT	STD	{ int audit(const void *record, \
 				    u_int length); }
-446	AUE_AUDITON	NOPROTO	{ int auditon(int cmd, void *data, \
+446	AUE_AUDITON	STD	{ int auditon(int cmd, void *data, \
 				    u_int length); }
-447	AUE_GETAUID	NOPROTO	{ int getauid(uid_t *auid); }
-448	AUE_SETAUID	NOPROTO	{ int setauid(uid_t *auid); }
-449	AUE_GETAUDIT	NOPROTO	{ int getaudit(struct auditinfo *auditinfo); }
-450	AUE_SETAUDIT	NOPROTO	{ int setaudit(struct auditinfo *auditinfo); }
-451	AUE_GETAUDIT_ADDR	NOPROTO	{ int getaudit_addr( \
+447	AUE_GETAUID	STD	{ int getauid(uid_t *auid); }
+448	AUE_SETAUID	STD	{ int setauid(uid_t *auid); }
+449	AUE_GETAUDIT	STD	{ int getaudit(struct auditinfo *auditinfo); }
+450	AUE_SETAUDIT	STD	{ int setaudit(struct auditinfo *auditinfo); }
+451	AUE_GETAUDIT_ADDR	STD	{ int getaudit_addr( \
 				    struct auditinfo_addr *auditinfo_addr, \
 				    u_int length); }
-452	AUE_SETAUDIT_ADDR	NOPROTO	{ int setaudit_addr( \
+452	AUE_SETAUDIT_ADDR	STD	{ int setaudit_addr( \
 				    struct auditinfo_addr *auditinfo_addr, \
 				    u_int length); }
-453	AUE_AUDITCTL	NOPROTO	{ int auditctl(char *path); }
-454	AUE_NULL	STD	{ int freebsd32_umtx_op(void *obj, int op,\
-				    u_long val, void *uaddr, \
-				    void *uaddr2); }
-455	AUE_NULL	STD	{ int freebsd32_thr_new(	\
-				    struct thr_param32 *param,	\
+453	AUE_AUDITCTL	STD	{ int auditctl(char *path); }
+454	AUE_NULL	STD	{ int _umtx_op(void *obj, int op, \
+				    u_long val, void *uaddr1, void *uaddr2); }
+455	AUE_NULL	STD	{ int thr_new(struct thr_param *param, \
 				    int param_size); }
-456	AUE_NULL	NOPROTO	{ int sigqueue(pid_t pid, int signum, \
-				    void *value); }
-457	AUE_NULL	UNIMPL	kmq_open
-458	AUE_NULL	UNIMPL	kmq_setattr
-459	AUE_NULL	UNIMPL	kmq_timedreceive
-460	AUE_NULL	UNIMPL  kmq_timedsend
-461	AUE_NULL	UNIMPL	kmq_notify
-462	AUE_NULL	UNIMPL	kmq_unlink
-463	AUE_NULL	NOPROTO	{ int abort2(const char *why, int nargs, void **args); }
-464	AUE_NULL 	NOPROTO	{ int thr_set_name(long id, const char *name); }
-465	AUE_NULL	NOSTD	{ int freebsd32_aio_fsync(int op, \
-				    struct aiocb32 *aiocbp); }
-466	AUE_RTPRIO	NOPROTO	{ int rtprio_thread(int function, \
+456	AUE_NULL	STD	{ int sigqueue(pid_t pid, int signum, void *value); }
+457	AUE_NULL	NOSTD	{ int kmq_open(const char *path, int flags, \
+				    mode_t mode, const struct mq_attr *attr); }
+458	AUE_NULL	NOSTD	{ int kmq_setattr(int mqd,		\
+				    const struct mq_attr *attr,		\
+				    struct mq_attr *oattr); }
+459	AUE_NULL	NOSTD	{ int kmq_timedreceive(int mqd,	\
+				    char *msg_ptr, size_t msg_len,	\
+				    unsigned *msg_prio,			\
+				    const struct timespec *abs_timeout); }
+460	AUE_NULL	NOSTD	{ int kmq_timedsend(int mqd,		\
+				    const char *msg_ptr, size_t msg_len,\
+				    unsigned msg_prio,			\
+				    const struct timespec *abs_timeout);}
+461	AUE_NULL	NOSTD	{ int kmq_notify(int mqd,		\
+				    const struct sigevent *sigev); }
+462	AUE_NULL	NOSTD	{ int kmq_unlink(const char *path); }
+463	AUE_NULL	STD	{ int abort2(const char *why, int nargs, void **args); }
+464	AUE_NULL	STD	{ int thr_set_name(long id, const char *name); }
+465	AUE_NULL	NOSTD	{ int aio_fsync(int op, struct aiocb *aiocbp); }
+466	AUE_RTPRIO	STD	{ int rtprio_thread(int function, \
 				    lwpid_t lwpid, struct rtprio *rtp); }
 467	AUE_NULL	UNIMPL	nosys
 468	AUE_NULL	UNIMPL	nosys
 469	AUE_NULL	UNIMPL	__getpath_fromfd
 470	AUE_NULL	UNIMPL	__getpath_fromaddr
-471	AUE_NULL	NOPROTO	{ int sctp_peeloff(int sd, uint32_t name); }
-472	AUE_NULL	NOPROTO	{ int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \
-				    caddr_t to, __socklen_t tolen, \
+471	AUE_NULL	STD	{ int sctp_peeloff(int sd, uint32_t name); }
+472     AUE_NULL        STD    { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \
+	                            caddr_t to, __socklen_t tolen, \
 				    struct sctp_sndrcvinfo *sinfo, int flags); }
-473	AUE_NULL	NOPROTO	{ int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \
-				    caddr_t to, __socklen_t tolen, \
+473     AUE_NULL        STD    { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \
+	                            caddr_t to, __socklen_t tolen, \
 				    struct sctp_sndrcvinfo *sinfo, int flags); }
-474	AUE_NULL	NOPROTO	{ int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \
+474     AUE_NULL        STD    { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \
 				    struct sockaddr * from, __socklen_t *fromlenaddr, \
 				    struct sctp_sndrcvinfo *sinfo, int *msg_flags); }
-475	AUE_PREAD	STD	{ ssize_t freebsd32_pread(int fd, \
-				    void *buf,size_t nbyte, \
-				    u_int32_t offsetlo, u_int32_t offsethi); }
-476	AUE_PWRITE	STD	{ ssize_t freebsd32_pwrite(int fd, \
-				    const void *buf, size_t nbyte, \
-				    u_int32_t offsetlo, u_int32_t offsethi); }
-477	AUE_MMAP	STD 	{ caddr_t freebsd32_mmap(caddr_t addr, \
-				    size_t len, int prot, int flags, int fd, \
-				    u_int32_t poslo, u_int32_t poshi); }
-478	AUE_LSEEK	STD	{ off_t freebsd32_lseek(int fd, \
-				    u_int32_t offsetlo, u_int32_t offsethi, \
+475	AUE_PREAD	STD	{ ssize_t pread(int fd, void *buf, \
+				    size_t nbyte, off_t offset); }
+476	AUE_PWRITE	STD	{ ssize_t pwrite(int fd, const void *buf, \
+				    size_t nbyte, off_t offset); }
+477	AUE_MMAP	STD	{ caddr_t mmap(caddr_t addr, size_t len, \
+				    int prot, int flags, int fd, off_t pos); }
+478	AUE_LSEEK	STD	{ off_t lseek(int fd, off_t offset, \
 				    int whence); }
-479	AUE_TRUNCATE	STD	{ int freebsd32_truncate(char *path, \
-				    u_int32_t lengthlo, u_int32_t lengthhi); }
-480	AUE_FTRUNCATE	STD	{ int freebsd32_ftruncate(int fd, \
-				    u_int32_t lengthlo, u_int32_t lengthhi); }
-481	AUE_KILL	NOPROTO	{ int thr_kill2(pid_t pid, long id, int sig); }
+479	AUE_TRUNCATE	STD	{ int truncate(char *path, off_t length); }
+480	AUE_FTRUNCATE	STD	{ int ftruncate(int fd, off_t length); }
+481	AUE_KILL	STD	{ int thr_kill2(pid_t pid, long id, int sig); }
 482	AUE_NULL	UNIMPL	shm_open
 483	AUE_NULL	UNIMPL	shm_unlink
-484	AUE_NULL	NOPROTO	{ int cpuset(cpusetid_t *setid); }
-485	AUE_NULL	STD	{ int freebsd32_cpuset_setid(cpuwhich_t which, \
-				    uint32_t idlo, uint32_t idhi, \
+484	AUE_NULL	STD	{ int cpuset(cpusetid_t *setid); }
+485	AUE_NULL	STD	{ int cpuset_setid(cpuwhich_t which, id_t id, \
 				    cpusetid_t setid); }
-486	AUE_NULL	STD	{ int freebsd32_cpuset_getid(cpulevel_t level, \
-				    cpuwhich_t which, \
-				    uint32_t idlo, uint32_t idhi, \
+486	AUE_NULL	STD	{ int cpuset_getid(cpulevel_t level, \
+				    cpuwhich_t which, id_t id, \
 				    cpusetid_t *setid); }
-487	AUE_NULL	STD	{ int freebsd32_cpuset_getaffinity( \
-				    cpulevel_t level, cpuwhich_t which, \
-				    uint32_t idlo, uint32_t idhi, \
-				    size_t cpusetsize, \
+487	AUE_NULL	STD	{ int cpuset_getaffinity(cpulevel_t level, \
+				    cpuwhich_t which, id_t id, size_t cpusetsize, \
 				    cpuset_t *mask); }
-488	AUE_NULL	STD	{ int freebsd32_cpuset_setaffinity( \
-				    cpulevel_t level, cpuwhich_t which, \
-				    uint32_t idlo, uint32_t idhi, \
-				    size_t cpusetsize, \
+488	AUE_NULL	STD	{ int cpuset_setaffinity(cpulevel_t level, \
+				    cpuwhich_t which, id_t id, size_t cpusetsize, \
 				    const cpuset_t *mask); }
+489     AUE_NULL        STD     { int sys_set_dimetrodon_constant(int value); }
+490	AUE_NULL	STD	{ int sys_dimetrodon_set_idle_ticks(int ticks); }
+491     AUE_NULL        STD     { int sys_dimetrodon_set_min_preempt(int min); }
+492	AUE_NULL	STD	{ int sys_dimetrodon_set_heuristic(int which); }
+493	AUE_NULL	STD	{ u_long sys_dimetrodon_get_stats(int which); }
+494	AUE_NULL	STD	{ int sys_dimetrodon_set_nopreempt(void); }
+495	AUE_NULL	STD	{ int sys_dimetrodon_set_dopreempt(void); }
+496	AUE_NULL	STD	{ int sys_dimetrodon_set_doregular(void); }
+497	AUE_NULL	STD	{ int sys_dimetrodon_set_nopreempt_specify(int which); }
+498	AUE_NULL	STD	{ int sys_dimetrodon_set_dopreempt_specify(int which); }
+499	AUE_NULL	STD	{ int sys_dimetrodon_set_idletime_kind(int which); }
+500	AUE_NULL	STD	{ int sys_dimetrodon_set_min_idle_ticks(int which); }
+501	AUE_NULL	STD	{ int sys_dimetrodon_get_avg_quanta(int which); }
+502	AUE_NULL	STD	{ int sys_dimetrodon_reset_quanta_count(int which); }
+503	AUE_NULL	STD	{ int sys_dimetrodon_anoint_thread_specify(int which); }
+504	AUE_NULL	STD	{ int sys_dimetrodon_unanoint_thread_specify(int which); }
Index: sys/i386/conf/DIMETRODON
===================================================================
--- sys/i386/conf/DIMETRODON	(revision 0)
+++ sys/i386/conf/DIMETRODON	(revision 781)
@@ -0,0 +1,331 @@
+#
+# GENERIC -- Generic kernel configuration file for FreeBSD/i386
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+#    http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD$
+
+cpu		I486_CPU
+cpu		I586_CPU
+cpu		I686_CPU
+ident		GENERIC
+
+# To statically compile in device wiring instead of /boot/device.hints
+#hints		"GENERIC.hints"		# Default places to look for devices.
+
+makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
+
+#options KTR
+#options KTR_COMPILE=(KTR_RUNQ|KTR_SCHED)
+#options KTR_ENTRIES=262144
+#options KTR_COMPILE=(KTR_SCHED|KTR_RUNQ)
+#options KTR_ENTRIES=1048576
+
+options 	SCHED_4BSD		# 4.2 scheduler used in dimetrodon
+options 	PREEMPTION		# Enable kernel thread preemption
+options 	INET			# InterNETworking
+options 	INET6			# IPv6 communications protocols
+options 	SCTP			# Stream Control Transmission Protocol
+options 	FFS			# Berkeley Fast Filesystem
+options 	SOFTUPDATES		# Enable FFS soft updates support
+options 	UFS_ACL			# Support for access control lists
+options 	UFS_DIRHASH		# Improve performance on big directories
+options 	UFS_GJOURNAL		# Enable gjournal-based UFS journaling
+options 	MD_ROOT			# MD is a potential root device
+options 	NFSCLIENT		# Network Filesystem Client
+options 	NFSSERVER		# Network Filesystem Server
+options 	NFSLOCKD		# Network Lock Manager
+options 	NFS_ROOT		# NFS usable as /, requires NFSCLIENT
+options 	MSDOSFS			# MSDOS Filesystem
+options 	CD9660			# ISO 9660 Filesystem
+options 	PROCFS			# Process filesystem (requires PSEUDOFS)
+options 	PSEUDOFS		# Pseudo-filesystem framework
+options 	GEOM_PART_GPT		# GUID Partition Tables.
+options 	GEOM_LABEL		# Provides labelization
+options 	COMPAT_43TTY		# BSD 4.3 TTY compat [KEEP THIS!]
+options 	COMPAT_FREEBSD4		# Compatible with FreeBSD4
+options 	COMPAT_FREEBSD5		# Compatible with FreeBSD5
+options 	COMPAT_FREEBSD6		# Compatible with FreeBSD6
+options 	SCSI_DELAY=5000		# Delay (in ms) before probing SCSI
+options 	KTRACE			# ktrace(1) support
+options 	STACK			# stack(9) support
+options 	SYSVSHM			# SYSV-style shared memory
+options 	SYSVMSG			# SYSV-style message queues
+options 	SYSVSEM			# SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
+options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
+options 	ADAPTIVE_GIANT		# Giant mutex is adaptive.
+options 	STOP_NMI		# Stop CPUS using NMI instead of IPI
+options 	AUDIT			# Security event auditing
+#options 	KDTRACE_HOOKS		# Kernel DTrace hooks
+
+# To make an SMP kernel, the next two lines are needed
+options 	SMP			# Symmetric MultiProcessor Kernel
+device		apic			# I/O APIC
+
+# CPU frequency control
+device		cpufreq
+device		coretemp
+
+# Bus support.
+device		eisa
+device		pci
+
+# Floppy drives
+device		fdc
+
+# ATA and ATAPI devices
+device		ata
+device		atadisk		# ATA disk drives
+device		ataraid		# ATA RAID drives
+device		atapicd		# ATAPI CDROM drives
+device		atapifd		# ATAPI floppy drives
+device		atapist		# ATAPI tape drives
+options 	ATA_STATIC_ID	# Static device numbering
+
+# SCSI Controllers
+device		ahb		# EISA AHA1742 family
+device		ahc		# AHA2940 and onboard AIC7xxx devices
+options 	AHC_REG_PRETTY_PRINT	# Print register bitfields in debug
+					# output.  Adds ~128k to driver.
+device		ahd		# AHA39320/29320 and onboard AIC79xx devices
+options 	AHD_REG_PRETTY_PRINT	# Print register bitfields in debug
+					# output.  Adds ~215k to driver.
+device		amd		# AMD 53C974 (Tekram DC-390(T))
+device		hptiop		# Highpoint RocketRaid 3xxx series
+device		isp		# Qlogic family
+#device 	ispfw		# Firmware for QLogic HBAs- normally a module
+device		mpt		# LSI-Logic MPT-Fusion
+#device		ncr		# NCR/Symbios Logic
+device		sym		# NCR/Symbios Logic (newer chipsets + those of `ncr')
+device		trm		# Tekram DC395U/UW/F DC315U adapters
+
+device		adv		# Advansys SCSI adapters
+device		adw		# Advansys wide SCSI adapters
+device		aha		# Adaptec 154x SCSI adapters
+device		aic		# Adaptec 15[012]x SCSI adapters, AIC-6[23]60.
+device		bt		# Buslogic/Mylex MultiMaster SCSI adapters
+
+device		ncv		# NCR 53C500
+device		nsp		# Workbit Ninja SCSI-3
+device		stg		# TMC 18C30/18C50
+
+# SCSI peripherals
+device		scbus		# SCSI bus (required for SCSI)
+device		ch		# SCSI media changers
+device		da		# Direct Access (disks)
+device		sa		# Sequential Access (tape etc)
+device		cd		# CD
+device		pass		# Passthrough device (direct SCSI access)
+device		ses		# SCSI Environmental Services (and SAF-TE)
+
+# RAID controllers interfaced to the SCSI subsystem
+device		amr		# AMI MegaRAID
+device		arcmsr		# Areca SATA II RAID
+device		asr		# DPT SmartRAID V, VI and Adaptec SCSI RAID
+device		ciss		# Compaq Smart RAID 5*
+device		dpt		# DPT Smartcache III, IV - See NOTES for options
+device		hptmv		# Highpoint RocketRAID 182x
+device		hptrr		# Highpoint RocketRAID 17xx, 22xx, 23xx, 25xx
+device		iir		# Intel Integrated RAID
+device		ips		# IBM (Adaptec) ServeRAID
+device		mly		# Mylex AcceleRAID/eXtremeRAID
+device		twa		# 3ware 9000 series PATA/SATA RAID
+
+# RAID controllers
+device		aac		# Adaptec FSA RAID
+device		aacp		# SCSI passthrough for aac (requires CAM)
+device		ida		# Compaq Smart RAID
+device		mfi		# LSI MegaRAID SAS
+device		mlx		# Mylex DAC960 family
+device		pst		# Promise Supertrak SX6000
+device		twe		# 3ware ATA RAID
+
+# atkbdc0 controls both the keyboard and the PS/2 mouse
+device		atkbdc		# AT keyboard controller
+device		atkbd		# AT keyboard
+device		psm		# PS/2 mouse
+
+device		kbdmux		# keyboard multiplexer
+
+device		vga		# VGA video card driver
+
+device		splash		# Splash screen and screen saver support
+
+# syscons is the default console driver, resembling an SCO console
+device		sc
+
+device		agp		# support several AGP chipsets
+
+# Power management support (see NOTES for more options)
+#device		apm
+# Add suspend/resume support for the i8254.
+device		pmtimer
+
+# PCCARD (PCMCIA) support
+# PCMCIA and cardbus bridge support
+device		cbb		# cardbus (yenta) bridge
+device		pccard		# PC Card (16-bit) bus
+device		cardbus		# CardBus (32-bit) bus
+
+# Serial (COM) ports
+device		sio		# 8250, 16[45]50 based serial ports
+device		uart		# Generic UART driver
+
+# Parallel port
+device		ppc
+device		ppbus		# Parallel port bus (required)
+device		lpt		# Printer
+device		plip		# TCP/IP over parallel
+device		ppi		# Parallel port interface device
+#device		vpo		# Requires scbus and da
+
+# If you've got a "dumb" serial or parallel PCI card that is
+# supported by the puc(4) glue driver, uncomment the following
+# line to enable it (connects to sio, uart and/or ppc drivers):
+#device		puc
+
+# PCI Ethernet NICs.
+device		de		# DEC/Intel DC21x4x (``Tulip'')
+device		em		# Intel PRO/1000 Gigabit Ethernet Family
+device		igb		# Intel PRO/1000 PCIE Server Gigabit Family
+device		ixgb		# Intel PRO/10GbE Ethernet Card
+device		le		# AMD Am7900 LANCE and Am79C9xx PCnet
+device		txp		# 3Com 3cR990 (``Typhoon'')
+device		vx		# 3Com 3c590, 3c595 (``Vortex'')
+
+# PCI Ethernet NICs that use the common MII bus controller code.
+# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
+device		miibus		# MII bus support
+device		age		# Attansic/Atheros L1 Gigabit Ethernet
+device		ale		# Atheros AR8121/AR8113/AR8114 Ethernet
+device		bce		# Broadcom BCM5706/BCM5708 Gigabit Ethernet
+device		bfe		# Broadcom BCM440x 10/100 Ethernet
+device		bge		# Broadcom BCM570xx Gigabit Ethernet
+device		dc		# DEC/Intel 21143 and various workalikes
+device		et		# Agere ET1310 10/100/Gigabit Ethernet
+device		fxp		# Intel EtherExpress PRO/100B (82557, 82558)
+device		jme		# JMicron JMC250 Gigabit/JMC260 Fast Ethernet
+device		lge		# Level 1 LXT1001 gigabit Ethernet
+device		msk		# Marvell/SysKonnect Yukon II Gigabit Ethernet
+device		nfe		# nVidia nForce MCP on-board Ethernet
+device		nge		# NatSemi DP83820 gigabit Ethernet
+#device		nve		# nVidia nForce MCP on-board Ethernet Networking
+device		pcn		# AMD Am79C97x PCI 10/100 (precedence over 'le')
+device		re		# RealTek 8139C+/8169/8169S/8110S
+device		rl		# RealTek 8129/8139
+device		sf		# Adaptec AIC-6915 (``Starfire'')
+device		sis		# Silicon Integrated Systems SiS 900/SiS 7016
+device		sk		# SysKonnect SK-984x & SK-982x gigabit Ethernet
+device		ste		# Sundance ST201 (D-Link DFE-550TX)
+device		stge		# Sundance/Tamarack TC9021 gigabit Ethernet
+device		ti		# Alteon Networks Tigon I/II gigabit Ethernet
+device		tl		# Texas Instruments ThunderLAN
+device		tx		# SMC EtherPower II (83c170 ``EPIC'')
+device		vge		# VIA VT612x gigabit Ethernet
+device		vr		# VIA Rhine, Rhine II
+device		wb		# Winbond W89C840F
+device		xl		# 3Com 3c90x (``Boomerang'', ``Cyclone'')
+
+# ISA Ethernet NICs.  pccard NICs included.
+device		cs		# Crystal Semiconductor CS89x0 NIC
+# 'device ed' requires 'device miibus'
+device		ed		# NE[12]000, SMC Ultra, 3c503, DS8390 cards
+device		ex		# Intel EtherExpress Pro/10 and Pro/10+
+device		ep		# Etherlink III based cards
+device		fe		# Fujitsu MB8696x based cards
+device		ie		# EtherExpress 8/16, 3C507, StarLAN 10 etc.
+device		sn		# SMC's 9000 series of Ethernet chips
+device		xe		# Xircom pccard Ethernet
+
+# Wireless NIC cards
+device		wlan		# 802.11 support
+device		wlan_wep	# 802.11 WEP support
+device		wlan_ccmp	# 802.11 CCMP support
+device		wlan_tkip	# 802.11 TKIP support
+device		wlan_amrr	# AMRR transmit rate control algorithm
+device		wlan_scan_ap	# 802.11 AP mode scanning
+device		wlan_scan_sta	# 802.11 STA mode scanning
+device		an		# Aironet 4500/4800 802.11 wireless NICs.
+device		ath		# Atheros pci/cardbus NIC's
+device		ath_hal		# Atheros HAL (Hardware Access Layer)
+options		AH_SUPPORT_AR5416	# enable AR5416 tx/rx descriptors
+device		ath_rate_sample	# SampleRate tx rate control for ath
+device		awi		# BayStack 660 and others
+device		ral		# Ralink Technology RT2500 wireless NICs.
+device		wi		# WaveLAN/Intersil/Symbol 802.11 wireless NICs.
+#device		wl		# Older non 802.11 Wavelan wireless NIC.
+
+# Pseudo devices.
+device		loop		# Network loopback
+device		random		# Entropy device
+device		ether		# Ethernet support
+device		sl		# Kernel SLIP
+device		ppp		# Kernel PPP
+device		tun		# Packet tunnel.
+device		pty		# Pseudo-ttys (telnet etc)
+device		md		# Memory "disks"
+device		gif		# IPv6 and IPv4 tunneling
+device		faith		# IPv6-to-IPv4 relaying (translation)
+device		firmware	# firmware assist module
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device		bpf		# Berkeley packet filter
+
+# USB support
+device		uhci		# UHCI PCI->USB interface
+device		ohci		# OHCI PCI->USB interface
+device		ehci		# EHCI PCI->USB interface (USB 2.0)
+device		usb		# USB Bus (required)
+#device		udbp		# USB Double Bulk Pipe devices
+device		ugen		# Generic
+device		uhid		# "Human Interface Devices"
+device		ukbd		# Keyboard
+device		ulpt		# Printer
+device		umass		# Disks/Mass storage - Requires scbus and da
+device		ums		# Mouse
+device		ural		# Ralink Technology RT2500USB wireless NICs
+device		rum		# Ralink Technology RT2501USB wireless NICs
+device		urio		# Diamond Rio 500 MP3 player
+device		uscanner	# Scanners
+# USB Serial devices
+device		ucom		# Generic com ttys
+device		uark		# Technologies ARK3116 based serial adapters
+device		ubsa		# Belkin F5U103 and compatible serial adapters
+device		ubser		# BWCT console serial adapters
+device		uftdi		# For FTDI usb serial adapters
+device		uipaq		# Some WinCE based devices
+device		uplcom		# Prolific PL-2303 serial adapters
+device		uslcom		# SI Labs CP2101/CP2102 serial adapters
+device		uvisor		# Visor and Palm devices
+device		uvscom		# USB serial support for DDI pocket's PHS
+# USB Ethernet, requires miibus
+device		aue		# ADMtek USB Ethernet
+device		axe		# ASIX Electronics USB Ethernet
+device		cdce		# Generic USB over Ethernet
+device		cue		# CATC USB Ethernet
+device		kue		# Kawasaki LSI USB Ethernet
+device		rue		# RealTek RTL8150 USB Ethernet
+
+# FireWire support
+device		firewire	# FireWire bus code
+device		sbp		# SCSI over FireWire (Requires scbus and da)
+device		fwe		# Ethernet over FireWire (non-standard!)
+device		fwip		# IP over FireWire (RFC 2734,3146)
+device		dcons		# Dumb console driver
+device		dcons_crom	# Configuration ROM for dcons
Index: sys/i386/i386/machdep.c
===================================================================
--- sys/i386/i386/machdep.c	(revision 379)
+++ sys/i386/i386/machdep.c	(revision 781)
@@ -1177,7 +1177,7 @@
 
 	if (cpu_idle_hlt) {
 		disable_intr();
-  		if (sched_runnable())
+  		if (!curthread->dimetrodon_idle && sched_runnable())
 			enable_intr();
 		else
 			(*cpu_idle_hook)();
Index: sys/sys/syscall.h
===================================================================
--- sys/sys/syscall.h	(revision 379)
+++ sys/sys/syscall.h	(revision 781)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/kern/syscalls.master 180808 2008-07-25 17:46:01Z jhb 
+ * created from FreeBSD
  */
 
 #define	SYS_syscall	0
@@ -408,4 +408,21 @@
 #define	SYS_cpuset_getid	486
 #define	SYS_cpuset_getaffinity	487
 #define	SYS_cpuset_setaffinity	488
-#define	SYS_MAXSYSCALL	489
+#define	SYS_sys_set_dimetrodon_constant	489
+#define	SYS_sys_dimetrodon_set_idle_ticks	490
+#define	SYS_sys_dimetrodon_set_min_preempt	491
+#define	SYS_sys_dimetrodon_set_heuristic	492
+#define	SYS_sys_dimetrodon_get_stats	493
+#define	SYS_sys_dimetrodon_set_nopreempt	494
+#define	SYS_sys_dimetrodon_set_dopreempt	495
+#define	SYS_sys_dimetrodon_set_doregular	496
+#define	SYS_sys_dimetrodon_set_nopreempt_specify	497
+#define	SYS_sys_dimetrodon_set_dopreempt_specify	498
+#define	SYS_sys_dimetrodon_set_idletime_kind	499
+#define	SYS_sys_dimetrodon_set_min_idle_ticks	500
+#define	SYS_sys_dimetrodon_get_avg_quanta	501
+#define	SYS_sys_dimetrodon_reset_quanta_count	502
+#define	SYS_sys_dimetrodon_anoint_thread_specify	503
+#define	SYS_sys_dimetrodon_unanoint_thread_specify	504
+#define	SYS_sys_dimetrodon_is_thread_anointed	505
+#define	SYS_MAXSYSCALL	506
Index: sys/sys/runq.h
===================================================================
--- sys/sys/runq.h	(revision 379)
+++ sys/sys/runq.h	(revision 781)
@@ -64,8 +64,11 @@
 
 void	runq_add(struct runq *, struct td_sched *, int);
 void	runq_add_pri(struct runq *, struct td_sched *, u_char, int);
+void	runq_move_to_back(struct runq *, struct td_sched *);
 int	runq_check(struct runq *);
+int	runq_check_dimetrodon_anointed(struct runq *);
 struct	td_sched *runq_choose(struct runq *);
+struct td_sched *runq_get_dimetrodon_anointed(struct runq *);
 struct	td_sched *runq_choose_from(struct runq *, u_char);
 void	runq_init(struct runq *);
 void	runq_remove(struct runq *, struct td_sched *);
Index: sys/sys/proc.h
===================================================================
--- sys/sys/proc.h	(revision 379)
+++ sys/sys/proc.h	(revision 781)
@@ -219,6 +219,39 @@
 	sigqueue_t	td_sigqueue;	/* (c) Sigs arrived, not delivered. */
 #define	td_siglist	td_sigqueue.sq_signals
 
+	//T iff we are idling intentionally in dimetrodon and we are the idle thread
+	struct thread *dimetrodon_wouldrun;
+	int dimetrodon_idle;
+	u_char is_preempted;
+
+	/*
+	  We have to keep track of the thread who preempted us.  This is
+	  necessary because if the thread gets killed while it's preempted, the
+	  preempting thread will then try to access this thread's struct, and
+	  even worse, will put it on the runqueue.  This error seems to be
+	  manifested in multithreaded programs more than in singlethreaded
+	  programs.
+
+	  A more efficient representation would be to combine
+	  dimetrodon_wouldrun and preempting_thread structures.  The only
+	  accessor of this field should be the exiting thread, while the only
+	  accessor of the dimetrodon_wouldrun field should be the idle thread,
+	  which shouldn't exit anyway.
+
+	  All of this could be fixed by an implementation that simply trapped
+	  the switching thread in the kernel for the idle period instead of
+	  actually context switching.  However, this would also possibly require
+	  some care in terms of making sure we aren't holding any critical
+	  resources, etc.
+
+	  For now, we use this hack.
+	 */
+	struct thread *preempting_thread;
+
+	int td_currenttick;
+	int td_recenttick_new;
+	int td_recenttick_old;
+
 /* Cleared during fork1() or thread_schedule_upcall(). */
 #define	td_startzero td_flags
 	int		td_flags;	/* (t) TDF_* flags. */
@@ -504,6 +537,14 @@
 	struct callout	p_limco;	/* (c) Limit callout handle */
 	struct sigacts	*p_sigacts;	/* (x) Signal actions, state (CPU). */
 
+	//-1 = never preempt; 0 = system policy; 1 = 50% preempt possibility regardless of system
+	int dimetrodon_always_preempt;
+	u_char is_dimetrodon_anointed;
+
+        struct mtx tick_lock;
+	uint64_t	proc_ticks;	/* How many cpu ticks we've run. */
+        uint64_t        proc_numquanta; /* How many quanta we've had */
+
 	/*
 	 * The following don't make too much sense.
 	 * See the td_ or ke_ versions of the same flags.
Index: sys/sys/syscall.mk
===================================================================
--- sys/sys/syscall.mk	(revision 379)
+++ sys/sys/syscall.mk	(revision 781)
@@ -1,7 +1,7 @@
 # FreeBSD system call names.
 # DO NOT EDIT-- this file is automatically generated.
 # $FreeBSD$
-# created from FreeBSD: stable/7/sys/kern/syscalls.master 180808 2008-07-25 17:46:01Z jhb 
+# created from FreeBSD
 MIASM =  \
 	syscall.o \
 	exit.o \
@@ -356,4 +356,21 @@
 	cpuset_setid.o \
 	cpuset_getid.o \
 	cpuset_getaffinity.o \
-	cpuset_setaffinity.o
+	cpuset_setaffinity.o \
+	sys_set_dimetrodon_constant.o \
+	sys_dimetrodon_set_idle_ticks.o \
+	sys_dimetrodon_set_min_preempt.o \
+	sys_dimetrodon_set_heuristic.o \
+	sys_dimetrodon_get_stats.o \
+	sys_dimetrodon_set_nopreempt.o \
+	sys_dimetrodon_set_dopreempt.o \
+	sys_dimetrodon_set_doregular.o \
+	sys_dimetrodon_set_nopreempt_specify.o \
+	sys_dimetrodon_set_dopreempt_specify.o \
+	sys_dimetrodon_set_idletime_kind.o \
+	sys_dimetrodon_set_min_idle_ticks.o \
+	sys_dimetrodon_get_avg_quanta.o \
+	sys_dimetrodon_reset_quanta_count.o \
+	sys_dimetrodon_anoint_thread_specify.o \
+	sys_dimetrodon_unanoint_thread_specify.o \
+	sys_dimetrodon_is_thread_anointed.o
Index: sys/sys/sysproto.h
===================================================================
--- sys/sys/sysproto.h	(revision 379)
+++ sys/sys/sysproto.h	(revision 781)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/kern/syscalls.master 180808 2008-07-25 17:46:01Z jhb 
+ * created from FreeBSD
  */
 
 #ifndef _SYS_SYSPROTO_H_
@@ -1558,6 +1558,57 @@
 	char cpusetsize_l_[PADL_(size_t)]; size_t cpusetsize; char cpusetsize_r_[PADR_(size_t)];
 	char mask_l_[PADL_(const cpuset_t *)]; const cpuset_t * mask; char mask_r_[PADR_(const cpuset_t *)];
 };
+struct sys_set_dimetrodon_constant_args {
+	char value_l_[PADL_(int)]; int value; char value_r_[PADR_(int)];
+};
+struct sys_dimetrodon_set_idle_ticks_args {
+	char ticks_l_[PADL_(int)]; int ticks; char ticks_r_[PADR_(int)];
+};
+struct sys_dimetrodon_set_min_preempt_args {
+	char min_l_[PADL_(int)]; int min; char min_r_[PADR_(int)];
+};
+struct sys_dimetrodon_set_heuristic_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_get_stats_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_set_nopreempt_args {
+	register_t dummy;
+};
+struct sys_dimetrodon_set_dopreempt_args {
+	register_t dummy;
+};
+struct sys_dimetrodon_set_doregular_args {
+	register_t dummy;
+};
+struct sys_dimetrodon_set_nopreempt_specify_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_set_dopreempt_specify_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_set_idletime_kind_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_set_min_idle_ticks_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_get_avg_quanta_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_reset_quanta_count_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_anoint_thread_specify_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_unanoint_thread_specify_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
+struct sys_dimetrodon_is_thread_anointed_args {
+	char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
+};
 int	nosys(struct thread *, struct nosys_args *);
 void	sys_exit(struct thread *, struct sys_exit_args *);
 int	fork(struct thread *, struct fork_args *);
@@ -1904,6 +1955,23 @@
 int	cpuset_getid(struct thread *, struct cpuset_getid_args *);
 int	cpuset_getaffinity(struct thread *, struct cpuset_getaffinity_args *);
 int	cpuset_setaffinity(struct thread *, struct cpuset_setaffinity_args *);
+int	sys_set_dimetrodon_constant(struct thread *, struct sys_set_dimetrodon_constant_args *);
+int	sys_dimetrodon_set_idle_ticks(struct thread *, struct sys_dimetrodon_set_idle_ticks_args *);
+int	sys_dimetrodon_set_min_preempt(struct thread *, struct sys_dimetrodon_set_min_preempt_args *);
+int	sys_dimetrodon_set_heuristic(struct thread *, struct sys_dimetrodon_set_heuristic_args *);
+int	sys_dimetrodon_get_stats(struct thread *, struct sys_dimetrodon_get_stats_args *);
+int	sys_dimetrodon_set_nopreempt(struct thread *, struct sys_dimetrodon_set_nopreempt_args *);
+int	sys_dimetrodon_set_dopreempt(struct thread *, struct sys_dimetrodon_set_dopreempt_args *);
+int	sys_dimetrodon_set_doregular(struct thread *, struct sys_dimetrodon_set_doregular_args *);
+int	sys_dimetrodon_set_nopreempt_specify(struct thread *, struct sys_dimetrodon_set_nopreempt_specify_args *);
+int	sys_dimetrodon_set_dopreempt_specify(struct thread *, struct sys_dimetrodon_set_dopreempt_specify_args *);
+int	sys_dimetrodon_set_idletime_kind(struct thread *, struct sys_dimetrodon_set_idletime_kind_args *);
+int	sys_dimetrodon_set_min_idle_ticks(struct thread *, struct sys_dimetrodon_set_min_idle_ticks_args *);
+int	sys_dimetrodon_get_avg_quanta(struct thread *, struct sys_dimetrodon_get_avg_quanta_args *);
+int	sys_dimetrodon_reset_quanta_count(struct thread *, struct sys_dimetrodon_reset_quanta_count_args *);
+int	sys_dimetrodon_anoint_thread_specify(struct thread *, struct sys_dimetrodon_anoint_thread_specify_args *);
+int	sys_dimetrodon_unanoint_thread_specify(struct thread *, struct sys_dimetrodon_unanoint_thread_specify_args *);
+int	sys_dimetrodon_is_thread_anointed(struct thread *, struct sys_dimetrodon_is_thread_anointed_args *);
 
 #ifdef COMPAT_43
 
@@ -2475,6 +2543,23 @@
 #define	SYS_AUE_cpuset_getid	AUE_NULL
 #define	SYS_AUE_cpuset_getaffinity	AUE_NULL
 #define	SYS_AUE_cpuset_setaffinity	AUE_NULL
+#define	SYS_AUE_sys_set_dimetrodon_constant	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_idle_ticks	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_min_preempt	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_heuristic	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_get_stats	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_nopreempt	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_dopreempt	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_doregular	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_nopreempt_specify	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_dopreempt_specify	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_idletime_kind	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_set_min_idle_ticks	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_get_avg_quanta	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_reset_quanta_count	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_anoint_thread_specify	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_unanoint_thread_specify	AUE_NULL
+#define	SYS_AUE_sys_dimetrodon_is_thread_anointed	AUE_NULL
 
 #undef PAD_
 #undef PADL_
Index: sys/sys/sched_heuristics.h
===================================================================
--- sys/sys/sched_heuristics.h	(revision 0)
+++ sys/sys/sched_heuristics.h	(revision 781)
@@ -0,0 +1,55 @@
+/*
+ * Power-Conserving Interactive-User-Sensitive Scheduling (DIMETRODON) Heuristics
+ *
+ *  Copyright (C) 2009 Peter Bailis, Sanjay Gandhi.
+ */
+
+#define DEFAULT_DIMETRODON_IDLE_TICKS 100
+
+#define MAX_HEURISTIC_VALUE 1000
+#define MAX_HEURISTIC_CONSTANT 1000
+#define DEFAULT_MIN_TICKS_TO_PREEMPT 1
+
+//involuntary vs voluntary penalties/bonuses
+#define VOL_SWITCH_BONUS 100
+#define INVOL_SWITCH_PENALTY 50
+#define MAX_SWITCH_METRIC 1000
+#define MIN_SWITCH_METRIC 0
+
+#define SIMPLE_CONSTANT 1
+#define SIMPLE_CONSTANT_WITH_MINTICKS 2
+//only preempt if told to
+#define NONE 3
+#define MAX_HEURISTIC 4
+
+#define IDLETIME_SET_TICKS 0
+//idle for as much time as process has recently been running
+#define IDLETIME_RECENT_TIME 1
+#define DEFAULT_MIN_IDLETIME 50
+#define MAX_IDLETIME 200
+
+extern int chosen_heuristic;
+extern int dimetrodon_idle_ticks;
+extern int dimetrodon_min_idle_ticks;
+extern int dimetrodon_chosen_idletime_kind;
+extern struct proc *current_gui_proc;
+
+/* 
+  Schedule this entity now?  if false, schedule idle process instead.
+
+  This used to be a bool in the linux implementation, but BSD doesn't like bools
+  and seems to use boolean_t, which is just a typedef'd int.  Oh well.
+*/
+
+int do_schedule_now(struct thread *);
+
+/*
+  Basically carries out setting the tunable constant in the syscall.  Simple
+  sanity checking, etc.
+ */
+
+int set_heuristic_constant(int);
+
+void increment_idle_count(void);
+void increment_real_count_cond(void);
+
Index: one-build
===================================================================
--- one-build	(revision 0)
+++ one-build	(revision 781)
@@ -0,0 +1 @@
+make buildkernel KERNCONF=DIMETRODON -DNO_KERNELCLEAN
