-Don't consider non-existence of a PID file an error.
-Add -P flag which prevents further action if the pidfile is empty or
doesn't exist.
-Add a -S switch to override the default syslog pid file.
-Add support for creating the archived log filenames using a time-stamp
instead of the traditional simple counter.
-Add xz(1) support.
-Rewrite and simplify logfile compression code.
-Convert newsyslog to using queue(3) macros.
-Add file include processing.

-Add some tests for omitting whitespace.
-Split off some special behaviour into separate tests.
-Do not use "local" in the test runner.
-Make execution/fork1.0 work even if the basename of ${SH} is not "sh".
-Test that the read builtin passes through all byte values except NUL,
newline and backslash.
-Unset some locale vars in two tests that may cause them to break.

* Clear the new BRIDGE_MBUF_TAGGED flag when a NAT or other translation
changes the source IP for a packet, otherwise packets traversing a bridged
interface may wind up with a source MAC that has nothing to do with
the translated source IP.

* Defaults to non-transparent (historical) operation, which is safer.
Set link0 to use in transparent MAC mode.

* Transparent MAC mode will attempt to retain the MAC source in the
link address header when retransmitting a packet on a different
interface.

Only IP/IPV6 packets will retain the MAC. ARP and other ether types
will get the outgoing interface's MAC address, which is usually
desireable.

* Note that transparent MAC mode is a bit dangerous, which is why it
isn't turned on by default. If a packet with the originating MAC
winds up being sent out the same interface it came in on with the
MAC intact, any switches between the two boxes will suddenly think
the originating machine is somewhere else and will get confused.

The code tries to avoid this situation.

Bridging loops can also cause this sort of behavior even with the spanning
tree protocol. link0 is not recommended if you have loops.

* Coded because I needed this for braindead at&t uverse routers which
do MAC-based security and only allow one IP association for each MAC,
and whos firewalls cannot be completely disabled, and which cannot deal
with IPs on routed networks (it expects everything to be directly connected
on a switched network. sigh).

* Allow rn_inithead() to be called earlier than rn_init(). rn_init() is
called very late and was responsible for creating the all-ones and
all-zeros keys. It also required the proto domains to be initialized(?).

* A PF module preload was calling rn_inithead() before the all-ones and
all-zeros keys could be allocated, resulting in a crash.

Issues synchronous IO requests in response to AIO calls; does not
support SIGEV_THREAD or SIGEV_SIGNAL; the former because our
infrastructure doesn't have SIGEV_THREAD already; the latter
because we do not support sigqueue() or sending signals w/ a
sigval payload.

* Stage 2 is a long-term (30-second) batch operations detector which de-tunes
the estcpu calculation based on how long the process has been acting
batch-like or non-batch-like. estcpu is detuned up to 50% for processes
considered to be fully interactive.

* Newly forked processes are placed two queue slots higher (less desireable)
than their parent in stage 1. If they aren't batch they will quickly
recover.

* Newly forked processes are given a batch heuristic value that is mid-range
for stage 2 and must prove themselves one way or the other.

* 'ps -o batch -axl' can be used to see the batch heuristic. ps will display
it as a value between 0 and 11 for the moment.

The idea here is for something like firefox and the X server to remain
interactive even if they use a lot of cpu, while something like a parallel
buildworld winds up remaining batch-like because the core processes are
cpu-bound.

Introduce ioapic enumerators, which is used to probe and config ioapics

ioapic enumerator implementation should provide two methods:

ioapic_probe()
Make sure that if this enumerator is selected, later ioapic
enumeration could work. Return error code upon failure.

ioapic_enumerate()
Enumerate ioapic and prepare for later ioapic configuration in
the common code (the configuration in the common code is not
implemented yet).

ioapic enumerator implementation could be registered by calling
ioapic_enumerator_register() with ioapic_enumerator struct. The
higher the priority field, the earlier the ioapic enumerator's
ioapic_probe method will be invoked.

Currently a do-nothing-other-than-logging ioapic enumerators are
implemented and registered. This dummy ioapic enumerator uses ACPI
MADT.

* pfind() zpfind() now returns a referenced proc structure, callers must
release the proc with PRELE(). Callers no longer need to hold proc_token
for stable access.

* Enhance pgrp, adding pgrp->pg_token and pgrp->pg_refs in addition to
pgrp->pg_lock. The lock is used to interlock races between fork() and
signals while the token and refs are used to control access.

* Add pfindn(), a version of pfind() which does not ref the returned proc.
Some code still uses it (linux emulation) ---> needs work.

