Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
Try this again, on the correct branch this time!

Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
Adapt to single-parameter mi_switch(), and fix up some contstants. Also
add notes covering the two places we really wanted a specific other
thread to run. We will need to adjust thread priorities to do the same
thing in the new world order.
Adapt to current POOL_INIT() signature. Add IPL values. I believe we
never pull anything out of our pools at IPL, so go with IPL_NONE.
While here, lose the comments at the end of the lines; move them
to before each POOL_INIT(). I find it hideously difficult to read,
so imporve it.

Our locks now are mutexes, so lose the simple lock code. The
per-VP mutex needs top be IPL_SCHED since we will aquire it when
we're called from sleepq_block(). Make the other mutex SCHED for
now.
System call handlers now are different. Instead of "void *",
we get passed the syscall arg structure directly. Mainly a
matter of typing. Adapt.
Scheduler and proc locking isn't the same as it was. Comment the
old locking out for now. Obviously needs updating. Remove a number
of int s variables as a result.

LPR_DETATCHED is not in the same flag word as LW_SA.
Reimpliment the preempt() handling from 4.0 SA. This time, however,
do it better. Since every call to preempt() set the "more" paremeter
to true except for one, leave preempt alone and add code to
explicitly handle what preempt() did w/ "more" set to false.

The one case in question is in sys_sched_yield(). Explicitly trigger
generating a BLOCKED upcall, which will also trigger an UNBLOCKED
upcall when we actually return to userland. This will sufficiently
rattle the libpthread scheduler as to let opther threads run.

This is a minor ABI change in that we now always generate the upcalls,
where as in 4.0 we only generated them iff mi_switch() switched us
to another thread. Since userland threads are what matter for an SA
process, I don't think that will hurt us.
I have no idea how this compiled before w/o sys/sa.h. But we need it, so
include it.
Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
Put back SA-clearing flags in execve1. Now use lwp_{un,}lock() for
locking.
Add back checks to ensure we don't mix 1:1 & SA threaded processes.
Pull in most all of the changes ad made to this file before
removing SA (other than the changes that disabled the system calls).

Changes were slightly modernized to use p_lock instead of p_smutex, and
also blended with the other changes I've made so far.

Locking needs review to ensure that if we block on p_lock that we don't
tell userland about it.
Add back p_timerpend.
Adapt to changes in kern/kern_sa.c. List locking, expect an RB
tree not a SPLAY tree, and zap an unused mutex. Also add fields
used by newlock-based changes to kern_sa.c.
PHOLD/PRELE -> uvm_lwp_hold/uvm_lwp_rele
Re-add userret hook. Add a new define, SA_NO_USERRET, which
indicates that upcall support should NOT be included. Add this
for all non-netbsd emulations. They will never be SA apps, so
let's make the invarient pretty blatant.

NetBSD code should include both sys/sa.h and sys/savar.h.
Re-add calls to sa_awaken() and sa_switch(). Also add
back sa_awaken() itself. While here, remove the "type"
arguement to sa_switch() - it is all about generating
blocked upcalls.
SA processes can only have one sigwaiter.
Re-add exit code. Clean up SA info on our way out of a process.

While here, change the documented locking on the lwp cache to be
based on p_lock, not sa_mutex. Avoids vile locking inversion work
in exit.