* Add pgref() and pgrel() to mess with the pgrp's pg_refs. pgrel()
automatically destroys the pgrp when the last reference goes away.

* Most process group operations now use the per-process token instead of
proc_token, though pgfind() still needs it temporarily.

* pgfind() now returns a referenced pgrp or NULL.

* Interlock signal handling with p->p_token instead of proc_token.

* Adjust most nice/priority functions to use the per-process token.

* Add protective PHOLD()s in various places in the signal code, the
ptrace code, and procfs.

* Change funsetown() to take the address of the sigio pointer to match
fsetown(), add sanity assertions.

-Fix more issues allowing /bin/sh to pass more regression tests.
-Do not use sh memory functions in sh builtin.
-We work on ctype's and not only on numbers so set LC_ALL.
-The only caller of mknum() provides a char instead of an int, so make
it match the definition.
-Remove support for building as a csh builtin.
-POSIX compliance.
-Prefer intmax_t over long long.
-Handle null characters in the format string.
-No reason to write \a and \v as octal escape sequences.
-Move parts of the long main() function into a new function doformat().
-Rewrite the loop in main() to be more understandable.
-Replace buggy for-loops to skip certain character with strspn().
-Support the L modifier for floating-point values as an extension.
-Allow %' to be used as a format flag by printf(1).
-Enable support for the %a, %A, and %F format specifiers.
-Let printf(1) tell the difference between zero width/precision and
unspecified width/precision.
-Allow format strings containing "%%" to be reused.
-Allow `%' to be written out with an octal escape (\45 or \045).
-Man page markup.

-Help /bin/sh pass a few more regression tests.
-Convert to use st_mtim instead of st_mtimespec.
-Fix various cases with 3 or 4 parameters in test(1) to be POSIX
compliant.
-Use intmax_t as a quad replacement instead of long long.
-__printflike() should really be __printf0like().
-Localize (LC_CTYPE).
-Cleanup whitespace.
-Simplify markup in man page.
-Describe how test(1) will evaluate its expressions for a symlink.
-Document that both sides of -a or -o are always evaluated.

* Pre-initialize result fields to NULL/0 because we do not check the return
value from linker_ddb_symbol_values(). This way if the lookup fails we
print a nice "(null)" out instead of faulting the debugger.

This is a combination of 198 commits that enhances performance,
standards compliance, and bug fixes:

-Fix exit status of case statement.
-sh.1: Update markup.
-Fix PWD values.
-Fix null pointer dereferences.
-Fix bugs where arithmetic expansion$((...)) was truncated
-Pass the correct flags to expandarg() for NFROMFD and NTOFD.
-Add __dead2
-Fix $? at the first command of a function.
-Report error messages to stderr instead of stdout.
-Make alias builtin POSIX compliant.
-Improve the IFS handling of the read built-in.
-Don't let empty lines overwrite the result of the last command with 0.
-Fix the eval command in combination with set -e.
-Make read's timeout (-t) apply to the entire line.
-align local ckmalloc() with malloc(3) by using a size_t
-style(9) to enhance readability
-explicit 'unsigned int' instead of just 'unsigned'
-Mention the range for the exit status for the exit builtin
-Don't skip forking for an external command if any traps are active.
-Avoid leaving unnecessary waiting shells.
-Properly flush input after an error in backquotes
-Fix some issues with quoted output
-Fix race condition in noclobber option
-Improve handling of setjmp/longjmp volatile
-Do not fork for EV_EXIT.
-Quote -x tracing output so it is unambiguous.
-Designate special builtins as such in command -V and type.
-Fix crash when undefining or redefining an executing function.
-Fix memory leak when using a variable in arithmetic like $((x)).
-Use sigaction instead of signal/siginterrupt combination.
-Allow a newline before "in" in a for command, as required by POSIX.
-Some changes to stderr flushing.
-Handle current work directories of arbitrary length.
-trap: do not consider a bad signal name a fatal error.
-Ensure the same command input file is on top after execing builtin.
-Fix various things about SIGINT handling.
-Fix some cases where file descriptors from redirections leak to programs.
-Remove setting variables from dotcmd/exportcmd.
-Fix a memory leak when calling . with variable assignments.
-Constify various strings.
-Do not consider a tilde-prefix with expansions in it.
-Do not run callers' exception handlers in subshells.
-Remove declaration of function that no longer exists.
-WARNS fixes to reduce diffs to FreeBSD
-arith: Return only 0 and 1 from && and ||.
-Fix memory leak when parsing backticks (``).
-Ensure funcnest is decremented if there's an error in the function.
-Allow command -pv and command -pV
-Fix some bugs with backquoted builtins.
-Send the "not found" message for builtin <cmd> to redirected fd 2.
-Do not stat() $MAIL/$MAILPATH in non-interactive shells.
-Fix expansion of \W in prompt strings when the working directory is "/".
-Improve the command builtin:
-Make sure to popredir() even if a special builtin caused an error.
-Make sure to popredir() even if a function caused an error.
-Make parsebackq a function instead of an emulated nested function.
-Do not abort on a redirection error if there is no command word.
-Do not abort on a redirection error on a compound command.
-Treat unexpected newlines in substitutions as a syntax error.
-Fix various things about expansions.
-Remove special handling for ' and " in arithmetic.
-Allow quoting pattern match characters in ${v%pat} and ${v#pat}.
-Do tilde expansion in substitutions.
-Automatically enable -o emacs in interactive shells with terminals.
-On startup of the shell, use PWD from the environment if it is valid.
-Use stalloc for arith variable names.
-Apply locale vars on builtins, recognize LC_MESSAGES as a locale var.
-Have only one copy of _PATH_STDPATH in the binary.
-Fix "reserved word" vs "keyword" inconsistency.
-Fix pathname expansion with quoted slashes like *\/.
-Reap any zombies before forking for a background command.
-Rework documentation of shell variables.
-Recognize "--" in . and exec.
-Change interaction of command substitution and here documents.
-Fix a crash if a heredoc was not properly ended and parsing continued.
-Pass TERM changes to libedit.
-Pass through SIGINT from a child if interactive and job control is enabled.
-Forget about terminated background processes sooner.
-Use $PWD instead of getcwd() for the \w and \W prompt expansions.
-Allow a background command consisting solely of redirections.
-Fix crash due to uninitialized here-document.
-Return 0 from eval if no command was given.
-Remove unnecessary duplicate letters in mksyntax.c
-Fix heap-based buffer overflow in pathname generation.
-Fix shadowing of sigset.
-Fix break/continue/return sometimes not skipping the rest of dot script.
-Add a brief summary of arithmetic expressions.
-Remove remnants of '!!' to negate pattern.
-Do not use locale for determining if something is a name.
-Get rid of some magic numbers.
-Improve comments in expand.c.
-Fix 'read' if all chars before the first IFS char are backslash-escaped.
-Remove xrefs for expr(1) and getopt(1).
-Apply variable assignments left-to-right in bltinlookup().
-Fix exit status if return is used within a loop condition.
-Suggest that DEBUG_FLAGS be used to enable extra debugging
-Make DEBUG traces 64-bit clean.
-Remove the "STATIC" macro
-Fix a bug in STACKSTRNUL()
-Clarify subshells/processes for pipelines.
-There cannot be a TNOT in simplecmd(), remove checks.
-Change ! within a pipeline to start a new pipeline instead.
-Check whether dup2 was successful for >&FD and <&FD.
-Make sure defined functions can actually be called.
-Do not allow overriding a special builtin with a function.
-Ignore double-quotes in arithmetic rather than treating them as quotes.
-Make double-quotes quote a '}' inside ${v#...} and ${v%...}.
-Only accept a '}' inside ${v+-=?...} if double-quote state matches.
-Do IFS splitting on word in ${v+word} and ${v-word}.
-Fix some issues with CTL* bytes and ${var#pat}.
-Error out on various specials/keywords in the wrong place in backticks.
-Detect various additional errors in the parser.
-Reject function names ending in one of !%*+-=?@}~
-Tweak some string constants to reduce code size.
-Use iteration instead of recursion to evaluate semicolon lists.
-Reindent evaltree().
-Correct synopsis and make precise how $0 is set.
-Fix some issues with aliases and case, by importing dash checkkwd code.
-Modernize the introduction a bit.
-Remove unused man page for echo builtin.
-Do the additional actions if 'local -' restore changes -i/-m/-E/-V.
-Add binary buffered output for use by the printf builtin.
-document printf builtin
-Code size optimizations to buffered output.
-Remove the check that alpha/name/in_name chars are not CTL* bytes.
-Fix confusing behaviour if chdir succeeded but getcwd failed in cd -P.
-Code size optimizations to "stack string" memory allocation
-jobs -p: Do not ask the kernel for the pgid.
-Improve jobs output of pipelines.
-POSIX says there should not be a space between Done and (exitstatus).
-Improve internal-representation-to-text code to avoid binary output.
-Use vsnprintf() rather than crafting our own in fmtstr().
-Replace some macros and repeated code in expand.c with functions.
-Remove the herefd hack.
-Various simplifications to jobs.c
-Remove duplicate check, turning dead code into live code.
-Fix corruption of command substitutions with special chars after newline
-Remove dead code.
-arith: Disallow decimal constants starting with 0 (containing 8 or 9).
-Make warnings in the printf builtin non-fatal.
-Add a function to print warnings (with command name and newline).
-Add kill builtin.
-Explain why it is a bad idea to use aliases in scripts.
-Allow arbitrary large numbers in CHECKSTRSPACE.
-Make expansion errors in optimized command substitution non-fatal.
-Don't do optimized command substitution if expansions have side effects.
-Properly restore exception handler in fc.
-Avoid side effects from builtins in optimized command substitution.
-Check if dup2 for redirection from/to a file succeeds.
-Check readonly status for assignments on regular builtins.
-Do not call exitshell() from evalcommand() unless evalcommand() forked itself
-Make exit without parameters from EXIT trap POSIX-compliant.
-Remove special %builtin PATH entry.
-Make 'trap -l' look like 'kill -l'.
-Fix some things about -- in trap.
-If exit is used without args from a trap action, exit on the signal.
-Fix signal messages being sent to the wrong file sometimes.
-Send messages about signals to stderr.
-Return only 126 or 127 for execve() failures.
-Make sys_signame upper case.
-Remove special code for shell scripts without magic number.
-Do not try to execute binary files as scripts.
-Forget all cached command locations on any PATH change.
-Fix two things about {(...)} <redir.
-Import arithmetic expression code from dash.
-Install /bin/sh safely.

* Add proc->p_token and use it to interlock signal-related operations.

* Remove the use of proc_token in various signal paths. Note that proc_token
is still used in conjuction with pfind().

* Remove the use of proc_token in CURSIG*()/issignal() sequences, which
also removes its use in the tsleep path and the syscall path. p->p_token
is use instead.

* Move the automatic interlock in the tsleep code to before the CURSIG code,
fixing a rare race where a SIGCHLD could race against a parent process
in sigsuspend(). Also acquire p->p_token here to interlock LWP_SINTR
handling.

* The minimum undo/redo fifo really needs to be larger. Don't play
around, make it 500M. People who want to run HAMMER on small hard
drives or images need to be cognizent of the requirement.

* This partially solves (only partially) a FIFO overflow condition.
Effectively the complexity of buffered operations hammer allows to
build up in the kernel could easily overflow a minimally-sized on-media
UNDO/REDO FIFO. Upping the requirement makes the case less likely.

The remainder of the resolution will require some fixes in the
HAMMER VFS code.

* Reduce the usched_bsd4_decay default to 1. It may be removed entirely
in the future.

* This improves the dynamic priority handling by reducing ad-hoc estcpu
decreases from the 1-second interval clock. The tsleep code handles
this a lot better already and the ad-hoc decreases don't do a good job
handling the case where there are a very large number of runnable
cpu-bound processes (because they don't actually get a lot of cpu but
still eat a large proportion of the scheduled time in aggregate).

Tested with blogbench during stage 1. Prior to this fix the 100+ blogbench
threads were being dropped down to almost realtime priorities even though
they remained in a 100% 'R'un state.

* Also reduce the amount the parent process of a fork() is docked for cpu
due to the fork. The value was high enough that interactive sessions were
being pushed up to batch priorities with only a moderate number of forks
and not decaying quickly enough to stabilize.

The child process is docked the same as before (handling the fork chaining
case).

Tested with blogbench and parallel makes of /usr/src/lib/libc. The
blogbench uniformly increases to batch priority and didn't need the
higher boost the old values gave it while the parallel compile's fork
chaining gave it a good shove towards batch priority while the repeated
forks slowly pushed the higher level make and /bin/sh's to more batch-like
priorities.

acpi(4): Fix a bug in acpi_cpu_cstate.c (we have to write, and not to read).

Introduced with 10f976749fd9ad2e8642ea80ce533f7416910a65. The commit message
said "Sync ACPI with FreeBSD 7.2", even though FreeBSD 7.2 doesn't seem to
have this code at all, so I'm not sure about what the idea behind that
change was. I'm guessing it is a typo, since newer FreeBSDs call
AcpiWriteBitRegister() here too.

All these headers #define _CPU_... and not _MACHINE_... even though they
are in /usr/include/machine. And the headers themselves have include
guards already. So there's little point in having them around the actual
#include additionally.

Move pkg_radd config to a more obvious name; make sure settings.conf gets
cleaned out on upgrade, and stick a warning in UPGRADING so nobody
(hopefully) gets surprised when pkg_radd starts downloading from
mirror-master again.