Home | History | Annotate | only in /src/sys/compat/common
History log of /src/sys/compat/common
RevisionDateAuthorComments
 1.67 20-Dec-2022  msaitoh Remove sys/compat/common/Makefile.*.

These files are not used anymore. Files for compat code are listed in
sys/comapt/common/files.common and sys/modules/compat_xxx/Makefile.
OK'd by riastradh@ and pgoyette@.
 1.66 25-May-2021  pgoyette PR port-xen/53130 was fixed and closed some time ago, so now we can
belatedly re-enable inclusion of the compat_60 x86 microcode code in
the loadable module. (It was already being included in the built-in
version of the module.)
 1.65 27-Jan-2019  pgoyette branches: 1.65.16; 1.65.18;
Merge the [pgoyette-compat] branch
 1.64 05-Jun-2018  christos branches: 1.64.2;
use the standard rules, instead of rolling our own.
 1.63 20-Dec-2017  maya branches: 1.63.2;
Pass LDFLAGS to ld.

Without this, mips64-ld thinks we want to link our n64 objects with the
default ABI, n32.
 1.62 16-Dec-2017  maxv compat_util.c must be compiled by default in the kernel. It is needed by
generic non-compat code, so it must not depend on anything (libcompat or
whatever option we choose to associate it to).
 1.61 04-Aug-2017  maxv typos
 1.60 05-Nov-2016  pgoyette Move if_43.c back into the shared Makefile.sysio where it really
belongs.

Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers. Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.

Addresses the issue pointed out in PR kern/51598
 1.59 03-Nov-2016  pgoyette Move if_43.c out of Makefile.sysio and into the main Makefile.

The former location gets included in both libcompat and the compat
module, leading to redefined symbols when the module is loaded. By
moving it to the main Makefile, it gets included only in libcompat.

XXX This still isn't an ideal solution, but it will suffice until
XXX PR kern/51598 is addressed.
 1.58 03-Nov-2016  riastradh Reorganize SRCS lists for libcompat, compat.kmod, sysv_ipc.kmod.

- Share lists between the libcompat and module makefiles.
- Include some omitted entries in compat.kmod:
. if_43.c
. kern_sa_60.c
. kern_time_30.c
. rndpseudo_50.c
. rtsock_14.c
. rtsock_50.c
. rtsock_70.c
. uipc_syscalls_40.c
. uipc_syscalls_50.c
- Exclude a (harmless) spurious entry in sysv_ipc.kmod on LP64 systems:
. kern_ipc_10.c

Should fix broken ifconfig on modular current kernels.

ok pgoyette
 1.57 21-Sep-2016  roy Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.
 1.56 06-Apr-2016  roy branches: 1.56.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.
 1.55 22-Mar-2016  mrg remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for. very few other targets claim they're done so just remove these.
 1.54 07-Sep-2015  uebayasi Order library object build.
 1.53 07-Sep-2015  uebayasi Sprinkle more done messages.
 1.52 04-Apr-2014  njoly branches: 1.52.6;
Move a few compat 50 syscalls, not applicable to rump kernels, out of
kern_time_50.c to a new source module.
 1.51 29-Mar-2013  christos branches: 1.51.4;
compat glue for new lwp_park()
 1.50 19-Oct-2012  apb Add COMPAT_60 versions of the TIOCPTMGET and TIOCPTSNAME ioctls.
 1.49 19-Feb-2012  matt branches: 1.49.2;
Add compat_60 stub for the SA syscall (all which just call sys_nosys).
 1.48 19-Dec-2011  apb Add COMPAT_50 and COMPAT_NETBSD32 compatibility code for rnd(4)
ioctl commands.

Tested with "rndctl -ls" using an old 32-bit version of rndctl(8)
(built for NetBSD-5.99.56/i386) and a new 64-bit kernel
(NetBSD-5.99.59/amd64).
 1.47 11-Aug-2011  jmcneill branches: 1.47.2; 1.47.6;
add libcompat.o/.po targets for COMPAT_AS=obj
 1.46 17-Jan-2011  pooka Put async i/o compat routines in a separate source module from the
ones related to clock and process management.
 1.45 19-Jan-2009  christos branches: 1.45.6; 1.45.8;
Provide compatibility for pre-christos-time_t sysv sysctls.
 1.44 11-Jan-2009  christos merge christos-time_t
 1.43 14-Nov-2008  ad - Move some more compat code into sys/compat.
- Split 4.3BSD ifioctl stuff into its own file.
- Remove some ifdefs that include small fragments of vfs compat code
which are difficult to relocate elsewhere.
 1.42 24-Feb-2008  martin branches: 1.42.2; 1.42.6; 1.42.12; 1.42.14;
Remove compat code for posix_fadvise
 1.41 27-Jan-2008  martin branches: 1.41.2; 1.41.6;
Implement new version of posix_fadvise as a stub callinig the real
worker function, and compatibility stub doing the same with old argument
sturcture.
 1.40 12-Dec-2007  dsl compat_file.[ch] are no longer used
 1.39 29-May-2007  christos branches: 1.39.8; 1.39.14; 1.39.16; 1.39.18; 1.39.20;
Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
 1.38 10-Mar-2007  dsl branches: 1.38.2;
Update all the compat stuff to not use the 'stackgap' for processing
sys_stat() and friends, instead use do_sys_stat() and do_sys_fstat()
that write the answer into a kernel buffer (on stack) that can be
converted to the correct form and written the userspace.
I've test compiled a few kernels, and tested i386 netbsd1.6 ls.
Given I think I've fixed some bugs, it might be 50-50 with new ones.
 1.37 26-Jun-2006  mrg branches: 1.37.10; 1.37.14;
version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.
 1.36 11-Dec-2005  christos branches: 1.36.4; 1.36.8; 1.36.16;
merge ktrace-lwp.
 1.35 19-Aug-2005  christos 64 bit inode changes.
 1.34 26-Feb-2005  perry branches: 1.34.4;
nuke trailing whitespace
 1.33 21-Apr-2004  christos branches: 1.33.4; 1.33.6;
Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.32 15-Oct-2003  fvdl Don't put the netbsd32_compat*.c files in the 'compat library'. Unconditionally
compiling these causes a ripple effect making it hard to conditionalize
anything on COMPAT_* in the kernel.
 1.31 08-Dec-2002  manu branches: 1.31.6;
Introduce BSD system calls with alternate patch checking (in /emul) in
compat/common, so that they can be shared by several emulations, and use
them for Darwin.

This removes the ugly dependance on FreeBSD freebsd_file.c for COMPAT_DARWIN
 1.30 02-Nov-2002  perry set LLIBS= so we don't try to check the lint lib against llib-lc.ln
 1.29 18-Jun-2002  wrstuden Updated version of cscope/mkid support. Check libkern and compat lib
for source files. Also include header files in mkid run.
 1.28 29-Apr-2002  mrg branches: 1.28.2; 1.28.4;
build the netbsd32_compat* objects into libcompat.a, so they are available
to emulations not just netbsd itself. rename the compat_10 functions to
match everything else. fixes a problem reported by julian coleman.
 1.27 12-Dec-2001  tv MKfoo=no -> NOfoo
 1.26 14-Nov-2001  tv Preload <bsd.own.mk> before .undef DESTDIR.
 1.25 14-Nov-2001  tv Undefine DESTDIR; we don't want the special DESTDIR <bsd.lib.mk>
handling for kernel libraries.

XXX this build method should be replaced by something more sane
 1.24 25-Aug-1999  thorpej branches: 1.24.14; 1.24.16;
Add compatibility calls for the 1.4 System V IPC *ctl() calls, and
update the 1.0 compat calls.
 1.23 07-May-1999  drochner Build libraries for kernel/standalone code from within their compilation
directories and use .PATH to lookup the source files.
(Formerly, the libs were built from the source dirs, with MAKEOBJDIR
set to the compilation directory.)
This solves 2 problems:
-"mkdep" and "make" are now consistent about the file lookup, this fixes
bad interactions with amd reported in PR bin/7374 (Arne Juul) and
lossage reported by Andrew Gillham ("obj" dirs and relative paths still
don't work well together)
-kernel compile trees can be moved around without forcing a new
"make depend" - fixing PR kern/4021 by Martin Husemann
 1.22 13-Feb-1999  lukem branches: 1.22.4;
convert from NOxxx= to MKxxx=no.
include <bsd.own.mk> if testing a MKxxx variable.
 1.21 28-Apr-1998  kleink Make adding new source files easier and enhance readability by ordering SRCS
items by (Net)BSD version first, then alphabetically.
 1.20 25-Nov-1997  kleink In XPG4.2, the ss_size member of type stack_t (struct sigaltstack) is specified
to be of type size_t; since this imposes an interface change on the Alpha
(sizeof(int) != sizeof(size_t)), allocate a new system call number and make
the previous version a compatibility system call.
 1.19 16-Oct-1997  christos PR/4269: msync is missing MS_*
 1.18 10-Oct-1997  fvdl Add getdirentries backward compat syscall. Provide common function to
signal cookie overflow during emulated getdents and friends.
 1.17 12-Jun-1997  mrg branches: 1.17.4;
bring mrg-vm-swap2 onto mainline.
 1.16 31-May-1997  cjs Back out BUILDDIR and NOINSTALL changes.
 1.15 30-May-1997  cjs branches: 1.15.2;
Use new NOINSTALL option for libraries that are used only during the build
of a program, and not installed into the final system.
 1.14 07-May-1997  mycroft Use libinstall::, not install:, to prevent instaling LIB.
 1.13 22-Oct-1996  explorer branches: 1.13.8;
Spelling error
 1.12 09-Aug-1996  mrg Change reboot(2) to take two arguments: bootopt like normal and also
a boot string for firmware that can do this, such as the SPARC and
the sun3 models. It is currently silently ignored on all other
hardware now, however. The MD function "boot()" has been changed to
also take a char *.
 1.11 08-Aug-1996  mycroft Run the child make in the source directory, so that nothing here needs to be
changed when the compile directory is outside the source tree.
 1.10 30-Jun-1996  christos Fix mysterious dissappearance of the .PATH directive.
 1.9 23-Jun-1996  mycroft Remove the old (broken) setre[ug]id() emulation.
 1.8 18-May-1996  christos branches: 1.8.4;
- Moving cpu_exec_aout_prep_oldzmagic -> exec_aout_prep_oldzmagic.
This is used by the i386, hp300 and mac68k ports.
- Added exec_aout_prep_oldomagic, and exec_aout_prep_oldnmagic
These are just copies of the respective prep functions from
kern_exec.c with text address starting at 0. Maybe a better fix
is to pass the starting address as a third argument so we don't
duplicate code, but this could be the next pass since the functions
are used in many places. These functions are used for BSDI binaries.
 1.7 05-Feb-1996  christos Extracted vm compat functions from vm and added them here where they belong.
 1.6 02-Feb-1996  mycroft Simplify, and add support for passing CPPFLAGS.
 1.5 02-Feb-1996  christos Renamed compat_tty.c to tty_43.c and updated with the newest copy from
kern/tty_compat.c
 1.4 20-Oct-1995  cgd set, don't add to, CFLAGS from COMPATCFLAGS
 1.3 28-Jun-1995  cgd light cleanup, adjustments for the Alpha
 1.2 26-Jun-1995  christos Add the ability to override COMPATREL and COMPATDST similar to libkern
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.8.4.2 10-Dec-1996  mycroft Oops; put back .PATH.
 1.8.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.13.8.1 04-May-1997  mrg add vm_swap_12.c here.
 1.15.2.3 19-Oct-1997  cjs Update to 1.19.
 1.15.2.2 13-Oct-1997  cjs Update to 1.18.
 1.15.2.1 22-Jun-1997  cjs Merge mainline up to 1.17.
 1.17.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.22.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.24.16.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.24.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.24.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.24.14.6 11-Dec-2002  thorpej Sync with HEAD.
 1.24.14.5 11-Nov-2002  nathanw Catch up to -current
 1.24.14.4 01-Aug-2002  nathanw Catch up to -current.
 1.24.14.3 20-Jun-2002  nathanw Catch up to -current.
 1.24.14.2 08-Jan-2002  nathanw Catch up to -current.
 1.24.14.1 14-Nov-2001  thorpej Merge from -current, required to cross-build kernels properly.
 1.28.4.1 19-Jun-2002  lukem Pull up revision 1.29 (requested by wrstuden in ticket #318):
Updated version of cscope/mkid support. Check libkern and compat lib
for source files. Also include header files in mkid run.
 1.28.2.1 15-Jul-2002  gehenna catch up with -current.
 1.31.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.31.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.31.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.31.6.1 03-Aug-2004  skrll Sync with HEAD
 1.33.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.33.4.1 29-Apr-2005  kent sync with -current
 1.34.4.6 27-Feb-2008  yamt sync with head.
 1.34.4.5 04-Feb-2008  yamt sync with head.
 1.34.4.4 21-Jan-2008  yamt sync with head
 1.34.4.3 03-Sep-2007  yamt sync with head.
 1.34.4.2 30-Dec-2006  yamt sync with head.
 1.34.4.1 21-Jun-2006  yamt sync with head.
 1.36.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.36.8.1 11-Aug-2006  yamt sync with head
 1.36.4.1 09-Sep-2006  rpaulo sync with head
 1.37.14.2 09-Jun-2007  ad Sync with head.
 1.37.14.1 13-Mar-2007  ad Sync with head.
 1.37.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.38.2.1 11-Jul-2007  mjf Sync with head.
 1.39.20.1 13-Dec-2007  bouyer Sync with HEAD
 1.39.18.1 13-Dec-2007  yamt sync with head.
 1.39.16.1 26-Dec-2007  ad Sync with head.
 1.39.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.39.8.1 09-Jan-2008  matt sync with HEAD
 1.41.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.41.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.41.2.1 24-Mar-2008  keiichi sync with head.
 1.42.14.2 03-Mar-2009  skrll Sync with HEAD.
 1.42.14.1 19-Jan-2009  skrll Sync with HEAD.
 1.42.12.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.42.6.1 04-May-2009  yamt sync with head.
 1.42.2.4 27-Nov-2008  christos handle ifdatareq
 1.42.2.3 20-Nov-2008  christos merge with head.
 1.42.2.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.42.2.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.45.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.6.1 05-Mar-2011  rmind sync with head
 1.47.6.2 24-Feb-2012  mrg sync to -current.
 1.47.6.1 18-Feb-2012  mrg merge to -current.
 1.47.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.47.2.2 30-Oct-2012  yamt sync with head
 1.47.2.1 17-Apr-2012  yamt sync with head
 1.49.2.4 03-Dec-2017  jdolecek update from HEAD
 1.49.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.49.2.2 23-Jun-2013  tls resync from head
 1.49.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.51.4.1 18-May-2014  rmind sync with head
 1.52.6.5 28-Aug-2017  skrll Sync with HEAD
 1.52.6.4 05-Dec-2016  skrll Sync with HEAD
 1.52.6.3 05-Oct-2016  skrll Sync with HEAD
 1.52.6.2 22-Apr-2016  skrll Sync with HEAD
 1.52.6.1 22-Sep-2015  skrll Sync with HEAD
 1.56.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.56.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.63.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.63.2.2 26-Mar-2018  pgoyette For now, disable CPU_UCODE stuff since we can't build it properly
with XEN. Re-enable it after we get fix for PR kern/53130
 1.63.2.1 18-Mar-2018  pgoyette Move closer to a complete compat_60 module. All that remains is some
tty stuff and some ccd ioctl()s.
 1.64.2.1 10-Jun-2019  christos Sync with HEAD
 1.65.18.1 31-May-2021  cjep sync with head
 1.65.16.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.27 20-Dec-2022  msaitoh Remove sys/compat/common/Makefile.*.

These files are not used anymore. Files for compat code are listed in
sys/comapt/common/files.common and sys/modules/compat_xxx/Makefile.
OK'd by riastradh@ and pgoyette@.
 1.26 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.25 27-May-2018  christos branches: 1.25.2;
- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
 1.24 12-Apr-2018  christos If we are modular, allow us to use modules for compat; don't load all the
compat code in.
 1.23 16-Dec-2017  maxv branches: 1.23.2;
Build libcompat as an object, not as a library. We want all of its
functions compiled in, because compat modules loaded from the filesystem
may depend on them.
 1.22 22-Mar-2016  mrg branches: 1.22.10;
remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for. very few other targets claim they're done so just remove these.
 1.21 06-Sep-2015  uebayasi In kernel lib build, print message when things not only start bug also end.
 1.20 14-Dec-2009  matt branches: 1.20.40;
Merge from matt-nb5-mips64
 1.19 02-Nov-2002  perry branches: 1.19.108; 1.19.128;
Add lint infrastructure
 1.18 05-Dec-2000  sommerfeld branches: 1.18.2;
Have recursive make invocations depend on the .MAKE pseudo-target so
make knows to handle them specially.
 1.17 01-Feb-2000  tsutsui Revert STRIPPROG -> STRIP
 1.16 19-Jan-2000  tsutsui STRIP -> STRIPPROG
 1.15 07-May-1999  drochner branches: 1.15.2;
Build libraries for kernel/standalone code from within their compilation
directories and use .PATH to lookup the source files.
(Formerly, the libs were built from the source dirs, with MAKEOBJDIR
set to the compilation directory.)
This solves 2 problems:
-"mkdep" and "make" are now consistent about the file lookup, this fixes
bad interactions with amd reported in PR bin/7374 (Arne Juul) and
lossage reported by Andrew Gillham ("obj" dirs and relative paths still
don't work well together)
-kernel compile trees can be moved around without forcing a new
"make depend" - fixing PR kern/4021 by Martin Husemann
 1.14 05-Sep-1998  lukem branches: 1.14.8;
distclean is a synonym for cleandir
 1.13 04-Nov-1997  gwr Pass down the values of: AR NM RANLIB
(Fixes PR#4426 from SAITOH Masanobu)
Also pass down LORDER TSORT.
 1.12 23-Jan-1997  cgd clean up substantially. Transform clean, depend, cleandir targets from ::
to :, so they can be used e.g. with <bsd.prog.mk>. Standardize variable
names used to configure kernel libraries.

Variables used by these Makefile.inc's are:

S must be set to the top of the 'sys' tree.
${LIB}DST may be set to the location of the directory where library
objects are to be built. Defaults to ${.OBJDIR}/lib/${lib}.
${LIB}_AS may be set to 'obj' to build a object from the library's
object files. (Otherwise, a library will be built.)
Defaults to 'library'.
${LIB}MISCMAKEFLAGS
Miscellaneous flags to be passed to the library's Makefile when
building. See library's Makefile for more details about
supported flags and their default values.

(where LIB is COMPAT, and lib is compat, in this case.)
 1.11 26-Dec-1996  christos PR/2981: use ${VAR:Q} instead of '${VAR}' to avoid quoting problems
 1.10 23-Sep-1996  ghudson Handle relative paths to the source tree if they begin with '.'.
 1.9 10-Aug-1996  mycroft Add anchors so that only exactly `-I. is modified.
 1.8 10-Aug-1996  mycroft Convert the -I. to -I${.OBJDIR}, so that the `machine symlink is available.
 1.7 08-Aug-1996  mycroft We dont need to pass down COMPATDIR and KERNDIR.
 1.6 08-Aug-1996  mycroft Run the child make in the source directory, so that nothing here needs to be
changed when the compile directory is outside the source tree.
 1.5 20-May-1996  mrg use ' not " when passing variables to a sub-make. pr#1199/pr#1296
 1.4 11-May-1996  mycroft Make `make depend' work for libraries.
 1.3 02-Feb-1996  mycroft Simplify, and add support for passing CPPFLAGS.
 1.2 26-Jun-1995  christos Add the ability to override COMPATREL and COMPATDST similar to libkern
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.14.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.15.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.15.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.18.2.1 11-Nov-2002  nathanw Catch up to -current
 1.19.128.1 21-Aug-2009  matt Pass LDFLAGS
 1.19.108.1 11-Mar-2010  yamt sync with head
 1.20.40.2 22-Apr-2016  skrll Sync with HEAD
 1.20.40.1 22-Sep-2015  skrll Sync with HEAD
 1.22.10.1 09-Jun-2018  martin Pull up following revision(s) (requested by christos in ticket #870):

sys/lib/libgnuefi/Makefile.inc: revision 1.5
external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
sys/compat/common/Makefile.inc: revision 1.25
usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
sys/lib/libsa/Makefile.inc: revision 1.24
usr.bin/make/var.c: revision 1.220
sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
sys/arch/hppa/spmath/Makefile.inc: revision 1.10
usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
usr.bin/make/unit-tests/Makefile: revision 1.53
sys/lib/libkern/Makefile.inc: revision 1.45
sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
usr.bin/make/make.1: revision 1.273
sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8
 1.23.2.4 25-Jun-2018  pgoyette Sync with HEAD
 1.23.2.3 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.23.2.2 12-Apr-2018  pgoyette Merge christos's recent changes on HEAD
 1.23.2.1 13-Mar-2018  pgoyette Revert the COMPAT_AS sestting back to library, the documented default.

It doesn't really matter, since we no longer build the library in any
format, but best to make the code match the comments.
 1.25.2.1 10-Jun-2019  christos Sync with HEAD
 1.16 20-Dec-2022  msaitoh Remove sys/compat/common/Makefile.*.

These files are not used anymore. Files for compat code are listed in
sys/comapt/common/files.common and sys/modules/compat_xxx/Makefile.
OK'd by riastradh@ and pgoyette@.
 1.15 10-Nov-2021  msaitoh s/compatability/compatibility/ in comment.
 1.14 09-Aug-2021  andvar fix various typos in compatibility, mainly in comments.
 1.13 27-Jan-2020  pgoyette Split the module glue out from the rest of opencrypto/ocryptodev to
make rump happy.

Rump doesn't have compat modules (the compat code is included in the
relevant librump*.so), so there's no module compat_50 listed in
link_set_modules, and thus ocryptodev's MODULE(...) can't "require"
it.

This fixes the problem of "built-in module compat_50 not found" when
starting up rump_allserver (or rump_server with -l rumpdev_opencrypto).

XXX This does not resolve the long-standing "crypto: unable to
XXX register devsw, error 17" message noted at line 78 of
XXX sys/rump/dev/lib/libopencrypto/opencrypto_component.c
 1.12 17-May-2019  msaitoh branches: 1.12.4;
The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.11 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.10 18-Mar-2018  christos branches: 1.10.2;
factor out the ccd COMPAT_60 code.
 1.9 17-Mar-2018  christos redo the cpu ucode compat code.
 1.8 15-Mar-2018  christos add uvm swap compat code.
 1.7 05-Nov-2016  pgoyette branches: 1.7.2; 1.7.16; 1.7.18;
Move if_43.c back into the shared Makefile.sysio where it really
belongs.

Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers. Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.

Addresses the issue pointed out in PR kern/51598
 1.6 03-Nov-2016  pgoyette branches: 1.6.2;
Move if_43.c out of Makefile.sysio and into the main Makefile.

The former location gets included in both libcompat and the compat
module, leading to redefined symbols when the module is loaded. By
moving it to the main Makefile, it gets included only in libcompat.

XXX This still isn't an ideal solution, but it will suffice until
XXX PR kern/51598 is addressed.
 1.5 03-Nov-2016  pgoyette Hmmm, if we omit if_43.c from the SRCS list, then we break the i386
build for one of the XEN kernels.

Adding it back to the list. At least the build will be successful.

XXX This is probably not the end of this saga, as we still have the
XXX redefined-symbol issue when loading the compat module on amd64.
XXX But for now, a working build for the vast majority of users
XXX (including our automated test suites) is more important than a
XXX successfully-loadable compat module.
 1.4 03-Nov-2016  pgoyette Really comment out if_43.c this time. (I need sleep and/or caffeine.)
 1.3 03-Nov-2016  pgoyette Use proper characgter to introduce comments!
 1.2 03-Nov-2016  pgoyette if_43.o gets included from libcompat automatically, due to two calls
to compat_cvtcmd() in if.c. Ideally, if.c would be modified to have
a pointer to a no-op compat_cvtcmd() and that pointer would get
replaced by compat_modcmd(MODULE_CMD_INIT, ...) code. But for now,
just don't include it in the compat module at all.
 1.1 03-Nov-2016  riastradh Reorganize SRCS lists for libcompat, compat.kmod, sysv_ipc.kmod.

- Share lists between the libcompat and module makefiles.
- Include some omitted entries in compat.kmod:
. if_43.c
. kern_sa_60.c
. kern_time_30.c
. rndpseudo_50.c
. rtsock_14.c
. rtsock_50.c
. rtsock_70.c
. uipc_syscalls_40.c
. uipc_syscalls_50.c
- Exclude a (harmless) spurious entry in sysv_ipc.kmod on LP64 systems:
. kern_ipc_10.c

Should fix broken ifconfig on modular current kernels.

ok pgoyette
 1.6.2.3 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.6.2.1 03-Nov-2016  pgoyette file Makefile.sysio was added on branch pgoyette-localcount on 2016-11-04 14:49:07 +0000
 1.7.18.22 19-Sep-2018  pgoyette Update for new vnd_50.c source file.

Not really necessary to update this, since we're no longer building
the "monolithic" compat module. But let's maintain it correctly, at
least until we delete the file.
 1.7.18.21 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.7.18.20 03-Apr-2018  pgoyette Remove fixed allocation of modules' "required" lists (previously
limited to MAXMODDEPS entries). Update the modctl(MODCTL_STAT)
syscall to return the required data in a new format, and retain
the previous data format in MODCTL_OSTAT. Update the compat_80
and compat_netbsd32 modules as needed.
 1.7.18.19 29-Mar-2018  pgoyette Rename usb_30_subr.c --> usb_subr_30.c for consistency with others
 1.7.18.18 28-Mar-2018  pgoyette Split vnd compat_30 code out of the main driver and into the compat_30
module
 1.7.18.17 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.7.18.16 25-Mar-2018  pgoyette Don't add the compat_60_cpu_ucode.c file here. It's already added in
the main Makefile, and doing again here results in trying to link it
twice (with resulting symbol redefinition errors).
 1.7.18.15 25-Mar-2018  pgoyette Include compat code in the modules
 1.7.18.14 25-Mar-2018  pgoyette Undo previous. Clearly this is not the right thing to do! The ucode
support should already be in the kernel.
 1.7.18.13 25-Mar-2018  pgoyette Include the cpu_ucode*.c files in the module for x86 machines
 1.7.18.12 24-Mar-2018  pgoyette Move the compat_50-specific code out of wscons/wsevent.c into its own
source file, which is now part of the compat_50 module.
 1.7.18.11 24-Mar-2018  pgoyette Add fs/puffs compat_50 to the modules
 1.7.18.10 24-Mar-2018  pgoyette Separate the compat_50 and compat_80 dispatching code from the main
body of raidframe, and place into the appropriate compat modules.

Enable building of the compat_80 module.
 1.7.18.9 23-Mar-2018  pgoyette Handle the compat_50 stuff for opencrypto/cryptodev
 1.7.18.8 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.7.18.7 21-Mar-2018  pgoyette Move if_spppsubr compat code into the compat50 module.

More prep work for compat80 module (for raidframe)
 1.7.18.6 21-Mar-2018  pgoyette Split the compat_50 code out from the dev/clockctl driver and include
it in the compat_50 and compat modules.
 1.7.18.5 18-Mar-2018  pgoyette Import compat_60 changes for dev/ccd
 1.7.18.4 17-Mar-2018  pgoyette Import christos's changes for the compat_60 cpu_ucode stuff
 1.7.18.3 15-Mar-2018  pgoyette Synch with HEAD
 1.7.18.2 14-Mar-2018  pgoyette Make do_openat()'s handling of path=NULL modular
 1.7.18.1 13-Mar-2018  pgoyette Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.
 1.7.16.2 03-Dec-2017  jdolecek update from HEAD
 1.7.16.1 05-Nov-2016  jdolecek file Makefile.sysio was added on branch tls-maxphys on 2017-12-03 11:36:53 +0000
 1.7.2.2 05-Dec-2016  skrll Sync with HEAD
 1.7.2.1 05-Nov-2016  skrll file Makefile.sysio was added on branch nick-nhusb on 2016-12-05 10:54:59 +0000
 1.10.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.2.1 10-Jun-2019  christos Sync with HEAD
 1.12.4.1 29-Feb-2020  ad Sync with head.
 1.2 20-Dec-2022  msaitoh Remove sys/compat/common/Makefile.*.

These files are not used anymore. Files for compat code are listed in
sys/comapt/common/files.common and sys/modules/compat_xxx/Makefile.
OK'd by riastradh@ and pgoyette@.
 1.1 03-Nov-2016  riastradh branches: 1.1.2; 1.1.4; 1.1.18;
Reorganize SRCS lists for libcompat, compat.kmod, sysv_ipc.kmod.

- Share lists between the libcompat and module makefiles.
- Include some omitted entries in compat.kmod:
. if_43.c
. kern_sa_60.c
. kern_time_30.c
. rndpseudo_50.c
. rtsock_14.c
. rtsock_50.c
. rtsock_70.c
. uipc_syscalls_40.c
. uipc_syscalls_50.c
- Exclude a (harmless) spurious entry in sysv_ipc.kmod on LP64 systems:
. kern_ipc_10.c

Should fix broken ifconfig on modular current kernels.

ok pgoyette
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Nov-2016  jdolecek file Makefile.sysv was added on branch tls-maxphys on 2017-12-03 11:36:53 +0000
 1.1.4.2 05-Dec-2016  skrll Sync with HEAD
 1.1.4.1 03-Nov-2016  skrll file Makefile.sysv was added on branch nick-nhusb on 2016-12-05 10:54:59 +0000
 1.1.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.1.2.1 03-Nov-2016  pgoyette file Makefile.sysv was added on branch pgoyette-localcount on 2016-11-04 14:49:07 +0000
 1.5 19-Dec-2020  thorpej malloc(9) -> kmem(9)
 1.4 12-Dec-2019  pgoyette branches: 1.4.8;
Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.3 01-Mar-2019  pgoyette branches: 1.3.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 28-Mar-2018  pgoyette branches: 1.1.2;
file bio_30.c was initially added on branch pgoyette-compat.
 1.1.2.5 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.1.2.1 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.3.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 01-Mar-2019  christos file bio_30.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.4.8.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.11 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.10 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.9 27-Jan-2019  christos make this compile again (enable #if 0 code)
 1.8 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.7 19-Mar-2018  martin branches: 1.7.2;
XXX stub it completely for now to make it compile
 1.6 19-Mar-2018  christos XXX: don't reference the global for now so that kernels without ccd build.
 1.5 19-Mar-2018  christos remove another error decl.
 1.4 18-Mar-2018  christos remove error decl
 1.3 18-Mar-2018  christos - use the conditional from the header file
- fix compilation
 1.2 18-Mar-2018  pgoyette Declare 'error' if needed
 1.1 18-Mar-2018  christos branches: 1.1.2;
factor out the ccd COMPAT_60 code.
 1.1.2.9 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.8 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.7 16-Sep-2018  pgoyette Yay - we got the ccd_ioctl_60 stuff to build!

Now we can use that as a template for cleaning up all the others.
 1.1.2.6 20-Mar-2018  pgoyette Initial implementation of sys/kern/kern_stup.c as discussed on tech-kern

For now, we only handle the dev/ccd and NTP needs; more to follow.
 1.1.2.5 19-Mar-2018  pgoyette Stub-out the compat ioctl routine for now to fix compile error on
kernels with no ccd device.
 1.1.2.4 18-Mar-2018  pgoyette Merge changes from HEAD into ccd_60.c

For all of the individual xxx_60_{init,fini} routines, don't force
them to artificially return a status; just make them void. This
simplifies the compat_60_{init,fini} handling of errors that remain.
 1.1.2.3 18-Mar-2018  pgoyette Declare 'error' if needed
 1.1.2.2 18-Mar-2018  pgoyette Import compat_60 changes for dev/ccd
 1.1.2.1 18-Mar-2018  pgoyette file ccd_60.c was added on branch pgoyette-compat on 2018-03-18 21:41:31 +0000
 1.7.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.2.1 10-Jun-2019  christos Sync with HEAD
 1.4 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.3 01-Mar-2019  pgoyette branches: 1.3.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 21-Mar-2018  pgoyette branches: 1.1.2;
file clockctl_50.c was initially added on branch pgoyette-compat.
 1.1.2.5 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.1.2.1 21-Mar-2018  pgoyette Split the compat_50 code out from the dev/clockctl driver and include
it in the compat_50 and compat modules.
 1.3.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 01-Mar-2019  christos file clockctl_50.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_09_mod.c was initially added on branch pgoyette-compat.
 1.1.2.5 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.4 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.3 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.2 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.1 17-Apr-2018  pgoyette Actually commit these three files to provide module interfaces
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_09_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.3 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.2 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.1 19-Dec-2022  pgoyette Create compat_100 module infrastructure now that we have branched
for NetBSD-10
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_10_mod.c was initially added on branch pgoyette-compat.
 1.1.2.5 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.4 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.3 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.2 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.1 17-Apr-2018  pgoyette Actually commit these three files to provide module interfaces
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_10_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.2 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.1 19-May-2024  christos version dup3
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 31-Mar-2018  pgoyette branches: 1.1.2;
file compat_12_mod.c was initially added on branch pgoyette-compat.
 1.1.2.6 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.5 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.4 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.3 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.2 01-Apr-2018  pgoyette Update modules' required lists to take advantage of the new unlimited
number of requirements permitted.
 1.1.2.1 31-Mar-2018  pgoyette create the compat_12 module
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_12_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 30-Mar-2018  pgoyette branches: 1.1.2;
file compat_13_mod.c was initially added on branch pgoyette-compat.
 1.1.2.6 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.5 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.4 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.3 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.2 01-Apr-2018  pgoyette Update modules' required lists to take advantage of the new unlimited
number of requirements permitted.
 1.1.2.1 30-Mar-2018  pgoyette Add compat_13 module
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_13_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 30-Mar-2018  pgoyette branches: 1.1.2;
file compat_14_mod.c was initially added on branch pgoyette-compat.
 1.1.2.5 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.4 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.3 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.2 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.1 30-Mar-2018  pgoyette Extract compat_14 stuff into its own module
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_14_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 30-Mar-2018  pgoyette branches: 1.1.2;
file compat_16_mod.c was initially added on branch pgoyette-compat.
 1.1.2.5 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.4 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.3 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.2 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.1 30-Mar-2018  pgoyette Create and build a compat_16 module
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_16_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 30-Mar-2018  pgoyette branches: 1.1.2;
file compat_20_mod.c was initially added on branch pgoyette-compat.
 1.1.2.5 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.4 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.3 13-Sep-2018  pgoyette Fix typo - Don't try to re-init the submodule when doing MODULE_CMD_fINI!
 1.1.2.2 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.1 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_20_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.3 28-Dec-2019  pgoyette For the built-in COMPAT_30 module code, make sure to initialize the
uipc_syscalls_30 stuff, notably to include compat_30_socket().

PR kern/54804

XXX Pullup-9 XXX
 1.2 27-Jan-2019  pgoyette branches: 1.2.4; 1.2.6;
Merge the [pgoyette-compat] branch
 1.1 28-Mar-2018  pgoyette branches: 1.1.2;
file compat_30_mod.c was initially added on branch pgoyette-compat.
 1.1.2.9 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.8 19-Sep-2018  pgoyette We have some COMPAT_30 code that needs compat_offseterr(), so let's
require the compat_util module.
 1.1.2.7 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.6 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.5 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.4 30-Mar-2018  pgoyette Create the compat_util module for use by version-specific compat code.
(It's automatically included in the monolithic compat module, as well
as in kernels with built-in compat code.)
 1.1.2.3 29-Mar-2018  pgoyette Split out the usb compat_30 code and add it to the module
 1.1.2.2 28-Mar-2018  pgoyette Split vnd compat_30 code out of the main driver and into the compat_30
module
 1.1.2.1 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.2.6.1 29-Dec-2019  martin Pull up following revision(s) (requested by pgoyette in ticket #588):
sys/compat/common/compat_30_mod.c: revision 1.3
For the built-in COMPAT_30 module code, make sure to initialize the
uipc_syscalls_30 stuff, notably to include compat_30_socket().
PR kern/54804
XXX Pullup-9 XXX
 1.2.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_30_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 27-Mar-2018  pgoyette branches: 1.1.2;
file compat_40_mod.c was initially added on branch pgoyette-compat.
 1.1.2.7 15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.1.2.6 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.5 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.4 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.3 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.2 16-Apr-2018  pgoyette Rename if_[45]0_{init,fini} entry points to more appropriate and more
consistent uipc_syscalls_[45]0_{init,fini} and remove some multiple
declarations.
 1.1.2.1 27-Mar-2018  pgoyette Create a compat_40 module
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_40_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.3 28-Jan-2019  christos branches: 1.3.4;
- provide a hook for the 43 tty ioctls
- make the 60 tty ioctl hook look the same
- fix the tty code to call both hooks and remove unused lock
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_43_mod.c was initially added on branch pgoyette-compat.
 1.1.2.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.3 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.2 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.1 17-Apr-2018  pgoyette Actually commit these three files to provide module interfaces
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 28-Jan-2019  christos file compat_43_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.4 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.3 15-Apr-2019  pgoyette branches: 1.3.4;
Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.c
and into its own source file, which is now included in the compat_50
module.

(Not sure how this got missed during the original [pgoyette-compat] work)
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 19-Mar-2018  pgoyette branches: 1.1.2;
file compat_50_mod.c was initially added on branch pgoyette-compat.
 1.1.2.18 11-Jan-2019  pgoyette Rework the various sysctl-related routines to call the correct code
for each version. While here, extract the 5.0 specific code instead
of including in the main rtsock.c code.

Also, clean up all the sysctl-related routines to prevent building
more than one copy, no matter how many places rtsock.c gets #include'd
into!
 1.1.2.17 12-Oct-2018  pgoyette Use a MP-safe hook for the rnd_ioctl compat_50 calls.
 1.1.2.16 23-Sep-2018  pgoyette No need to declare the crypto_50 init/fini routines. The compat_50
module no longer needs them, and they're declared static in the
ocryptodev.c code
 1.1.2.15 23-Sep-2018  pgoyette Now that cryptodev_50 is a separate module we can't initialize it
from the generic compat_50 module.
 1.1.2.14 22-Sep-2018  pgoyette Split the raidframe compatability code out into separate modules, since
the driver is already a module. This avoids having to pass a bunch of
function pointers as arguments to raidframe's compat_ioctl().
 1.1.2.13 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.12 19-Sep-2018  pgoyette Split out the vnd COMPAT_50 code
 1.1.2.11 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.10 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.9 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.8 16-Apr-2018  pgoyette Rename if_[45]0_{init,fini} entry points to more appropriate and more
consistent uipc_syscalls_[45]0_{init,fini} and remove some multiple
declarations.
 1.1.2.7 24-Mar-2018  pgoyette Move the compat_50-specific code out of wscons/wsevent.c into its own
source file, which is now part of the compat_50 module.
 1.1.2.6 24-Mar-2018  pgoyette Don't include unneeded opt_* files
 1.1.2.5 24-Mar-2018  pgoyette Add raidframe init/fini calls
 1.1.2.4 23-Mar-2018  pgoyette Handle the compat_50 stuff for opencrypto/cryptodev
 1.1.2.3 21-Mar-2018  pgoyette Add a compat_80 module - we need this for some raidframe stuff.

Update other modules to add compat_80 to the required lists.
 1.1.2.2 21-Mar-2018  pgoyette Split the compat_50 code out from the dev/clockctl driver and include
it in the compat_50 and compat modules.
 1.1.2.1 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 15-Apr-2019  christos file compat_50_mod.c was added on branch phil-wifi on 2019-06-10 22:06:57 +0000
 1.4 21-Sep-2022  dholland compat_50_quota: reject invalid quota id types.

Reported-by: syzbot+ce8391eb74a16e1967ab@syzkaller.appspotmail.com
 1.3 09-Mar-2020  pgoyette branches: 1.3.2;
The compat_50_quota code needs quota support from ufs. Add dependency.
 1.2 22-Jan-2020  pgoyette branches: 1.2.2;
Since this used to be part of the compat_50 module, make it depend on
compat_50 rather than compat_60 module.
 1.1 21-Jan-2020  pgoyette Split the compat_50 module into two, separating the QUOTA-related
stuff from the rest of the module. This allows loading of the
(main) compat_50 module on kernels that don't include ``options
QUOTA''.

Welcome to 9.99.40 !

Addresses PR kern/54875
 1.2.2.2 25-Jan-2020  ad Sync with head.
 1.2.2.1 22-Jan-2020  ad file compat_50_quota.c was added on branch ad-namecache on 2020-01-25 22:38:44 +0000
 1.3.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.2.1 09-Mar-2020  martin file compat_50_quota.c was added on branch phil-wifi on 2020-04-08 14:08:00 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 15-Mar-2018  pgoyette branches: 1.1.2;
file compat_60_mod.c was initially added on branch pgoyette-compat.
 1.1.2.19 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.18 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.17 13-Sep-2018  pgoyette When unloading a module with MODULE_CMD_FINI, call the compat_xx_fini()
routine rather than again calling the compat_xx_init() routine!

(Cut&paste strikes again)
 1.1.2.16 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.15 31-Mar-2018  pgoyette Re-enable inclusion of CPU_UCODE for i386/amd64. Even though it won't
build correctly on XEN (won't use the XEN ABI), it works fine on real
hardware.
 1.1.2.14 26-Mar-2018  pgoyette For now, disable CPU_UCODE stuff since we can't build it properly
with XEN. Re-enable it after we get fix for PR kern/53130
 1.1.2.13 24-Mar-2018  pgoyette Don't include unneeded opt_* files
 1.1.2.12 21-Mar-2018  pgoyette Add a compat_80 module - we need this for some raidframe stuff.

Update other modules to add compat_80 to the required lists.
 1.1.2.11 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.1.2.10 18-Mar-2018  pgoyette Merge changes from HEAD into ccd_60.c

For all of the individual xxx_60_{init,fini} routines, don't force
them to artificially return a status; just make them void. This
simplifies the compat_60_{init,fini} handling of errors that remain.
 1.1.2.9 18-Mar-2018  pgoyette Import compat_60 changes for dev/ccd
 1.1.2.8 18-Mar-2018  pgoyette Initial pass at getting the tty stuff properly modularized. Subject
to review and revision.
 1.1.2.7 18-Mar-2018  pgoyette Clean-up for kern_cpu_60 code.

Also, although not strictly necessary, include the kern_sa_60 stuff in
the compat_60 module, for completeness.

Still need to deal with some tty code and the ccd driver to finish off
the compat_60 module.
 1.1.2.6 18-Mar-2018  pgoyette Move closer to a complete compat_60 module. All that remains is some
tty stuff and some ccd ioctl()s.
 1.1.2.5 17-Mar-2018  pgoyette Back out changes on the branch related to kernel microcode compat.

Christos didn't like the way it was done, so waiting for a better
approach/implementation.
 1.1.2.4 17-Mar-2018  pgoyette Move closer to having a compat_60 module
 1.1.2.3 16-Mar-2018  pgoyette Move closer to getting a compat_60 module - still needs more work
 1.1.2.2 16-Mar-2018  pgoyette Initial pass at setting up the compat_60 module.

XXX needs some work to properly handle cpu_ucode stuff.

While here, move details of compat_70 init/fini routines into the
module itself.
 1.1.2.1 15-Mar-2018  pgoyette Initial set-up for compat_60 module
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_60_mod.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.3 17-Apr-2019  msaitoh branches: 1.3.4;
KNF. No functional change.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 15-Mar-2018  pgoyette branches: 1.1.2;
file compat_70_mod.c was initially added on branch pgoyette-compat.
 1.1.2.12 15-Oct-2018  pgoyette Convert the compat70_unp_addsockcred hook to the MP-safe mechanism.

XXX One more remaining: sysvipc50_sysctl
 1.1.2.11 15-Oct-2018  pgoyette Convert another hook to the MP-sfe mechanism.

XXX still have three more to convert: openat_10, sysvipc50_sysctl and
XXX compat70_unp_addsockcred
 1.1.2.10 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.9 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.8 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.7 24-Mar-2018  pgoyette Don't include unneeded opt_* files
 1.1.2.6 21-Mar-2018  pgoyette Add a compat_80 module - we need this for some raidframe stuff.

Update other modules to add compat_80 to the required lists.
 1.1.2.5 17-Mar-2018  pgoyette Make all the compat_xx_{init,fini} routines return an int, whether or
not they currently need it.
 1.1.2.4 16-Mar-2018  pgoyette Move closer to getting a compat_60 module - still needs more work
 1.1.2.3 16-Mar-2018  pgoyette Initial pass at setting up the compat_60 module.

XXX needs some work to properly handle cpu_ucode stuff.

While here, move details of compat_70 init/fini routines into the
module itself.
 1.1.2.2 15-Mar-2018  pgoyette Remove some unnecessary #includes
 1.1.2.1 15-Mar-2018  pgoyette Create a separate module for COMPAT_70 code only, and untangle the
70 compat code from the current.
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 17-Apr-2019  christos file compat_70_mod.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.5 03-Oct-2019  pgoyette Since we now have a compat_90 module, the compat_80 module should depend
on it.
 1.4 17-May-2019  msaitoh branches: 1.4.2;
The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.3 17-Apr-2019  msaitoh KNF. No functional change.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 21-Mar-2018  pgoyette branches: 1.1.2;
file compat_80_mod.c was initially added on branch pgoyette-compat.
 1.1.2.11 22-Sep-2018  pgoyette Split the raidframe compatability code out into separate modules, since
the driver is already a module. This avoids having to pass a bunch of
function pointers as arguments to raidframe's compat_ioctl().
 1.1.2.10 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.9 15-Sep-2018  pgoyette Since we've already removed the maximum recursion depth for
required modules, there's no need for us to force loading of
the most-recent (ie, "deepest") modules first. So, simplify
the required-modules lists to require only the next-highest
version's module.

This will also make it easier to add new compat_xx modules
for future release versions.
 1.1.2.8 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.7 03-Apr-2018  pgoyette Remove fixed allocation of modules' "required" lists (previously
limited to MAXMODDEPS entries). Update the modctl(MODCTL_STAT)
syscall to return the required data in a new format, and retain
the previous data format in MODCTL_OSTAT. Update the compat_80
and compat_netbsd32 modules as needed.
 1.1.2.6 24-Mar-2018  pgoyette Remove unneeded opt_* includes.

Since raidframe_80_{init,fini} don't return values, don't try to use them!
 1.1.2.5 24-Mar-2018  pgoyette Also add raidframe init/fini for compat_80
 1.1.2.4 24-Mar-2018  pgoyette Separate the compat_50 and compat_80 dispatching code from the main
body of raidframe, and place into the appropriate compat modules.

Enable building of the compat_80 module.
 1.1.2.3 23-Mar-2018  pgoyette For now, the compat_80 module is empty.
 1.1.2.2 21-Mar-2018  pgoyette Move if_spppsubr compat code into the compat50 module.

More prep work for compat80 module (for raidframe)
 1.1.2.1 21-Mar-2018  pgoyette Add a compat_80 module - we need this for some raidframe stuff.

Update other modules to add compat_80 to the required lists.
 1.4.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.2.2 10-Jun-2019  christos Sync with HEAD
 1.4.2.1 17-May-2019  christos file compat_80_mod.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.6 09-Dec-2023  oster Allow kernels builds which don't define INET6 to compile compat bits too.
 1.5 09-Dec-2023  pgoyette Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

XXX pullup-10 - hopefully before RC2
 1.4 19-Dec-2022  pgoyette Create compat_100 module infrastructure now that we have branched
for NetBSD-10
 1.3 04-Jan-2020  pgoyette branches: 1.3.8; 1.3.28;
Resurrect boottime, but only in the compat_90 module (whether built-in
or separately loaded). This will enable running of old vmstat(1) images
on newer kernels.
 1.2 28-Oct-2019  christos Don't ignore EBUSY from disestablish or we can crash by unloading busy
syscalls.
 1.1 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.3.28.1 10-Dec-2023  martin Pull up following revision(s) (requested by pgoyette in ticket #487):

sys/compat/common/compat_90_mod.c: revision 1.5
sys/compat/common/compat_90_mod.c: revision 1.6
sys/netinet6/in6.c: revision 1.290
sys/netinet6/in6.c: revision 1.291
sys/compat/common/files.common: revision 1.11
sys/netinet6/icmp6.c: revision 1.255
sys/compat/common/net_inet6_nd_90.c: revision 1.1
sys/compat/common/net_inet6_nd_90.c: revision 1.2
sys/modules/compat_90/Makefile: revision 1.2
sys/modules/compat_90/Makefile: revision 1.3
sys/netinet6/nd6.c: revision 1.281
sys/compat/common/compat_mod.h: revision 1.10
sys/kern/compat_stub.c: revision 1.23
sys/sys/compat_stub.h: revision 1.27

Identify the need to rework the COMPAT_* code to be more
module-aware.
This is an XXX comment block only, NFCI.

Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

Allow kernels builds which don't define INET6 to compile compat bits
too.

Default the build of compat_90 module to include IPv6, as is done
for other INET6-sensitive modules (see if_lagg).
 1.3.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.8.1 04-Jan-2020  martin file compat_90_mod.c was added on branch phil-wifi on 2020-04-13 08:04:13 +0000
 1.18 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.17 15-Aug-2009  matt branches: 1.17.62; 1.17.64;
Include <sys/exec_aout.h> explicitly instead of relying on <sys/exec.h> to
do it for you.
 1.16 13-Aug-2009  matt #include "opt_execfmt.h" and only compile innards if EXEC_AOUT is defined.
 1.15 08-Dec-2007  dsl branches: 1.15.16;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.14 11-Dec-2005  christos branches: 1.14.44; 1.14.46; 1.14.56;
merge ktrace-lwp.
 1.13 26-Feb-2005  perry branches: 1.13.4;
nuke trailing whitespace
 1.12 30-Jan-2005  christos Don't try to map a 0 size bss.
 1.11 19-Nov-2003  christos branches: 1.11.8; 1.11.10;
Don't include malloc.h if you are not going to use it.
 1.10 08-Aug-2003  christos - GC all the setup_stack functions
- add one for linux/i386
 1.9 01-Apr-2003  thorpej branches: 1.9.2;
Use PAGE_SIZE rather than NBPG.
 1.8 10-Dec-2002  thorpej Rename __LDPGSZ to AOUT_LDPGSZ, to accurately reflect what it is.
 1.7 05-Oct-2002  chs count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.6 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.5 13-Nov-2001  lukem branches: 1.5.10;
add RCSIDs (including regeneration of files as appropriate)
 1.4 30-Oct-2001  thorpej - Add a new vnode flag VEXECMAP, which indicates that a vnode has
executable mappings. Stop overloading VTEXT for this purpose (VTEXT
also has another meaning).
- Rename vn_marktext() to vn_markexec(), and use it when executable
mappings of a vnode are established.
- In places where we want to set VTEXT, set it in v_flag directly, rather
than making a function call to do this (it no longer makes sense to
use a function call, since we no longer overload VTEXT with VEXECMAP's
meaning).

VEXECMAP suggested by Chuq Silvers.
 1.3 28-Jun-2000  mrg branches: 1.3.2; 1.3.4; 1.3.8;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 11-Apr-2000  chs add a new function vn_marktext() for exec code to let others know
that the vnode is now being used as process text.
 1.1 18-May-1996  christos branches: 1.1.26; 1.1.30;
- Moving cpu_exec_aout_prep_oldzmagic -> exec_aout_prep_oldzmagic.
This is used by the i386, hp300 and mac68k ports.
- Added exec_aout_prep_oldomagic, and exec_aout_prep_oldnmagic
These are just copies of the respective prep functions from
kern_exec.c with text address starting at 0. Maybe a better fix
is to pass the starting address as a third argument so we don't
duplicate code, but this could be the next pass since the functions
are used in many places. These functions are used for BSDI binaries.
 1.1.30.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.1.26.1 04-Jul-1999  chs after setting VTEXT on a vnode, flush any UBC mappings
to try to prevent unnecessary VAC aliases.
 1.3.8.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.3.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.3 11-Dec-2002  thorpej Sync with HEAD.
 1.3.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.5.10.2 02-Oct-2003  tron Pull up revision 1.7 (requested by junyoung in ticket #1488):
count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.5.10.1 27-Sep-2003  tron Pull up revision 1.6 (requested by junyoung in ticket #1466):
remove trailing \n in panic(). approved perry.
 1.9.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.9.2.4 04-Feb-2005  skrll Adapt to branch.
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.10.1 12-Feb-2005  yamt sync with head.
 1.11.8.1 29-Apr-2005  kent sync with -current
 1.13.4.2 21-Jan-2008  yamt sync with head
 1.13.4.1 21-Jun-2006  yamt sync with head.
 1.14.56.1 26-Dec-2007  ad Sync with head.
 1.14.46.1 09-Jan-2008  matt sync with HEAD
 1.14.44.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.15.16.1 19-Aug-2009  yamt sync with head.
 1.17.64.1 10-Jun-2019  christos Sync with HEAD
 1.17.62.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.25 12-Dec-2007  dsl compat_file.[ch] are no longer used
 1.24 08-Dec-2007  dsl branches: 1.24.2; 1.24.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.23 14-Jul-2007  dsl branches: 1.23.6; 1.23.8; 1.23.14; 1.23.16;
Adapt for sys_mount() becoming compat_40_sys_mount(),
 1.22 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.21 04-Mar-2007  christos branches: 1.21.2; 1.21.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 09-Feb-2007  ad branches: 1.20.2;
Merge newlock2 to head.
 1.19 14-Jul-2006  christos branches: 1.19.4;
make this compile again.
 1.18 13-Jul-2006  pavel sys_getfh -> compot_30_sys_getfh
 1.17 11-Dec-2005  christos branches: 1.17.4; 1.17.8;
merge ktrace-lwp.
 1.16 19-Aug-2005  christos 64 bit inode changes.
 1.15 29-May-2005  christos branches: 1.15.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.14 26-Feb-2005  perry nuke trailing whitespace
 1.13 24-Jul-2004  manu branches: 1.13.4; 1.13.6;
Add a wrapper for connect that check an alternate path in emulation tree
for AF_LOCAL sockets.
 1.12 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.11 19-Nov-2003  christos Don't include malloc.h if you are not going to use it.
 1.10 29-Jun-2003  fvdl branches: 1.10.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.9 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.8 05-Jun-2003  christos simplify bsd_sys_bind()
 1.7 05-Jun-2003  manu Ooops, I deleted a debug printf just before committing and one bit was
remaining. While I'm there, fix a typo in a comment.
 1.6 05-Jun-2003  manu Search alternate /emul/* path for AF_LOCAL sockets at bind() time.
 1.5 04-Jun-2003  manu Build again with SA
 1.4 10-Feb-2003  christos include more opt_ files for nfs.
 1.3 10-Feb-2003  christos getfh is needed for NFS server.
 1.2 22-Jan-2003  christos lwp'ify
 1.1 08-Dec-2002  manu branches: 1.1.2;
Introduce BSD system calls with alternate patch checking (in /emul) in
compat/common, so that they can be shared by several emulations, and use
them for Darwin.

This removes the ugly dependance on FreeBSD freebsd_file.c for COMPAT_DARWIN
 1.1.2.2 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.1 08-Dec-2002  thorpej file compat_file.c was added on branch nathanw_sa on 2002-12-11 06:37:03 +0000
 1.10.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.7 12-Nov-2004  skrll Adapt to branch.
 1.10.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.4 12-Aug-2004  skrll Sync with HEAD.
 1.10.2.3 03-Aug-2004  skrll Sync with HEAD
 1.10.2.2 19-Aug-2003  skrll LWPify
 1.10.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.13.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.4.1 29-Apr-2005  kent sync with -current
 1.15.2.5 21-Jan-2008  yamt sync with head
 1.15.2.4 03-Sep-2007  yamt sync with head.
 1.15.2.3 26-Feb-2007  yamt sync with head.
 1.15.2.2 30-Dec-2006  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.17.8.1 11-Aug-2006  yamt sync with head
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.19.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.20.2.2 07-May-2007  yamt sync with head.
 1.20.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.21.4.1 11-Jul-2007  mjf Sync with head.
 1.21.2.2 15-Jul-2007  ad Sync with head.
 1.21.2.1 27-May-2007  ad Sync with head.
 1.23.16.1 26-Dec-2007  ad Sync with head.
 1.23.14.1 27-Dec-2007  mjf Sync with HEAD.
 1.23.8.1 23-Mar-2008  matt sync with HEAD
 1.23.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.24.4.1 13-Dec-2007  bouyer Sync with HEAD
 1.24.2.1 13-Dec-2007  yamt sync with head.
 1.8 12-Dec-2007  dsl compat_file.[ch] are no longer used
 1.7 30-Apr-2007  dsl branches: 1.7.8; 1.7.14; 1.7.16; 1.7.18; 1.7.20;
Rework compat stat() and statvfs() code so that it no longer uses the stackgap.
 1.6 11-Dec-2005  christos branches: 1.6.26; 1.6.30; 1.6.32;
merge ktrace-lwp.
 1.5 19-Aug-2005  christos 64 bit inode changes.
 1.4 24-Jul-2004  manu branches: 1.4.12;
Add a wrapper for connect that check an alternate path in emulation tree
for AF_LOCAL sockets.
 1.3 05-Jun-2003  manu branches: 1.3.2;
Search alternate /emul/* path for AF_LOCAL sockets at bind() time.
 1.2 22-Jan-2003  christos lwp'ify
 1.1 08-Dec-2002  manu branches: 1.1.2;
Introduce BSD system calls with alternate patch checking (in /emul) in
compat/common, so that they can be shared by several emulations, and use
them for Darwin.

This removes the ugly dependance on FreeBSD freebsd_file.c for COMPAT_DARWIN
 1.1.2.2 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.1 08-Dec-2002  thorpej file compat_file.h was added on branch nathanw_sa on 2002-12-11 06:37:03 +0000
 1.3.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.12.3 21-Jan-2008  yamt sync with head
 1.4.12.2 03-Sep-2007  yamt sync with head.
 1.4.12.1 21-Jun-2006  yamt sync with head.
 1.6.32.1 11-Jul-2007  mjf Sync with head.
 1.6.30.1 27-May-2007  ad Sync with head.
 1.6.26.1 07-May-2007  yamt sync with head.
 1.7.20.1 13-Dec-2007  bouyer Sync with HEAD
 1.7.18.1 13-Dec-2007  yamt sync with head.
 1.7.16.1 26-Dec-2007  ad Sync with head.
 1.7.14.1 27-Dec-2007  mjf Sync with HEAD.
 1.7.8.1 23-Mar-2008  matt sync with HEAD
 1.31 01-Jan-2020  pgoyette Emove vestigial remains of the monolithic compat module.
 1.30 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.29 04-May-2018  pgoyette branches: 1.29.2;
Clean up a stray #ifdef _MODULE - it prevented definition of
COMPAT_SIGCONTEXT which in turn prevented building of the
SYS_compat16_sigaction_14 code.

Should address PR kern/53260

XXX Pull-up to netbsd-8
 1.28 12-Apr-2018  christos provide vectors for the ifconf compat code and ifdatareq compat code.
 1.27 18-Mar-2018  christos factor out the ccd COMPAT_60 code.
 1.26 17-Mar-2018  christos redo the cpu ucode compat code.
 1.25 15-Mar-2018  christos add uvm swap compat code.
 1.24 05-Nov-2016  pgoyette branches: 1.24.8; 1.24.14;
Move if_43.c back into the shared Makefile.sysio where it really
belongs.

Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers. Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.

Addresses the issue pointed out in PR kern/51598
 1.23 05-Dec-2015  pgoyette branches: 1.23.2;
The COMPAT_10 code for SYSVxxx is now part of the sysv_ipc module, so
don't install syscall function pointers from the compat module.
 1.22 11-May-2015  pgoyette Fix the #ifdef _MODULE stuff so that the syscall packages and sysctl stuff
gets handled properly even in built-in module case.

XXX
Whatever was I thinking when I put those conditionals in? And wouldn't it
be a wonderful thing to have some atf regression tests to actually catch
errors in the compat{,_sysv} modules? :)
 1.21 10-May-2015  pgoyette Split the SYSV* compat code out into a separate compat_sysv module.

For monolithic kernels, both modules will be compiled as "built-ins",
while modular environments will be able to load the SYSVSEM, SYSVSHM,
and SYSVMSG code independant from the rest of compat.

This is a necessary precursor step to making the "STD" SYSV* code
into a separate module.

Tested in both monolithic and modular environments with no errors
seen.
 1.20 19-Sep-2013  christos branches: 1.20.6;
exec modules need to be of the exec kind
 1.19 29-Mar-2013  christos branches: 1.19.4;
compat glue for new lwp_park()
 1.18 21-Feb-2013  christos remove empty #if
 1.17 21-Feb-2013  skrll Wrap sysctl_teardown(&compat_clog) with the appropriate #if defined()s
 1.16 21-Feb-2013  pgoyette Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.

OK christos@

Will request pull-up to 6.0 in a few days.
 1.15 22-Jan-2013  christos Simplify the ifdef mess. No functional context.
 1.14 08-Aug-2011  jakllsch branches: 1.14.2; 1.14.8; 1.14.12;
COMPAT_16 code only exists on amd64 in the presence of COMPAT_NETBSD32.
 1.13 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.12 19-Jan-2011  tsutsui branches: 1.12.2;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.11 05-Mar-2010  pooka branches: 1.11.2; 1.11.4;
Reset sendsig_sigcontext_vec at fini to avoid having it point at
garbage and to allow re-init of the module (if DIAGNOSTIC).
 1.10 21-Dec-2009  njoly branches: 1.10.2;
Remove SYS_compat_50_mq_timedreceive/SYS_compat_50_mq_timedsend
duplicate entries.

Fix a KASSERT when unloading the compat kernel module.
 1.9 22-Nov-2009  mbalmer more s/the the/the/
 1.8 19-Jul-2009  rmind - Use #ifdef AIO, instead of #ifdef notyet. Not a solution, but at
least gets it working for MONOLITHIC kernel.
- Similarily add #ifdef MQUEUE for mqueue compat.
- Amend TNF license to be 2-clause. Approved by <christos>.
 1.7 13-Jan-2009  martin branches: 1.7.2; 1.7.4; 1.7.6; 1.7.8;
Add a few missing includes, so the ifdefs work as expected.
 1.6 11-Jan-2009  christos fix lutimes.
 1.5 11-Jan-2009  christos merge christos-time_t
 1.4 19-Nov-2008  cegger branches: 1.4.2; 1.4.6;
make this compile (for next68k)
 1.3 19-Nov-2008  ad Additionally, set emul_netbsd_object=NULL after detaching it.
 1.2 19-Nov-2008  ad compat_modcmd: emul_netbsd_object will be NULL if no exec has taken place
between load and unload of the compat module.
 1.1 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.4.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.6.1 19-Nov-2008  haad file compat_mod.c was added on branch haad-dm on 2008-12-13 01:13:47 +0000
 1.4.2.2 27-Nov-2008  christos add more 50 compat syscalls.
 1.4.2.1 19-Nov-2008  christos file compat_mod.c was added on branch christos-time_t on 2008-11-27 21:32:02 +0000
 1.7.8.4 11-Mar-2010  yamt sync with head
 1.7.8.3 19-Aug-2009  yamt sync with head.
 1.7.8.2 04-May-2009  yamt sync with head.
 1.7.8.1 13-Jan-2009  yamt file compat_mod.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:17 +0000
 1.7.6.1 23-Jul-2009  jym Sync with HEAD.
 1.7.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.7.4.1 13-Jan-2009  skrll file compat_mod.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.7.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.7.2.1 13-Jan-2009  mjf file compat_mod.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.10.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.2.2 21-Apr-2011  rmind sync with head
 1.11.2.1 05-Mar-2011  rmind sync with head
 1.12.2.1 15-Feb-2011  bouyer Implement COMPAT_50 quotactl(2)
 1.14.12.4 03-Dec-2017  jdolecek update from HEAD
 1.14.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.12.2 23-Jun-2013  tls resync from head
 1.14.12.1 25-Feb-2013  tls resync with head
 1.14.8.1 14-Mar-2013  riz Pull up following revision(s) (requested by pgoyette in ticket #837):
sys/compat/common/kern_time_50.c: revision 1.25
sys/kern/init_sysctl.c: revision 1.195
sys/kern/init_main.c: revision 1.447
sys/compat/common/compat_util.h: revision 1.23
sys/compat/common/compat_mod.h: revision 1.1
sys/compat/common/compat_mod.c: revision 1.16
sys/compat/common/compat_mod.c: revision 1.17
sys/compat/common/compat_mod.c: revision 1.18
sys/compat/common/vfs_syscalls_43.c: revision 1.55
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.
OK christos@
Will request pull-up to 6.0 in a few days.
Wrap sysctl_teardown(&compat_clog) with the appropriate #if defined()s
remove empty #if
 1.14.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.2.1 23-Jan-2013  yamt sync with head
 1.19.4.1 18-May-2014  rmind sync with head
 1.20.6.3 05-Dec-2016  skrll Sync with HEAD
 1.20.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.20.6.1 06-Jun-2015  skrll Sync with HEAD
 1.23.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.14.37 07-Sep-2018  pgoyette At the request of reviewers, remove the module alias functionality.

We will rely only on module names and duplicate-symbol detection to
detect module conflicts.
 1.24.14.36 21-May-2018  pgoyette Sync with HEAD
 1.24.14.35 17-Apr-2018  pgoyette Ooops - forgot to enable the last couple of alias module names.
 1.24.14.34 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.24.14.33 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.24.14.32 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.24.14.31 31-Mar-2018  pgoyette Add compat_12 to the alias list, and add compat_80 entry points to the
init-fini list.
 1.24.14.30 31-Mar-2018  pgoyette create the compat_12 module
 1.24.14.29 30-Mar-2018  pgoyette Update list of modules which are included in the monolithic compat_netbsd
module.
 1.24.14.28 30-Mar-2018  pgoyette Add compat_13 module
 1.24.14.27 30-Mar-2018  pgoyette Extract compat_14 stuff into its own module
 1.24.14.26 30-Mar-2018  pgoyette Create and build a compat_16 module
 1.24.14.25 30-Mar-2018  pgoyette Add compat_20 to the list of aliases
 1.24.14.24 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.24.14.23 29-Mar-2018  pgoyette Split out the usb compat_30 code and add it to the module
 1.24.14.22 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.24.14.21 27-Mar-2018  pgoyette Create a compat_40 module
 1.24.14.20 25-Mar-2018  pgoyette Now that we have a compat_80 module, make sure it is marked as "included"
in the monolithic compat module
 1.24.14.19 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.24.14.18 20-Mar-2018  pgoyette Prep for additional version-specific compat modules; commented out for now.
 1.24.14.17 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.24.14.16 18-Mar-2018  pgoyette Initial pass at getting the tty stuff properly modularized. Subject
to review and revision.
 1.24.14.15 18-Mar-2018  pgoyette Move closer to a complete compat_60 module. All that remains is some
tty stuff and some ccd ioctl()s.
 1.24.14.14 17-Mar-2018  pgoyette Import christos's changes for the compat_60 cpu_ucode stuff
 1.24.14.13 16-Mar-2018  pgoyette Move closer to getting a compat_60 module - still needs more work
 1.24.14.12 16-Mar-2018  pgoyette Initial pass at setting up the compat_60 module.

XXX needs some work to properly handle cpu_ucode stuff.

While here, move details of compat_70 init/fini routines into the
module itself.
 1.24.14.11 15-Mar-2018  pgoyette Update alias list for included modules for compat_60
 1.24.14.10 15-Mar-2018  pgoyette The big all-inclusive compat module still needs to initialize the
compat_70 stuff.
 1.24.14.9 15-Mar-2018  pgoyette Add alias module name 'compat_70' since the full compat module includes
the entire compat_70 module.
 1.24.14.8 15-Mar-2018  pgoyette Resolve conflicts from sync-with-HEAD
 1.24.14.7 15-Mar-2018  pgoyette Synch with HEAD
 1.24.14.6 14-Mar-2018  pgoyette Make do_openat()'s handling of path=NULL modular
 1.24.14.5 13-Mar-2018  pgoyette Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.
 1.24.14.4 08-Mar-2018  pgoyette Include if.h to get IFNAMSIZE
 1.24.14.3 08-Mar-2018  pgoyette Implement vector initialization for ifreqo2n and ifdatareq
 1.24.14.2 06-Mar-2018  pgoyette Use a .h file for declaring the if_40_{init, fini} routines
 1.24.14.1 06-Mar-2018  pgoyette Untangle some networking compat code so we can build a kernel with
networking and MODULAR, but without any actual COMPAT_* code (ie,
assuming that all the compat stuff can be added later via modules).
 1.24.8.1 06-May-2018  martin Pull up following revision(s) (requested by pgoyette in ticket #807):

sys/compat/common/compat_mod.c: revision 1.29

Clean up a stray #ifdef _MODULE - it prevented definition of
COMPAT_SIGCONTEXT which in turn prevented building of the
SYS_compat16_sigaction_14 code.

Should address PR kern/53260

XXX Pull-up to netbsd-8
 1.29.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.29.2.1 10-Jun-2019  christos Sync with HEAD
 1.12 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.11 19-May-2024  christos version dup3
 1.10 09-Dec-2023  pgoyette Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

XXX pullup-10 - hopefully before RC2
 1.9 18-Aug-2023  christos Add linux waitid(2) from GSoC 2023 (Theodore Preduta)
 1.8 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.7 19-Dec-2022  pgoyette Create compat_100 module infrastructure now that we have branched
for NetBSD-10
 1.6 22-Sep-2019  christos branches: 1.6.26;
Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.5 17-May-2019  msaitoh The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.4 15-Apr-2019  pgoyette Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.c
and into its own source file, which is now included in the compat_50
module.

(Not sure how this got missed during the original [pgoyette-compat] work)
 1.3 28-Jan-2019  christos - provide a hook for the 43 tty ioctls
- make the 60 tty ioctl hook look the same
- fix the tty code to call both hooks and remove unused lock
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 21-Feb-2013  pgoyette branches: 1.1.4; 1.1.6; 1.1.16; 1.1.42; 1.1.44;
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.

OK christos@

Will request pull-up to 6.0 in a few days.
 1.1.44.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.44.1 10-Jun-2019  christos Sync with HEAD
 1.1.42.24 11-Jan-2019  pgoyette Rework the various sysctl-related routines to call the correct code
for each version. While here, extract the 5.0 specific code instead
of including in the main rtsock.c code.

Also, clean up all the sysctl-related routines to prevent building
more than one copy, no matter how many places rtsock.c gets #include'd
into!
 1.1.42.23 12-Oct-2018  pgoyette Use a MP-safe hook for the rnd_ioctl compat_50 calls.
 1.1.42.22 19-Sep-2018  pgoyette Split out the vnd COMPAT_50 code
 1.1.42.21 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.1.42.20 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.1.42.19 16-Apr-2018  pgoyette Rename if_[45]0_{init,fini} entry points to more appropriate and more
consistent uipc_syscalls_[45]0_{init,fini} and remove some multiple
declarations.
 1.1.42.18 03-Apr-2018  pgoyette Remove fixed allocation of modules' "required" lists (previously
limited to MAXMODDEPS entries). Update the modctl(MODCTL_STAT)
syscall to return the required data in a new format, and retain
the previous data format in MODCTL_OSTAT. Update the compat_80
and compat_netbsd32 modules as needed.
 1.1.42.17 31-Mar-2018  pgoyette create the compat_12 module
 1.1.42.16 30-Mar-2018  pgoyette Add compat_13 module
 1.1.42.15 30-Mar-2018  pgoyette Extract compat_14 stuff into its own module
 1.1.42.14 30-Mar-2018  pgoyette Create and build a compat_16 module
 1.1.42.13 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.1.42.12 29-Mar-2018  pgoyette Split out the usb compat_30 code and add it to the module
 1.1.42.11 28-Mar-2018  pgoyette Split vnd compat_30 code out of the main driver and into the compat_30
module
 1.1.42.10 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.1.42.9 27-Mar-2018  pgoyette Create a compat_40 module
 1.1.42.8 23-Mar-2018  pgoyette For now, the compat_80 module is empty.
 1.1.42.7 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.1.42.6 18-Mar-2018  pgoyette Merge changes from HEAD into ccd_60.c

For all of the individual xxx_60_{init,fini} routines, don't force
them to artificially return a status; just make them void. This
simplifies the compat_60_{init,fini} handling of errors that remain.
 1.1.42.5 18-Mar-2018  pgoyette Clean-up for kern_cpu_60 code.

Also, although not strictly necessary, include the kern_sa_60 stuff in
the compat_60 module, for completeness.

Still need to deal with some tty code and the ccd driver to finish off
the compat_60 module.
 1.1.42.4 18-Mar-2018  pgoyette Move closer to a complete compat_60 module. All that remains is some
tty stuff and some ccd ioctl()s.
 1.1.42.3 17-Mar-2018  pgoyette Make all the compat_xx_{init,fini} routines return an int, whether or
not they currently need it.
 1.1.42.2 16-Mar-2018  pgoyette Move closer to getting a compat_60 module - still needs more work
 1.1.42.1 16-Mar-2018  pgoyette Initial pass at setting up the compat_60 module.

XXX needs some work to properly handle cpu_ucode stuff.

While here, move details of compat_70 init/fini routines into the
module itself.
 1.1.16.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.16.1 21-Feb-2013  yamt file compat_mod.h was added on branch yamt-pagecache on 2014-05-22 11:40:15 +0000
 1.1.6.2 14-Mar-2013  riz Pull up following revision(s) (requested by pgoyette in ticket #837):
sys/compat/common/kern_time_50.c: revision 1.25
sys/kern/init_sysctl.c: revision 1.195
sys/kern/init_main.c: revision 1.447
sys/compat/common/compat_util.h: revision 1.23
sys/compat/common/compat_mod.h: revision 1.1
sys/compat/common/compat_mod.c: revision 1.16
sys/compat/common/compat_mod.c: revision 1.17
sys/compat/common/compat_mod.c: revision 1.18
sys/compat/common/vfs_syscalls_43.c: revision 1.55
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.
OK christos@
Will request pull-up to 6.0 in a few days.
Wrap sysctl_teardown(&compat_clog) with the appropriate #if defined()s
remove empty #if
 1.1.6.1 21-Feb-2013  riz file compat_mod.h was added on branch netbsd-6 on 2013-03-14 16:33:09 +0000
 1.1.4.2 25-Feb-2013  tls resync with head
 1.1.4.1 21-Feb-2013  tls file compat_mod.h was added on branch tls-maxphys on 2013-02-25 00:29:07 +0000
 1.6.26.1 10-Dec-2023  martin Pull up following revision(s) (requested by pgoyette in ticket #487):

sys/compat/common/compat_90_mod.c: revision 1.5
sys/compat/common/compat_90_mod.c: revision 1.6
sys/netinet6/in6.c: revision 1.290
sys/netinet6/in6.c: revision 1.291
sys/compat/common/files.common: revision 1.11
sys/netinet6/icmp6.c: revision 1.255
sys/compat/common/net_inet6_nd_90.c: revision 1.1
sys/compat/common/net_inet6_nd_90.c: revision 1.2
sys/modules/compat_90/Makefile: revision 1.2
sys/modules/compat_90/Makefile: revision 1.3
sys/netinet6/nd6.c: revision 1.281
sys/compat/common/compat_mod.h: revision 1.10
sys/kern/compat_stub.c: revision 1.23
sys/sys/compat_stub.h: revision 1.27

Identify the need to rework the COMPAT_* code to be more
module-aware.
This is an XXX comment block only, NFCI.

Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

Allow kernels builds which don't define INET6 to compile compat bits
too.

Default the build of compat_90 module to include IPv6, as is done
for other INET6-sensitive modules (see if_lagg).
 1.1 22-Sep-2018  pgoyette branches: 1.1.2;
file compat_raid_50.c was initially added on branch pgoyette-compat.
 1.1.2.3 24-Jan-2019  pgoyette The raidframe compat code lives in sys/dev/raidframe/ so move all the
module stuff there. Update the Makefiles appropriately.
 1.1.2.2 23-Jan-2019  pgoyette Add compat_raid_80 to the required list
 1.1.2.1 22-Sep-2018  pgoyette Split the raidframe compatability code out into separate modules, since
the driver is already a module. This avoids having to pass a bunch of
function pointers as arguments to raidframe's compat_ioctl().
 1.1 22-Sep-2018  pgoyette branches: 1.1.2;
file compat_raid_80.c was initially added on branch pgoyette-compat.
 1.1.2.2 24-Jan-2019  pgoyette The raidframe compat code lives in sys/dev/raidframe/ so move all the
module stuff there. Update the Makefiles appropriately.
 1.1.2.1 22-Sep-2018  pgoyette Split the raidframe compatability code out into separate modules, since
the driver is already a module. This avoids having to pass a bunch of
function pointers as arguments to raidframe's compat_ioctl().
 1.4 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.3 05-Jun-2011  dsl Use 'curlwp' here insteald of the 'l' - which isn't passsed as an arg
to the #define, but will always be curlwp.
 1.2 16-Jun-2007  dsl branches: 1.2.2; 1.2.12; 1.2.60; 1.2.66; 1.2.70;
Modify the (recently added) compat_sigaltstack() #define to take the
values of the SS_ONSTACK and SS_DISABLE constants.
Use it to shorten the source files when this action is replicated.
Actually, given the monstrous complexity of sigaltstack1() there is
probably a much better way to do this...
 1.1 03-Jun-2007  dsl branches: 1.1.2;
Add a #define that expands to the compat wrapper for sigaltstack1().
Use it for the netbsd32_compat_13.c version of the code.
 1.1.2.5 15-Jul-2007  ad Sync with head.
 1.1.2.4 15-Jul-2007  ad Sync with head.
 1.1.2.3 09-Jun-2007  ad Sync with head.
 1.1.2.2 09-Jun-2007  ad Sync with head.
 1.1.2.1 03-Jun-2007  ad file compat_sigaltstack.h was added on branch vmlocking on 2007-06-09 21:37:07 +0000
 1.2.70.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.66.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.60.1 12-Jun-2011  rmind sync with head
 1.2.12.2 03-Sep-2007  yamt sync with head.
 1.2.12.1 16-Jun-2007  yamt file compat_sigaltstack.h was added on branch yamt-lazymbuf on 2007-09-03 14:31:49 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 16-Jun-2007  mjf file compat_sigaltstack.h was added on branch mjf-ufs-trans on 2007-07-11 20:03:46 +0000
 1.6 26-Mar-2020  pgoyette When using SYSCTL_SETUP there is no guarantee of the order in which
the set-up functions will be called, so it is perfectly acceptable
for a compat code's routine to be called ahead of the code in other
parts of the kernel.

So make sure that the 2nd level sysctl node ``vfs.generic'' exists
before trying to add the 3rd level entries.

XXX Rather than creating the 2nd level node in two places, we could
XXX add the shared ``vfs.generic'' node to sysctl_init_base.c but
XXX this is left for another day.
 1.5 27-Feb-2020  pgoyette Ooppss - SYSCTL_SETUP() functions return void.
 1.4 27-Feb-2020  pgoyette Remove explicit calls to the sysctl setup routines, since this is now
handled by the module infrastructure.
 1.3 06-Dec-2019  maxv branches: 1.3.2;
Fix a bunch of unimportant "Local variable hides global variable" warnings
from the LGTM bot.
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_sysctl_09_43.c was initially added on branch pgoyette-compat.
 1.1.2.2 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.1 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.2.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_sysctl_09_43.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.3.2.1 29-Feb-2020  ad Sync with head.
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_sysv_10_mod.c was initially added on branch pgoyette-compat.
 1.1.2.2 13-Sep-2018  pgoyette Fix some module requirements
 1.1.2.1 17-Apr-2018  pgoyette Split the compat_sysv module into several version-specific modules,
similar to the compat module.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_sysv_10_mod.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_sysv_14_mod.c was initially added on branch pgoyette-compat.
 1.1.2.2 13-Sep-2018  pgoyette Fix some module requirements
 1.1.2.1 17-Apr-2018  pgoyette Split the compat_sysv module into several version-specific modules,
similar to the compat module.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_sysv_14_mod.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 01-Mar-2019  pgoyette branches: 1.4.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_sysv_50_mod.c was initially added on branch pgoyette-compat.
 1.1.2.3 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.2 15-Oct-2018  pgoyette Convert the final non-MP-safe "vectored" compat routine to use the
MP-safe mechanism.
 1.1.2.1 17-Apr-2018  pgoyette Split the compat_sysv module into several version-specific modules,
similar to the compat module.
 1.4.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 01-Mar-2019  christos file compat_sysv_50_mod.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.4 03-Dec-2015  pgoyette branches: 1.4.10;
Merge the compat_sysv module into the sysv_ipc module - it should
never have been a separate module in the first place (my bad).

Adjust dependencies as appropriate.
 1.3 13-May-2015  pgoyette branches: 1.3.2;
The compat_sysv module now depends on sysv_ipc module.
 1.2 11-May-2015  pgoyette Fix the #ifdef _MODULE stuff so that the syscall packages and sysctl stuff
gets handled properly even in built-in module case.

XXX
Whatever was I thinking when I put those conditionals in? And wouldn't it
be a wonderful thing to have some atf regression tests to actually catch
errors in the compat{,_sysv} modules? :)
 1.1 10-May-2015  pgoyette Split the SYSV* compat code out into a separate compat_sysv module.

For monolithic kernels, both modules will be compiled as "built-ins",
while modular environments will be able to load the SYSVSEM, SYSVSHM,
and SYSVMSG code independant from the rest of compat.

This is a necessary precursor step to making the "STD" SYSV* code
into a separate module.

Tested in both monolithic and modular environments with no errors
seen.
 1.3.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.2.2 06-Jun-2015  skrll Sync with HEAD
 1.3.2.1 13-May-2015  skrll file compat_sysv_mod.c was added on branch nick-nhusb on 2015-06-06 14:40:05 +0000
 1.4.10.5 12-Sep-2018  pgoyette Complete removal of the "monolithic" all-version compat_sysvipc module
 1.4.10.4 07-Sep-2018  pgoyette At the request of reviewers, remove the module alias functionality.

We will rely only on module names and duplicate-symbol detection to
detect module conflicts.
 1.4.10.3 04-Sep-2018  pgoyette Use correct module names for the aliases.
 1.4.10.2 17-Apr-2018  pgoyette Split the compat_sysv module into several version-specific modules,
similar to the compat module.
 1.4.10.1 17-Apr-2018  pgoyette Rename sysv_mod.[ch] to compat_sysv_mod.[ch] for consistency with other
files that provide module(7) interfaces.
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 17-Apr-2018  pgoyette branches: 1.1.2;
file compat_sysv_mod.h was initially added on branch pgoyette-compat.
 1.1.2.2 15-Oct-2018  pgoyette Convert the final non-MP-safe "vectored" compat routine to use the
MP-safe mechanism.
 1.1.2.1 17-Apr-2018  pgoyette Rename sysv_mod.[ch] to compat_sysv_mod.[ch] for consistency with other
files that provide module(7) interfaces.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file compat_sysv_mod.h was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.2 02-Feb-1996  christos Renamed compat_tty.c to tty_43.c and updated with the newest copy from
kern/tty_compat.c
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.47 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.46 09-Nov-2014  maxv branches: 1.46.18; 1.46.20;
Do not uselessly include <sys/malloc.h>.
 1.45 17-Dec-2013  martin branches: 1.45.4;
Free pathbuf in an error path.
From Maxime Villard.
 1.44 19-Nov-2010  dholland branches: 1.44.8; 1.44.14; 1.44.18; 1.44.20; 1.44.22; 1.44.28;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.43 14-Dec-2009  mrg branches: 1.43.4;
replace mips:elf_check_itp() and ELFNAME2(netbsd32,probe_noteless) that
it's based upon with a common compat_elf_check_interp().

tested on MALTA64 and sparc64.
 1.42 29-Jun-2009  dholland Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.41 28-Apr-2008  martin branches: 1.41.10; 1.41.14; 1.41.18; 1.41.20; 1.41.24;
Remove clause 3 and 4 from TNF licenses
 1.40 31-Dec-2007  ad branches: 1.40.6; 1.40.8; 1.40.10;
Remove systrace. Ok core@.
 1.39 08-Dec-2007  pooka branches: 1.39.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.38 08-Dec-2007  dsl ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.37 13-Jul-2007  dsl branches: 1.37.6; 1.37.8; 1.37.14; 1.37.16;
Put the stackgap code under OPT_SYSTRACE.
 1.36 26-Apr-2007  dsl Pass the emulation root string into namei() from emul_find_interp() so that
the ktrace entries for lookups done during exec can have the full filename.
This is rather a hack :-)
 1.35 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.34 04-Mar-2007  christos branches: 1.34.2; 1.34.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33 24-Nov-2006  wiz branches: 1.33.4;
s/existance/existence/, from Zafer.
 1.32 23-Jul-2006  ad branches: 1.32.4; 1.32.6;
Use the LWP cached credentials where sane.
 1.31 14-May-2006  elad integrate kauth.
 1.30 11-Dec-2005  christos branches: 1.30.4; 1.30.6; 1.30.8; 1.30.10; 1.30.12;
merge ktrace-lwp.
 1.29 29-May-2005  christos branches: 1.29.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.28 26-Feb-2005  perry nuke trailing whitespace
 1.27 29-Jun-2003  fvdl branches: 1.27.2; 1.27.10; 1.27.12;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.26 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.25 29-Nov-2002  jdolecek add emul_find_interp() function: the function looks for interpreter
in alternative emul tree first, and updates interpreter pathname
if found there; if not found in alternative emul tree, pathname
without the emul prefix is checked, and error returned if the file
doesn't exist
 1.24 23-Sep-2002  simonb Remove a meaningless type qualifier on a cast.
 1.23 17-Mar-2002  christos panic if more space than stackgaplen is requested. Maybe I should remove the
size option completely.
 1.22 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.21 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.20 02-Feb-2001  jdolecek branches: 1.20.2; 1.20.4;
emul_find(): actually, the emulation root vnode dance has to be done for
CHECK_ALT_SYMLINK() same way as for CHECK_ALT_EXISTS()
This fixes lossage reported on current-users and kern/12019 by Ross Harvey.
 1.19 22-Jan-2001  jdolecek Introduce CHECK_ALT_SYMLINK() - this checks for alternative location without
following links, hence is usable for checking of presence of a symlink.
Also slighly cleanup EXISTS and CREAT cases - use symbolic constants
instead of 0/1.
This is needed for emulation of readlink(2), lchown(2) and similar.
Addresses kern/11757.
 1.18 20-Nov-2000  jdolecek make const the struct emul * pointers passed/used in stackgap_init(),
stackgap_alloc()
 1.17 28-Sep-2000  eeh Add support for variable end of user stacks needed to support COMPAT_NETBSD32:

`struct vmspace' has a new field `vm_minsaddr' which is the user TOS.

PS_STRINGS is deprecated in favor of curproc->p_pstr which is derived
from `vm_minsaddr'.

Bump the kernel version number.
 1.16 29-Aug-2000  sommerfeld Emulation stackgap sanity checks, based partly on fixes from
FreeBSD-SA00:42.

Change stackgap_alloc to bounds-check the allocation vs. the stack
gap, returning NULL if there isn't room for the allocation.

Change emul_find() to check for a NULL return from stackgap_alloc()
and convert that into ENAMETOOLONG.

Reorder various emulation syscalls so that all *_CHECK_ALT_{EXIST,CREAT}
calls (which turn into emul_find() under the covers come *after* small,
fixed-size stackgap_alloc() calls.

Clean up ibcs2 {get,set}groups.
 1.15 26-Jun-2000  mrg remove redundant vm includes.
 1.14 27-Apr-1999  christos branches: 1.14.2; 1.14.12;
From cgd again: pbuf == path on failure.
 1.13 27-Apr-1999  christos Make the usage consistant and document it:
if the path was given in a user buffer, return the new path in
a user buffer.
if the path was given in a kernel buffer, allocate a new kernel buffer
to return the new path; the caller is responsible for freeing the buffer
if we fail always set the new path to NULL.
This usage broke when I adde the /../ shortcut. Noted by cgd.
 1.12 24-Apr-1999  cgd implement a simple function, emul_flags_translate() to do table-based
flags translation.
 1.11 14-Feb-1999  christos branches: 1.11.2; 1.11.4; 1.11.6;
Provide a way for compat programs to specify files in the normal tree.
We do this using a trick similar to mach's /../; if a path is given as
/..<absolute-path-name>, then we return <absolute-path-name>
 1.10 09-Feb-1999  christos char * and char ** -> const char * and const char **
 1.9 03-Oct-1998  fvdl Assign to TNF completely.
 1.8 05-Sep-1998  christos Assign copyright to TNF.
 1.7 10-Oct-1997  fvdl Add getdirentries backward compat syscall. Provide common function to
signal cookie overflow during emulated getdents and friends.
 1.6 25-Oct-1996  cgd branches: 1.6.10;
make the namei struct members ni_dirp and ni_next, and the componentname
struct member cn_nameptr 'const', since they should never be used to
modify the path name. (Only the pathname buffer, cn_pnbuf, should be
modified.) Propagate the const poisoning to code that uses the namei
and componentname structs.
 1.5 12-Oct-1996  thorpej Don't inline stackgap_init() and stackgap_alloc(). Doing so generates
an include file dependency graph that's much more complicated than
it needs to be, and wastes space in the kernel.
 1.4 14-Mar-1996  christos Fix compiler warnings
 1.3 22-Oct-1995  mycroft Make sure we free the pathname buffer in all error cases.
 1.2 26-Jun-1995  christos branches: 1.2.2;
Fix PR1160... (bug with the new compat_util prefix)
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.2.2.1 22-Oct-1995  mycroft Make sure we free the pathname buffer in all error cases.
 1.6.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.6.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.3 09-Sep-2000  he Pull up revision 1.16 (requested by simonb):
More carefully check length of user-supplied data, in particular
make sure we don't overrun the available stack gap in stack gap
allocations.
 1.11.2.2 21-Jun-1999  cgd pull up rev(s) 1.12 from trunk. (cgd)
 1.11.2.1 18-Jun-1999  perry pullup 1.12->1.14 (cgd)
 1.14.12.2 18-Oct-2000  tv Pullup by patch [eeh]:
Support userspace at multiple addresses by making PSSTRINGS variable (using
p_psstr), and fix stackgap_init() appropriately.
 1.14.12.1 30-Aug-2000  sommerfeld Pull up:
syssrc/sys/compat/common/compat_util.c 1.16
syssrc/sys/compat/hpux/hpux_file.c 1.14
syssrc/sys/compat/ibcs2/ibcs2_misc.c 1.52
syssrc/sys/compat/ibcs2/ibcs2_stat.c 1.16
syssrc/sys/compat/linux/common/linux_file.c 1.29
syssrc/sys/compat/linux/common/linux_misc_notalpha.c 1.58
syssrc/sys/compat/svr4/svr4_stat.c 1.40
syssrc/sys/compat/svr4/svr4_stream.c 1.40,1.41

Approved by thorpej and jhawk.

Emulation stackgap sanity checks, based partly on fixes from
FreeBSD-SA00:42.

Change stackgap_alloc to bounds-check the allocation vs. the stack
gap, returning NULL if there isn't room for the allocation.

Change emul_find() to check for a NULL return from stackgap_alloc()
and convert that into ENAMETOOLONG.

Reorder various emulation syscalls so that all *_CHECK_ALT_{EXIST,CREAT}
calls (which turn into emul_find() under the covers come *after* small,
fixed-size stackgap_alloc() calls.

Clean up ibcs2 {get,set}groups.

Add range checks to svr4_stream.c
 1.14.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.14.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.14.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.20.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.20.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.20.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.2.6 11-Dec-2002  thorpej Sync with HEAD.
 1.20.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.20.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.20.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.20.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.20.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.27.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.27.10.1 29-Apr-2005  kent sync with -current
 1.27.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.27.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.27.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.27.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.27.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.29.2.4 21-Jan-2008  yamt sync with head
 1.29.2.3 03-Sep-2007  yamt sync with head.
 1.29.2.2 30-Dec-2006  yamt sync with head.
 1.29.2.1 21-Jun-2006  yamt sync with head.
 1.30.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.30.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.30.8.2 11-Aug-2006  yamt sync with head
 1.30.8.1 24-May-2006  yamt sync with head.
 1.30.6.1 01-Jun-2006  kardel Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.32.6.1 10-Dec-2006  yamt sync with head.
 1.32.4.1 12-Jan-2007  ad Sync with head.
 1.33.4.2 07-May-2007  yamt sync with head.
 1.33.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.34.4.1 11-Jul-2007  mjf Sync with head.
 1.34.2.2 15-Jul-2007  ad Sync with head.
 1.34.2.1 27-May-2007  ad Sync with head.
 1.37.16.1 26-Dec-2007  ad Sync with head.
 1.37.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.37.8.1 09-Jan-2008  matt sync with HEAD
 1.37.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.39.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.40.10.3 11-Mar-2010  yamt sync with head
 1.40.10.2 18-Jul-2009  yamt sync with head.
 1.40.10.1 16-May-2008  yamt sync with head.
 1.40.8.1 18-May-2008  yamt sync with head.
 1.40.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.41.24.2 18-Dec-2013  riz Revert ticket #1893 - netbsd-5 does not have pathbuf_destroy()
 1.41.24.1 17-Dec-2013  bouyer Pull up following revision(s) (requested by martin in ticket #1893):
sys/compat/common/compat_util.c: revision 1.45
Free pathbuf in an error path.
From Maxime Villard.
 1.41.20.2 18-Dec-2013  riz Revert ticket #1893 - netbsd-5 does not have pathbuf_destroy()
 1.41.20.1 17-Dec-2013  bouyer Pull up following revision(s) (requested by martin in ticket #1893):
sys/compat/common/compat_util.c: revision 1.45
Free pathbuf in an error path.
From Maxime Villard.
 1.41.18.1 14-Dec-2009  mrg pullup from -current:
>replace mips:elf_check_itp() and ELFNAME2(netbsd32,probe_noteless) that
>it's based upon with a common compat_elf_check_interp().
>
>tested on MALTA64 and sparc64.
 1.41.14.1 23-Jul-2009  jym Sync with HEAD.
 1.41.10.2 18-Dec-2013  riz Revert ticket #1893 - netbsd-5 does not have pathbuf_destroy()
 1.41.10.1 17-Dec-2013  bouyer Pull up following revision(s) (requested by martin in ticket #1893):
sys/compat/common/compat_util.c: revision 1.45
Free pathbuf in an error path.
From Maxime Villard.
 1.43.4.1 05-Mar-2011  rmind sync with head
 1.44.28.1 17-Dec-2013  bouyer Pull up following revision(s) (requested by martin in ticket #999):
sys/compat/common/compat_util.c: revision 1.45
Free pathbuf in an error path.
From Maxime Villard.
 1.44.22.1 18-May-2014  rmind sync with head
 1.44.20.1 17-Dec-2013  bouyer Pull up following revision(s) (requested by martin in ticket #999):
sys/compat/common/compat_util.c: revision 1.45
Free pathbuf in an error path.
From Maxime Villard.
 1.44.18.2 03-Dec-2017  jdolecek update from HEAD
 1.44.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.44.14.1 17-Dec-2013  bouyer Pull up following revision(s) (requested by martin in ticket #999):
sys/compat/common/compat_util.c: revision 1.45
Free pathbuf in an error path.
From Maxime Villard.
 1.44.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.4.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.46.20.1 10-Jun-2019  christos Sync with HEAD
 1.46.18.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.46.18.3 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.46.18.2 30-Mar-2018  pgoyette Create the compat_util module for use by version-specific compat code.
(It's automatically included in the monolithic compat module, as well
as in kernels with built-in compat code.)
 1.46.18.1 06-Mar-2018  pgoyette Move necessary routines out of compat_util.c and into exec_elf.c

Once again, compat_util.c is only for modules, so move it back into
compat/common/files.common and out of kern/files.kern
 1.24 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.23 21-Feb-2013  pgoyette branches: 1.23.36; 1.23.38;
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.

OK christos@

Will request pull-up to 6.0 in a few days.
 1.22 14-Dec-2009  mrg branches: 1.22.12; 1.22.18; 1.22.22;
replace mips:elf_check_itp() and ELFNAME2(netbsd32,probe_noteless) that
it's based upon with a common compat_elf_check_interp().

tested on MALTA64 and sparc64.
 1.21 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.20 28-Apr-2008  martin branches: 1.20.6; 1.20.8; 1.20.14;
Remove clause 3 and 4 from TNF licenses
 1.19 20-Jan-2008  dsl branches: 1.19.6; 1.19.8; 1.19.10;
Remove stackgap functions externs.
 1.18 22-Apr-2007  dsl branches: 1.18.8; 1.18.14; 1.18.20;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.17 04-Mar-2007  christos branches: 1.17.2; 1.17.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16 11-Dec-2005  christos branches: 1.16.26;
merge ktrace-lwp.
 1.15 29-May-2005  christos branches: 1.15.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.14 29-Jun-2003  fvdl branches: 1.14.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.13 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.12 29-Nov-2002  jdolecek add emul_find_interp() function: the function looks for interpreter
in alternative emul tree first, and updates interpreter pathname
if found there; if not found in alternative emul tree, pathname
without the emul prefix is checked, and error returned if the file
doesn't exist
 1.11 29-Nov-2002  jdolecek de-__P()
 1.10 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.9 22-Jan-2001  jdolecek branches: 1.9.2; 1.9.4;
Introduce CHECK_ALT_SYMLINK() - this checks for alternative location without
following links, hence is usable for checking of presence of a symlink.
Also slighly cleanup EXISTS and CREAT cases - use symbolic constants
instead of 0/1.
This is needed for emulation of readlink(2), lchown(2) and similar.
Addresses kern/11757.
 1.8 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.7 20-Nov-2000  jdolecek make const the struct emul * pointers passed/used in stackgap_init(),
stackgap_alloc()
 1.6 24-Apr-1999  cgd branches: 1.6.2;
implement a simple function, emul_flags_translate() to do table-based
flags translation.
 1.5 09-Feb-1999  christos branches: 1.5.2; 1.5.4; 1.5.6;
char * and char ** -> const char * and const char **
 1.4 05-Sep-1998  christos Assign copyright to TNF.
 1.3 10-Oct-1997  fvdl Add getdirentries backward compat syscall. Provide common function to
signal cookie overflow during emulated getdents and friends.
 1.2 12-Oct-1996  thorpej branches: 1.2.10;
Don't inline stackgap_init() and stackgap_alloc(). Doing so generates
an include file dependency graph that's much more complicated than
it needs to be, and wastes space in the kernel.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.2.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.6.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.5.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.1 21-Jun-1999  cgd pull up rev(s) 1.6 from trunk. (cgd)
 1.6.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.6.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.6.2.1 22-Nov-2000  bouyer Sync with HEAD.
 1.9.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.2.2 11-Dec-2002  thorpej Sync with HEAD.
 1.9.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.14.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.15.2.3 21-Jan-2008  yamt sync with head
 1.15.2.2 03-Sep-2007  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.26.2 07-May-2007  yamt sync with head.
 1.16.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.17.4.1 11-Jul-2007  mjf Sync with head.
 1.17.2.1 27-May-2007  ad Sync with head.
 1.18.20.1 20-Jan-2008  bouyer Sync with HEAD
 1.18.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.8.1 23-Mar-2008  matt sync with HEAD
 1.19.10.3 11-Mar-2010  yamt sync with head
 1.19.10.2 04-May-2009  yamt sync with head.
 1.19.10.1 16-May-2008  yamt sync with head.
 1.19.8.1 18-May-2008  yamt sync with head.
 1.19.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.19.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.20.14.1 14-Dec-2009  mrg pullup from -current:
>replace mips:elf_check_itp() and ELFNAME2(netbsd32,probe_noteless) that
>it's based upon with a common compat_elf_check_interp().
>
>tested on MALTA64 and sparc64.
 1.20.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.20.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.22.22.1 25-Feb-2013  tls resync with head
 1.22.18.1 14-Mar-2013  riz Pull up following revision(s) (requested by pgoyette in ticket #837):
sys/compat/common/kern_time_50.c: revision 1.25
sys/kern/init_sysctl.c: revision 1.195
sys/kern/init_main.c: revision 1.447
sys/compat/common/compat_util.h: revision 1.23
sys/compat/common/compat_mod.h: revision 1.1
sys/compat/common/compat_mod.c: revision 1.16
sys/compat/common/compat_mod.c: revision 1.17
sys/compat/common/compat_mod.c: revision 1.18
sys/compat/common/vfs_syscalls_43.c: revision 1.55
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.
OK christos@
Will request pull-up to 6.0 in a few days.
Wrap sysctl_teardown(&compat_clog) with the appropriate #if defined()s
remove empty #if
 1.22.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.38.1 10-Jun-2019  christos Sync with HEAD
 1.23.36.1 07-Mar-2018  pgoyette Move the emul_find_root() and emul_find_interp() to a new file
subr_emul.c

The previous location was in exec_elf.c but that can get built
multiple times for a single kernel, so we could end up with
duplicate symbols.

Thanks to ,rg@ for the heads-up.
 1.14 20-May-2024  christos remove dup line
 1.13 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.12 19-May-2024  christos version dup3
 1.11 09-Dec-2023  pgoyette Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

XXX pullup-10 - hopefully before RC2
 1.10 18-Aug-2023  christos Add linux waitid(2) from GSoC 2023 (Theodore Preduta)
 1.9 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.8 19-Dec-2022  pgoyette Create compat_100 module infrastructure now that we have branched
for NetBSD-10
 1.7 09-Aug-2021  andvar branches: 1.7.4;
fix various typos in compatibility, mainly in comments.
 1.6 21-Jan-2020  pgoyette Split the compat_50 module into two, separating the QUOTA-related
stuff from the rest of the module. This allows loading of the
(main) compat_50 module on kernels that don't include ``options
QUOTA''.

Welcome to 9.99.40 !

Addresses PR kern/54875
 1.5 22-Sep-2019  christos branches: 1.5.2;
Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.4 17-May-2019  msaitoh branches: 1.4.2;
The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.3 15-Apr-2019  pgoyette Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.c
and into its own source file, which is now included in the compat_50
module.

(Not sure how this got missed during the original [pgoyette-compat] work)
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 06-Mar-2018  pgoyette branches: 1.1.2;
file files.common was initially added on branch pgoyette-compat.
 1.1.2.40 28-Sep-2018  pgoyette Use the correct attribute - compat_utils vs compat_util
 1.1.2.39 28-Sep-2018  pgoyette Revert previous commit. There are still random unidentified references
to these utility routings.
 1.1.2.38 27-Sep-2018  pgoyette Add dependencies to ensure that the utility routines get included
as built-in module when needed.
 1.1.2.37 22-Sep-2018  pgoyette Missed this in previous files.* changes
 1.1.2.36 19-Sep-2018  pgoyette Split out the vnd COMPAT_50 code
 1.1.2.35 12-Sep-2018  pgoyette Complete removal of the "monolithic" all-version compat_sysvipc module
 1.1.2.34 10-Sep-2018  pgoyette Remove the monolithic compat and compat_sysv modules. Now that we
don't have aliases, we need to use only the version-specific module
names when resolving dependencies.
 1.1.2.33 17-Apr-2018  pgoyette Rename sysv_mod.[ch] to compat_sysv_mod.[ch] for consistency with other
files that provide module(7) interfaces.
 1.1.2.32 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.1.2.31 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.1.2.30 03-Apr-2018  pgoyette Remove fixed allocation of modules' "required" lists (previously
limited to MAXMODDEPS entries). Update the modctl(MODCTL_STAT)
syscall to return the required data in a new format, and retain
the previous data format in MODCTL_OSTAT. Update the compat_80
and compat_netbsd32 modules as needed.
 1.1.2.29 31-Mar-2018  pgoyette create the compat_12 module
 1.1.2.28 30-Mar-2018  pgoyette Add compat_13 module
 1.1.2.27 30-Mar-2018  pgoyette Extract compat_14 stuff into its own module
 1.1.2.26 30-Mar-2018  pgoyette typo in version dependency
 1.1.2.25 30-Mar-2018  pgoyette Create and build a compat_16 module
 1.1.2.24 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.1.2.23 29-Mar-2018  pgoyette Rename usb_30_subr.c --> usb_subr_30.c for consistency with others
 1.1.2.22 29-Mar-2018  pgoyette Split out the usb compat_30 code and add it to the module
 1.1.2.21 28-Mar-2018  pgoyette Split vnd compat_30 code out of the main driver and into the compat_30
module
 1.1.2.20 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.1.2.19 27-Mar-2018  pgoyette Create a compat_40 module
 1.1.2.18 24-Mar-2018  pgoyette Separate the compat_50 and compat_80 dispatching code from the main
body of raidframe, and place into the appropriate compat modules.

Enable building of the compat_80 module.
 1.1.2.17 23-Mar-2018  pgoyette For now, the compat_80 module is empty.
 1.1.2.16 21-Mar-2018  pgoyette Move if_spppsubr compat code into the compat50 module.

More prep work for compat80 module (for raidframe)
 1.1.2.15 21-Mar-2018  pgoyette Split the compat_50 code out from the dev/clockctl driver and include
it in the compat_50 and compat modules.
 1.1.2.14 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.1.2.13 18-Mar-2018  pgoyette Import compat_60 changes for dev/ccd
 1.1.2.12 18-Mar-2018  pgoyette Move closer to a complete compat_60 module. All that remains is some
tty stuff and some ccd ioctl()s.
 1.1.2.11 16-Mar-2018  pgoyette Move closer to getting a compat_60 module - still needs more work
 1.1.2.10 15-Mar-2018  pgoyette Resolve conflicts from sync-with-HEAD
 1.1.2.9 14-Mar-2018  pgoyette Tag files with their specific compat version required. This way
the files only get included if needed, allowing for subsequent
loading of COMPAT_xx modules for older-than-built-in code.
 1.1.2.8 14-Mar-2018  pgoyette Make do_openat()'s handling of path=NULL modular
 1.1.2.7 13-Mar-2018  pgoyette Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.
 1.1.2.6 12-Mar-2018  pgoyette Update dependencies for modules when they are built-in. Now we don't
(or at least, shouldn't) need reminders in the GENERIC config files
about which module options require other options.

Update branch status doc accordingly.
 1.1.2.5 09-Mar-2018  pgoyette More on renaming the new module
 1.1.2.4 09-Mar-2018  pgoyette Split the sysv_ipc module into two pieces: one for contemporary
SYSV* functionality, and one for compatability with previous NetBSD
versions. No need to pull in all of compat just to have a sysv_ipc
module.
 1.1.2.3 06-Mar-2018  pgoyette Move necessary routines out of compat_util.c and into exec_elf.c

Once again, compat_util.c is only for modules, so move it back into
compat/common/files.common and out of kern/files.kern
 1.1.2.2 06-Mar-2018  pgoyette compat_util.c is included in all kernels, so does not need to be
listed here.
 1.1.2.1 06-Mar-2018  pgoyette Add a files.common to list all the compat source files.
 1.4.2.4 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.2.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.2.2 10-Jun-2019  christos Sync with HEAD
 1.4.2.1 17-May-2019  christos file files.common was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.5.2.1 25-Jan-2020  ad Sync with head.
 1.7.4.1 10-Dec-2023  martin Pull up following revision(s) (requested by pgoyette in ticket #487):

sys/compat/common/compat_90_mod.c: revision 1.5
sys/compat/common/compat_90_mod.c: revision 1.6
sys/netinet6/in6.c: revision 1.290
sys/netinet6/in6.c: revision 1.291
sys/compat/common/files.common: revision 1.11
sys/netinet6/icmp6.c: revision 1.255
sys/compat/common/net_inet6_nd_90.c: revision 1.1
sys/compat/common/net_inet6_nd_90.c: revision 1.2
sys/modules/compat_90/Makefile: revision 1.2
sys/modules/compat_90/Makefile: revision 1.3
sys/netinet6/nd6.c: revision 1.281
sys/compat/common/compat_mod.h: revision 1.10
sys/kern/compat_stub.c: revision 1.23
sys/sys/compat_stub.h: revision 1.27

Identify the need to rework the COMPAT_* code to be more
module-aware.
This is an XXX comment block only, NFCI.

Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

Allow kernels builds which don't define INET6 to compile compat bits
too.

Default the build of compat_90 module to include IPv6, as is done
for other INET6-sensitive modules (see if_lagg).
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 26-Feb-2005  perry nuke trailing whitespace
 1.1 23-Apr-1999  cgd branches: 1.1.2; 1.1.38; 1.1.46; 1.1.48;
a quick hack to make generating errno conversion tables from our and other
systems' headers a bit easier. leaves much to be desired, but it's better
than nothing.
 1.1.48.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.46.1 29-Apr-2005  kent sync with -current
 1.1.38.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.6 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.5 01-Mar-2019  pgoyette branches: 1.5.4; 1.5.6;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.4 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.3 28-Jan-2019  christos - Don't expose random data conversion functions, but expose the high level
entry point (such as ioctl) instead.
- Attempt to autoload the module before using it.

Naming: Should the names of the hooks be:
<category>_<version>_<function>_hook_t
or:
<category>_<function>_<version>_hook_t

We should make those consistent.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 30-Mar-2018  pgoyette branches: 1.1.2;
file ieee80211_20.c was initially added on branch pgoyette-compat.
 1.1.2.3 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.2 21-Sep-2018  pgoyette Adapt the ieee80211_20 code to the new MP-safe mechanism
 1.1.2.1 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.5.6.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.5.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.4.2 10-Jun-2019  christos Sync with HEAD
 1.5.4.1 01-Mar-2019  christos file ieee80211_20.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 01-Mar-2019  pgoyette branches: 1.4.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 29-Jan-2019  pgoyette Rename the if43_20_hook to if43_cvtcmd_20_hook
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 30-Mar-2018  pgoyette branches: 1.1.2;
file if43_20.c was initially added on branch pgoyette-compat.
 1.1.2.5 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.4 30-Sep-2018  pgoyette atm is gone
 1.1.2.3 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.2 21-Sep-2018  pgoyette Clean-up some pre-existing function-pointer code (related to if_43)
to use the new MP-safe mechanism.
 1.1.2.1 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.4.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 01-Mar-2019  christos file if43_20.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.1 06-Mar-2018  pgoyette branches: 1.1.2;
file if_40.h was initially added on branch pgoyette-compat.
 1.1.2.4 15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.1.2.3 16-Apr-2018  pgoyette Rename if_[45]0_{init,fini} entry points to more appropriate and more
consistent uipc_syscalls_[45]0_{init,fini} and remove some multiple
declarations.
 1.1.2.2 06-Mar-2018  pgoyette Better to add these required headers closer to where they're needed
 1.1.2.1 06-Mar-2018  pgoyette Use a .h file for declaring the if_40_{init, fini} routines
 1.27 30-Mar-2023  riastradh atalk(4): Omit spurious satosat.

The input is already a struct sockaddr_at pointer.
 1.26 28-Sep-2022  msaitoh branches: 1.26.4;
Simplify sys/compat/sys/sockio.h. No functional change intended.

- Move some definitions from sys/compat/sockio.h to compat/net/if.h.
struct oif_data in sockio.h and if_data50 are the same, so remove oif_data.
Do the same thing to oifdatareq, too.
- u_quad_t -> uint64_t. No functional change.
 1.25 12-Jun-2020  roy Remove in-kernel handling of Router Advertisements

This is much better handled by a user-land tool.
Proposed on tech-net here:
https://mail-index.netbsd.org/tech-net/2020/04/22/msg007766.html

Note that the ioctl SIOCGIFINFO_IN6 no longer sets flags. That now
needs to be done using the pre-existing SIOCSIFINFO_FLAGS ioctl.

Compat is fully provided where it makes sense, but trying to turn on
RA handling will obviously throw an error as it no longer exists.

Note that if you use IPv6 temporary addresses, this now needs to be
turned on in dhcpcd.conf(5) rather than in sysctl.conf(5).
 1.24 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.23 23-Sep-2019  maxv Remove unused assignment. Found by the lgtm bot.
 1.22 17-May-2019  msaitoh The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.21 16-Apr-2019  msaitoh Rename ifreqo2n() and ifreqo2n() to IFREQO2N_43() and IFREQN2O_43():
- ifreqo2n() and ifreqn2o() are for COMPAT_43, so add _43 to the name.
- Uppercase to make it clear those are macros.
 1.20 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.19 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.18 29-Jan-2019  pgoyette Rename the if43_20_hook to if43_cvtcmd_20_hook
 1.17 29-Jan-2019  pgoyette The if43_20_hook function returns an errno; use it to determine whether
to allow conversion of the ioctl cmd --> ncmd

Should address issue reported by msaitoh@ on irc as well as via e-mail
from Patrick Welche and Ryo ONODERA.
 1.16 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.15 06-Sep-2018  maxv Remove the network ATM code.
 1.14 29-Jul-2017  riastradh branches: 1.14.2; 1.14.4;
Kill needless nested extern of vec_compat_cvtcmd/ioctl.

Already declared in if_43.h.
 1.13 05-Nov-2016  pgoyette Move if_43.c back into the shared Makefile.sysio where it really
belongs.

Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers. Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.

Addresses the issue pointed out in PR kern/51598
 1.12 25-Jul-2016  ozaki-r Apply if_get/if_put to compat_ifioctl
 1.11 11-Jul-2015  njoly branches: 1.11.2;
Handle case where compat_ifioctl() is called with ocmd != cmd, as found in
compat Linux. Do not crash by ensuring that oifr is correctly set.

Fix crash reported by Robert Swindells on tech-kern@.
 1.10 12-May-2015  christos rump is compiled with COMPAT_OSOCK not COMPAT_OIFREQ and the code in if.c
is not handling this case properly. Make this work by checking again if
we need to convert struct ifreq here, and if we do, we do it ourselves.
 1.9 09-Nov-2014  maxv branches: 1.9.2;
Do not uselessly include <sys/malloc.h>.
 1.8 05-Sep-2014  matt Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.7 01-Jul-2014  rtr branches: 1.7.2;
fix parameter types in pr_ioctl, called xx_control() functions and remove
abuse of pointer to struct mbuf type.

param2 changed to u_long type and uses parameter name 'cmd' (ioctl command)
param3 changed to void * type and uses parameter name 'data'
param4 changed to struct ifnet * and uses parameter name 'ifp'
param5 has been removed (formerly struct lwp *) and uses of 'l' have been
replaced with curlwp from curproc(9).

callers have had (now unnecessary) casts to struct mbuf * removed, called
code has had (now unnecessary) casts to u_long, void * and struct ifnet *
respectively removed.

reviewed by rmind@
 1.6 22-Jun-2014  rtr * split PRU_CONTROL functionality out of xxx_userreq() switches and place
into separate xxx_ioctl() functions.
* place KASSERT(req != PRU_CONTROL) inside xxx_userreq() as it is now
inappropriate for req = PRU_CONTROL in xxx_userreq().
* replace calls to pr_generic() with req = PRU_CONTROL with pr_ioctl().
* remove & fixup references to PRU_CONTROL xxx_userreq() function comments.
* fix various comments references for xxx_userreq() that mentioned
PRU_CONTROL as xxx_userreq() no longer handles the request.

a further change will follow to fix parameter and naming inconsistencies
retained from original code.

Reviewed by rmind@
 1.5 18-May-2014  rmind Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!
 1.4 19-Jan-2011  tsutsui branches: 1.4.16; 1.4.20; 1.4.30;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.3 06-Nov-2010  christos branches: 1.3.2;
can't map the old and the new SIO calls the way we did before because the
numbers have changed. Instead provide a switch. Keep the old code there,
to handle cases we did not handle in the first switch, but this is a hack
and should be removed.
 1.2 17-Mar-2009  dyoung branches: 1.2.2; 1.2.6;
#include "opt_compat_netbsd.h" for COMPAT_20.
 1.1 14-Nov-2008  ad branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10;
- Move some more compat code into sys/compat.
- Split 4.3BSD ifioctl stuff into its own file.
- Remove some ifdefs that include small fragments of vfs compat code
which are difficult to relocate elsewhere.
 1.1.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.8.3 28-Apr-2009  skrll Sync with HEAD.
 1.1.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.8.1 14-Nov-2008  skrll file if_43.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.1.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.1 14-Nov-2008  mjf file if_43.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 14-Nov-2008  haad file if_43.c was added on branch haad-dm on 2008-12-13 01:13:47 +0000
 1.2.6.1 05-Mar-2011  rmind sync with head
 1.2.2.2 04-May-2009  yamt sync with head.
 1.2.2.1 17-Mar-2009  yamt file if_43.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:17 +0000
 1.3.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.30.1 10-Aug-2014  tls Rebase.
 1.4.20.1 28-Aug-2013  rmind Checkpoint work in progress:
- Initial split of the protocol user-request method into the following
methods: pr_attach, pr_detach and pr_generic for old the pr_usrreq.
- Adjust socreate(9) and sonewconn(9) to call pr_attach without the
socket lock held (as a preparation for the locking scheme adjustment).
- Adjust all pr_attach routines to assert that PCB is not set.
- Sprinkle various comments, document some routines and their locking.
- Remove M_PCB, replace with kmem(9).
- Fix few bugs spotted on the way.
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.9.2.5 28-Aug-2017  skrll Sync with HEAD
 1.9.2.4 05-Dec-2016  skrll Sync with HEAD
 1.9.2.3 05-Oct-2016  skrll Sync with HEAD
 1.9.2.2 22-Sep-2015  skrll Sync with HEAD
 1.9.2.1 06-Jun-2015  skrll Sync with HEAD
 1.11.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.11.2.1 26-Jul-2016  pgoyette Sync with HEAD
 1.14.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.14.4.1 10-Jun-2019  christos Sync with HEAD
 1.14.2.15 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.14.2.14 22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.14.2.13 18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.14.2.12 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.14.2.11 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.14.2.10 15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.14.2.9 03-Oct-2018  pgoyette Don't define if_43_{init,fini}() in multiple .h files.
 1.14.2.8 03-Oct-2018  pgoyette Make if_43_{init,fini} return an int, for consistency with all the
related *_{init,fini} routines.
 1.14.2.7 30-Sep-2018  pgoyette Ssync with HEAD
 1.14.2.6 29-Sep-2018  pgoyette In MODULE_HOOK_CALL_DECL we don't need to provide the actual argument
list for calling the hook function, nor do we need to provide the
default value (for when the hook has not been set).
 1.14.2.5 21-Sep-2018  pgoyette Clean-up some pre-existing function-pointer code (related to if_43)
to use the new MP-safe mechanism.
 1.14.2.4 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.14.2.3 18-Sep-2018  pgoyette Split the COMPAT_CALL_HOOK to separate the declaration from the
implementation. Some hooks are called from multiple source files,
and the old method resulted in duplicate implementations.

Implement MP-safe hooks for the usb_subr_30 code. Pass the helper
functions as arguments to the compat code so it does not have to
determine if the kernel contains usb code.
 1.14.2.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.14.2.1 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.26.4.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #278):

sys/netatalk/ddp_output.c: revision 1.22
sys/compat/common/if_43.c: revision 1.27
sys/netatalk/ddp_input.c: revision 1.34
sys/netatalk/at_control.c: revision 1.43

atalk(4): Don't abuse queue(9) internals.

atalk(4): Omit spurious satosat.
The input is already a struct sockaddr_at pointer.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 05-Nov-2016  pgoyette branches: 1.1.2; 1.1.4; 1.1.18; 1.1.20; 1.1.22;
Move if_43.c back into the shared Makefile.sysio where it really
belongs.

Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers. Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.

Addresses the issue pointed out in PR kern/51598
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.3 15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.1.20.2 03-Oct-2018  pgoyette Don't define if_43_{init,fini}() in multiple .h files.
 1.1.20.1 03-Oct-2018  pgoyette Make if_43_{init,fini} return an int, for consistency with all the
related *_{init,fini} routines.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 05-Nov-2016  jdolecek file if_43.h was added on branch tls-maxphys on 2017-12-03 11:36:53 +0000
 1.1.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.1 05-Nov-2016  pgoyette file if_43.h was added on branch pgoyette-localcount on 2017-01-07 08:56:29 +0000
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 05-Nov-2016  skrll file if_43.h was added on branch nick-nhusb on 2016-12-05 10:54:59 +0000
 1.5 03-Aug-2022  riastradh sys/compat/common/if_media_80.c: Add kernel rcsid.
 1.4 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.3 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.2 26-Sep-2019  christos fix sign-compare issues.
 1.1 17-May-2019  msaitoh branches: 1.1.2; 1.1.4;
The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.1.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.1.2.4 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.2.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.2.2 10-Jun-2019  christos Sync with HEAD
 1.1.2.1 17-May-2019  christos file if_media_80.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.5 03-Sep-2022  thorpej Remove <net/netisr.h>
 1.4 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.3 01-Mar-2019  pgoyette branches: 1.3.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 21-Mar-2018  pgoyette branches: 1.1.2;
file if_spppsubr50.c was initially added on branch pgoyette-compat.
 1.1.2.4 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.1.2.1 21-Mar-2018  pgoyette Move if_spppsubr compat code into the compat50 module.

More prep work for compat80 module (for raidframe)
 1.3.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 01-Mar-2019  christos file if_spppsubr50.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 21-Mar-2018  pgoyette branches: 1.1.2;
file if_spppsubr50.h was initially added on branch pgoyette-compat.
 1.1.2.1 21-Mar-2018  pgoyette Move if_spppsubr compat code into the compat50 module.

More prep work for compat80 module (for raidframe)
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file if_spppsubr50.h was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.3 29-Jan-2020  ad - Track LWPs in a per-process radixtree. It uses no extra memory in the
single threaded case. Replace scans of p->p_lwps with lookups in the
tree. Find free LIDs for new LWPs in the tree. Replace the hashed sleep
queues for park/unpark with lookups in the tree under cover of a RW lock.

- lwp_wait(): if waiting on a specific LWP, find the LWP via tree lookup and
return EINVAL if it's detached, not ESRCH.

- Group the locks in struct proc at the end of the struct in their own cache
line.

- Add some comments.
 1.2 27-Jan-2019  pgoyette branches: 1.2.6;
Merge the [pgoyette-compat] branch
 1.1 04-Apr-2014  njoly branches: 1.1.4; 1.1.6; 1.1.10; 1.1.34; 1.1.36;
Move a few compat 50 syscalls, not applicable to rump kernels, out of
kern_time_50.c to a new source module.
 1.1.36.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.36.1 10-Jun-2019  christos Sync with HEAD
 1.1.34.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.34.1 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 04-Apr-2014  tls file kern_50.c was added on branch tls-maxphys on 2014-08-20 00:03:31 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 04-Apr-2014  yamt file kern_50.c was added on branch yamt-pagecache on 2014-05-22 11:40:15 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 04-Apr-2014  rmind file kern_50.c was added on branch rmind-smpnet on 2014-05-18 17:45:31 +0000
 1.2.6.1 29-Feb-2020  ad Sync with head.
 1.4 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.3 18-Mar-2018  christos branches: 1.3.2;
include compat/sys/cpuio.h and multiple include protection.
 1.2 18-Mar-2018  christos finish MD glue for compat ucode module.
 1.1 17-Mar-2018  christos branches: 1.1.2;
redo the cpu ucode compat code.
 1.1.2.6 31-Mar-2018  pgoyette Re-enable inclusion of CPU_UCODE for i386/amd64. Even though it won't
build correctly on XEN (won't use the XEN ABI), it works fine on real
hardware.
 1.1.2.5 18-Mar-2018  pgoyette Merge changes from HEAD into ccd_60.c

For all of the individual xxx_60_{init,fini} routines, don't force
them to artificially return a status; just make them void. This
simplifies the compat_60_{init,fini} handling of errors that remain.
 1.1.2.4 18-Mar-2018  pgoyette Clean-up for kern_cpu_60 code.

Also, although not strictly necessary, include the kern_sa_60 stuff in
the compat_60 module, for completeness.

Still need to deal with some tty code and the ccd driver to finish off
the compat_60 module.
 1.1.2.3 18-Mar-2018  pgoyette Import from -current the MD glue code for compat cpu_ucode
 1.1.2.2 17-Mar-2018  pgoyette Import christos's changes for the compat_60 cpu_ucode stuff
 1.1.2.1 17-Mar-2018  pgoyette file kern_cpu_60.c was added on branch pgoyette-compat on 2018-03-17 21:37:52 +0000
 1.3.2.1 10-Jun-2019  christos Sync with HEAD
 1.2 24-Feb-2008  martin Remove compat code for posix_fadvise
 1.1 27-Jan-2008  martin branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10;
Implement new version of posix_fadvise as a stub callinig the real
worker function, and compatibility stub doing the same with old argument
sturcture.
 1.1.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.1.6.1 24-Mar-2008  keiichi sync with head.
 1.1.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.1 27-Jan-2008  mjf file kern_descrip_40.c was added on branch mjf-devfs on 2008-02-18 21:05:22 +0000
 1.1.2.3 27-Feb-2008  yamt sync with head.
 1.1.2.2 04-Feb-2008  yamt sync with head.
 1.1.2.1 27-Jan-2008  yamt file kern_descrip_40.c was added on branch yamt-lazymbuf on 2008-02-04 09:23:00 +0000
 1.1 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.23 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.22 04-Nov-2009  rmind branches: 1.22.62; 1.22.64;
do_sys_wait(): fix previous by checking for ru != NULL. Noticed by
Onno van der Linden. Also, remove redundant arguments (seems that
was_zombie was not used since rev 1.177 ?).
 1.21 20-Dec-2007  dsl branches: 1.21.10; 1.21.12;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.20 19-Oct-2007  ad branches: 1.20.4; 1.20.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.19 07-May-2007  dsl branches: 1.19.6; 1.19.8; 1.19.12;
Split sys_wait4() so that compat code can fiddle with the returned 'status'
and 'rusage' without having to copy data to/from stackgap buffers.
The old split (find_stopped_child) could be removed.
amd64 seems to run netbsd32, linux and linux32 emulations. sparc64 compiles.
 1.18 04-Mar-2007  christos branches: 1.18.2; 1.18.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 09-Feb-2007  ad branches: 1.17.2;
Merge newlock2 to head.
 1.16 29-Jan-2007  hubertf Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.15 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.14 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.13 11-Dec-2005  christos branches: 1.13.20; 1.13.22;
merge ktrace-lwp.
 1.12 19-Nov-2003  christos branches: 1.12.16;
Don't include malloc.h if you are not going to use it.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.10 18-Jan-2003  thorpej branches: 1.10.2;
Merge the nathanw_sa branch.
 1.9 25-Sep-2002  thorpej Don't include <sys/map.h>.
 1.8 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.7 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.6 28-Jun-2000  mrg branches: 1.6.2; 1.6.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.4 03-Sep-1997  jonathan branches: 1.4.18;
machine/psl.h is deprecated; move #include <machine/psl.h> inside #ifdef m68k.
 1.3 07-Oct-1995  mycroft branches: 1.3.14;
Prefix names of system call implementation functions with `sys_'.
 1.2 29-Sep-1995  thorpej Fix the declaration of compat_43_wait() (int * -> register_t *), pointed
out by Chris Demetriou.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.3.14.1 04-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.18.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.6.2.5 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.6.2.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.6.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.6.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.16.4 21-Jan-2008  yamt sync with head
 1.12.16.3 27-Oct-2007  yamt sync with head.
 1.12.16.2 03-Sep-2007  yamt sync with head.
 1.12.16.1 26-Feb-2007  yamt sync with head.
 1.13.22.2 10-Dec-2006  yamt sync with head.
 1.13.22.1 22-Oct-2006  yamt sync with head
 1.13.20.3 01-Feb-2007  ad Sync with head.
 1.13.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.13.20.1 18-Nov-2006  ad Sync with head.
 1.17.2.2 17-May-2007  yamt sync with head.
 1.17.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.4.1 11-Jul-2007  mjf Sync with head.
 1.18.2.2 23-Oct-2007  ad Sync with head.
 1.18.2.1 27-May-2007  ad Sync with head.
 1.19.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.19.8.2 09-Jan-2008  matt sync with HEAD
 1.19.8.1 06-Nov-2007  matt sync with HEAD
 1.19.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.20.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.20.4.1 26-Dec-2007  ad Sync with head.
 1.21.12.2 14-May-2008  wrstuden 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.
 1.21.12.1 10-May-2008  wrstuden 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.
 1.21.10.1 11-Mar-2010  yamt sync with head
 1.22.64.1 10-Jun-2019  christos Sync with HEAD
 1.22.62.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.22.62.1 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.22 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.21 27-Jan-2019  pgoyette branches: 1.21.4;
Merge the [pgoyette-compat] branch
 1.20 20-Dec-2007  dsl branches: 1.20.12; 1.20.90; 1.20.96; 1.20.98;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.19 04-Mar-2007  christos branches: 1.19.16; 1.19.24; 1.19.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.18 09-Feb-2007  ad branches: 1.18.2;
Merge newlock2 to head.
 1.17 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 11-Dec-2005  christos branches: 1.15.20; 1.15.22;
merge ktrace-lwp.
 1.14 04-Dec-2003  atatat branches: 1.14.16;
Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.12 29-Jun-2003  fvdl branches: 1.12.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.11 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.10 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.9 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.8 14-Jul-2000  thorpej branches: 1.8.2; 1.8.4;
Sprinkle in some const.
 1.7 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.6 28-Mar-2000  simonb branches: 1.6.4;
Centralise the declarations of cpu_model, machine, machine_arch,
osrelease, and ostype and remove "extern char foo[];" (for hostname
and domainname too).

Also delete redunctant decl of boottime in kern_info_43.c.
 1.5 21-Feb-1996  cgd branches: 1.5.30;
fourth argument to kern_sysctl() must be a size_t *. simply passing a pointer
to SCARG(uap, len) won't do, because that'd be an int *. copy the value
into a size_t, and pass pointer to that.
 1.4 04-Feb-1996  christos kern_sysctl was missing process argument. Elimited -Wall warnings from
the files that were affected
 1.3 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.2 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.5.30.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.4.1 14-Jul-2000  thorpej Pull up rev. 1.8:
Sprinkle in some const.
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.8.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.8.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.8.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.12.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.2 03-Aug-2004  skrll Sync with HEAD
 1.12.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.14.16.4 21-Jan-2008  yamt sync with head
 1.14.16.3 03-Sep-2007  yamt sync with head.
 1.14.16.2 26-Feb-2007  yamt sync with head.
 1.14.16.1 30-Dec-2006  yamt sync with head.
 1.15.22.2 10-Dec-2006  yamt sync with head.
 1.15.22.1 22-Oct-2006  yamt sync with head
 1.15.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.15.20.1 18-Nov-2006  ad Sync with head.
 1.18.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.28.1 02-Jan-2008  bouyer Sync with HEAD
 1.19.24.1 26-Dec-2007  ad Sync with head.
 1.19.16.1 09-Jan-2008  matt sync with HEAD
 1.20.98.1 10-Jun-2019  christos Sync with HEAD
 1.20.96.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.20.96.1 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.20.90.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.20.12.2 14-May-2008  wrstuden 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.
 1.20.12.1 10-May-2008  wrstuden 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.
 1.21.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.40 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.39 30-Jan-2020  christos - make sure size is not used uninitialized
- limit size range
- fix type botch for "size"
from maxv@
 1.38 02-Jan-2020  thorpej branches: 1.38.2;
- Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
 1.37 27-Jan-2019  pgoyette branches: 1.37.4;
Merge the [pgoyette-compat] branch
 1.36 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.35 24-Mar-2014  christos branches: 1.35.22; 1.35.28; 1.35.30;
use cpu_getmodel() to get the model name
 1.34 11-Jan-2009  christos branches: 1.34.14; 1.34.24; 1.34.28;
merge christos-time_t
 1.33 24-Apr-2008  ad branches: 1.33.2; 1.33.4; 1.33.10;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.32 08-Jan-2008  elad branches: 1.32.6; 1.32.8; 1.32.10;
Make compat_43_sys_sethostid() use old_sysctl(), allowing for the removal
of a kauth(9) call.

okay christos@.
 1.31 05-Jan-2008  ad Missing lock acquire.
 1.30 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.29 04-Mar-2007  christos branches: 1.29.16; 1.29.22; 1.29.24; 1.29.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 15-Feb-2007  ad branches: 1.28.2;
Count the number of CPUs at boot and stash in 'ncpu'. Eventually should
have each CPU register at attach, so we can figure out the topology for
the scheduler.
 1.27 09-Feb-2007  ad Merge newlock2 to head.
 1.26 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.25 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 23-Jul-2006  ad branches: 1.23.4; 1.23.6;
Use the LWP cached credentials where sane.
 1.22 14-May-2006  elad integrate kauth.
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
merge ktrace-lwp.
 1.20 26-Feb-2005  perry branches: 1.20.4;
nuke trailing whitespace
 1.19 04-Dec-2003  atatat branches: 1.19.8; 1.19.10;
Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.18 19-Nov-2003  christos Don't include malloc.h if you are not going to use it.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.16 29-Jun-2003  fvdl branches: 1.16.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.15 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.14 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.13 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.12 28-Jun-2000  mrg branches: 1.12.2; 1.12.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.11 30-Mar-2000  augustss Kill register declarations.
 1.10 28-Mar-2000  simonb Centralise the declarations of cpu_model, machine, machine_arch,
osrelease, and ostype and remove "extern char foo[];" (for hostname
and domainname too).

Also delete redunctant decl of boottime in kern_info_43.c.
 1.9 24-Mar-1999  mrg branches: 1.9.8;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.8 10-Feb-1998  mrg - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.7 05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly. :-)
 1.6 18-May-1996  christos Support bsdi getkerninfo(SYSINFO,...) call so that the BSDI netscape
calling uname(3) can find out what os it is running on. Tested only with a
bsdi binary that calls getkerninfo directly. Funny thing is that I ran
the same binary on a bsdi machine, and they fill in fewer fields in the
emulation than we do; maybe I went overboard :-)
 1.5 21-Feb-1996  cgd fourth argument to kern_sysctl() must be a size_t *. simply passing a pointer
to SCARG(uap, len) won't do, because that'd be an int *. copy the value
into a size_t, and pass pointer to that.
 1.4 04-Feb-1996  christos kern_sysctl was missing process argument. Elimited -Wall warnings from
the files that were affected
 1.3 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.2 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.9.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.12.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.12.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.12.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.12.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.16.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.16.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.2 03-Aug-2004  skrll Sync with HEAD
 1.16.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.19.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.19.8.1 29-Apr-2005  kent sync with -current
 1.20.4.5 21-Jan-2008  yamt sync with head
 1.20.4.4 03-Sep-2007  yamt sync with head.
 1.20.4.3 26-Feb-2007  yamt sync with head.
 1.20.4.2 30-Dec-2006  yamt sync with head.
 1.20.4.1 21-Jun-2006  yamt sync with head.
 1.21.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.21.10.3 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.21.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.21.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.21.8.2 11-Aug-2006  yamt sync with head
 1.21.8.1 24-May-2006  yamt sync with head.
 1.21.6.1 01-Jun-2006  kardel Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.23.6.2 10-Dec-2006  yamt sync with head.
 1.23.6.1 22-Oct-2006  yamt sync with head
 1.23.4.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.23.4.2 12-Jan-2007  ad Sync with head.
 1.23.4.1 18-Nov-2006  ad Sync with head.
 1.28.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.29.28.3 10-Jan-2008  bouyer Sync with HEAD
 1.29.28.2 08-Jan-2008  bouyer Sync with HEAD
 1.29.28.1 02-Jan-2008  bouyer Sync with HEAD
 1.29.24.1 26-Dec-2007  ad Sync with head.
 1.29.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.29.16.2 23-Mar-2008  matt sync with HEAD
 1.29.16.1 09-Jan-2008  matt sync with HEAD
 1.32.10.1 18-May-2008  yamt sync with head.
 1.32.8.2 01-Nov-2008  christos Sync with head.
 1.32.8.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.32.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.32.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.33.10.1 19-Jan-2009  skrll Sync with HEAD.
 1.33.4.2 14-May-2008  wrstuden 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.
 1.33.4.1 10-May-2008  wrstuden 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.
 1.33.2.1 04-May-2009  yamt sync with head.
 1.34.28.1 18-May-2014  rmind sync with head
 1.34.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.35.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.35.30.1 10-Jun-2019  christos Sync with HEAD
 1.35.28.3 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.35.28.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.35.28.1 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.35.22.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.37.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.38.2.1 29-Feb-2020  ad Sync with head.
 1.26 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.25 11-Jan-2009  christos branches: 1.25.64; 1.25.66;
merge christos-time_t
 1.24 14-Nov-2008  ad _KERNEL_OPT
 1.23 20-Dec-2007  dsl branches: 1.23.6; 1.23.8; 1.23.12; 1.23.14; 1.23.18; 1.23.20;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.22 08-Dec-2007  dsl branches: 1.22.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.21 17-Jun-2007  dsl branches: 1.21.6; 1.21.8; 1.21.16;
Call semctl1() directly, not via stackgap and compat_14_sys___semctl().
 1.20 04-Mar-2007  christos branches: 1.20.2; 1.20.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 09-Feb-2007  ad branches: 1.19.2;
Merge newlock2 to head.
 1.18 10-Nov-2005  christos branches: 1.18.22;
Include new compat header.
 1.17 19-Nov-2003  christos branches: 1.17.16;
Don't include malloc.h if you are not going to use it.
 1.16 18-Jan-2003  thorpej branches: 1.16.2;
Merge the nathanw_sa branch.
 1.15 28-Sep-2002  scw Add !defined(_LP64) in the appropriate places to correspond with
sys/syscallargs.h.
 1.14 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.13 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.12 27-Jul-2000  mrg branches: 1.12.2; 1.12.4;
fix LP64 warnings.
 1.11 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.10 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.9 25-Aug-1999  thorpej branches: 1.9.2;
Add compatibility calls for the 1.4 System V IPC *ctl() calls, and
update the 1.0 compat calls.
 1.8 19-Oct-1998  tron Defopt SYSVMSG, SYSVSEM and SYSVSHM.
 1.7 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.6 05-Mar-1998  scottb Modified compat_10_sys_semsys to correctly read in a union arg (a5)
and pass a union pointer arg to sys___semctl
 1.5 22-Jan-1998  mycroft Fix an old typo that caused shmdt() to fail.
 1.4 07-Oct-1995  mycroft branches: 1.4.18;
Prefix names of system call implementation functions with `sys_'.
 1.3 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.2 10-Aug-1995  mycroft Make this compile if one of SYSV{SEM,SHM,MSG} is not defined.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.4.18.2 05-May-1998  mycroft Pull up 1.6, per request of scottb.
 1.4.18.1 29-Jan-1998  mellon Pull up 1.5 (mycroft)
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.12.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.12.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.12.2.5 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.12.2.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.12.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.12.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.12.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.16.2.4 11-Dec-2005  christos Sync with head.
 1.16.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.16.4 21-Jan-2008  yamt sync with head
 1.17.16.3 03-Sep-2007  yamt sync with head.
 1.17.16.2 26-Feb-2007  yamt sync with head.
 1.17.16.1 21-Jun-2006  yamt sync with head.
 1.18.22.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.19.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.4.1 11-Jul-2007  mjf Sync with head.
 1.20.2.1 15-Jul-2007  ad Sync with head.
 1.21.16.1 26-Dec-2007  ad Sync with head.
 1.21.8.1 09-Jan-2008  matt sync with HEAD
 1.21.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.22.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.20.1 19-Jan-2009  skrll Sync with HEAD.
 1.23.18.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.23.14.2 14-May-2008  wrstuden 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.
 1.23.14.1 10-May-2008  wrstuden 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.
 1.23.12.1 04-May-2009  yamt sync with head.
 1.23.8.3 20-Nov-2008  christos merge with head.
 1.23.8.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.23.8.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.23.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.25.66.1 10-Jun-2019  christos Sync with HEAD
 1.25.64.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.6 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.5 01-Mar-2019  pgoyette branches: 1.5.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.4 27-Jan-2019  pgoyette Include new header from correct directory
 1.3 27-Jan-2019  christos - autoload the compat_80 for modstat
- move compat struct to a compat header
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 03-Apr-2018  pgoyette branches: 1.1.2;
file kern_mod_80.c was initially added on branch pgoyette-compat.
 1.1.2.8 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.7 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.6 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.5 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.1.2.4 07-Sep-2018  pgoyette At the request of reviewers, remove the module alias functionality.

We will rely only on module names and duplicate-symbol detection to
detect module conflicts.
 1.1.2.3 06-Sep-2018  pgoyette Remove editor glitch
 1.1.2.2 06-Sep-2018  pgoyette Catch up to recent change on head: min() -> uimin()
 1.1.2.1 03-Apr-2018  pgoyette Remove fixed allocation of modules' "required" lists (previously
limited to MAXMODDEPS entries). Update the modctl(MODCTL_STAT)
syscall to return the required data in a new format, and retain
the previous data format in MODCTL_OSTAT. Update the compat_80
and compat_netbsd32 modules as needed.
 1.5.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.4.2 10-Jun-2019  christos Sync with HEAD
 1.5.4.1 01-Mar-2019  christos file kern_mod_80.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.4 23-Jun-1996  mycroft Remove the old (broken) setre[ug]id() emulation.
 1.3 07-Oct-1995  mycroft branches: 1.3.6;
Prefix names of system call implementation functions with `sys_'.
 1.2 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.3.6.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.23 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.22 27-Jan-2019  pgoyette branches: 1.22.4;
Merge the [pgoyette-compat] branch
 1.21 20-Dec-2007  dsl branches: 1.21.12; 1.21.90; 1.21.96; 1.21.98;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.20 12-May-2007  dsl branches: 1.20.8; 1.20.16; 1.20.20;
There is no need to use the stackgap for get/setrlimit.
 1.19 04-Mar-2007  christos branches: 1.19.2; 1.19.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.18 09-Feb-2007  ad branches: 1.18.2;
Merge newlock2 to head.
 1.17 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 23-Jul-2006  ad branches: 1.15.4; 1.15.6;
Use the LWP cached credentials where sane.
 1.14 11-Dec-2005  christos branches: 1.14.4; 1.14.8;
merge ktrace-lwp.
 1.13 29-May-2005  christos branches: 1.13.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.12 19-Nov-2003  christos Don't include malloc.h if you are not going to use it.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.10 18-Jan-2003  thorpej branches: 1.10.2;
Merge the nathanw_sa branch.
 1.9 13-Nov-2001  lukem branches: 1.9.12;
add RCSIDs (including regeneration of files as appropriate)
 1.8 28-Jun-2000  mrg branches: 1.8.2; 1.8.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.7 30-Mar-2000  augustss Kill register declarations.
 1.6 28-Sep-1999  bouyer branches: 1.6.2;
Remplace kern.shortcorename sysctl with a more flexible sheme,
core filename format, which allow to change the name of the core dump,
and to relocate it in a directory. Credits to Bill Sommerfeld for giving me
the idea :)
The default core filename format can be changed by options DEFCORENAME and/or
kern.defcorename
Create a new sysctl tree, proc, which holds per-process values (for now
the corename format, and resources limits). Process is designed by its pid
at the second level name. These values are inherited on fork, and the corename
fomat is reset to defcorename on suid/sgid exec.
Create a p_sugid() function, to take appropriate actions on suid/sgid
exec (for now set the P_SUGID flag and reset the per-proc corename).
Adjust dosetrlimit() to allow changing limits of one proc by another, with
credential controls.
 1.5 15-Oct-1997  mycroft Adjust u_int arguments of some system calls to int, to match user-level
prototypes.
 1.4 14-Mar-1996  christos Fix compiler warnings
 1.3 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.2 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.8.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.8.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.8.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.9.12.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.10.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.2.4 21-Jan-2008  yamt sync with head
 1.13.2.3 03-Sep-2007  yamt sync with head.
 1.13.2.2 26-Feb-2007  yamt sync with head.
 1.13.2.1 30-Dec-2006  yamt sync with head.
 1.14.8.1 11-Aug-2006  yamt sync with head
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.6.2 10-Dec-2006  yamt sync with head.
 1.15.6.1 22-Oct-2006  yamt sync with head
 1.15.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.15.4.1 18-Nov-2006  ad Sync with head.
 1.18.2.2 17-May-2007  yamt sync with head.
 1.18.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.4.1 11-Jul-2007  mjf Sync with head.
 1.19.2.1 27-May-2007  ad Sync with head.
 1.20.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.20.16.1 26-Dec-2007  ad Sync with head.
 1.20.8.1 09-Jan-2008  matt sync with HEAD
 1.21.98.1 10-Jun-2019  christos Sync with HEAD
 1.21.96.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.21.96.1 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.21.90.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.21.12.2 14-May-2008  wrstuden 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.
 1.21.12.1 10-May-2008  wrstuden 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.
 1.22.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 19-Feb-2012  matt branches: 1.1.2; 1.1.4; 1.1.42; 1.1.44;
Add compat_60 stub for the SA syscall (all which just call sys_nosys).
 1.1.44.1 10-Jun-2019  christos Sync with HEAD
 1.1.42.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.42.3 18-Mar-2018  pgoyette Clean-up for kern_cpu_60 code.

Also, although not strictly necessary, include the kern_sa_60 stuff in
the compat_60 module, for completeness.

Still need to deal with some tty code and the ccd driver to finish off
the compat_60 module.
 1.1.42.2 16-Mar-2018  pgoyette Move closer to getting a compat_60 module - still needs more work
 1.1.42.1 16-Mar-2018  pgoyette Initial pass at setting up the compat_60 module.

XXX needs some work to properly handle cpu_ucode stuff.

While here, move details of compat_70 init/fini routines into the
module itself.
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 19-Feb-2012  yamt file kern_sa_60.c was added on branch yamt-pagecache on 2012-04-17 00:07:14 +0000
 1.1.2.2 24-Feb-2012  mrg sync to -current.
 1.1.2.1 19-Feb-2012  mrg file kern_sa_60.c was added on branch jmcneill-usbmp on 2012-02-24 09:11:38 +0000
 1.4 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.3 20-Sep-2019  kamil Validate usec ranges in compat_50_sys_select()

Later in the code selcommon() checks for proper timespec, check only
correct usec of timeval before type conversions.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 17-Jan-2011  pooka branches: 1.1.4; 1.1.8; 1.1.60; 1.1.62;
Put async i/o compat routines in a separate source module from the
ones related to clock and process management.
 1.1.62.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.62.1 10-Jun-2019  christos Sync with HEAD
 1.1.60.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.60.1 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 17-Jan-2011  jruoho file kern_select_50.c was added on branch jruoho-x86intr on 2011-06-06 09:07:15 +0000
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 17-Jan-2011  rmind file kern_select_50.c was added on branch rmind-uvmplock on 2011-03-05 20:52:38 +0000
 1.22 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.21 27-Jan-2019  pgoyette branches: 1.21.4;
Merge the [pgoyette-compat] branch
 1.20 19-Jan-2011  tsutsui branches: 1.20.50; 1.20.56; 1.20.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.19 28-Apr-2008  martin branches: 1.19.2; 1.19.22; 1.19.28;
Remove clause 3 and 4 from TNF licenses
 1.18 24-Apr-2008  ad branches: 1.18.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.17 20-Dec-2007  dsl branches: 1.17.6; 1.17.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.16 08-Dec-2007  dsl branches: 1.16.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.15 16-Jun-2007  dsl branches: 1.15.6; 1.15.8; 1.15.16;
Modify the (recently added) compat_sigaltstack() #define to take the
values of the SS_ONSTACK and SS_DISABLE constants.
Use it to shorten the source files when this action is replicated.
Actually, given the monstrous complexity of sigaltstack1() there is
probably a much better way to do this...
 1.14 09-Feb-2007  ad branches: 1.14.6; 1.14.8;
Merge newlock2 to head.
 1.13 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 13-Sep-2005  christos compat code reorg.
 1.9 18-Jan-2003  thorpej branches: 1.9.2; 1.9.18;
Merge the nathanw_sa branch.
 1.8 26-Nov-2002  christos rename: s/sa_/<compat>sa/g
 1.7 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.6 13-Nov-2001  lukem branches: 1.6.8;
add RCSIDs (including regeneration of files as appropriate)
 1.5 30-Mar-2000  augustss branches: 1.5.6; 1.5.8;
Kill register declarations.
 1.4 13-Sep-1998  thorpej branches: 1.4.12;
Put the prototypes for native_sig*_to_sig*() in one place.
 1.3 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.2 29-Nov-1997  kleink Modify the recent sigaltstack() interface change to use the __RENAME() scheme;
add __sigaltstack14().
 1.1 25-Nov-1997  kleink In XPG4.2, the ss_size member of type stack_t (struct sigaltstack) is specified
to be of type size_t; since this imposes an interface change on the Alpha
(sizeof(int) != sizeof(size_t)), allocate a new system call number and make
the previous version a compatibility system call.
 1.4.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.8.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.6.6 11-Dec-2002  thorpej Sync with HEAD.
 1.5.6.5 01-Aug-2002  nathanw Catch up to -current.
 1.5.6.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.5.6.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.5.6.2 14-Nov-2001  nathanw Catch up to -current.
 1.5.6.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.6.8.1 15-Jul-2002  gehenna catch up with -current.
 1.9.18.4 21-Jan-2008  yamt sync with head
 1.9.18.3 03-Sep-2007  yamt sync with head.
 1.9.18.2 26-Feb-2007  yamt sync with head.
 1.9.18.1 21-Jun-2006  yamt sync with head.
 1.9.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.11.20.2 11-Jan-2007  ad Checkpoint work in progress.
 1.11.20.1 21-Oct-2006  ad Checkpoint work in progress on locking and per-LWP signals. Very much a
a work in progress and there is still a lot to do.
 1.14.8.1 11-Jul-2007  mjf Sync with head.
 1.14.6.1 15-Jul-2007  ad Sync with head.
 1.15.16.1 26-Dec-2007  ad Sync with head.
 1.15.8.1 09-Jan-2008  matt sync with HEAD
 1.15.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.17.8.1 18-May-2008  yamt sync with head.
 1.17.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.2.1 16-May-2008  yamt sync with head.
 1.19.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.22.1 05-Mar-2011  rmind sync with head
 1.19.2.2 14-May-2008  wrstuden 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.
 1.19.2.1 10-May-2008  wrstuden 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.
 1.20.58.1 10-Jun-2019  christos Sync with HEAD
 1.20.56.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.20.56.1 30-Mar-2018  pgoyette Add compat_13 module
 1.20.50.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.21.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.10 10-Dec-2024  mlelstv It's __aarch64__, not __arch64__.
 1.9 22-Nov-2024  mlelstv Crude patch to allow building and loading of compat_16 and compat_netbsd32_16 code
on aarch64.
 1.8 02-Dec-2021  ryo branches: 1.8.10;
don't call MODULE_HOOK_SET(), if exec_sigcode_alloc() fails.
 1.7 26-Nov-2021  ryo Fix anonymous memory object leak for sigcode.

- Repeating "modload compat_linux && /emul/linux/bin/ls && modunload compat_linux"
will reproduce this problem.
- It cause in exec_sigcode_map(), anon-object for sigcode was created at
first exec, but it remained even after exec_remove.
- Fixed that the anon-object for sigcode is created at exec_add(), and the
anon-object reference is removed at exec_remove().
- sigobject_lock is no longer needed since it is locked by exec_lock.
- The compat_16 module rewrites the e_sigcode entry in emul_netbsd directly and
does not use exec_add()/exec_remove(), so it needs to call
sigcode_alloc()/sigcode_free() on its own.
 1.6 23-May-2020  ad Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 10-Nov-2019  pgoyette Convert the sendsig_sigcontext_16 function pointer to use the new
compat_hook mechanism.

XXX Despite being a kernel<-->module abi change, this should be
XXX pulled up to -9
 1.3 27-Jan-2019  pgoyette branches: 1.3.4;
Merge the [pgoyette-compat] branch
 1.2 19-Feb-2012  rmind branches: 1.2.38; 1.2.40;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.1 14-Nov-2008  ad branches: 1.1.4; 1.1.6; 1.1.8; 1.1.12; 1.1.24; 1.1.28;
- Move some more compat code into sys/compat.
- Split 4.3BSD ifioctl stuff into its own file.
- Remove some ifdefs that include small fragments of vfs compat code
which are difficult to relocate elsewhere.
 1.1.28.1 24-Feb-2012  mrg sync to -current.
 1.1.24.1 17-Apr-2012  yamt sync with head
 1.1.12.2 04-May-2009  yamt sync with head.
 1.1.12.1 14-Nov-2008  yamt file kern_sig_16.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:17 +0000
 1.1.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.8.1 14-Nov-2008  skrll file kern_sig_16.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.1.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.1 14-Nov-2008  mjf file kern_sig_16.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 14-Nov-2008  haad file kern_sig_16.c was added on branch haad-dm on 2008-12-13 01:13:47 +0000
 1.2.40.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.40.1 10-Jun-2019  christos Sync with HEAD
 1.2.38.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.2.38.3 04-May-2018  pgoyette Add comment to note that compat_16_sigreturn14 is in MD code!
 1.2.38.2 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.2.38.1 30-Mar-2018  pgoyette Create and build a compat_16 module
 1.3.4.1 11-Nov-2019  martin Pull up following revision(s) (requested by pgoyette in ticket #413):

sys/kern/kern_core.c: revision 1.27 (patch)
sys/kern/kern_sig.c: revision 1.377 (patch)
sys/kern/kern_sig.c: revision 1.378 (patch)
sys/kern/sys_sig.c: revision 1.50
sys/kern/sys_ptrace_common.c: revision 1.70
sys/kern/compat_stub.c: revision 1.16
sys/compat/common/kern_sig_16.c: revision 1.4
sys/kern/compat_stub.c: revision 1.17
sys/sys/compat_stub.h: revision 1.20
sys/sys/signalvar.h: revision 1.98
sys/sys/compat_stub.h: revision 1.21
sys/sys/signalvar.h: revision 1.99

Convert the sendsig_sigcontext_16 function pointer to use the new
compat_hook mechanism.
XXX Despite being a kernel<-->module abi change, this should be
XXX pulled up to -9

-

Convert the coredump_vec modular function pointer to use the new
compat_hook mechanism.
XXX Should be pulled up to -9 despite the kernel <--> module ABI
XXX change.
 1.8.10.1 02-Aug-2025  perseant Sync with HEAD
 1.38 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.37 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.36 01-Jan-2020  maxv Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
 1.35 27-Jan-2019  pgoyette branches: 1.35.4;
Merge the [pgoyette-compat] branch
 1.34 19-Jan-2011  tsutsui branches: 1.34.32; 1.34.44; 1.34.50; 1.34.56; 1.34.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.33 23-Nov-2009  rmind branches: 1.33.4; 1.33.6;
Use lwp_getpcb() in compat code, clean from struct user.
 1.32 28-Apr-2008  martin branches: 1.32.2;
Remove clause 3 and 4 from TNF licenses
 1.31 24-Apr-2008  ad branches: 1.31.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.30 20-Dec-2007  dsl branches: 1.30.6; 1.30.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.29 08-Dec-2007  dsl branches: 1.29.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.28 04-Dec-2007  dsl Remove all the __P
 1.27 19-Oct-2007  ad branches: 1.27.2; 1.27.4;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.26 09-Feb-2007  ad branches: 1.26.6; 1.26.18; 1.26.20; 1.26.24;
Merge newlock2 to head.
 1.25 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 23-Jul-2006  ad branches: 1.23.4; 1.23.6;
Use the LWP cached credentials where sane.
 1.22 14-May-2006  elad integrate kauth.
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
merge ktrace-lwp.
 1.20 13-Sep-2005  christos compat code reorg.
 1.19 06-Sep-2003  christos branches: 1.19.16;
SA_SIGINFO changes
 1.18 18-Jan-2003  thorpej branches: 1.18.2;
Merge the nathanw_sa branch.
 1.17 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.16 13-Nov-2001  lukem branches: 1.16.8;
add RCSIDs (including regeneration of files as appropriate)
 1.15 30-May-2001  mrg branches: 1.15.2;
use _KERNEL_OPT.
 1.14 17-Dec-2000  jdolecek branches: 1.14.2;
make LKM safe
 1.13 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.12 30-Mar-2000  augustss Kill register declarations.
 1.11 29-Apr-1999  christos branches: 1.11.2;
Make ss_size something reasonable (not 0) so sigaltstack does not fail.
Pull me up plz!
 1.10 14-Sep-1998  pk branches: 1.10.6;
Fix copyout() arguments.
 1.9 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.8 05-Jul-1998  jonathan * defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.
 1.7 14-Mar-1996  christos branches: 1.7.14;
Fix compiler warnings
 1.6 04-Jan-1996  jtc Changed name of sigaltstack's ss_base field to ss_sp to match XPG4.2 and
traditional usage.
 1.5 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.4 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.3 17-Aug-1995  mycroft Update for signal handling changes.
 1.2 15-Aug-1995  mycroft Rename ss_flags bits.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.7.14.1 08-Sep-1997  thorpej Significantly restructure the way signal state for a process is stored.
Rather than using bitmasks to redundantly store the information kept
in the process's sigacts (because the sigacts was kept in the u-area),
hang sigacts directly off the process, and access it directly.

Simplify signal setup code tremendously by storing information in
the sigacts as an array of struct sigactions, rather than in a different
format, since userspace uses sigactions.

Make sigacts sharable by adding reference counting.
 1.10.6.1 30-Apr-1999  perry branches: 1.10.6.1.2;
pullup 1.10->1.11 (christos)
 1.10.6.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.14.2.5 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.14.2.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.14.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.14.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.14.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.15.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.15.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.16.8.1 15-Jul-2002  gehenna catch up with -current.
 1.18.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.16.6 21-Jan-2008  yamt sync with head
 1.19.16.5 07-Dec-2007  yamt sync with head
 1.19.16.4 27-Oct-2007  yamt sync with head.
 1.19.16.3 26-Feb-2007  yamt sync with head.
 1.19.16.2 30-Dec-2006  yamt sync with head.
 1.19.16.1 21-Jun-2006  yamt sync with head.
 1.21.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.21.10.2 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.21.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.21.8.2 11-Aug-2006  yamt sync with head
 1.21.8.1 24-May-2006  yamt sync with head.
 1.21.6.1 01-Jun-2006  kardel Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.23.6.2 10-Dec-2006  yamt sync with head.
 1.23.6.1 22-Oct-2006  yamt sync with head
 1.23.4.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.23.4.2 11-Jan-2007  ad Checkpoint work in progress.
 1.23.4.1 21-Oct-2006  ad Checkpoint work in progress on locking and per-LWP signals. Very much a
a work in progress and there is still a lot to do.
 1.26.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.20.2 09-Jan-2008  matt sync with HEAD
 1.26.20.1 06-Nov-2007  matt sync with HEAD
 1.26.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.26.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.26.6.1 23-Oct-2007  ad Sync with head.
 1.27.4.2 26-Dec-2007  ad Sync with head.
 1.27.4.1 08-Dec-2007  ad Sync with head.
 1.27.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.27.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.29.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.30.8.1 18-May-2008  yamt sync with head.
 1.30.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.31.2.2 11-Mar-2010  yamt sync with head
 1.31.2.1 16-May-2008  yamt sync with head.
 1.32.2.2 14-May-2008  wrstuden 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.
 1.32.2.1 10-May-2008  wrstuden 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.
 1.33.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.33.4.1 05-Mar-2011  rmind sync with head
 1.34.58.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.34.58.1 10-Jun-2019  christos Sync with HEAD
 1.34.56.2 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.34.56.1 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.34.50.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.34.50.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.34.44.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.34.32.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.35.4.2 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.35.4.1 02-Jan-2020  martin Pull up following revision(s) (requested by maxv in ticket #597):

sys/compat/common/kern_sig_43.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.39
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.59
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.44

Fix sizeof mismatch in copyin. This leads to a user-triggerable stack
overflow. On my test build at least, by luck, the compiler orders the
variables in a way that the overflow hits only local structures which
haven't yet been initialized and used, so the overflow is harmless.

Very easily seeable with kASan - just invoke the syscall from a 32bit
binary.

Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
 1.8 15-Dec-2019  tsutsui Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.7 27-Jan-2019  pgoyette branches: 1.7.4;
Merge the [pgoyette-compat] branch
 1.6 30-Oct-2018  riastradh Paranoia: zero COMPAT_30 ntptimeval and 32-bit ntptimeval too.

These structs don't have padding but safer to keep the code
structured the same way between the various ntp_gettimes in case
anyone makes more copypasta of it for future updates.
 1.5 03-Nov-2016  riastradh branches: 1.5.8; 1.5.14; 1.5.16;
Sprinkle #ifdef _KERNEL_OPT.
 1.4 19-Jan-2011  tsutsui branches: 1.4.16; 1.4.34; 1.4.38;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.3 11-Jan-2009  tsutsui branches: 1.3.2; 1.3.4; 1.3.10; 1.3.12;
<sys/syscallargs.h> requires <sys/sched.h> for cpuset_t.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file kern_time_30.c was initially added on branch christos-time_t.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.1 29-Mar-2008  christos new files
 1.3.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.10.1 05-Mar-2011  rmind sync with head
 1.3.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.3.4.1 11-Jan-2009  skrll file kern_time_30.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.3.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.2.1 11-Jan-2009  mjf file kern_time_30.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.4.38.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.34.1 05-Dec-2016  skrll Sync with HEAD
 1.4.16.1 03-Dec-2017  jdolecek update from HEAD
 1.5.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.16.1 10-Jun-2019  christos Sync with HEAD
 1.5.14.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.5.14.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.5.14.1 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.5.8.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1839):

sys/compat/common/kern_time_30.c: revision 1.6
sys/compat/netbsd32/netbsd32_time.c: revision 1.50

Paranoia: zero COMPAT_30 ntptimeval and 32-bit ntptimeval too.

These structs don't have padding but safer to keep the code
structured the same way between the various ntp_gettimes in case
anyone makes more copypasta of it for future updates.
 1.7.4.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.38 19-Jan-2024  christos Add missing decls, make rusage_to_rusage50 static inline.
 1.37 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.36 03-Apr-2021  simonb Centralise the setitimer() timer type validation in dosetitimer() as is
done with dogetitimer().
 1.35 27-Feb-2020  pgoyette branches: 1.35.6; 1.35.8;
Remove explicit calls to the sysctl setup routines, since this is now
handled by the module infrastructure.
 1.34 02-Jan-2020  thorpej branches: 1.34.2;
- Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
 1.33 27-Jan-2019  pgoyette branches: 1.33.4;
Merge the [pgoyette-compat] branch
 1.32 30-Oct-2018  riastradh Zero ntptimeval50 too to prevent 4-byte kernel stack disclosure.

From Thomas Barabosch of Fraunhofer FKIE.

XXX pullup-7, pullup-8 (along with rev. 1.60 of kern_ntptime.c)
 1.31 11-Mar-2016  christos branches: 1.31.10; 1.31.16; 1.31.18;
PR/50947: David Binderman: sprinkle parens
 1.30 07-Dec-2015  pgoyette Modularize the clockctl pseudo-device and link to the build.
 1.29 24-Jul-2015  maxv Unused inits (harmless).

Found by Brainy.
 1.28 09-Nov-2014  maxv branches: 1.28.2;
Do not uselessly include <sys/malloc.h>.
 1.27 04-Apr-2014  njoly branches: 1.27.4;
Move a few compat 50 syscalls, not applicable to rump kernels, out of
kern_time_50.c to a new source module.
 1.26 29-Mar-2013  christos branches: 1.26.4;
compat glue for new lwp_park()
 1.25 21-Feb-2013  pgoyette Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.

OK christos@

Will request pull-up to 6.0 in a few days.
 1.24 03-Nov-2012  njoly Move rusage computation to a new getrusage1() function. Adjust all
compat/emulations to make use of it.
 1.23 02-Oct-2012  christos kernel portion of clock_nanosleep()
 1.22 04-Jan-2012  apb branches: 1.22.2; 1.22.6;
Instead of calling clockctl_ioctl directly, lookup the cdevsw and
call its d_ioctl function. This should fix an undefined reference to
`clockctlioctl' when you build a kernel that has COMPAT_50 but does not
have pseudo-device clockctl.
 1.21 04-Jan-2012  apb Provide a COMPAT_50 version of the CLOCKCTL_NTP_ADJTIME ioctl.
When time_t was changed from 32 to 64 bits, this ioctl's number
was changed from _IOWR('C', 0x4, struct clockctl_ntp_adjtime)
to _IOWR('C', 0x8, struct clockctl_ntp_adjtime), but the data
structure did not change, so all the compat code has to do is
change the number and try again.
 1.20 18-Nov-2011  christos branches: 1.20.4;
add a copyin function for sigset so that we can use sigtimedwait1 from
emulations.
 1.19 04-Mar-2011  christos branches: 1.19.4;
PR/44674: Taylor R Campbell: Fix compat copyin and copyout routines which
were obviously broken.
 1.18 19-Jan-2011  tsutsui branches: 1.18.2;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.17 17-Jan-2011  pooka Put async i/o compat routines in a separate source module from the
ones related to clock and process management.
 1.16 30-May-2010  drochner branches: 1.16.2;
-fix internal use of sigwaitinfo(2) by sigwait(3): The former returns
the signal number now, as required by POSIX. The latter should just
return 0 on success. Fixes a mysql problem reported by Kurt Schreiner.
-document the new behavior of sigwaitinfo and sigtimedwait
-retain non-POSIX behavior for NetBSD-5 binary compatibility -- the fix
would likely not be polled into the .0-branches, and having 5.0.x and
5.x behave differently would be confusing. Besides that, it was
documented in the manpage all the time.
 1.15 08-Apr-2010  njoly Add a new clock_gettime1() function that holds most of the
clock_gettime syscall code (except for the copyout). Adjust all
corresponding syscalls to make use of it.
 1.14 03-Apr-2010  njoly Move most clock_getres syscall code, except for coypout call, to a new
clock_getres1() function which can be used by emulations. Adjust all
clock_getres syscalls to now make of use it.
 1.13 19-Jan-2010  pooka branches: 1.13.2; 1.13.4;
Get rid of last "easy" kernel symbols starting with __:
__assert -> kern_assert
__sigtimedwait1 -> sigtimedwait1
__wdstart -> wdstart1

The rest are MD and/or shared with userspace, so they will require
a little more involvement than what is available for this quick
"ride the 5.99.24 bump" action.
 1.12 11-Nov-2009  rmind - selcommon/pollcommon: drop redundant l argument.
- Use cached curlwp->l_fd, instead of p->p_fd.
- Inline selscan/pollscan.
 1.11 04-Nov-2009  rmind do_sys_wait(): fix previous by checking for ru != NULL. Noticed by
Onno van der Linden. Also, remove redundant arguments (seems that
was_zombie was not used since rev 1.177 ?).
 1.10 12-Oct-2009  yamt compat_50_sys_aio_suspend:
- fix the buffer size.
- use kmem_alloc instead of kmem_zalloc for buffers which we will
overwrite soon.
 1.9 05-Oct-2009  rmind mq_timedsend/mq_timedreceive: timeout value is absolute, not relative.
While here, drop unecessary (since fdesc API changes) lwp_t arguments.

Bug reported by Stathis Kamperis, thanks!
 1.8 19-Jul-2009  rmind - Use #ifdef AIO, instead of #ifdef notyet. Not a solution, but at
least gets it working for MONOLITHIC kernel.
- Similarily add #ifdef MQUEUE for mqueue compat.
- Amend TNF license to be 2-clause. Approved by <christos>.
 1.7 29-Mar-2009  christos Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).
 1.6 26-Mar-2009  gmcgarry Replace gcc initialisers with c99 designated initialisers.
 1.5 22-Feb-2009  nakayama - fix copyout size in CLOCKCTL_O?ADJTIME.
- add missing break in CLOCKCTL_NTP_ADJTIME.
 1.4 17-Jan-2009  njoly branches: 1.4.2; 1.4.4;
Convert linux/linux32 wait(4) to use a compat50 rusage structure.
 1.3 14-Jan-2009  njoly branches: 1.3.2;
In rusage_to_rusage50() function, fix memcpy size to include last
struct member (ru_nivcsw) which was missing.

ok by christos.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file kern_time_50.c was initially added on branch christos-time_t.
 1.1.6.4 11-Aug-2010  yamt sync with head.
 1.1.6.3 11-Mar-2010  yamt sync with head
 1.1.6.2 19-Aug-2009  yamt sync with head.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.4 28-Dec-2008  christos for now don't bother with aio and lfs.
 1.1.2.3 28-Dec-2008  christos minor adjustments for module builds.
 1.1.2.2 01-Nov-2008  christos catch up with changes in head.
 1.1.2.1 29-Mar-2008  christos new files
 1.3.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.2.1 14-Jan-2009  mjf file kern_time_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.4.4.2 23-Jul-2009  jym Sync with HEAD.
 1.4.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.2.4 28-Apr-2009  skrll Sync with HEAD.
 1.4.2.3 03-Mar-2009  skrll Sync with HEAD.
 1.4.2.2 19-Jan-2009  skrll Sync with HEAD.
 1.4.2.1 17-Jan-2009  skrll file kern_time_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.13.4.3 05-Mar-2011  rmind sync with head
 1.13.4.2 03-Jul-2010  rmind sync with head
 1.13.4.1 30-May-2010  rmind sync with head
 1.13.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.13.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.19.4.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.4.3 16-Jan-2013  yamt sync with (a bit old) head
 1.19.4.2 30-Oct-2012  yamt sync with head
 1.19.4.1 17-Apr-2012  yamt sync with head
 1.20.4.1 18-Feb-2012  mrg merge to -current.
 1.22.6.5 03-Dec-2017  jdolecek update from HEAD
 1.22.6.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.6.3 23-Jun-2013  tls resync from head
 1.22.6.2 25-Feb-2013  tls resync with head
 1.22.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.22.2.1 14-Mar-2013  riz Pull up following revision(s) (requested by pgoyette in ticket #837):
sys/compat/common/kern_time_50.c: revision 1.25
sys/kern/init_sysctl.c: revision 1.195
sys/kern/init_main.c: revision 1.447
sys/compat/common/compat_util.h: revision 1.23
sys/compat/common/compat_mod.h: revision 1.1
sys/compat/common/compat_mod.c: revision 1.16
sys/compat/common/compat_mod.c: revision 1.17
sys/compat/common/compat_mod.c: revision 1.18
sys/compat/common/vfs_syscalls_43.c: revision 1.55
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.
OK christos@
Will request pull-up to 6.0 in a few days.
Wrap sysctl_teardown(&compat_clog) with the appropriate #if defined()s
remove empty #if
 1.26.4.1 18-May-2014  rmind sync with head
 1.27.4.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.28.2.3 19-Mar-2016  skrll Sync with HEAD
 1.28.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.28.2.1 22-Sep-2015  skrll Sync with HEAD
 1.31.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.31.18.1 10-Jun-2019  christos Sync with HEAD
 1.31.16.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.31.16.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.31.16.3 13-Sep-2018  pgoyette Remove duplicate syscall package entry for ntp_gettime30. Duplicate
entries cause a panic when disestablishing, since when it looks at the
second entry it finds that the entrypoint doesn't match what's in the
package (it's alrady been reverted to sys_nosys() by the first entry.)
 1.31.16.2 20-Mar-2018  pgoyette Initial implementation of sys/kern/kern_stup.c as discussed on tech-kern

For now, we only handle the dev/ccd and NTP needs; more to follow.
 1.31.16.1 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.31.10.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1838):

sys/compat/common/kern_time_50.c: revision 1.32

Zero ntptimeval50 too to prevent 4-byte kernel stack disclosure.

From Thomas Barabosch of Fraunhofer FKIE.
 1.31.10.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.33.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.34.2.1 29-Feb-2020  ad Sync with head.
 1.35.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.35.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 29-Jan-2020  ad - Track LWPs in a per-process radixtree. It uses no extra memory in the
single threaded case. Replace scans of p->p_lwps with lookups in the
tree. Find free LIDs for new LWPs in the tree. Replace the hashed sleep
queues for park/unpark with lookups in the tree under cover of a RW lock.

- lwp_wait(): if waiting on a specific LWP, find the LWP via tree lookup and
return EINVAL if it's detached, not ESRCH.

- Group the locks in struct proc at the end of the struct in their own cache
line.

- Add some comments.
 1.2 27-Jan-2019  pgoyette branches: 1.2.6;
Merge the [pgoyette-compat] branch
 1.1 29-Mar-2013  christos branches: 1.1.4; 1.1.12; 1.1.38; 1.1.40;
compat glue for new lwp_park()
 1.1.40.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.40.1 10-Jun-2019  christos Sync with HEAD
 1.1.38.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.38.1 18-Mar-2018  pgoyette Move closer to a complete compat_60 module. All that remains is some
tty stuff and some ccd ioctl()s.
 1.1.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.12.1 29-Mar-2013  yamt file kern_time_60.c was added on branch yamt-pagecache on 2014-05-22 11:40:15 +0000
 1.1.4.2 23-Jun-2013  tls resync from head
 1.1.4.1 29-Mar-2013  tls file kern_time_60.c was added on branch tls-maxphys on 2013-06-23 06:20:15 +0000
 1.2.6.1 29-Feb-2020  ad Sync with head.
 1.4 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.3 27-Sep-2019  pgoyette Actually return the updated pointer-to-mbuf-pointer to the caller
rather than discarding-after-assignment. Introduced from the
[pgoyette-compat] branch work.

Welcome to 9.99.14 !!! (Module hook routine prototype changed.)

Found by the lgtm bot, reported via private Email from maxv@
 1.2 15-Apr-2019  pgoyette branches: 1.2.4; 1.2.6;
Clean up this mess and simplify, so that all the socket options get
handled correctly whether or not the compat_50 module is loaded.
 1.1 15-Apr-2019  pgoyette Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.c
and into its own source file, which is now included in the compat_50
module.

(Not sure how this got missed during the original [pgoyette-compat] work)
 1.2.6.1 21-Oct-2019  martin Pull up following revision(s) (requested by pgoyette in ticket #339):

sys/compat/common/kern_uipc_socket_50.c: revision 1.3
sys/sys/compat_stub.h: revision 1.19
sys/kern/uipc_socket.c: revision 1.284

Actually return the updated pointer-to-mbuf-pointer to the caller
rather than discarding-after-assignment. Introduced from the
[pgoyette-compat] branch work.
 1.2.4.4 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 15-Apr-2019  christos file kern_uipc_socket_50.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.18 23-Feb-2020  ad Don't bother with kernel_lock for kern_reboot().
 1.17 01-Jan-2020  thorpej branches: 1.17.2;
- Introduce a new global kernel variable "shutting_down" to indicate that
the system is shutting down or rebooting.
- Set this global in a new function called kern_reboot(), which is currently
just a basic wrapper around cpu_reboot().
- Call kern_reboot() instead of cpu_reboot() almost everywhere; a few
places remain where it's still called directly, but those are in early
pre-main() machdep locations.

Eventually, all of the various cpu_reboot() functions should be re-factored
and common functionality moved to kern_reboot(), but that's for another day.
 1.16 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.15 19-Jan-2011  tsutsui branches: 1.15.56; 1.15.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.14 23-Apr-2008  ad branches: 1.14.4; 1.14.24; 1.14.30;
Grab kernel_lock for cpu_reboot().
 1.13 20-Dec-2007  dsl branches: 1.13.6; 1.13.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.12 09-Feb-2007  ad branches: 1.12.20; 1.12.28; 1.12.32;
Merge newlock2 to head.
 1.11 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.10 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.9 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8 23-Jul-2006  ad branches: 1.8.4; 1.8.6;
Use the LWP cached credentials where sane.
 1.7 14-May-2006  elad integrate kauth.
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8; 1.6.10; 1.6.12;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc branches: 1.5.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 18-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.2 26-Mar-1997  gwr branches: 1.2.34; 1.2.36;
s/boot/cpu_reboot/
 1.1 09-Aug-1996  mrg Change reboot(2) to take two arguments: bootopt like normal and also
a boot string for firmware that can do this, such as the SPARC and
the sun3 models. It is currently silently ignored on all other
hardware now, however. The MD function "boot()" has been changed to
also take a char *.
 1.2.36.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.34.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.2.34.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.2.34.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.34.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.4 21-Jan-2008  yamt sync with head
 1.5.16.3 26-Feb-2007  yamt sync with head.
 1.5.16.2 30-Dec-2006  yamt sync with head.
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.6.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.6.10.3 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.6.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.6.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.6.8.2 11-Aug-2006  yamt sync with head
 1.6.8.1 24-May-2006  yamt sync with head.
 1.6.6.1 01-Jun-2006  kardel Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.8.6.2 10-Dec-2006  yamt sync with head.
 1.8.6.1 22-Oct-2006  yamt sync with head
 1.8.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.8.4.1 18-Nov-2006  ad Sync with head.
 1.12.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.28.1 26-Dec-2007  ad Sync with head.
 1.12.20.1 09-Jan-2008  matt sync with HEAD
 1.13.8.1 18-May-2008  yamt sync with head.
 1.13.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.30.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.24.1 05-Mar-2011  rmind sync with head
 1.14.4.2 14-May-2008  wrstuden 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.
 1.14.4.1 10-May-2008  wrstuden 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.
 1.15.58.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.58.1 10-Jun-2019  christos Sync with HEAD
 1.15.56.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.15.56.1 31-Mar-2018  pgoyette create the compat_12 module
 1.17.2.1 29-Feb-2020  ad Sync with head.
 1.2 09-Dec-2023  oster branches: 1.2.2;

Allow kernels builds which don't define INET6 to compile compat bits too.
 1.1 09-Dec-2023  pgoyette Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

XXX pullup-10 - hopefully before RC2
 1.2.2.2 10-Dec-2023  martin Pull up following revision(s) (requested by pgoyette in ticket #487):

sys/compat/common/compat_90_mod.c: revision 1.5
sys/compat/common/compat_90_mod.c: revision 1.6
sys/netinet6/in6.c: revision 1.290
sys/netinet6/in6.c: revision 1.291
sys/compat/common/files.common: revision 1.11
sys/netinet6/icmp6.c: revision 1.255
sys/compat/common/net_inet6_nd_90.c: revision 1.1
sys/compat/common/net_inet6_nd_90.c: revision 1.2
sys/modules/compat_90/Makefile: revision 1.2
sys/modules/compat_90/Makefile: revision 1.3
sys/netinet6/nd6.c: revision 1.281
sys/compat/common/compat_mod.h: revision 1.10
sys/kern/compat_stub.c: revision 1.23
sys/sys/compat_stub.h: revision 1.27

Identify the need to rework the COMPAT_* code to be more
module-aware.
This is an XXX comment block only, NFCI.

Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel. Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

Allow kernels builds which don't define INET6 to compile compat bits
too.

Default the build of compat_90 module to include IPv6, as is done
for other INET6-sensitive modules (see if_lagg).
 1.2.2.1 09-Dec-2023  martin file net_inet6_nd_90.c was added on branch netbsd-10 on 2023-12-10 13:06:16 +0000
 1.7 30-Apr-2020  riastradh Omit needless #include <sys/rnd.h>.
 1.6 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.5 26-Sep-2019  christos fix sign-compare issues.
 1.4 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.2 03-Aug-2012  matt branches: 1.2.38; 1.2.40;
Only do COMPAT_NETBSD32 stuff if _LP64
 1.1 19-Dec-2011  apb branches: 1.1.4; 1.1.6;
Add COMPAT_50 and COMPAT_NETBSD32 compatibility code for rnd(4)
ioctl commands.

Tested with "rndctl -ls" using an old 32-bit version of rndctl(8)
(built for NetBSD-5.99.56/i386) and a new 64-bit kernel
(NetBSD-5.99.59/amd64).
 1.1.6.3 30-Oct-2012  yamt sync with head
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 19-Dec-2011  yamt file rndpseudo_50.c was added on branch yamt-pagecache on 2012-04-17 00:07:14 +0000
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 19-Dec-2011  mrg file rndpseudo_50.c was added on branch jmcneill-usbmp on 2012-02-18 07:33:54 +0000
 1.2.40.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.40.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.40.1 10-Jun-2019  christos Sync with HEAD
 1.2.38.3 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.2.38.2 12-Oct-2018  pgoyette Use a MP-safe hook for the rnd_ioctl compat_50 calls.
 1.2.38.1 21-Mar-2018  pgoyette Split compat/rndpseudo_50.c into two pieces, one for native compat and
a second piece for compat32. Update both modules accordingly.
 1.10 29-Jan-2020  thorpej Don't reference ifp->if_data directly; use if_export_if_data().
 1.9 12-Dec-2019  pgoyette branches: 1.9.2;
Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.8 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.7 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.6 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.5 03-Nov-2016  riastradh branches: 1.5.14; 1.5.16;
Sprinkle #ifdef _KERNEL_OPT.
 1.4 17-Jul-2011  joerg branches: 1.4.12; 1.4.30; 1.4.34;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.3 01-Feb-2011  matt Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.
 1.2 11-Jan-2009  christos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.12; 1.2.14;
merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file rtsock_14.c was initially added on branch christos-time_t.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.1 29-Mar-2008  christos new files
 1.2.14.1 08-Feb-2011  bouyer Sync with HEAD
 1.2.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.10.1 05-Mar-2011  rmind sync with head
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2009  skrll file rtsock_14.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 11-Jan-2009  mjf file rtsock_14.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.4.34.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.30.1 05-Dec-2016  skrll Sync with HEAD
 1.4.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.16.1 10-Jun-2019  christos Sync with HEAD
 1.5.14.7 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.5.14.6 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.5.14.5 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.5.14.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.5.14.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.5.14.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.5.14.1 30-Mar-2018  pgoyette Extract compat_14 stuff into its own module
 1.9.2.1 29-Feb-2020  ad Sync with head.
 1.16 29-Jan-2020  thorpej Don't reference ifp->if_data directly; use if_export_if_data().
 1.15 12-Dec-2019  pgoyette branches: 1.15.2;
Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.14 04-Oct-2019  msaitoh Make clog static. Found by lgtm bot.
 1.13 29-Apr-2019  roy Introduce rt_addrmsg_src which adds RTA_AUTHOR to the message.
Use this when we notify userland of a duplicate address
and set RTA_AUTHOR to the hardware address of the sender.

While here, match the logging diagnostic of INET6 to the simpler one
of INET so it's consistent.
 1.12 29-Apr-2019  roy rtsock: Route address message simplification

Rename rt_newaddrmsg to rt_addrmsg_rt.
Add rt_addrmsg which drops the error and route arguments which are only
needed by one caller.
 1.11 29-Apr-2019  pgoyette Move the set-up of the net.oroute... sysctl tree to compat_50 since
the new AF_ROUTE was introduced in NetBSD-6.0
 1.10 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.9 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.8 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.7 10-May-2018  nonaka branches: 1.7.2;
Added missing ifi_link_state at compat_50_rt_oifmsg() and compat_50_iflist().
 1.6 16-Dec-2017  maxv branches: 1.6.2;
Build these functions regardless of whether COMPAT_50 or COMPAT_70 are
enabled. They must be there, because they are needed in rtsock.c even
when no compat option is enabled.
 1.5 16-Dec-2017  mrg remove check for netbsd 1.5 without 5.0. it doesn't happen.
 1.4 24-Aug-2015  pooka branches: 1.4.10;
to garnish, dust with _KERNEL_OPT
 1.3 01-Feb-2011  matt branches: 1.3.14; 1.3.32;
Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.
 1.2 11-Jan-2009  christos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.12; 1.2.14;
merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file rtsock_50.c was initially added on branch christos-time_t.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.1 29-Mar-2008  christos new files
 1.2.14.1 08-Feb-2011  bouyer Sync with HEAD
 1.2.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.10.1 05-Mar-2011  rmind sync with head
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2009  skrll file rtsock_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 11-Jan-2009  mjf file rtsock_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.3.32.1 22-Sep-2015  skrll Sync with HEAD
 1.3.14.1 03-Dec-2017  jdolecek update from HEAD
 1.4.10.2 21-Jan-2020  martin Apply patch, requested by pgoyette in ticket #1484:

sys/compat/common/rtsock_50.c (patch)

PR kern/54861:

For MODULAR kernels, we include all of the compat code, even if not
required by the selected COMPAT_xx options. Thus, rtsock_14.c is
included in the kernel.

rtsock_14.c in turn references routines in rtsock_50.c which is also
included in the kernel. However, if the kernel is built without the
COMPAT_50 option, rtsock_50.c ends up being a no-op and doesn't
define any of the routines that rtsock_14.c needs.

Thus, MODULAR kernels which only have COMPAT_60 (or newer) will fail
to link becuase of the undefined symbols.

Fix is to make rtsock_50.c functional if MODULAR kernel option is
specified.
 1.4.10.1 09-Jun-2018  martin Pull up following revision(s) (requested by nonaka in ticket #861):

sys/compat/common/rtsock_50.c: revision 1.7

Added missing ifi_link_state at compat_50_rt_oifmsg() and compat_50_iflist().
 1.6.2.7 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.6.2.6 15-Jan-2019  pgoyette Remove a couple of unneeded #include-s

XXX There's probably a lot more clean-up that could happen here!
 1.6.2.5 15-Jan-2019  pgoyette Split sys/net/rtsock.c into two pieces, one of which is applicable only
to -current and one which is shared between -current and COMPAT_50.
 1.6.2.4 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.6.2.3 13-Jan-2019  pgoyette Add the required hooks for rtsock_50 and modify the COMPATCALL() macro
to use the hooks. While the rtsock_50 situation is still sub-optimal
(it includes the main rtsock.c with a whole bunch of function and
variable redefinitions via macros), this at least makes it possible to
load the rtsock_50 code separately from more recent code, rather than
the previous requirement that rtsock_50 be built-in.
 1.6.2.2 11-Jan-2019  pgoyette Rework the various sysctl-related routines to call the correct code
for each version. While here, extract the 5.0 specific code instead
of including in the main rtsock.c code.

Also, clean up all the sysctl-related routines to prevent building
more than one copy, no matter how many places rtsock.c gets #include'd
into!
 1.6.2.1 21-May-2018  pgoyette Sync with HEAD
 1.7.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.2.1 10-Jun-2019  christos Sync with HEAD
 1.15.2.1 29-Feb-2020  ad Sync with head.
 1.8 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.7 29-Apr-2019  pgoyette Move the set-up of the net.oroute... sysctl tree to compat_50 since
the new AF_ROUTE was introduced in NetBSD-6.0
 1.6 29-Apr-2019  pgoyette For the rtsock compat code, make sure we create the "oroute" sysctl
tree. Otherwise a 5.2 version of getifaddrs(2) gets errors.

This makes the 5.2 version of ifconfig(8) behave the same on both
NetBSD-8 and -current. HOWEVER, both of them print nothing (for
``ifconfig -l'' command) so there's still a bug somewhere.

As reported originally by der Mouse.
 1.5 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.4 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.3 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.2 16-Dec-2017  maxv branches: 1.2.2; 1.2.4;
Build these functions regardless of whether COMPAT_50 or COMPAT_70 are
enabled. They must be there, because they are needed in rtsock.c even
when no compat option is enabled.
 1.1 21-Sep-2016  roy branches: 1.1.2; 1.1.4; 1.1.18;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 21-Sep-2016  jdolecek file rtsock_70.c was added on branch tls-maxphys on 2017-12-03 11:36:53 +0000
 1.1.4.2 04-Nov-2016  pgoyette Sync with HEAD
 1.1.4.1 21-Sep-2016  pgoyette file rtsock_70.c was added on branch pgoyette-localcount on 2016-11-04 14:49:07 +0000
 1.1.2.2 05-Oct-2016  skrll Sync with HEAD
 1.1.2.1 21-Sep-2016  skrll file rtsock_70.c was added on branch nick-nhusb on 2016-10-05 20:55:37 +0000
 1.2.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.1 10-Jun-2019  christos Sync with HEAD
 1.2.2.5 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.2.2.4 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.2.2.3 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.2.2.2 15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.2.2.1 15-Mar-2018  pgoyette Create a separate module for COMPAT_70 code only, and untangle the
70 compat code from the current.
 1.2 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.1 19-May-2024  christos version dup3
 1.2 20-May-2024  martin Fix a few oversights from the renaming of dup3110 to dup3100
 1.1 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.4 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.3 01-Mar-2019  pgoyette branches: 1.3.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 27-Mar-2018  pgoyette branches: 1.1.2;
file sysmon_power_40.c was initially added on branch pgoyette-compat.
 1.1.2.6 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.5 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.1.2.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.1.2.1 27-Mar-2018  pgoyette Create a compat_40 module
 1.3.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 01-Mar-2019  christos file sysmon_power_40.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.6 11-Jan-2009  christos merge christos-time_t
 1.5 28-Apr-2008  martin branches: 1.5.8; 1.5.12;
Remove clause 3 and 4 from TNF licenses
 1.4 08-Dec-2007  dsl branches: 1.4.12; 1.4.14; 1.4.16;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.3 11-Nov-2005  christos branches: 1.3.46; 1.3.48; 1.3.58;
Move more compat stuff from sys.
 1.2 13-Nov-2001  lukem branches: 1.2.16; 1.2.32;
add RCSIDs (including regeneration of files as appropriate)
 1.1 25-Aug-1999  thorpej branches: 1.1.14; 1.1.16;
Add compatibility calls for the 1.4 System V IPC *ctl() calls, and
update the 1.0 compat calls.
 1.1.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.14.1 14-Nov-2001  nathanw Catch up to -current.
 1.2.32.2 21-Jan-2008  yamt sync with head
 1.2.32.1 21-Jun-2006  yamt sync with head.
 1.2.16.1 11-Dec-2005  christos Sync with head.
 1.3.58.1 26-Dec-2007  ad Sync with head.
 1.3.48.1 09-Jan-2008  matt sync with HEAD
 1.3.46.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.4.16.2 04-May-2009  yamt sync with head.
 1.4.16.1 16-May-2008  yamt sync with head.
 1.4.14.1 18-May-2008  yamt sync with head.
 1.4.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.4.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.12.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.5.12.1 28-Apr-2008  christos file sysv_ipc_14.c was added on branch christos-time_t on 2008-11-09 23:28:36 +0000
 1.5.8.1 03-Mar-2009  skrll Sync with HEAD.
 1.6 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.5 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.4 03-Dec-2015  pgoyette branches: 1.4.16; 1.4.18;
Add comment to #ifdef - it's a long way from its original #if
 1.3 10-May-2015  pgoyette Split the SYSV* compat code out into a separate compat_sysv module.

For monolithic kernels, both modules will be compiled as "built-ins",
while modular environments will be able to load the SYSVSEM, SYSVSHM,
and SYSVMSG code independant from the rest of compat.

This is a necessary precursor step to making the "STD" SYSV* code
into a separate module.

Tested in both monolithic and modular environments with no errors
seen.
 1.2 21-Jan-2009  christos branches: 1.2.4; 1.2.6; 1.2.28; 1.2.46;
compile into nothing if not compat 50.
 1.1 19-Jan-2009  christos Provide compatibility for pre-christos-time_t sysv sysctls.
 1.2.46.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.2.46.1 06-Jun-2015  skrll Sync with HEAD
 1.2.28.1 03-Dec-2017  jdolecek update from HEAD
 1.2.6.2 04-May-2009  yamt sync with head.
 1.2.6.1 21-Jan-2009  yamt file sysv_ipc_50.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:17 +0000
 1.2.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.2.4.1 21-Jan-2009  skrll file sysv_ipc_50.c was added on branch nick-hppapmap on 2009-03-03 18:30:07 +0000
 1.4.18.1 10-Jun-2019  christos Sync with HEAD
 1.4.16.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4.16.1 10-Mar-2018  pgoyette Put declaration of the 5.0 sysctl routine in a header file
 1.1 09-Mar-2018  pgoyette branches: 1.1.2;
file sysv_ipc_mod.c was initially added on branch pgoyette-compat.
 1.1.2.2 09-Mar-2018  pgoyette More on renaming the new module
 1.1.2.1 09-Mar-2018  pgoyette Split the sysv_ipc module into two pieces: one for contemporary
SYSV* functionality, and one for compatability with previous NetBSD
versions. No need to pull in all of compat just to have a sysv_ipc
module.
 1.1 09-Mar-2018  pgoyette branches: 1.1.2;
file sysv_ipc_mod.h was initially added on branch pgoyette-compat.
 1.1.2.2 09-Mar-2018  pgoyette More on renaming the new module
 1.1.2.1 09-Mar-2018  pgoyette Split the sysv_ipc module into two pieces: one for contemporary
SYSV* functionality, and one for compatability with previous NetBSD
versions. No need to pull in all of compat just to have a sysv_ipc
module.
 1.1 09-Mar-2018  pgoyette branches: 1.1.2;
file sysv_mod.c was initially added on branch pgoyette-compat.
 1.1.2.8 17-Apr-2018  pgoyette Rename sysv_mod.[ch] to compat_sysv_mod.[ch] for consistency with other
files that provide module(7) interfaces.
 1.1.2.7 10-Mar-2018  pgoyette Put declaration of the 5.0 sysctl routine in a header file
 1.1.2.6 09-Mar-2018  pgoyette The last of the rename
 1.1.2.5 09-Mar-2018  pgoyette Include correct header file
 1.1.2.4 09-Mar-2018  pgoyette All the COMPAT_xx macros are already in opt_compat_netbsd.h so no
need to look for them in opt_compat_xx.h
 1.1.2.3 09-Mar-2018  pgoyette Finish renaming the new module.
 1.1.2.2 09-Mar-2018  pgoyette Update dependency: compat_sysv requires sysv_ipc
 1.1.2.1 09-Mar-2018  pgoyette More on renaming the new module
 1.1 09-Mar-2018  pgoyette branches: 1.1.2;
file sysv_mod.h was initially added on branch pgoyette-compat.
 1.1.2.4 17-Apr-2018  pgoyette Rename sysv_mod.[ch] to compat_sysv_mod.[ch] for consistency with other
files that provide module(7) interfaces.
 1.1.2.3 10-Mar-2018  pgoyette Put declaration of the 5.0 sysctl routine in a header file
 1.1.2.2 09-Mar-2018  pgoyette Allocate the function vector only once.
 1.1.2.1 09-Mar-2018  pgoyette More on renaming the new module
 1.20 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.19 19-Jan-2011  tsutsui branches: 1.19.56; 1.19.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.18 11-Jan-2009  christos branches: 1.18.6; 1.18.8;
merge christos-time_t
 1.17 28-Apr-2008  martin branches: 1.17.2; 1.17.8; 1.17.12;
Remove clause 3 and 4 from TNF licenses
 1.16 20-Dec-2007  dsl branches: 1.16.6; 1.16.8; 1.16.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.15 08-Dec-2007  dsl branches: 1.15.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.14 04-Dec-2007  dsl Remove all the __P
 1.13 09-Feb-2007  ad branches: 1.13.18; 1.13.20; 1.13.26; 1.13.28;
Merge newlock2 to head.
 1.12 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 23-Jul-2006  ad branches: 1.10.4; 1.10.6;
Use the LWP cached credentials where sane.
 1.9 11-Nov-2005  christos branches: 1.9.6; 1.9.10;
Move more compat stuff from sys.
 1.8 10-Nov-2005  christos These two really don't need the new header.
 1.7 10-Nov-2005  christos Include new compat header.
 1.6 26-Feb-2005  perry branches: 1.6.4;
nuke trailing whitespace
 1.5 18-Jan-2003  thorpej branches: 1.5.2; 1.5.10; 1.5.12;
Merge the nathanw_sa branch.
 1.4 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.3 21-Dec-2000  jdolecek branches: 1.3.2; 1.3.4;
don't define SYSVMSG if it's already defined
 1.2 02-Jun-2000  simonb Add new sysctl node "KERN_SYSVIPC_INFO" with "KERN_SYSVIPC_MSG_INFO",
"KERN_SYSVIPC_SEM_INFO" and "KERN_SYSVIPC_SHM_INFO" to return the
info and data structures for the relevent SysV IPC types. The return
structures use fixed-size types and should be compat32 safe. All
user-visible changes are protected with
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

Make all variable declarations extern in msg.h, sem.h and shm.h and
add relevent variable declarations to sysv_*.c and remove unneeded
header files from those .c files.

Make compat14 SysV IPC conversion functions and sysctl_file() static.

Change the data pointer to "void *" in sysctl_clockrate(),
sysctl_ntptime(), sysctl_file() and sysctl_doeproc().
 1.1 25-Aug-1999  thorpej branches: 1.1.2; 1.1.10;
Add compatibility calls for the 1.4 System V IPC *ctl() calls, and
update the 1.0 compat calls.
 1.1.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.3.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.3.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.5.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.2.2 11-Dec-2005  christos Sync with head.
 1.5.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.4.5 21-Jan-2008  yamt sync with head
 1.6.4.4 07-Dec-2007  yamt sync with head
 1.6.4.3 26-Feb-2007  yamt sync with head.
 1.6.4.2 30-Dec-2006  yamt sync with head.
 1.6.4.1 21-Jun-2006  yamt sync with head.
 1.9.10.1 11-Aug-2006  yamt sync with head
 1.9.6.1 09-Sep-2006  rpaulo sync with head
 1.10.6.2 10-Dec-2006  yamt sync with head.
 1.10.6.1 22-Oct-2006  yamt sync with head
 1.10.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.10.4.1 18-Nov-2006  ad Sync with head.
 1.13.28.2 26-Dec-2007  ad Sync with head.
 1.13.28.1 08-Dec-2007  ad Sync with head.
 1.13.26.2 27-Dec-2007  mjf Sync with HEAD.
 1.13.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.20.1 09-Jan-2008  matt sync with HEAD
 1.13.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.15.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.16.10.2 04-May-2009  yamt sync with head.
 1.16.10.1 16-May-2008  yamt sync with head.
 1.16.8.1 18-May-2008  yamt sync with head.
 1.16.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.16.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.12.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.17.12.1 28-Apr-2008  christos file sysv_msg_14.c was added on branch christos-time_t on 2008-11-09 23:28:36 +0000
 1.17.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.2.2 14-May-2008  wrstuden 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.
 1.17.2.1 10-May-2008  wrstuden 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.
 1.18.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.6.1 05-Mar-2011  rmind sync with head
 1.19.58.1 10-Jun-2019  christos Sync with HEAD
 1.19.56.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.5 15-Dec-2019  tsutsui Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.4 27-Jan-2019  pgoyette branches: 1.4.4;
Merge the [pgoyette-compat] branch
 1.3 19-Jan-2011  tsutsui branches: 1.3.56; 1.3.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.2 11-Jan-2009  christos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.12;
merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file sysv_msg_50.c was initially added on branch christos-time_t.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.1.2.1 29-Mar-2008  christos new files
 1.2.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.10.1 05-Mar-2011  rmind sync with head
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2009  skrll file sysv_msg_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 11-Jan-2009  mjf file sysv_msg_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.3.58.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.58.1 10-Jun-2019  christos Sync with HEAD
 1.3.56.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.4.4.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.17 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.16 19-Jan-2011  tsutsui branches: 1.16.56; 1.16.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.15 11-Jan-2009  christos branches: 1.15.6; 1.15.8;
merge christos-time_t
 1.14 28-Apr-2008  martin branches: 1.14.2; 1.14.8; 1.14.12;
Remove clause 3 and 4 from TNF licenses
 1.13 20-Dec-2007  dsl branches: 1.13.6; 1.13.8; 1.13.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.12 17-Jun-2007  dsl branches: 1.12.8; 1.12.16; 1.12.20;
Expose semid_ds14_to_native() to otherparts of the system.
Don't leak kernel stack back to userspace.
 1.11 09-Feb-2007  ad branches: 1.11.6; 1.11.8;
Merge newlock2 to head.
 1.10 23-Jul-2006  ad branches: 1.10.4;
Use the LWP cached credentials where sane.
 1.9 10-Nov-2005  christos branches: 1.9.6; 1.9.10;
These two really don't need the new header.
 1.8 10-Nov-2005  christos Include new compat header.
 1.7 13-Sep-2005  christos compat code reorg.
 1.6 26-Feb-2005  perry branches: 1.6.4;
nuke trailing whitespace
 1.5 18-Jan-2003  thorpej branches: 1.5.2; 1.5.10; 1.5.12;
Merge the nathanw_sa branch.
 1.4 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.3 17-Dec-2000  jdolecek branches: 1.3.2; 1.3.4;
make LKM safe
 1.2 02-Jun-2000  simonb Add new sysctl node "KERN_SYSVIPC_INFO" with "KERN_SYSVIPC_MSG_INFO",
"KERN_SYSVIPC_SEM_INFO" and "KERN_SYSVIPC_SHM_INFO" to return the
info and data structures for the relevent SysV IPC types. The return
structures use fixed-size types and should be compat32 safe. All
user-visible changes are protected with
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

Make all variable declarations extern in msg.h, sem.h and shm.h and
add relevent variable declarations to sysv_*.c and remove unneeded
header files from those .c files.

Make compat14 SysV IPC conversion functions and sysctl_file() static.

Change the data pointer to "void *" in sysctl_clockrate(),
sysctl_ntptime(), sysctl_file() and sysctl_doeproc().
 1.1 25-Aug-1999  thorpej branches: 1.1.2; 1.1.10;
Add compatibility calls for the 1.4 System V IPC *ctl() calls, and
update the 1.0 compat calls.
 1.1.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.3.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.3.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.5.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.2.3 11-Dec-2005  christos Sync with head.
 1.5.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.4.5 21-Jan-2008  yamt sync with head
 1.6.4.4 03-Sep-2007  yamt sync with head.
 1.6.4.3 26-Feb-2007  yamt sync with head.
 1.6.4.2 30-Dec-2006  yamt sync with head.
 1.6.4.1 21-Jun-2006  yamt sync with head.
 1.9.10.1 11-Aug-2006  yamt sync with head
 1.9.6.1 09-Sep-2006  rpaulo sync with head
 1.10.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.11.8.1 11-Jul-2007  mjf Sync with head.
 1.11.6.1 15-Jul-2007  ad Sync with head.
 1.12.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.16.1 26-Dec-2007  ad Sync with head.
 1.12.8.1 09-Jan-2008  matt sync with HEAD
 1.13.10.2 04-May-2009  yamt sync with head.
 1.13.10.1 16-May-2008  yamt sync with head.
 1.13.8.1 18-May-2008  yamt sync with head.
 1.13.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.13.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.12.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.14.12.1 28-Apr-2008  christos file sysv_sem_14.c was added on branch christos-time_t on 2008-11-09 23:28:36 +0000
 1.14.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.2.2 14-May-2008  wrstuden 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.
 1.14.2.1 10-May-2008  wrstuden 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.
 1.15.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.6.1 05-Mar-2011  rmind sync with head
 1.16.58.1 10-Jun-2019  christos Sync with HEAD
 1.16.56.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.5 15-Dec-2019  tsutsui Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.4 27-Jan-2019  pgoyette branches: 1.4.4;
Merge the [pgoyette-compat] branch
 1.3 19-Jan-2011  tsutsui branches: 1.3.56; 1.3.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.2 11-Jan-2009  christos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.12;
merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file sysv_sem_50.c was initially added on branch christos-time_t.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.1.2.1 29-Mar-2008  christos new files
 1.2.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.10.1 05-Mar-2011  rmind sync with head
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2009  skrll file sysv_sem_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 11-Jan-2009  mjf file sysv_sem_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.3.58.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.58.1 10-Jun-2019  christos Sync with HEAD
 1.3.56.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.4.4.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.18 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.17 19-Jan-2011  tsutsui branches: 1.17.56; 1.17.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.16 11-Jan-2009  christos branches: 1.16.6; 1.16.8;
merge christos-time_t
 1.15 28-Apr-2008  martin branches: 1.15.2; 1.15.8; 1.15.12;
Remove clause 3 and 4 from TNF licenses
 1.14 20-Dec-2007  dsl branches: 1.14.6; 1.14.8; 1.14.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.13 08-Dec-2007  dsl branches: 1.13.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.12 04-Dec-2007  dsl Remove all the __P
 1.11 09-Feb-2007  ad branches: 1.11.18; 1.11.20; 1.11.26; 1.11.28;
Merge newlock2 to head.
 1.10 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.9 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8 23-Jul-2006  ad branches: 1.8.4; 1.8.6;
Use the LWP cached credentials where sane.
 1.7 10-Nov-2005  christos branches: 1.7.6; 1.7.10;
Include new compat header.
 1.6 26-Feb-2005  perry branches: 1.6.4;
nuke trailing whitespace
 1.5 18-Jan-2003  thorpej branches: 1.5.2; 1.5.10; 1.5.12;
Merge the nathanw_sa branch.
 1.4 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.3 17-Dec-2000  jdolecek branches: 1.3.2; 1.3.4;
make LKM safe
 1.2 02-Jun-2000  simonb Add new sysctl node "KERN_SYSVIPC_INFO" with "KERN_SYSVIPC_MSG_INFO",
"KERN_SYSVIPC_SEM_INFO" and "KERN_SYSVIPC_SHM_INFO" to return the
info and data structures for the relevent SysV IPC types. The return
structures use fixed-size types and should be compat32 safe. All
user-visible changes are protected with
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

Make all variable declarations extern in msg.h, sem.h and shm.h and
add relevent variable declarations to sysv_*.c and remove unneeded
header files from those .c files.

Make compat14 SysV IPC conversion functions and sysctl_file() static.

Change the data pointer to "void *" in sysctl_clockrate(),
sysctl_ntptime(), sysctl_file() and sysctl_doeproc().
 1.1 25-Aug-1999  thorpej branches: 1.1.2; 1.1.10;
Add compatibility calls for the 1.4 System V IPC *ctl() calls, and
update the 1.0 compat calls.
 1.1.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.3.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.3.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.5.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.2.2 11-Dec-2005  christos Sync with head.
 1.5.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.4.5 21-Jan-2008  yamt sync with head
 1.6.4.4 07-Dec-2007  yamt sync with head
 1.6.4.3 26-Feb-2007  yamt sync with head.
 1.6.4.2 30-Dec-2006  yamt sync with head.
 1.6.4.1 21-Jun-2006  yamt sync with head.
 1.7.10.1 11-Aug-2006  yamt sync with head
 1.7.6.1 09-Sep-2006  rpaulo sync with head
 1.8.6.2 10-Dec-2006  yamt sync with head.
 1.8.6.1 22-Oct-2006  yamt sync with head
 1.8.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.8.4.1 18-Nov-2006  ad Sync with head.
 1.11.28.2 26-Dec-2007  ad Sync with head.
 1.11.28.1 08-Dec-2007  ad Sync with head.
 1.11.26.2 27-Dec-2007  mjf Sync with HEAD.
 1.11.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.11.20.1 09-Jan-2008  matt sync with HEAD
 1.11.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.13.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.10.2 04-May-2009  yamt sync with head.
 1.14.10.1 16-May-2008  yamt sync with head.
 1.14.8.1 18-May-2008  yamt sync with head.
 1.14.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.14.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.12.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.15.12.1 28-Apr-2008  christos file sysv_shm_14.c was added on branch christos-time_t on 2008-11-09 23:28:36 +0000
 1.15.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.2.2 14-May-2008  wrstuden 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.
 1.15.2.1 10-May-2008  wrstuden 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.
 1.16.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.6.1 05-Mar-2011  rmind sync with head
 1.17.58.1 10-Jun-2019  christos Sync with HEAD
 1.17.56.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.5 15-Dec-2019  tsutsui Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.4 27-Jan-2019  pgoyette branches: 1.4.4;
Merge the [pgoyette-compat] branch
 1.3 19-Jan-2011  tsutsui branches: 1.3.56; 1.3.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.2 11-Jan-2009  christos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.12;
merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file sysv_shm_50.c was initially added on branch christos-time_t.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.2 09-Nov-2008  christos garbage collect all the conversion functions and put them in the header
files so that userland can share them. Also fix bugs in them!
 1.1.2.1 29-Mar-2008  christos new files
 1.2.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.10.1 05-Mar-2011  rmind sync with head
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2009  skrll file sysv_shm_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 11-Jan-2009  mjf file sysv_shm_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.3.58.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.58.1 10-Jun-2019  christos Sync with HEAD
 1.3.56.1 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.4.4.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.40 10-Jul-2022  riastradh tty_43: Do unsigned arithmetic to avoid shift into sign bits.

Omit input validation -- it's not a great idea for compatibility with
historical kernels, since they ignored the bits instead of rejecting
them if set. With unsigned arithmetic, we get the same semantics as
was previously assumed (discarding bits that get shifted into the
sign bit or off into oblivion) without the formal undefined
behaviour.

Reported-by: syzbot+e408764cdd8c0c0ff535@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=8318f0039e68187cd8d27b2c520816fff3f7266a
 1.39 10-Oct-2020  christos TIOCGSID is used by tcgetsid() so it is not really compat :-)
This should reduce loading the compat module.
 1.38 09-Oct-2020  nia tty_43: Check a bitset from userspace is valid before shifting it

Passing a negative value to these legacy compat ioctls results in
left shift on a negative value which is undefined behaviour and results
in the tty (at least, possibly other things) locking up.

The argument to the ioctl should always be > 0. Return EINVAL otherwise.

While here, adjustments to code style to match current guidelines.

Found by UBSan.

Reported-by: syzbot+39cd551a05298b222756@syzkaller.appspotmail.com
 1.37 08-Aug-2020  christos Fix the OTIOCGETD emulation. Line discipline 0 is NTTYDISC.
 1.36 23-May-2020  ad Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.35 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.34 01-Mar-2019  pgoyette branches: 1.34.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.33 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.32 28-Jan-2019  christos - provide a hook for the 43 tty ioctls
- make the 60 tty ioctl hook look the same
- fix the tty code to call both hooks and remove unused lock
 1.31 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.30 22-May-2014  dholland branches: 1.30.20; 1.30.26; 1.30.28;
Use accessor functions for the tty's table of control characters.
(at least from outside the core tty sources)

Move some xon/xoff code from net/ppp_tty.c to kern/tty.c.
 1.29 19-Nov-2008  ad branches: 1.29.26; 1.29.40;
Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.28 14-Nov-2008  ad - Move some more compat code into sys/compat.
- Split 4.3BSD ifioctl stuff into its own file.
- Remove some ifdefs that include small fragments of vfs compat code
which are difficult to relocate elsewhere.
 1.27 28-Apr-2008  martin branches: 1.27.6; 1.27.8;
Remove clause 3 and 4 from TNF licenses
 1.26 24-Apr-2008  ad branches: 1.26.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.25 23-Apr-2008  ad Fix locking.
 1.24 08-Dec-2007  dsl branches: 1.24.12; 1.24.14;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.23 04-Dec-2007  dsl Remove all the __P
 1.22 04-Mar-2007  christos branches: 1.22.14; 1.22.16; 1.22.22; 1.22.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.21 05-Mar-2006  christos branches: 1.21.18;
cleanup more SET/CLR/ISSET lossage
 1.20 11-Dec-2005  christos branches: 1.20.4; 1.20.6; 1.20.8;
merge ktrace-lwp.
 1.19 27-Nov-2005  thorpej Overhaul how TTY line disciplines are handled:
- Replace references to linesw[0] with a ttyldisc_default() function
that returns the default ("termios") line discipline.
- The linesw[] array is gone, replaced by a linked list.
- ttyldisc_add() and ttyldisc_remove() have been replaced by
ttyldisc_attach() and ttyldisc_detach().
- Things that provide line disciplines are now responsible for
registering those disciplines with the system. The linesw
structures are no longer declared in tty_conf.c
- Line disciplines are now refcounted; a lookup causes a reference to
be held. ttyldisc_release() releases the reference. Attempts to
detach an in-use line discipline result in EBUSY.
- Fix function signature lossage in if_sl.c, if_strip.c, and tty_tb.c
that was masked by the old tty_conf.c
- tty_init() is no longer necessary; delete it and its call from main().
 1.18 25-Apr-2004  matt branches: 1.18.12; 1.18.18;
Constify the speedtab arrays
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.16 29-Jun-2003  fvdl branches: 1.16.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.15 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.14 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.13 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.12 08-Nov-2000  eeh branches: 1.12.2; 1.12.4; 1.12.6;
Don't dereference NULL t_linesw.
 1.11 02-Nov-2000  itohy Adapt to the new line discipline scheme.
 1.10 30-Mar-2000  augustss Kill register declarations.
 1.9 29-Mar-2000  simonb Don't need to include <sys/conf.h> here.
 1.8 01-Mar-1998  fvdl branches: 1.8.14;
Merge with Lite2 + local changes
 1.7 13-Oct-1996  christos Backout previous kprintf change.
 1.6 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.5 20-May-1996  mark cast -1 to a char for comparision with tc->t_brkc so that this test
will work with signed and unsigned chars.
 1.4 18-May-1996  veego Put this into an #ifdef COMPAT_OLDTTY.
look in <sys/tty.h> for more infomations about that.
 1.3 14-Mar-1996  christos Fix compiler warnings
 1.2 10-Feb-1996  christos Don't declare MSG_COMPAT in two places.
More prototype fixes
 1.1 02-Feb-1996  christos Renamed compat_tty.c to tty_43.c and updated with the newest copy from
kern/tty_compat.c
 1.8.14.2 22-Nov-2000  bouyer Sync with HEAD.
 1.8.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.12.6.1 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.12.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.12.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.12.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.16.2.5 11-Dec-2005  christos Sync with head.
 1.16.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.2 03-Aug-2004  skrll Sync with HEAD
 1.16.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.18.18.1 29-Nov-2005  yamt sync with head.
 1.18.12.4 21-Jan-2008  yamt sync with head
 1.18.12.3 07-Dec-2007  yamt sync with head
 1.18.12.2 03-Sep-2007  yamt sync with head.
 1.18.12.1 21-Jun-2006  yamt sync with head.
 1.20.8.1 13-Mar-2006  yamt sync with head.
 1.20.6.1 22-Apr-2006  simonb Sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.21.18.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.24.2 26-Dec-2007  ad Sync with head.
 1.22.24.1 08-Dec-2007  ad Sync with head.
 1.22.22.2 27-Dec-2007  mjf Sync with HEAD.
 1.22.22.1 08-Dec-2007  mjf Sync with HEAD.
 1.22.16.1 09-Jan-2008  matt sync with HEAD
 1.22.14.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.24.14.1 18-May-2008  yamt sync with head.
 1.24.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.24.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.26.2.2 04-May-2009  yamt sync with head.
 1.26.2.1 16-May-2008  yamt sync with head.
 1.27.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.27.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.29.40.1 10-Aug-2014  tls Rebase.
 1.29.26.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.28.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.30.28.1 10-Jun-2019  christos Sync with HEAD
 1.30.26.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.30.26.1 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.30.20.1 10-Oct-2020  martin Pull up following revision(s) (requested by nia in ticket #1614):

sys/compat/common/tty_43.c: revision 1.38

tty_43: Check a bitset from userspace is valid before shifting it

Passing a negative value to these legacy compat ioctls results in
left shift on a negative value which is undefined behaviour and results
in the tty (at least, possibly other things) locking up.
The argument to the ioctl should always be > 0. Return EINVAL otherwise.

While here, adjustments to code style to match current guidelines.
Found by UBSan.
 1.34.4.1 10-Oct-2020  martin Pull up following revision(s) (requested by nia in ticket #1106):

sys/compat/common/tty_43.c: revision 1.38

tty_43: Check a bitset from userspace is valid before shifting it

Passing a negative value to these legacy compat ioctls results in
left shift on a negative value which is undefined behaviour and results
in the tty (at least, possibly other things) locking up.
The argument to the ioctl should always be > 0. Return EINVAL otherwise.

While here, adjustments to code style to match current guidelines.
Found by UBSan.
 1.11 21-Jul-2021  skrll need <sys/param.h> for COHERENCY_UNIT

Minor KNF along the way.
 1.10 24-Jun-2020  jdolecek branches: 1.10.6;
reduce stack usage in compat_60_ptmget_ioctl() - allocate struct ptmget
via kmem_alloc()
 1.9 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.8 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.7 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.6 28-Jan-2019  christos - provide a hook for the 43 tty ioctls
- make the 60 tty ioctl hook look the same
- fix the tty code to call both hooks and remove unused lock
 1.5 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.4 22-Oct-2015  christos branches: 1.4.2; 1.4.8; 1.4.16; 1.4.18;
Handle both ioctls in both places :-)
 1.3 19-Oct-2012  apb branches: 1.3.2; 1.3.4; 1.3.18;
Also copy the sfd element of struct ptmget. This somehow
got lost between testing and commit.
 1.2 19-Oct-2012  apb This file getscompiled even if COMPAT_60 is not defined, so
protect most of the contents with #ifdef COMPAT_60
 1.1 19-Oct-2012  apb Add COMPAT_60 versions of the TIOCPTMGET and TIOCPTSNAME ioctls.
 1.3.18.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.4.3 03-Dec-2017  jdolecek update from HEAD
 1.3.4.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.3.4.1 19-Oct-2012  tls file tty_60.c was added on branch tls-maxphys on 2012-11-20 03:01:53 +0000
 1.3.2.2 30-Oct-2012  yamt sync with head
 1.3.2.1 19-Oct-2012  yamt file tty_60.c was added on branch yamt-pagecache on 2012-10-30 17:20:39 +0000
 1.4.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.18.1 10-Jun-2019  christos Sync with HEAD
 1.4.16.7 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.4.16.6 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.4.16.5 15-Oct-2018  pgoyette Convert another hook to the MP-sfe mechanism.

XXX still have three more to convert: openat_10, sysvipc50_sysctl and
XXX compat70_unp_addsockcred
 1.4.16.4 04-Sep-2018  pgoyette Separate COMPAT_BSDPTY stuff from tty COMPAT_60 stuff. Enables
building of COMPAT_60 module whether or not COMPAT_BSDPTY is
defined in the kernel.
 1.4.16.3 18-Mar-2018  pgoyette Merge changes from HEAD into ccd_60.c

For all of the individual xxx_60_{init,fini} routines, don't force
them to artificially return a status; just make them void. This
simplifies the compat_60_{init,fini} handling of errors that remain.
 1.4.16.2 18-Mar-2018  pgoyette Initial pass at getting the tty stuff properly modularized. Subject
to review and revision.
 1.4.16.1 08-Mar-2018  pgoyette We don't need to conditionalize the code on COMPAT_60 since we'll
only include the source file when COMPAT_60 is requested (either
by kernel option or module specification)
 1.4.8.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.4.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.10.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.4 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.3 20-Dec-2007  dsl branches: 1.3.12; 1.3.96; 1.3.98;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.2 09-Feb-2007  ad branches: 1.2.20; 1.2.28; 1.2.32;
Merge newlock2 to head.
 1.1 26-Jun-2006  mrg branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10; 1.1.16;
version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.
 1.1.16.4 21-Jan-2008  yamt sync with head
 1.1.16.3 26-Feb-2007  yamt sync with head.
 1.1.16.2 30-Dec-2006  yamt sync with head.
 1.1.16.1 26-Jun-2006  yamt file uipc_syscalls_30.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:31 +0000
 1.1.10.2 09-Sep-2006  rpaulo sync with head
 1.1.10.1 26-Jun-2006  rpaulo file uipc_syscalls_30.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:14 +0000
 1.1.8.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.6.2 11-Aug-2006  yamt sync with head
 1.1.6.1 26-Jun-2006  yamt file uipc_syscalls_30.c was added on branch yamt-pdpolicy on 2006-08-11 15:43:19 +0000
 1.1.2.2 13-Jul-2006  gdamore Merge from HEAD.
 1.1.2.1 26-Jun-2006  gdamore file uipc_syscalls_30.c was added on branch gdamore-uart on 2006-07-13 17:49:07 +0000
 1.2.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.2.28.1 26-Dec-2007  ad Sync with head.
 1.2.20.1 09-Jan-2008  matt sync with HEAD
 1.3.98.1 10-Jun-2019  christos Sync with HEAD
 1.3.96.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.3.96.1 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.3.12.2 14-May-2008  wrstuden 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.
 1.3.12.1 10-May-2008  wrstuden 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.
 1.24 07-Jul-2022  riastradh ifioctl(9): Don't touch ifconf or ifreq until command is validated.

sys_ioctl validates the data pointer according to the command's size
and direction. But userland may ioctl commands other than
OSIOCGIFCONF or OOSIOCGIFCONF -- and if userland passes an IOC_VOID
command, the argument is passed through verbatim and may be null.

Reported-by: syzbot+19b1bf83e5481273eafc@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=f4c91a7dcd31901c80d91af6ed01456faf0a7286

Reported-by: syzbot+442c033feb784d055185@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=4a3a4b92dbe9695046ff17a5474cef52aed23e0b

Reported-by: syzbot+4c87d0cdf7025741ea7a@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=3e5f42c998e43ad42da40dec3c7873e6aae187e4
 1.23 16-Jul-2020  msaitoh Don't accept negative value.

Reported-by: syzbot+e71a77402d6668f1868d@syzkaller.appspotmail.com
 1.22 22-Feb-2020  maxv pass the address of the field, instead of relying on it being the first
field of the structure, no functional change
 1.21 12-Dec-2019  pgoyette branches: 1.21.2;
Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.20 23-Apr-2019  msaitoh branches: 1.20.2;
KNF. No functional change.
 1.19 18-Apr-2019  christos Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.18 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.17 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.16 12-Apr-2018  christos branches: 1.16.2;
provide vectors for the ifconf compat code and ifdatareq compat code.
 1.15 22-Nov-2017  martin branches: 1.15.2;
#idef the label next_ifa: just like the only goto using it.
 1.14 22-Nov-2017  ozaki-r Fix and make consistent of usages of psz/psref in ifconf variants
 1.13 14-Mar-2017  ozaki-r branches: 1.13.6;
Use if_acquire and if_release instead of using psref API directly

- Provide if_release for consistency to if_acquire
- Use if_acquire and if_release for ifp iterations
- Make ifnet_psref_class static
 1.12 01-Aug-2016  ozaki-r branches: 1.12.2;
Apply pserialize and psref to struct ifaddr and its variants

This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr)
MP-safe by using pserialize and psref. At this moment, pserialize_perform
and psref_target_destroy are disabled because (1) we don't need them
because of softnet_lock (2) they cause a deadlock because of softnet_lock.
So we'll enable them when we remove softnet_lock in the future.
 1.11 07-Jul-2016  ozaki-r branches: 1.11.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.10 16-Jun-2016  ozaki-r Use curlwp_bind and curlwp_bindx instead of open-coding LP_BOUND
 1.9 12-May-2016  ozaki-r Protect ifnet list with psz and psref

The change ensures that ifnet objects in the ifnet list aren't freed during
list iterations by using pserialize(9) and psref(9).

Note that the change adds a pslist(9) for ifnet but doesn't remove the
original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We
shouldn't use the original list in the kernel anymore.
 1.8 26-Nov-2014  ozaki-r branches: 1.8.2;
Tweak ifconf variants

The tweaks make the code intention clear and make further changes easy.

No functional change.
 1.7 19-Jan-2011  tsutsui branches: 1.7.16; 1.7.32; 1.7.34; 1.7.38;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.6 05-Dec-2007  dyoung branches: 1.6.38; 1.6.44;
Use IFADDR_EMPTY().
 1.5 05-Dec-2007  dyoung Use IFADDR_FOREACH().
 1.4 02-Jun-2007  enami branches: 1.4.2; 1.4.4; 1.4.10; 1.4.12; 1.4.14; 1.4.20; 1.4.22;
Reduce difference between compat_ifconf() and ifconf():
- exit on error rather than proceeding to next interface.
- make code simpler.
 1.3 30-May-2007  christos Move the nasty ifdefs in one place. Requested by ad and dyoung.
 1.2 29-May-2007  christos wrap the whole function in COMPAT_40
 1.1 29-May-2007  christos Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
 1.4.22.1 08-Dec-2007  ad Sync with head.
 1.4.20.1 08-Dec-2007  mjf Sync with HEAD.
 1.4.14.3 07-Dec-2007  yamt sync with head
 1.4.14.2 03-Sep-2007  yamt sync with head.
 1.4.14.1 02-Jun-2007  yamt file uipc_syscalls_40.c was added on branch yamt-lazymbuf on 2007-09-03 14:31:52 +0000
 1.4.12.1 09-Jan-2008  matt sync with HEAD
 1.4.10.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.4.4.2 11-Jul-2007  mjf Sync with head.
 1.4.4.1 02-Jun-2007  mjf file uipc_syscalls_40.c was added on branch mjf-ufs-trans on 2007-07-11 20:03:49 +0000
 1.4.2.3 09-Jun-2007  ad Sync with head.
 1.4.2.2 09-Jun-2007  ad Sync with head.
 1.4.2.1 02-Jun-2007  ad file uipc_syscalls_40.c was added on branch vmlocking on 2007-06-09 21:37:08 +0000
 1.6.44.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.38.1 05-Mar-2011  rmind sync with head
 1.7.38.1 19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.7.34.1 19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.7.32.1 19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.7.16.1 03-Dec-2017  jdolecek update from HEAD
 1.8.2.4 28-Aug-2017  skrll Sync with HEAD
 1.8.2.3 05-Oct-2016  skrll Sync with HEAD
 1.8.2.2 09-Jul-2016  skrll Sync with HEAD
 1.8.2.1 29-May-2016  skrll Sync with HEAD
 1.11.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.11.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.12.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.13.6.4 17-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1576):

sys/net/if.c: revision 1.479
sys/compat/common/uipc_syscalls_40.c: revision 1.23
sys/compat/linux/common/linux_socket.c: revision 1.150
sys/compat/linux32/common/linux32_socket.c: revision 1.31

Don't accept negative value.
 1.13.6.3 19-Apr-2019  martin Pull up following revision(s) (requested by christos in ticket #1233):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.13.6.2 04-Dec-2017  martin Additionaly pull up rev 1.15 for ticket #407, requested by ozaki-r:
#idef the label next_ifa: just like the only goto using it.
 1.13.6.1 30-Nov-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #407):
sys/compat/linux32/common/linux32_socket.c: revision 1.28
sys/net/if.c: revision 1.400
sys/netipsec/key.c: revision 1.243
sys/compat/linux/common/linux_socket.c: revision 1.139
sys/netinet/ip_carp.c: revision 1.93
sys/netinet6/in6.c: revision 1.252
sys/netinet6/in6.c: revision 1.253
sys/netinet6/in6.c: revision 1.254
sys/net/if_spppsubr.c: revision 1.173
sys/net/if_spppsubr.c: revision 1.174
sys/compat/common/uipc_syscalls_40.c: revision 1.14
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Fix usage of FOREACH macro
key_sad.lock is held there so SAVLIST_WRITER_FOREACH is enough.
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref (more)
Fix and make consistent of usages of psz/psref in ifconf variants
Remove unnecessary goto because there is no cleanup code to share (NFC)
Tweak a condition; we don't need to care ifacount to be negative
Fix a race condition of in6_ifinit
in6_ifinit checks the number of IPv6 addresses on a given interface and
if it's zero (i.e., an IPv6 address being assigned to the interface
is the first one), call if_addr_init. However, the actual assignment of
the address (ifa_insert) is out of in6_ifinit. The check and the
assignment must be done atomically.
Fix it by holding in6_ifaddr_lock during in6_ifinit and ifa_insert.
And also add missing pserialize to IFADDR_READER_FOREACH.
 1.15.2.13 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.15.2.12 15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.15.2.11 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.15.2.10 20-Sep-2018  pgoyette Use the MP-safe hooks mechanism for the uipc_syscalls_40 and _50
routines.
 1.15.2.9 16-Apr-2018  pgoyette Rename if_[45]0_{init,fini} entry points to more appropriate and more
consistent uipc_syscalls_[45]0_{init,fini} and remove some multiple
declarations.
 1.15.2.8 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.15.2.7 15-Apr-2018  pgoyette Make compat_ifconf() and compat_ifdatareq() static
 1.15.2.6 12-Apr-2018  pgoyette Merge christos's recent changes on HEAD
 1.15.2.5 08-Mar-2018  pgoyette Remove unnecessary conditionals. These files aren't built unless
their content is needed (via config option or module configuration).
 1.15.2.4 08-Mar-2018  pgoyette Handle ifconf() compat vectors
 1.15.2.3 06-Mar-2018  pgoyette Use a .h file for declaring the if_40_{init, fini} routines
 1.15.2.2 06-Mar-2018  pgoyette Typo in function declaration.
 1.15.2.1 06-Mar-2018  pgoyette Untangle some networking compat code so we can build a kernel with
networking and MODULAR, but without any actual COMPAT_* code (ie,
assuming that all the compat stuff can be added later via modules).
 1.16.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.16.2.1 10-Jun-2019  christos Sync with HEAD
 1.20.2.1 17-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1018):

sys/net/if.c: revision 1.479
sys/compat/common/uipc_syscalls_40.c: revision 1.23
sys/compat/linux/common/linux_socket.c: revision 1.150
sys/compat/linux32/common/linux32_socket.c: revision 1.31

Don't accept negative value.
 1.21.2.1 29-Feb-2020  ad Sync with head.
 1.51 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.50 06-Sep-2018  maxv Remove the network ATM code.
 1.49 03-May-2018  christos branches: 1.49.2;
Fix COMPAT_NETBSD32 cmsg handling:

1. alignment was wrong for > 1 message
2. macros were doing incorrect pointer comparisons, fortunately ending
the iteration early after the fists cmsg instead of crashing.
3. don't output 32 bit ktrace records for cmsg. 32 bit programs running
under emulation on 64 bit systems should produce 64 bit ktrace records
so that the native ktrace can handle the records; remove extra arguments
that are now not needed (the 32 bit msghdr).
4. output the correct type for cmsg trace records.
5. output all the cmsg records in traces instead of just the first one.

Welcome to 8.99.15 because of the argument removal.

XXX: Really all the code should be changed to use the CMSG_{FIRST,NXT}HDR
macros...
 1.48 16-Mar-2018  christos PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.
 1.47 13-Sep-2016  martin branches: 1.47.14;
Make the ktrace record written by do_sys_sendmsg/do_sys_recvmsg overridable
by the caller. Use this in compat_netbsd32 to log the 32bit version, so
the 32bit userland kdump is happy.
 1.46 09-Nov-2014  maxv branches: 1.46.2;
Do not uselessly include <sys/malloc.h>.
 1.45 05-Sep-2014  matt Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.44 14-Nov-2008  ad branches: 1.44.26; 1.44.42;
- Move some more compat code into sys/compat.
- Split 4.3BSD ifioctl stuff into its own file.
- Remove some ifdefs that include small fragments of vfs compat code
which are difficult to relocate elsewhere.
 1.43 29-Apr-2008  ad branches: 1.43.2; 1.43.6; 1.43.8; 1.43.10;
Remove now bogus assertion.
 1.42 24-Apr-2008  ad branches: 1.42.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
 1.41 15-Jan-2008  martin branches: 1.41.6;
#ifdef COMPAT_20 the ioctls only available conditionally. Patch from
Geoff Wing.
 1.40 14-Jan-2008  martin Add net80211 ioctls that I apparently ovelooked when grepping for ioctls
that need "struct ifreq" compat treatment.
This makes for example old (like 4.0) wpa_supplicant work with -current
kernels.
 1.39 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.38 08-Dec-2007  dsl branches: 1.38.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.37 11-Sep-2007  gdt branches: 1.37.6; 1.37.8;
remove SIOCSIFALIFETIME_IN6 (should have been part of previous commit)
 1.36 20-Aug-2007  martin branches: 1.36.2;
Remove all ioctls from the conversion list that are explicitly defined
to use struct oifreq - the magic size changing makes them fail.
 1.35 20-Aug-2007  martin Sigh - revert previous. Seems we can't avoid the big list, so fill it.
Now both "ifconfig ... create" and "pppoectl -d" work again with old
userland.
 1.34 20-Aug-2007  martin Put back the previous hack to make compat_cvtcmd() work for all the ioctls
that use struct ifreq which have not been explicitly versioned.
If someone feels like fixing it with a list aproach, I think below is
a complete list - the one used in the previous version missed a lot of them.

BIOCGETIF
BIOCSETIF
GREDSOCK
GREGADDRD
GREGADDRS
GREGPROTO
GRESADDRD
GRESADDRS
GRESPROTO
GRESSOCK
SIOCADDMULTI
SIOCDELMULTI
SIOCDIFADDR
SIOCDIFADDR_IN6
SIOCDIFPHYADDR
SIOCGDEFIFACE_IN6
SIOCGIFADDR
SIOCGIFADDR_IN6
SIOCGIFAFLAG_IN6
SIOCGIFALIFETIME_IN6
SIOCGIFBRDADDR
SIOCGIFDLT
SIOCGIFDSTADDR
SIOCGIFDSTADDR_IN6
SIOCGIFFLAGS
SIOCGIFGENERIC
SIOCGIFMETRIC
SIOCGIFMTU
SIOCGIFNETMASK
SIOCGIFNETMASK_IN6
SIOCGIFPDSTADDR
SIOCGIFPDSTADDR_IN6
SIOCGIFPSRCADDR
SIOCGIFPSRCADDR_IN6
SIOCGIFSTAT_ICMP6
SIOCGIFSTAT_IN6
SIOCGPVCSIF
SIOCGVH
SIOCIFCREATE
SIOCIFDESTROY
SIOCSDEFIFACE_IN6
SIOCSIFADDR
SIOCSIFADDR_IN6
SIOCSIFALIFETIME_IN6
SIOCSIFBRDADDR
SIOCSIFDSTADDR
SIOCSIFDSTADDR_IN6
SIOCSIFFLAGS
SIOCSIFGENERIC
SIOCSIFMEDIA
SIOCSIFMETRIC
SIOCSIFMTU
SIOCSIFNETMASK
SIOCSIFNETMASK_IN6
SIOCSNDFLUSH_IN6
SIOCSPFXFLUSH_IN6
SIOCSPVCSIF
SIOCSRTRFLUSH_IN6
SIOCSVH
TAPGIFNAME
 1.33 20-Aug-2007  skd Clean up net compat ioctls, and clean up handling of wireless ioctls.
 1.32 30-Jun-2007  dsl branches: 1.32.2; 1.32.6;
Changes to sompat socket function to avoid the dreaded stackgap.
 1.31 24-Jun-2007  dsl Update to call do_sys_recv() instead of recvit().
 1.30 01-Jun-2007  dsl Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.
 1.29 29-May-2007  christos Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
 1.28 04-Mar-2007  christos branches: 1.28.2; 1.28.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.27 09-Feb-2007  ad branches: 1.27.2;
Merge newlock2 to head.
 1.26 29-Jan-2007  hubertf Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.25 11-Dec-2005  christos branches: 1.25.20;
merge ktrace-lwp.
 1.24 24-Sep-2005  christos factor out some of the osockaddr, omsghdr code.
 1.23 26-Feb-2005  perry branches: 1.23.4;
nuke trailing whitespace
 1.22 07-Aug-2003  agc branches: 1.22.8; 1.22.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.21 29-Jun-2003  fvdl branches: 1.21.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.20 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.19 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.18 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.17 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.16 22-Jul-2001  jdolecek return EMSGSIZE rather than ENOMEM if it would not be possible to
allocate space for accrights within stackgap
comment the copyin() of msg.msg_control in recvmsg() is safe
 1.15 17-Jul-2001  jdolecek Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.
 1.14 07-Jul-2001  jdolecek branches: 1.14.2;
compat_43_sys_send(): wrap using sys_sendto() rathen than sendit()
compat_43_sys_recv(): wrap using sys_recvfrom() rathen than recvit()
 1.13 25-Jun-2001  jdolecek Back off the sendit()/recvit() change, some have problems with it
 1.12 25-Jun-2001  jdolecek Add 'kernsa' parameter for sendit()/recvit(); if nonzero, msg->msg_name
is supposed to point directly to struct mbuf or struct sockaddr in kernel
space as appropriate, rather than being a pointer to memory in userland.

This is to be used by compat/* when emulation needs to wrap
send{to|msg}(2)/recv{from|msg}(2) and modify the passed struct
sockaddr.
 1.11 30-Mar-2000  augustss branches: 1.11.6;
Kill register declarations.
 1.10 18-Dec-1998  drochner branches: 1.10.8;
solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.
 1.9 18-Dec-1998  mrg back out previous; it breaks when MSG_COMPAT is not defined (no compatibility modules)
 1.8 14-Dec-1998  mycroft Nuke some #ifdefs that no longer work with COMPAT_43 defopted.
 1.7 04-Aug-1998  kleink UIO_MAXIOV -> IOV_MAX
 1.6 03-Aug-1998  kleink Fix two off-by-one bugs, both present in each recvmsg(2) and sendmsg(2):
* the first one would cause an unnecessary malloc() of iovec storage for
a msg_iovlen of UIO_SMALLIOV although the required amount of memory has
been allocated on the stack.
* the second one would cause a recvmsg() or sendmsg() with a msg_iovlen of
UIO_MAXIOV to fail with EMSGSIZE, which is also a violation of XNS5.
 1.5 14-Mar-1996  christos Fix compiler warnings
 1.4 10-Feb-1996  christos Don't declare MSG_COMPAT in two places.
More prototype fixes
 1.3 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.2 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.10.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.11.6.8 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.11.6.7 03-Jul-2002  nathanw Whitespace.
 1.11.6.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.11.6.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.11.6.4 14-Nov-2001  nathanw Catch up to -current.
 1.11.6.3 24-Aug-2001  nathanw A few files and lwp/proc conversions I missed in the last big update.
GENERIC runs again.
 1.11.6.2 24-Aug-2001  nathanw Catch up with -current.
 1.11.6.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.14.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.14.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.1 03-Aug-2001  lukem update to -current
 1.21.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.21.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.2 03-Aug-2004  skrll Sync with HEAD
 1.21.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.22.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.8.1 29-Apr-2005  kent sync with -current
 1.23.4.5 21-Jan-2008  yamt sync with head
 1.23.4.4 27-Oct-2007  yamt sync with head.
 1.23.4.3 03-Sep-2007  yamt sync with head.
 1.23.4.2 26-Feb-2007  yamt sync with head.
 1.23.4.1 21-Jun-2006  yamt sync with head.
 1.25.20.2 01-Feb-2007  ad Sync with head.
 1.25.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.27.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.28.4.1 11-Jul-2007  mjf Sync with head.
 1.28.2.4 09-Oct-2007  ad Sync with head.
 1.28.2.3 20-Aug-2007  ad Sync with HEAD.
 1.28.2.2 15-Jul-2007  ad Sync with head.
 1.28.2.1 09-Jun-2007  ad Sync with head.
 1.32.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.32.6.2 02-Oct-2007  joerg Sync with HEAD.
 1.32.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.32.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.36.2.3 23-Mar-2008  matt sync with HEAD
 1.36.2.2 09-Jan-2008  matt sync with HEAD
 1.36.2.1 06-Nov-2007  matt sync with HEAD
 1.37.8.1 26-Dec-2007  ad Sync with head.
 1.37.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.38.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.38.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.41.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.42.2.2 04-May-2009  yamt sync with head.
 1.42.2.1 16-May-2008  yamt sync with head.
 1.43.10.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by chs in ticket #1541):
sys/compat/common/if_43.c: revision 1.3 via patch
sys/net/if.c: revision 1.247 via patch
PR/44054: Onno van der Linden: Stacksmashing in handling of ioctl OOSIO*
parameter.
can't map the old and the new SIO calls the way we did before because the
numbers have changed. Instead provide a switch. Keep the old code there,
to handle cases we did not handle in the first switch, but this is a hack
and should be removed.
 1.43.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.43.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.43.2.2 14-May-2008  wrstuden 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.
 1.43.2.1 10-May-2008  wrstuden 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.
 1.44.42.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.44.26.1 03-Dec-2017  jdolecek update from HEAD
 1.46.2.1 05-Oct-2016  skrll Sync with HEAD
 1.47.14.7 30-Sep-2018  pgoyette Ssync with HEAD
 1.47.14.6 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.47.14.5 21-May-2018  pgoyette Sync with HEAD
 1.47.14.4 04-May-2018  pgoyette Undo merge of changes from HEAD. This will get re-done properly
at the next sync-with-HEAD (which will also pull in other changes
needed).
 1.47.14.3 04-May-2018  pgoyette Merge rev 1.49 from HEAD
 1.47.14.2 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.47.14.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.49.2.1 10-Jun-2019  christos Sync with HEAD
 1.12 28-Sep-2022  msaitoh Simplify sys/compat/sys/sockio.h. No functional change intended.

- Move some definitions from sys/compat/sockio.h to compat/net/if.h.
struct oif_data in sockio.h and if_data50 are the same, so remove oif_data.
Do the same thing to oifdatareq, too.
- u_quad_t -> uint64_t. No functional change.
 1.11 29-Jan-2020  thorpej Don't reference ifp->if_data directly; use if_export_if_data().
 1.10 15-Dec-2019  tsutsui branches: 1.10.2;
Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.9 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.8 01-Mar-2019  pgoyette branches: 1.8.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.7 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.6 12-Sep-2018  msaitoh Fix a bug that SIOC[GZ]IFDATA returned old ifreq structure.
 1.5 26-Apr-2018  roy branches: 1.5.2;
Test for valid interface for ioctls that demand it.

Thanks to Robert Swindells for the patch.
 1.4 12-Apr-2018  christos provide vectors for the ifconf compat code and ifdatareq compat code.
 1.3 19-Jan-2011  tsutsui branches: 1.3.56;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.2 11-Jan-2009  christos branches: 1.2.2; 1.2.4; 1.2.8; 1.2.12; 1.2.14;
merge christos-time_t
 1.1 27-Nov-2008  christos branches: 1.1.2;
file uipc_syscalls_50.c was initially added on branch christos-time_t.
 1.1.2.1 27-Nov-2008  christos handle ifdatareq
 1.2.14.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.12.1 05-Mar-2011  rmind sync with head
 1.2.8.2 04-May-2009  yamt sync with head.
 1.2.8.1 11-Jan-2009  yamt file uipc_syscalls_50.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:17 +0000
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2009  skrll file uipc_syscalls_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 11-Jan-2009  mjf file uipc_syscalls_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.3.56.13 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.3.56.12 15-Oct-2018  pgoyette Convert a couple more hooks to the MP-safe mechanism.

While here, clean up some headers and remove any that are now empty.
 1.3.56.11 30-Sep-2018  pgoyette Ssync with HEAD
 1.3.56.10 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.3.56.9 20-Sep-2018  pgoyette Use the MP-safe hooks mechanism for the uipc_syscalls_40 and _50
routines.
 1.3.56.8 02-May-2018  pgoyette Synch with HEAD
 1.3.56.7 26-Apr-2018  pgoyette Import rev 1.5 from HEAD
 1.3.56.6 16-Apr-2018  pgoyette Rename if_[45]0_{init,fini} entry points to more appropriate and more
consistent uipc_syscalls_[45]0_{init,fini} and remove some multiple
declarations.
 1.3.56.5 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.3.56.4 12-Apr-2018  pgoyette Merge christos's recent changes on HEAD
 1.3.56.3 08-Mar-2018  pgoyette Remove unnecessary conditionals. These files aren't built unless
their content is needed (via config option or module configuration).
 1.3.56.2 08-Mar-2018  pgoyette Clean up compat routine vectors
 1.3.56.1 08-Mar-2018  pgoyette Implement vector initialization for ifreqo2n and ifdatareq
 1.5.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.2.1 10-Jun-2019  christos Sync with HEAD
 1.8.4.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.10.2.1 29-Feb-2020  ad Sync with head.
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 06-Apr-2016  roy branches: 1.1.2; 1.1.18; 1.1.20; 1.1.22;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.
 1.1.22.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.6 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.20.5 18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.1.20.4 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.1.20.3 15-Oct-2018  pgoyette Convert the compat70_unp_addsockcred hook to the MP-safe mechanism.

XXX One more remaining: sysvipc50_sysctl
 1.1.20.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.20.1 08-Mar-2018  pgoyette No need to compile conditionally, since it won't be compiled at all
unless requested.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 06-Apr-2016  jdolecek file uipc_usrreq_70.c was added on branch tls-maxphys on 2017-12-03 11:36:53 +0000
 1.1.2.2 22-Apr-2016  skrll Sync with HEAD
 1.1.2.1 06-Apr-2016  skrll file uipc_usrreq_70.c was added on branch nick-nhusb on 2016-04-22 15:44:12 +0000
 1.1 29-Mar-2018  pgoyette branches: 1.1.2;
file usb_30_subr.c was initially added on branch pgoyette-compat.
 1.1.2.2 29-Mar-2018  pgoyette Rename usb_30_subr.c --> usb_subr_30.c for consistency with others
 1.1.2.1 29-Mar-2018  pgoyette Split out the usb compat_30 code and add it to the module
 1.7 31-Jul-2023  christos Don't call versioned stuff "old". Follow the naming convention for versioning
and name them after the last version of the OS they appeared on.
 1.6 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.5 26-Sep-2019  christos fix sign-compare issues.
 1.4 01-Mar-2019  pgoyette branches: 1.4.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 29-Mar-2018  pgoyette branches: 1.1.2;
file usb_subr_30.c was initially added on branch pgoyette-compat.
 1.1.2.7 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.6 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.1.2.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.4 23-Sep-2018  pgoyette Don't try to include usb_verbose.h - it might not exist on platforms
that don't have USB!

It turns out that nothing uses it any.
 1.1.2.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.2 18-Sep-2018  pgoyette Split the COMPAT_CALL_HOOK to separate the declaration from the
implementation. Some hooks are called from multiple source files,
and the old method resulted in duplicate implementations.

Implement MP-safe hooks for the usb_subr_30 code. Pass the helper
functions as arguments to the compat code so it does not have to
determine if the kernel contains usb code.
 1.1.2.1 29-Mar-2018  pgoyette Rename usb_30_subr.c --> usb_subr_30.c for consistency with others
 1.4.4.4 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 01-Mar-2019  christos file usb_subr_30.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.3 05-Sep-2020  riastradh Round of uvm.h cleanup.

The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
to query whether curlwp is the pagedaemon, which should maybe be
exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
by it. We should split up uvm_extern.h but this will serve for now
to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
UVMHIST(ubchist), since ubchist is declared in uvm.h but the
reference evaporates if UVMHIST is not defined, so we reduce header
file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
here.

ok chs@
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 15-Mar-2018  christos branches: 1.1.2; 1.1.4;
add uvm swap compat code.
 1.1.4.1 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.2.1 15-Mar-2018  pgoyette file uvm_13.c was added on branch pgoyette-compat on 2018-03-15 09:12:05 +0000
 1.3 05-Sep-2020  riastradh Round of uvm.h cleanup.

The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
to query whether curlwp is the pagedaemon, which should maybe be
exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
by it. We should split up uvm_extern.h but this will serve for now
to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
UVMHIST(ubchist), since ubchist is declared in uvm.h but the
reference evaporates if UVMHIST is not defined, so we reduce header
file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
here.

ok chs@
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 15-Mar-2018  christos branches: 1.1.2; 1.1.4;
add uvm swap compat code.
 1.1.4.1 10-Jun-2019  christos Sync with HEAD
 1.1.2.3 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.2.1 15-Mar-2018  pgoyette file uvm_50.c was added on branch pgoyette-compat on 2018-03-15 09:12:05 +0000
 1.1 13-Mar-2018  pgoyette branches: 1.1.2;
file uvm_stats_13.c was initially added on branch pgoyette-compat.
 1.1.2.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.2.1 13-Mar-2018  pgoyette Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.
 1.1 13-Mar-2018  pgoyette branches: 1.1.2;
file uvm_stats_13.h was initially added on branch pgoyette-compat.
 1.1.2.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.2.1 13-Mar-2018  pgoyette Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.
 1.1 13-Mar-2018  pgoyette branches: 1.1.2;
file uvm_stats_50.c was initially added on branch pgoyette-compat.
 1.1.2.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.2.1 13-Mar-2018  pgoyette Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.
 1.1 13-Mar-2018  pgoyette branches: 1.1.2;
file uvm_stats_50.h was initially added on branch pgoyette-compat.
 1.1.2.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.2.1 13-Mar-2018  pgoyette Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 01-Mar-2019  pgoyette branches: 1.4.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 14-Mar-2018  pgoyette branches: 1.1.2;
file vfs_syscalls_10.c was initially added on branch pgoyette-compat.
 1.1.2.5 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.4 15-Oct-2018  pgoyette Convert the openat_10 hook to use the MP-safe mechanism

XXX Still to do: compat70_unp_addsockcred and sysvipc50_sysctl
 1.1.2.3 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.2 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.1.2.1 14-Mar-2018  pgoyette Make do_openat()'s handling of path=NULL modular
 1.4.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 01-Mar-2019  christos file vfs_syscalls_10.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.38 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.37 27-Jan-2019  pgoyette branches: 1.37.4;
Merge the [pgoyette-compat] branch
 1.36 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.35 03-Dec-2017  christos branches: 1.35.2; 1.35.4;
Make code look the same, in particular zero out the rest of the directory
record.
XXX: pullup-8
 1.34 28-Jul-2017  riastradh Fail, don't panic, on bad dirents from file system.

Controllable via puffs from userland.

From Ilja Van Sprundel.
 1.33 13-Jan-2017  christos branches: 1.33.8;
use bdp, to avoid compiler warning.
 1.32 13-Jan-2017  christos convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
 1.31 05-Sep-2014  matt branches: 1.31.2; 1.31.4;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.30 24-Jan-2014  christos branches: 1.30.4; 1.30.6; 1.30.10;
It is wishful thinking that vn_readdir will return dirent12 structures.
 1.29 19-Jan-2011  tsutsui branches: 1.29.6; 1.29.12; 1.29.16; 1.29.18; 1.29.20; 1.29.26;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.28 26-Jan-2009  njoly branches: 1.28.6; 1.28.8;
Make all fstat(2) compat syscalls consistently use do_sys_fstat(),
instead of fd_getfile()/fd_putfile() dance.

ok by christos.
 1.27 11-Jan-2009  christos merge christos-time_t
 1.26 24-Jun-2008  ad branches: 1.26.4;
Replace references to getsock/getvnode.
 1.25 21-Mar-2008  ad branches: 1.25.2; 1.25.6; 1.25.8; 1.25.10;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.24 20-Dec-2007  dsl branches: 1.24.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.23 12-Dec-2007  dsl compat_file.[ch] are no longer used
 1.22 30-Apr-2007  dsl branches: 1.22.8; 1.22.16; 1.22.18; 1.22.20;
Rework compat stat() and statvfs() code so that it no longer uses the stackgap.
 1.21 10-Mar-2007  dsl branches: 1.21.2; 1.21.4;
Use the support routines from kern_syscalls.c instead of rolling our own code.
 1.20 09-Feb-2007  ad branches: 1.20.2;
Merge newlock2 to head.
 1.19 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 11-Dec-2005  christos branches: 1.17.20; 1.17.22;
merge ktrace-lwp.
 1.16 13-Sep-2005  christos compat code reorg.
 1.15 19-Nov-2003  christos branches: 1.15.16;
Don't include malloc.h if you are not going to use it.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.13 29-Jun-2003  fvdl branches: 1.13.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.12 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.11 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.10 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.9 14-Jun-2001  thorpej branches: 1.9.2;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.8 09-Apr-2001  jdolecek Change the first arg to fileops fo_stat routine to struct file *, adjust
callers and appropriate routines to cope. This makes fo_stat more
consistent with rest of fileops routines and also makes the fo_stat
match FreeBSD as an added bonus.
Discussed with Luke Mewburn on tech-kern@.
 1.7 07-Apr-2001  jdolecek Add new 'stat' fileop and call the stat function via f_ops rather
than directly.
For compat syscalls, also add necessary FILE_USE()/FILE_UNUSE().
Now that soo_stat() gets a proc arg, pass it on to usrreq function.
 1.6 30-Mar-2000  augustss branches: 1.6.6;
Kill register declarations.
 1.5 05-May-1999  thorpej branches: 1.5.2;
Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
 1.4 30-Mar-1999  wrstuden branches: 1.4.4;
Explicitly mask mode returned in old stat structure to 16 bits. Also correct
comment (we're converting from a new to an old struct stat).
 1.3 19-Oct-1997  mycroft Copy the whole timespec, not just half of it. Other minor changes.
 1.2 16-Oct-1997  christos add stat12 compatibility calls and rename ostat to stat43
 1.1 10-Oct-1997  fvdl branches: 1.1.2;
Add getdirentries backward compat syscall. Provide common function to
signal cookie overflow during emulated getdents and friends.
 1.1.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 10-Oct-1997  thorpej file vfs_syscalls_12.c was added on branch marc-pcmcia on 1997-10-14 10:21:17 +0000
 1.4.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.6.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.6.6.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.6.6.4 14-Nov-2001  nathanw Catch up to -current.
 1.6.6.3 21-Jun-2001  nathanw Catch up to -current.
 1.6.6.2 09-Apr-2001  nathanw Catch up with -current.
 1.6.6.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.9.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.2 03-Aug-2004  skrll Sync with HEAD
 1.13.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.15.16.5 24-Mar-2008  yamt sync with head.
 1.15.16.4 21-Jan-2008  yamt sync with head
 1.15.16.3 03-Sep-2007  yamt sync with head.
 1.15.16.2 26-Feb-2007  yamt sync with head.
 1.15.16.1 21-Jun-2006  yamt sync with head.
 1.17.22.2 10-Dec-2006  yamt sync with head.
 1.17.22.1 22-Oct-2006  yamt sync with head
 1.17.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.17.20.1 18-Nov-2006  ad Sync with head.
 1.20.2.2 07-May-2007  yamt sync with head.
 1.20.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.21.4.1 11-Jul-2007  mjf Sync with head.
 1.21.2.1 27-May-2007  ad Sync with head.
 1.22.20.2 02-Jan-2008  bouyer Sync with HEAD
 1.22.20.1 13-Dec-2007  bouyer Sync with HEAD
 1.22.18.1 13-Dec-2007  yamt sync with head.
 1.22.16.1 26-Dec-2007  ad Sync with head.
 1.22.8.1 09-Jan-2008  matt sync with HEAD
 1.24.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.24.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.24.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.10.1 27-Jun-2008  simonb Sync with head.
 1.25.8.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.25.8.2 14-May-2008  wrstuden 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.
 1.25.8.1 10-May-2008  wrstuden 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.
 1.25.6.1 04-May-2009  yamt sync with head.
 1.25.2.2 01-Nov-2008  christos Sync with head.
 1.25.2.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.26.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.26.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.28.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.6.1 05-Mar-2011  rmind sync with head
 1.29.26.2 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.29.26.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/compat/common/vfs_syscalls_12.c: revision 1.30
sys/compat/common/vfs_syscalls_43.c: revision 1.56
sys/compat/sys/dirent.h: revision 1.3
It is wishful thinking that vn_readdir will return dirent12 structures.
--
Fix the compat-4.3 getdirentries call (pre d_type). This is used in NetBSD-0.9.
--
add a struct for the 4.3BSD struct direct
 1.29.20.1 18-May-2014  rmind sync with head
 1.29.18.2 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.29.18.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/compat/common/vfs_syscalls_12.c: revision 1.30
sys/compat/common/vfs_syscalls_43.c: revision 1.56
sys/compat/sys/dirent.h: revision 1.3
It is wishful thinking that vn_readdir will return dirent12 structures.
--
Fix the compat-4.3 getdirentries call (pre d_type). This is used in NetBSD-0.9.
--
add a struct for the 4.3BSD struct direct
 1.29.16.2 03-Dec-2017  jdolecek update from HEAD
 1.29.16.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.12.2 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.29.12.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/compat/common/vfs_syscalls_12.c: revision 1.30
sys/compat/common/vfs_syscalls_43.c: revision 1.56
sys/compat/sys/dirent.h: revision 1.3
It is wishful thinking that vn_readdir will return dirent12 structures.
--
Fix the compat-4.3 getdirentries call (pre d_type). This is used in NetBSD-0.9.
--
add a struct for the 4.3BSD struct direct
 1.29.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.30.10.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.30.6.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.30.4.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.31.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.31.2.2 28-Aug-2017  skrll Sync with HEAD
 1.31.2.1 05-Feb-2017  skrll Sync with HEAD
 1.33.8.3 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.33.8.2 10-Dec-2017  snj Pull up following revision(s) (requested by christos in ticket #418):
sys/compat/common/vfs_syscalls_12.c: revision 1.35
sys/compat/common/vfs_syscalls_43.c: revision 1.62
Make code look the same, in particular zero out the rest of the directory
record.
 1.33.8.1 09-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #193):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.35.4.1 10-Jun-2019  christos Sync with HEAD
 1.35.2.3 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.35.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.35.2.1 31-Mar-2018  pgoyette create the compat_12 module
 1.37.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.46 28-Jun-2020  christos Fix struct entry size (thanks kre@)
 1.45 17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.44 04-Oct-2019  christos branches: 1.44.2;
deduplicate the conversion function from statvfs -> statfs12
 1.43 26-Sep-2019  christos fix sign-compare issues.
 1.42 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.41 27-Jan-2019  pgoyette branches: 1.41.4;
Merge the [pgoyette-compat] branch
 1.40 13-Apr-2017  hannken branches: 1.40.10; 1.40.12;
Switch compat_20_sys_getfsstat() to mountlist iterator.
 1.39 24-Jul-2015  maxv branches: 1.39.2; 1.39.4;
Unused inits (harmless).

Found by Brainy.
 1.38 05-Sep-2014  matt branches: 1.38.2;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.37 27-Nov-2013  christos Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
 1.36 23-Nov-2013  christos change the mountlist CIRCLEQ into a TAILQ
 1.35 24-Jun-2010  hannken branches: 1.35.8; 1.35.18; 1.35.22;
Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.34 29-Jun-2009  dholland branches: 1.34.2; 1.34.4;
Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.33 20-Nov-2008  ad branches: 1.33.4;
PR port-amd64 modules/compat missing symbols on amd64

Also, test for compat_??_machdep.c so we don't have to grow more ifdefs
in the makefile.
 1.32 14-Nov-2008  ad _KERNEL_OPT
 1.31 24-Jun-2008  ad branches: 1.31.2; 1.31.4;
Replace references to getsock/getvnode.
 1.30 06-May-2008  ad branches: 1.30.2; 1.30.4;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
 1.29 05-May-2008  ad Remove unneeded includes.
 1.28 30-Apr-2008  ad PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.
 1.27 29-Apr-2008  ad kern/38135 vfs_busy/vfs_trybusy confusion

The symptom was that sometimes file systems would occasionally not appear
in output from 'df' or 'mount' if the system was busy. Resolution:

- Make mount locks work somewhat like vm_map locks.
- vfs_trybusy() now only fails if the mount is gone, or if someone is
unmounting the file system. Simple contention on mnt_lock doesn't
cause it to fail.
- vfs_busy() will wait even if the file system is being unmounted.
 1.26 21-Mar-2008  ad branches: 1.26.2; 1.26.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.25 30-Jan-2008  ad branches: 1.25.6;
PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.
 1.24 07-Jan-2008  ad Don't drop vnode refs until we are done with the mount.
 1.23 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.22 08-Dec-2007  pooka branches: 1.22.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.21 08-Dec-2007  dsl ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.20 26-Nov-2007  pooka branches: 1.20.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.19 01-Nov-2007  oster branches: 1.19.2;
This should be a mutex_enter() instead of a mutex_exit().
Fixes:
Mutex error: mutex_vector_exit: assertion failed: MUTEX_OWNER(mtx->mtx_owner) == curthread
...
mutex_abort(c0aba23c,c07bf8b0,c09c9164,bfbfee34,10) at netbsd:mutex_abort+0x36
mutex_vector_exit(c0aba23c,10,c0aba23c,ca8efc6c,ca8f8540) at netbsd:mutex_vector_exit+0xe2
compat_20_sys_getfsstat(ca8f8540,cb243c48,cb243c68,805eb24,805e000) at netbsd:compat_20_sys_getfsstat+0x1bf
...
 1.18 10-Oct-2007  ad branches: 1.18.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
 1.17 22-Apr-2007  dsl branches: 1.17.6; 1.17.8; 1.17.10;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.16 09-Feb-2007  ad branches: 1.16.2; 1.16.6; 1.16.8;
Merge newlock2 to head.
 1.15 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.14 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 23-Jul-2006  ad branches: 1.12.4; 1.12.6;
Use the LWP cached credentials where sane.
 1.11 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.10 30-Jun-2006  drochner -fix for previous: don't malloc() with spinlock held
-wrap some long lines
 1.9 12-Jun-2006  christos branches: 1.9.2;
stack police: don't allocate statvfs on the stack.
 1.8 14-May-2006  elad branches: 1.8.2;
integrate kauth.
 1.7 07-Mar-2006  thorpej branches: 1.7.2; 1.7.4;
Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8;
merge ktrace-lwp.
 1.5 13-Sep-2005  christos compat code reorg.
 1.4 26-Feb-2005  perry branches: 1.4.4;
nuke trailing whitespace
 1.3 22-May-2004  christos branches: 1.3.2; 1.3.6; 1.3.8;
grr, forgot to take out the &
 1.2 22-May-2004  christos allocate memory for statvfs instead of using the stack.
 1.1 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.3.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.6.1 29-Apr-2005  kent sync with -current
 1.3.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.3.2.2 03-Aug-2004  skrll Sync with HEAD
 1.3.2.1 22-May-2004  skrll file vfs_syscalls_20.c was added on branch ktrace-lwp on 2004-08-03 10:43:29 +0000
 1.4.4.10 24-Mar-2008  yamt sync with head.
 1.4.4.9 04-Feb-2008  yamt sync with head.
 1.4.4.8 21-Jan-2008  yamt sync with head
 1.4.4.7 07-Dec-2007  yamt sync with head
 1.4.4.6 15-Nov-2007  yamt sync with head.
 1.4.4.5 27-Oct-2007  yamt sync with head.
 1.4.4.4 03-Sep-2007  yamt sync with head.
 1.4.4.3 26-Feb-2007  yamt sync with head.
 1.4.4.2 30-Dec-2006  yamt sync with head.
 1.4.4.1 21-Jun-2006  yamt sync with head.
 1.6.8.4 11-Aug-2006  yamt sync with head
 1.6.8.3 26-Jun-2006  yamt sync with head.
 1.6.8.2 24-May-2006  yamt sync with head.
 1.6.8.1 13-Mar-2006  yamt sync with head.
 1.6.6.2 01-Jun-2006  kardel Sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.4.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.2.4 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.7.2.3 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.7.2.2 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.7.2.1 07-Mar-2006  elad file vfs_syscalls_20.c was added on branch elad-kernelauth on 2006-03-08 01:48:37 +0000
 1.8.2.1 19-Jun-2006  chap Sync with head.
 1.9.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.12.6.2 10-Dec-2006  yamt sync with head.
 1.12.6.1 22-Oct-2006  yamt sync with head
 1.12.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.12.4.1 18-Nov-2006  ad Sync with head.
 1.16.8.1 11-Jul-2007  mjf Sync with head.
 1.16.6.2 27-May-2007  ad Sync with head.
 1.16.6.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.16.2.1 07-May-2007  yamt sync with head.
 1.17.10.1 14-Oct-2007  yamt sync with head.
 1.17.8.3 23-Mar-2008  matt sync with HEAD
 1.17.8.2 09-Jan-2008  matt sync with HEAD
 1.17.8.1 06-Nov-2007  matt sync with HEAD
 1.17.6.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.17.6.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.17.6.2 04-Nov-2007  jmcneill Sync with HEAD.
 1.17.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.18.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.19.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.19.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.19.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.20.2.1 26-Dec-2007  ad Sync with head.
 1.22.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.22.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.25.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.25.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.25.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.25.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.4.4 11-Aug-2010  yamt sync with head.
 1.26.4.3 18-Jul-2009  yamt sync with head.
 1.26.4.2 04-May-2009  yamt sync with head.
 1.26.4.1 16-May-2008  yamt sync with head.
 1.26.2.1 18-May-2008  yamt sync with head.
 1.30.4.1 27-Jun-2008  simonb Sync with head.
 1.30.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.2.2 14-May-2008  wrstuden 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.
 1.30.2.1 10-May-2008  wrstuden 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.
 1.31.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.31.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.33.4.1 23-Jul-2009  jym Sync with HEAD.
 1.34.4.1 03-Jul-2010  rmind sync with head
 1.34.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.35.22.1 18-May-2014  rmind sync with head
 1.35.18.2 03-Dec-2017  jdolecek update from HEAD
 1.35.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.38.2.2 28-Aug-2017  skrll Sync with HEAD
 1.38.2.1 22-Sep-2015  skrll Sync with HEAD
 1.39.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.39.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.40.12.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.40.12.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.40.12.1 10-Jun-2019  christos Sync with HEAD
 1.40.10.1 30-Mar-2018  pgoyette Create and build the compat_20 module
 1.41.4.1 03-Aug-2022  martin Apply patch, requested by riastradh in ticket #1487:

sys/compat/common/vfs_syscalls_20.c (apply patch)

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.44.2.1 17-Jan-2020  ad Sync with head.
 1.45 12-Mar-2022  riastradh compat_30: Fix thinko in previous.

Let's not go into an infinite loop of stack smashing!
 1.44 12-Mar-2022  riastradh compat_30: Avoid what might be technically undefined behaviour.

Not sure advancing a user pointer by one for the purpose of making an
equality test fail later on is actually likely to be a problem, but
let's just pacify the sanitizer.

Reported-by: syzbot+758b18164c5c444f4249@syzkaller.appspotmail.com
 1.43 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.42 15-Aug-2021  christos - memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.41 31-Jan-2020  maxv Fix copyout overflows in fhstat, found by the LGTM bot. Not a big problem
since this syscall is privileged.
 1.40 17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.39 22-Sep-2019  christos branches: 1.39.2;
Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.38 27-Jan-2019  pgoyette branches: 1.38.4;
Merge the [pgoyette-compat] branch
 1.37 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.36 20-Oct-2014  christos branches: 1.36.12; 1.36.18; 1.36.20;
simplify
 1.35 20-Oct-2014  maxv Memory leak, triggerable from root only.

Found by my code scanner.

ok christos@
 1.34 05-Sep-2014  matt Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.33 19-Nov-2010  dholland branches: 1.33.18; 1.33.34;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.32 24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.31 03-Mar-2010  he branches: 1.31.2;
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.

This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.

Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.30 26-Jan-2009  njoly branches: 1.30.4;
Make all fstat(2) compat syscalls consistently use do_sys_fstat(),
instead of fd_getfile()/fd_putfile() dance.

ok by christos.
 1.29 11-Jan-2009  christos merge christos-time_t
 1.28 24-Jun-2008  ad branches: 1.28.4; 1.28.6; 1.28.12;
Replace references to getsock/getvnode.
 1.27 28-Apr-2008  martin branches: 1.27.2; 1.27.4;
Remove clause 3 and 4 from TNF licenses
 1.26 21-Mar-2008  ad branches: 1.26.2; 1.26.4; 1.26.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.25 20-Dec-2007  dsl branches: 1.25.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.24 08-Dec-2007  pooka branches: 1.24.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.23 30-Apr-2007  dsl branches: 1.23.6; 1.23.8; 1.23.16;
Split the statvfs functions so that the 'work' is done to a kernel buffer
which can either be copied directly to userspace, or converted then copied.
Saves replicating a lot of code in the compat functions (esp. for
getvfsstat) at a cast of an extra function call in the non-emulated case -
which is unlikely to be measurable given the other costs of the actions
involved (even on vax).
Remove dofhstat() and dofhstatvfs() (and the last caller).
Remove some redundant stackgap_init() calls.
 1.22 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.21 10-Mar-2007  dsl branches: 1.21.2; 1.21.4;
Use the support routines from kern_syscalls.c instead of rolling our own code.
 1.20 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 09-Feb-2007  ad branches: 1.19.2;
Merge newlock2 to head.
 1.18 16-Nov-2006  christos branches: 1.18.2;
__unused removal on arguments; approved by core.
 1.17 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 04-Aug-2006  yamt branches: 1.15.4; 1.15.6;
compat_30_sys_getfh: check the size of filehandle. remove an unnecessary cast.
 1.14 04-Aug-2006  yamt some filehandle syscall related changes.

- remove the support of variable-sized filehandle from compat version of
syscalls. (strictly speaking, it breaks abi. i don't think it's a problem
because this feature is short-lived and there are no affected in-tree
filesystems.)
- unify vfs_copyinfh_alloc and vfs_copyinfh_alloc_size.
- vfs_copyinfh_alloc_size: check fhsize strictly.
- reduce code duplication between compat and current syscalls.
 1.13 31-Jul-2006  martin Make filehandles opaque to userland
 1.12 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.11 13-Jul-2006  yamt compat_30_sys_getfh: s/fhandle_t/struct compat_30_fhandle/ (fix overrun.)
 1.10 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.9 14-May-2006  elad branches: 1.9.4; 1.9.6;
integrate kauth.
 1.8 04-May-2006  christos fhstat needs to be versioned too (for ino_t). Pointed out by Izumi Tsutsui
 1.7 01-Mar-2006  yamt branches: 1.7.2; 1.7.4; 1.7.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.6 11-Dec-2005  christos branches: 1.6.2; 1.6.4; 1.6.6;
merge ktrace-lwp.
 1.5 13-Sep-2005  christos branches: 1.5.6;
compat code reorg.
 1.4 19-Aug-2005  yamt compat_30_sys_getdents: netbsd 1.2 -> 3.0 in comments/messages.
 1.3 19-Aug-2005  yamt compat_30_sys_getdents: don't leak kernel stack garbage to userland.
 1.2 19-Aug-2005  christos change a hard-coded 0xf to _DIRENT_ALIGN (thanks yamt)
 1.1 19-Aug-2005  christos 64 bit inode changes.
 1.5.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.1 13-Sep-2005  skrll file vfs_syscalls_30.c was added on branch ktrace-lwp on 2005-11-10 14:00:40 +0000
 1.6.6.2 01-Jun-2006  kardel Sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.6.2.1 31-Dec-2005  yamt adapt some random parts of kernel to uio_vmspace.
 1.7.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.4.2 12-May-2006  elad adapt to kauth kpi, include sys/kauth.h where needed..
 1.7.4.1 11-May-2006  elad sync with head
 1.7.2.2 11-Aug-2006  yamt sync with head
 1.7.2.1 24-May-2006  yamt sync with head.
 1.9.6.7 24-Mar-2008  yamt sync with head.
 1.9.6.6 21-Jan-2008  yamt sync with head
 1.9.6.5 03-Sep-2007  yamt sync with head.
 1.9.6.4 26-Feb-2007  yamt sync with head.
 1.9.6.3 30-Dec-2006  yamt sync with head.
 1.9.6.2 21-Jun-2006  yamt sync with head.
 1.9.6.1 14-May-2006  yamt file vfs_syscalls_30.c was added on branch yamt-lazymbuf on 2006-06-21 14:58:32 +0000
 1.9.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.15.6.2 10-Dec-2006  yamt sync with head.
 1.15.6.1 22-Oct-2006  yamt sync with head
 1.15.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.15.4.1 18-Nov-2006  ad Sync with head.
 1.18.2.1 12-Jun-2010  riz Pull up following revision(s) (requested by he in ticket #1387):
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/osf1/osf1_file.c: revision 1.38
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.19.2.2 07-May-2007  yamt sync with head.
 1.19.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.21.4.1 11-Jul-2007  mjf Sync with head.
 1.21.2.1 27-May-2007  ad Sync with head.
 1.23.16.1 26-Dec-2007  ad Sync with head.
 1.23.8.1 09-Jan-2008  matt sync with HEAD
 1.23.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.24.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.25.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.25.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.25.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.25.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.6.4 11-Aug-2010  yamt sync with head.
 1.26.6.3 11-Mar-2010  yamt sync with head
 1.26.6.2 04-May-2009  yamt sync with head.
 1.26.6.1 16-May-2008  yamt sync with head.
 1.26.4.1 18-May-2008  yamt sync with head.
 1.26.2.3 09-Nov-2008  christos fix fhstat.
 1.26.2.2 01-Nov-2008  christos Sync with head.
 1.26.2.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.27.4.1 27-Jun-2008  simonb Sync with head.
 1.27.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.27.2.2 14-May-2008  wrstuden 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.
 1.27.2.1 10-May-2008  wrstuden 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.
 1.28.12.1 21-Apr-2010  matt sync to netbsd-5
 1.28.6.1 17-Mar-2010  snj Pull up following revision(s) (requested by he in ticket #1323):
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.28.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.28.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.30.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.30.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.31.2.2 05-Mar-2011  rmind sync with head
 1.31.2.1 03-Jul-2010  rmind sync with head
 1.33.34.1 29-Dec-2014  martin Pull up following revision(s) (requested by maxv in ticket #353):
sys/ufs/chfs/chfs_vfsops.c: revision 1.12
sys/compat/common/vfs_syscalls_30.c: revision 1.35
sys/compat/linux/common/linux_uselib.c: revision 1.31
sys/compat/linux/common/linux_uselib.c: revision 1.32
Resource leak.
Memory leaks.
Reject non-regular files.
 1.33.18.1 03-Dec-2017  jdolecek update from HEAD
 1.36.20.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.36.20.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.36.20.1 10-Jun-2019  christos Sync with HEAD
 1.36.18.3 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.36.18.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.36.18.1 28-Mar-2018  pgoyette Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*
 1.36.12.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.36.12.1 15-Aug-2021  martin Pull up following revision(s) (requested by christos in ticket #1691):

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.38.4.2 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.38.4.1 15-Aug-2021  martin Pull up following revision(s) (requested by christos in ticket #1337):

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.39.2.2 29-Feb-2020  ad Sync with head.
 1.39.2.1 17-Jan-2020  ad Sync with head.
 1.5 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.4 23-Oct-2015  maxv branches: 1.4.16; 1.4.18;
Change do_sys_mount() so that it only takes as argument the type of the
drive instead of its associated vfsops. Makes it more friendly, and allows
compat binaries to autoload VFS modules if needed.

sent on tech-kern@, ok christos@
 1.3 19-Jan-2011  tsutsui branches: 1.3.16; 1.3.34;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.2 16-Nov-2008  martin branches: 1.2.4; 1.2.6; 1.2.8; 1.2.12; 1.2.16; 1.2.18;
Make it compile
 1.1 14-Nov-2008  ad - Move some more compat code into sys/compat.
- Split 4.3BSD ifioctl stuff into its own file.
- Remove some ifdefs that include small fragments of vfs compat code
which are difficult to relocate elsewhere.
 1.2.18.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.16.1 05-Mar-2011  rmind sync with head
 1.2.12.2 04-May-2009  yamt sync with head.
 1.2.12.1 16-Nov-2008  yamt file vfs_syscalls_40.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:17 +0000
 1.2.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.8.1 16-Nov-2008  skrll file vfs_syscalls_40.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.2.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.6.1 16-Nov-2008  mjf file vfs_syscalls_40.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.2.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.4.1 16-Nov-2008  haad file vfs_syscalls_40.c was added on branch haad-dm on 2008-12-13 01:13:47 +0000
 1.3.34.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.16.1 03-Dec-2017  jdolecek update from HEAD
 1.4.18.1 10-Jun-2019  christos Sync with HEAD
 1.4.16.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.4.16.1 27-Mar-2018  pgoyette Create a compat_40 module
 1.68 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.67 15-Aug-2021  christos - memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.66 24-Jun-2020  jdolecek remove special handling for symbolic links for COMPAT_43 lstat, it's
not necessary; this removes the only places in kernel which did namei
LOOKUP with LOCKPARENT

fixes diagnostic KASSERT() in namei() code

Reported-by: syzbot+628382ecf1438e53d08d@syzkaller.appspotmail.com
 1.65 27-Feb-2020  pgoyette Include all of the vfs syscalls in the syscall_package, not just oquota.

Should fix PR kern/55025

XXX pullup-9
 1.64 27-Jan-2019  pgoyette branches: 1.64.4; 1.64.6;
Merge the [pgoyette-compat] branch
 1.63 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.62 03-Dec-2017  christos branches: 1.62.2; 1.62.4;
Make code look the same, in particular zero out the rest of the directory
record.
XXX: pullup-8
 1.61 29-Jul-2017  riastradh Declare mountcompatnames in sys/vfs_syscalls.h to kill nested extern.
 1.60 28-Jul-2017  riastradh Fail, don't panic, on bad dirents from file system.

Controllable via puffs from userland.

From Ilja Van Sprundel.
 1.59 13-Jan-2017  christos branches: 1.59.8;
convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
 1.58 20-Aug-2016  mrg fill in the tv_nsec parts of the converted timespec in cvtstat().
 1.57 05-Sep-2014  matt branches: 1.57.2; 1.57.4;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.56 28-Jan-2014  christos branches: 1.56.4; 1.56.6;
Fix the compat-4.3 getdirentries call (pre d_type). This is used in NetBSD-0.9.
 1.55 21-Feb-2013  pgoyette branches: 1.55.2;
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.

OK christos@

Will request pull-up to 6.0 in a few days.
 1.54 19-Nov-2010  dholland branches: 1.54.8; 1.54.14; 1.54.18; 1.54.20;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.53 24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.52 02-Mar-2010  pooka branches: 1.52.2;
fs_union.h is not used here anymore ... diudau
 1.51 08-Jan-2010  pooka branches: 1.51.2;
The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase). Plenty of mix'n match upper/lowercase has creeped
into the tree since then. Nuke the macros and convert all callsites
to lowercase.

no functional change
 1.50 17-Mar-2009  dyoung Add #include "opt_compat_netbsd.h" for COMPAT_09.
 1.49 26-Jan-2009  njoly branches: 1.49.2;
Make all fstat(2) compat syscalls consistently use do_sys_fstat(),
instead of fd_getfile()/fd_putfile() dance.

ok by christos.
 1.48 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.47 24-Jun-2008  ad branches: 1.47.2; 1.47.4;
Replace references to getsock/getvnode.
 1.46 21-Mar-2008  ad branches: 1.46.4; 1.46.6; 1.46.8;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.45 20-Dec-2007  dsl branches: 1.45.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.44 08-Dec-2007  pooka branches: 1.44.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.43 08-Dec-2007  dsl ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.42 04-Dec-2007  dsl Remove all the __P
 1.41 26-Nov-2007  pooka branches: 1.41.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.40 10-Oct-2007  ad branches: 1.40.4;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
 1.39 17-Jul-2007  christos branches: 1.39.6; 1.39.8; 1.39.10;
MFSNAMELEN only belongs in compat.
 1.38 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.37 10-Mar-2007  dsl branches: 1.37.2; 1.37.4;
Use the support routines from kern_syscalls.c instead of rolling our own code.
 1.36 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 09-Feb-2007  ad branches: 1.35.2;
Merge newlock2 to head.
 1.34 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.33 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.32 01-Mar-2006  yamt branches: 1.32.14; 1.32.16;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.31 11-Dec-2005  christos branches: 1.31.2; 1.31.4; 1.31.6;
merge ktrace-lwp.
 1.30 13-Sep-2005  christos compat code reorg.
 1.29 26-Feb-2005  perry branches: 1.29.4;
nuke trailing whitespace
 1.28 15-Aug-2004  mycroft branches: 1.28.4; 1.28.6;
Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

Add 3 new elements to ufsmount:
* um_maxsymlinklen, replaces mnt_maxsymlinklen (which never should have existed
in the first place).
* um_dirblksiz, which tracks the current directory block size, eliminating the
FS-specific checks littered throughout the code. This may be used later to
make the block size variable.
* um_maxfilesize, which is the maximum file size, possibly adjusted lower due
to implementation issues.

Sync some bug fixes from FFS into ext2fs, particularly:
* ffs_lookup.c 1.21, 1.28, 1.33, 1.48
* ffs_inode.c 1.43, 1.44, 1.45, 1.66, 1.67
* ffs_vnops.c 1.84, 1.85, 1.86

Clean up some crappy pointer frobnication.
 1.27 19-Nov-2003  christos - don't use MALLOC for non constant counts
- check malloc() size.
 1.26 19-Nov-2003  christos Don't include malloc.h if you are not going to use it.
 1.25 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.24 29-Jun-2003  fvdl branches: 1.24.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.23 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.22 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.21 25-Nov-2002  thorpej Avoid strict-alias warnings.
 1.20 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.19 14-Jun-2001  thorpej branches: 1.19.2; 1.19.4;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.18 30-May-2001  mrg use _KERNEL_OPT.
 1.17 09-Apr-2001  jdolecek Change the first arg to fileops fo_stat routine to struct file *, adjust
callers and appropriate routines to cope. This makes fo_stat more
consistent with rest of fileops routines and also makes the fo_stat
match FreeBSD as an added bonus.
Discussed with Luke Mewburn on tech-kern@.
 1.16 07-Apr-2001  jdolecek Add new 'stat' fileop and call the stat function via f_ops rather
than directly.
For compat syscalls, also add necessary FILE_USE()/FILE_UNUSE().
Now that soo_stat() gets a proc arg, pass it on to usrreq function.
 1.15 29-Nov-2000  jdolecek branches: 1.15.2;
LKMify
 1.14 26-Jul-2000  pk lstat: since namei() returns an error (EISDIR) if there is no parent to lock,
retry the lookup without LOCKPARENT if that happens. This is safe, since
need to have LOCKPARENT only if the vnode is of type VLNK.
 1.13 30-Mar-2000  augustss Kill register declarations.
 1.12 05-May-1999  thorpej branches: 1.12.2;
Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
 1.11 30-Mar-1999  wrstuden branches: 1.11.4;
Explicitly mask mode returned in old stat structure to 16 bits. Also correct
comment (we're converting from a new to an old struct stat).
 1.10 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.9 19-Feb-1998  thorpej Include the UNION option header.
 1.8 16-Oct-1997  christos add stat12 compatibility calls and rename ostat to stat43
 1.7 10-Oct-1997  fvdl u_long -> off_t, I missed the big endian case. From Juergen Hannken-Illjes
 1.6 10-Oct-1997  fvdl Add getdirentries backward compat syscall. Provide common function to
signal cookie overflow during emulated getdents and friends.
 1.5 06-Jun-1997  christos branches: 1.5.4;
PR/3701: Arne H. Juul: olstat can't stat "/", because it still pretended
that symlinks don't have inodes.
 1.4 14-Mar-1996  christos Fix compiler warnings
 1.3 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.2 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.1 24-Jun-1995  christos - Extracted all compat routines from the kern directory and moved here.
- Created compat_util.c and compat_util.h to be used by the compatibility
modules, so they don't duplicate the same code.
- Added prototypes to the stackgap allocation routines.
 1.5.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.12.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.15.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.15.2.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.15.2.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.15.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.15.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.15.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.19.4.1 18-Sep-2001  fvdl Various changes to make cloning devices possible:

* Add an extra argument (struct vnode **) to VOP_OPEN. If it is
not NULL, specfs will create a cloned (aliased) vnode during
the call, and return it there. The caller should release and
unlock the original vnode if a new vnode was returned. The
new vnode is returned locked.

* Add a flag field to the cdevsw and bdevsw structures.
DF_CLONING indicates that it wants a new vnode for each
open (XXX is there a better way? devprop?)

* If a device is cloning, always call the close entry
point for a VOP_CLOSE.


Also, rewrite cons.c to do the right thing with vnodes. Use VOPs
rather then direct device entry calls. Suggested by mycroft@

Light to moderate testing done an i386 system (arch doesn't matter
though, these are MI changes).
 1.19.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.24.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.24.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.24.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.24.2.2 03-Aug-2004  skrll Sync with HEAD
 1.24.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.28.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.28.4.1 29-Apr-2005  kent sync with -current
 1.29.4.8 24-Mar-2008  yamt sync with head.
 1.29.4.7 21-Jan-2008  yamt sync with head
 1.29.4.6 07-Dec-2007  yamt sync with head
 1.29.4.5 27-Oct-2007  yamt sync with head.
 1.29.4.4 03-Sep-2007  yamt sync with head.
 1.29.4.3 26-Feb-2007  yamt sync with head.
 1.29.4.2 30-Dec-2006  yamt sync with head.
 1.29.4.1 21-Jun-2006  yamt sync with head.
 1.31.6.1 22-Apr-2006  simonb Sync with head.
 1.31.4.1 09-Sep-2006  rpaulo sync with head
 1.31.2.1 31-Dec-2005  yamt adapt some random parts of kernel to uio_vmspace.
 1.32.16.2 10-Dec-2006  yamt sync with head.
 1.32.16.1 22-Oct-2006  yamt sync with head
 1.32.14.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.32.14.1 18-Nov-2006  ad Sync with head.
 1.35.2.2 07-May-2007  yamt sync with head.
 1.35.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.4.1 11-Jul-2007  mjf Sync with head.
 1.37.2.4 20-Aug-2007  ad Sync with HEAD.
 1.37.2.3 17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.37.2.2 27-May-2007  ad Sync with head.
 1.37.2.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.39.10.1 14-Oct-2007  yamt sync with head.
 1.39.8.2 09-Jan-2008  matt sync with HEAD
 1.39.8.1 06-Nov-2007  matt sync with HEAD
 1.39.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.39.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.39.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.40.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.40.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.41.2.2 26-Dec-2007  ad Sync with head.
 1.41.2.1 08-Dec-2007  ad Sync with head.
 1.44.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.45.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.45.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.45.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.46.8.1 27-Jun-2008  simonb Sync with head.
 1.46.6.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.46.6.2 14-May-2008  wrstuden 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.
 1.46.6.1 10-May-2008  wrstuden 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.
 1.46.4.3 11-Aug-2010  yamt sync with head.
 1.46.4.2 11-Mar-2010  yamt sync with head
 1.46.4.1 04-May-2009  yamt sync with head.
 1.47.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.47.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.47.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.47.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.49.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.51.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.51.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.52.2.2 05-Mar-2011  rmind sync with head
 1.52.2.1 03-Jul-2010  rmind sync with head
 1.54.20.3 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.54.20.2 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/compat/common/vfs_syscalls_12.c: revision 1.30
sys/compat/common/vfs_syscalls_43.c: revision 1.56
sys/compat/sys/dirent.h: revision 1.3
It is wishful thinking that vn_readdir will return dirent12 structures.
--
Fix the compat-4.3 getdirentries call (pre d_type). This is used in NetBSD-0.9.
--
add a struct for the 4.3BSD struct direct
 1.54.20.1 27-Aug-2016  bouyer Pull up following revision(s) (requested by mrg in ticket #1400):
sys/compat/common/vfs_syscalls_43.c: revision 1.58
fill in the tv_nsec parts of the converted timespec in cvtstat().
 1.54.18.3 03-Dec-2017  jdolecek update from HEAD
 1.54.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.18.1 25-Feb-2013  tls resync with head
 1.54.14.4 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.54.14.3 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/compat/common/vfs_syscalls_12.c: revision 1.30
sys/compat/common/vfs_syscalls_43.c: revision 1.56
sys/compat/sys/dirent.h: revision 1.3
It is wishful thinking that vn_readdir will return dirent12 structures.
--
Fix the compat-4.3 getdirentries call (pre d_type). This is used in NetBSD-0.9.
--
add a struct for the 4.3BSD struct direct
 1.54.14.2 27-Aug-2016  bouyer Pull up following revision(s) (requested by mrg in ticket #1400):
sys/compat/common/vfs_syscalls_43.c: revision 1.58
fill in the tv_nsec parts of the converted timespec in cvtstat().
 1.54.14.1 14-Mar-2013  riz branches: 1.54.14.1.2;
Pull up following revision(s) (requested by pgoyette in ticket #837):
sys/compat/common/kern_time_50.c: revision 1.25
sys/kern/init_sysctl.c: revision 1.195
sys/kern/init_main.c: revision 1.447
sys/compat/common/compat_util.h: revision 1.23
sys/compat/common/compat_mod.h: revision 1.1
sys/compat/common/compat_mod.c: revision 1.16
sys/compat/common/compat_mod.c: revision 1.17
sys/compat/common/compat_mod.c: revision 1.18
sys/compat/common/vfs_syscalls_43.c: revision 1.55
Move boottime50 and its associated sysctl into the compat module. As
noted on tech-kern. Should fix PR/47579.
OK christos@
Will request pull-up to 6.0 in a few days.
Wrap sysctl_teardown(&compat_clog) with the appropriate #if defined()s
remove empty #if
 1.54.14.1.2.3 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.54.14.1.2.2 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/compat/common/vfs_syscalls_12.c: revision 1.30
sys/compat/common/vfs_syscalls_43.c: revision 1.56
sys/compat/sys/dirent.h: revision 1.3
It is wishful thinking that vn_readdir will return dirent12 structures.
--
Fix the compat-4.3 getdirentries call (pre d_type). This is used in NetBSD-0.9.
--
add a struct for the 4.3BSD struct direct
 1.54.14.1.2.1 27-Aug-2016  bouyer Pull up following revision(s) (requested by mrg in ticket #1400):
sys/compat/common/vfs_syscalls_43.c: revision 1.58
fill in the tv_nsec parts of the converted timespec in cvtstat().
 1.54.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.55.2.1 18-May-2014  rmind sync with head
 1.56.6.2 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.56.6.1 27-Aug-2016  bouyer Pull up following revision(s) (requested by mrg in ticket #1240):
sys/compat/common/vfs_syscalls_43.c: revision 1.58
fill in the tv_nsec parts of the converted timespec in cvtstat().
 1.56.4.2 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.56.4.1 27-Aug-2016  bouyer branches: 1.56.4.1.4;
Pull up following revision(s) (requested by mrg in ticket #1240):
sys/compat/common/vfs_syscalls_43.c: revision 1.58
fill in the tv_nsec parts of the converted timespec in cvtstat().
 1.56.4.1.4.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.57.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.57.2.3 28-Aug-2017  skrll Sync with HEAD
 1.57.2.2 05-Feb-2017  skrll Sync with HEAD
 1.57.2.1 05-Oct-2016  skrll Sync with HEAD
 1.59.8.4 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.59.8.3 15-Aug-2021  martin Pull up following revision(s) (requested by christos in ticket #1691):

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.59.8.2 10-Dec-2017  snj Pull up following revision(s) (requested by christos in ticket #418):
sys/compat/common/vfs_syscalls_12.c: revision 1.35
sys/compat/common/vfs_syscalls_43.c: revision 1.62
Make code look the same, in particular zero out the rest of the directory
record.
 1.59.8.1 09-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #193):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.62.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.62.4.1 10-Jun-2019  christos Sync with HEAD
 1.62.2.4 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.62.2.3 17-Apr-2018  pgoyette Finish separating the compat_09 and compat_43 stuff
 1.62.2.2 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.62.2.1 31-Mar-2018  pgoyette Only need to #include sysctl.h once
 1.64.6.1 29-Feb-2020  ad Sync with head.
 1.64.4.3 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.64.4.2 15-Aug-2021  martin Pull up following revision(s) (requested by christos in ticket #1337):

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.64.4.1 27-Feb-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #741):

sys/compat/common/vfs_syscalls_43.c: revision 1.65

Include all of the vfs syscalls in the syscall_package, not just oquota.
Should fix PR kern/55025

XXX pullup-9
 1.26 15-Aug-2021  christos - memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.25 21-Jan-2020  pgoyette Split the compat_50 module into two, separating the QUOTA-related
stuff from the rest of the module. This allows loading of the
(main) compat_50 module on kernels that don't include ``options
QUOTA''.

Welcome to 9.99.40 !

Addresses PR kern/54875
 1.24 15-Dec-2019  tsutsui branches: 1.24.2;
Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.23 18-Jun-2019  kamil branches: 1.23.2;
Drop unused retval pointer from do_sys_mknod{,at}()

No functional change intended.
 1.22 17-Jun-2019  christos Add QUOTA ifdef (Paul Goyette)
 1.21 17-Jun-2019  pgoyette Use tabs, not spaces, for indentation. NFCI
 1.20 17-Jun-2019  christos If we don't compile a kernel with QUOTA, we don't support the compat quota
syscalls. XXX: need to fix the modules build.
 1.19 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.18 05-Sep-2014  matt branches: 1.18.12; 1.18.18; 1.18.20;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.17 13-Mar-2012  elad branches: 1.17.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.16 01-Feb-2012  dholland Change the syscall API for quotas over to the new non-proplib one.

- struct vfs_quotactl_args -> struct quotactl_args
- add sys/stdint.h to sys/quotactl.h for clean userland build
- install sys/quotactl.h in /usr/include
- update set lists for same
- add new marshalling code in libquota
- add new unmarshalling code in vfs_syscalls.c
- discard proplib interpreter code in vfs_quotactl.c
- add dispatching code for the 14 quotactl ops in vfs_quotactl.c
- mark the proplib quotactl syscall obsolete
- add a new syscall number for the new quotactl syscall
- change the name of the syscall to __quotactl()
- remove the decl of the old quotactl from quota/quotaprop.h
- add a decl of the new quotactl to sys/quotactl.h
- update the libc build
- update ktruss
- remove proplib marshalling code from libquota
- update copy of syscall table in gdb ppc sources
- hack rumphijack to accomodate new quotactl name (as I recall,
pooka wanted such a name change to simplify something, but I
don't really see what/how)

This change appears to require a kernel version bump for rumpish
reasons.
 1.15 29-Jan-2012  dholland Some further tidying for the COMPAT_50 quotactl code. Mostly cosmetic,
but also use PNBUF_GET() and PNBUF_PUT() for a path buffer instead of
malloc with M_TEMP.
 1.14 29-Jan-2012  dholland Remove the proplib goop from the COMPAT_50 code for the old quotactl;
use the new VFS_QUOTACTL instead.
 1.13 29-Jan-2012  dholland Rename static inline "helper" functions:
ufsclass2qtype -> quota_idtype_to_ufs
qtype2ufsclass -> quota_idtype_from_ufs

The reason for the direction of "ufs" changing is that the old names
were among the symbols using "ufs" to mean "fs-independent". So the
old names were for translating "ufsclass" (fs-independent quota id
type) to "qtype" (ufs-specific quota id type) and vice versa.

These functions are used in only two places, both of which are
inappropriate, so at some point they should probably be removed.
They're also identity transformations so not particularly helpful,
unless one were to make a careful and concerted effort to distinguish
the ufs quota code numbers from the fs-independent ones. This has not
been done and is probably impossible without support from a program
verifier, and maybe not even then.

They are static inline, so no compat concerns arise.

Also adjust the symbols they use to avoid <quota/quotaprop.h>.
 1.12 29-Jan-2012  dholland Add vfs_quotactl() in between the syscall and VFS_QUOTACTL. Call it
from the COMPAT_50 code as well as the current sys_quotactl instead
of going directly to VFS_QUOTACTL. Doesn't actually do anything yet.
 1.11 29-Jan-2012  dholland Change dqblk_to_quotaval() from quota1_subr.c to dqblk_to_quotavals(),
and pass in two single quotaval structs (for blocks and inodes)
instead of an array of (implicitly) QUOTA_NLIMITS quotaval structs
indexed by constants from quotaprop.h.

Note: because this code is used by COMPAT_50 as well as ufs, this
change requires a kernel version bump. (The code is also used by
edquota, but via .PATH so it's not ABI-sensitive there.)
 1.10 25-Nov-2011  dholland branches: 1.10.2;
Rename struct ufs_quota_entry -> struct quotaval.
 1.9 20-Nov-2011  dholland Reshuffle decls among the quota headers so everything is in the place
it should be:
- stuff for the proplib interface goes in <quota/quotaprop.h>
- stuff for userlevel only goes in <quota/quota.h>
- stuff shared between user and kernel goes in <sys/quota.h>

Note that <quota/quota.h> and <quota/quotaprop.h> are expected to be
moved or removed later on... one thing at a time.

Update include directives in other files as needed.
 1.8 24-Mar-2011  bouyer branches: 1.8.4;
Add a new libquota library, which contains some blocks to build and/or
parse quota plists; as well as a getfsquota() function to retrieve quotas
for a single id from a single filesystem (whatever filesystem this is:
a local quota-enabled fs or NFS). This is build on functions getufsquota()
(for local filesystems with UFS-like quotas) and getnfsquota();
which are also available to userland programs.
move functions from quota2_subr.c to libquota or libprop as appropriate,
and ajust in-tree quota tools.
move some declarations from kernel headers to either sys/quota.h or
quota/quota.h as appropriate. ufs/ufs/quota.h still installed because
it's needed by other installed ufs headers.
ufs/ufs/quota1.h still installed as a quick&dirty way to get a code
using the old quotactl() to compile (just include ufs/ufs/quota1.h instead of
ufs/ufs/quota.h - old code won't compile without this change and this is
on purpose).
Discussed on tech-kern@ and tech-net@ (long thread, but not much about
libquota itself ...)
 1.7 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.6 13-Jul-2010  pooka branches: 1.6.2; 1.6.4;
Don't leak kernel stack into userspace.
 1.5 09-Aug-2009  haad branches: 1.5.2; 1.5.4;
Add enum uio_seg argument to do_sys_mknod and do_sys_mkdir so these functions
can be called from kernel, too.

Change needed for zfs device node creation, until we have propoer devfs.

Oked by ad@.
 1.4 26-Jan-2009  njoly Make all fstat(2) compat syscalls consistently use do_sys_fstat(),
instead of fd_getfile()/fd_putfile() dance.

ok by christos.
 1.3 11-Jan-2009  christos branches: 1.3.2; 1.3.4;
*utimes should allow NULL tvp.
 1.2 11-Jan-2009  christos merge christos-time_t
 1.1 29-Mar-2008  christos branches: 1.1.2; 1.1.6;
file vfs_syscalls_50.c was initially added on branch christos-time_t.
 1.1.6.3 11-Aug-2010  yamt sync with head.
 1.1.6.2 19-Aug-2009  yamt sync with head.
 1.1.6.1 04-May-2009  yamt sync with head.
 1.1.2.4 28-Dec-2008  christos for now don't bother with aio and lfs.
 1.1.2.3 09-Nov-2008  christos fix fhstat.
 1.1.2.2 26-Apr-2008  christos fix broken futimes.
 1.1.2.1 29-Mar-2008  christos new files
 1.3.4.3 03-Mar-2009  skrll Sync with HEAD.
 1.3.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.3.4.1 11-Jan-2009  skrll file vfs_syscalls_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:17 +0000
 1.3.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.2.1 11-Jan-2009  mjf file vfs_syscalls_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:41 +0000
 1.5.4.2 21-Apr-2011  rmind sync with head
 1.5.4.1 05-Mar-2011  rmind sync with head
 1.5.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.4.1 15-Feb-2011  bouyer Implement COMPAT_50 quotactl(2)
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.10.2.2 05-Apr-2012  mrg sync to latest -current.
 1.10.2.1 18-Feb-2012  mrg merge to -current.
 1.17.2.1 03-Dec-2017  jdolecek update from HEAD
 1.18.20.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.20.1 10-Jun-2019  christos Sync with HEAD
 1.18.18.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.18.18.1 19-Mar-2018  pgoyette Initial pass at a COMPAT_50 module. More to come.
 1.18.12.1 15-Aug-2021  martin Pull up following revision(s) (requested by christos in ticket #1691):

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.23.2.2 15-Aug-2021  martin Pull up following revision(s) (requested by christos in ticket #1337):

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
(thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions
 1.23.2.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.24.2.1 25-Jan-2020  ad Sync with head.
 1.1 22-Sep-2019  christos branches: 1.1.8;
Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 22-Sep-2019  martin file vfs_syscalls_90.c was added on branch phil-wifi on 2020-04-13 08:04:14 +0000
 1.21 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.20 19-Jan-2011  tsutsui branches: 1.20.56; 1.20.58;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.19 17-Jun-2008  tsutsui branches: 1.19.18; 1.19.24;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.18 29-May-2008  mrg branches: 1.18.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.17 20-Dec-2007  dsl branches: 1.17.6; 1.17.8; 1.17.10; 1.17.12;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.16 04-Mar-2007  christos branches: 1.16.16; 1.16.24; 1.16.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.15 09-Feb-2007  ad branches: 1.15.2;
Merge newlock2 to head.
 1.14 11-Dec-2005  christos branches: 1.14.20;
merge ktrace-lwp.
 1.13 29-May-2005  christos branches: 1.13.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.12 20-Jan-2003  simonb branches: 1.12.2;
The Double-Semi-Colon Police.
 1.11 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.10 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.9 29-Aug-1998  mrg branches: 1.9.24; 1.9.26;
move <vm/vm_swap.h> to <sys/swap.h>. <vm/vm_swap.h> still works for now (goes away later)
 1.8 20-Oct-1997  thorpej Fix the shared library versioning snafu caused by the recent changes
to the stat(2) family and msync(2). This uses a primitive function
versioning scheme.

This reverts the libc shared library major version from 13 to 12, and
adds a few new interfaces to bring us to libc version 12.20.

From Frank van der Linden <fvdl@NetBSD.ORG>.
 1.7 16-Oct-1997  christos PR/4269: msync is missing MS_*
 1.6 10-Oct-1997  mrg remove advertising clause from all my licenses.
 1.5 13-Jun-1997  thorpej branches: 1.5.4;
Don't #ifdef compat_12_sys_swapon() so that it can be used by other compat
modules.
 1.4 12-Jun-1997  mrg put the front end into libc.
 1.3 12-Jun-1997  mrg make this sys_swapon() for now.
 1.2 12-Jun-1997  mrg bring mrg-vm-swap2 onto mainline.
 1.1 14-Feb-1997  mrg branches: 1.1.2;
file vm_swap_12.c was initially added on branch mrg-vm-swap.
 1.1.2.2 14-Feb-1997  mrg branches: 1.1.2.2.2;
make this more likely to work; follow naming conventions
 1.1.2.1 14-Feb-1997  mrg emulate old swapon().
 1.1.2.2.2.3 01-Jun-1997  mrg it is called sys_swapctl() now.
 1.1.2.2.2.2 06-May-1997  pk Cast away `const' from old swapon's `name' argument.
Include <sys/systm.h>
 1.1.2.2.2.1 06-May-1997  mrg add <sys/syscallargs.h> as required, and <sys/mount.h> as previous requires.
 1.5.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.26.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.24.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.9.24.2 14-Nov-2001  nathanw Catch up to -current.
 1.9.24.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.12.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.3 21-Jan-2008  yamt sync with head
 1.13.2.2 03-Sep-2007  yamt sync with head.
 1.13.2.1 26-Feb-2007  yamt sync with head.
 1.14.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.15.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.28.1 02-Jan-2008  bouyer Sync with HEAD
 1.16.24.1 26-Dec-2007  ad Sync with head.
 1.16.16.1 09-Jan-2008  matt sync with HEAD
 1.17.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.12.2 14-May-2008  wrstuden 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.
 1.17.12.1 10-May-2008  wrstuden 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.
 1.17.10.1 04-May-2009  yamt sync with head.
 1.17.8.1 04-Jun-2008  yamt sync with head
 1.17.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.17.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.2.1 18-Jun-2008  simonb Sync with head.
 1.19.24.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.18.1 05-Mar-2011  rmind sync with head
 1.20.58.1 10-Jun-2019  christos Sync with HEAD
 1.20.56.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.20.56.1 31-Mar-2018  pgoyette create the compat_12 module
 1.21 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.20 29-Apr-2017  christos branches: 1.20.8; 1.20.10;
remove extra S
 1.19 29-Apr-2017  christos move MAP_COPY in compat
 1.18 08-Feb-2011  rmind branches: 1.18.14; 1.18.32; 1.18.46;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.17 19-Jan-2011  tsutsui branches: 1.17.2;
Remove includes <sys/mount.h> and <sys/sched.h> added for <sys/syscallargs.h>.
Now they are handled by $sysarghdrextra in sys/kern/syscalls.conf.
 1.16 20-Dec-2007  dsl branches: 1.16.12; 1.16.32; 1.16.38;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.15 04-Mar-2007  christos branches: 1.15.16; 1.15.24; 1.15.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 09-Feb-2007  ad branches: 1.14.2;
Merge newlock2 to head.
 1.13 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 27-Oct-2004  david branches: 1.10.12;
Bounds check syscall arguments where appropriate
 1.9 07-Aug-2003  agc branches: 1.9.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 18-Jan-2003  thorpej branches: 1.8.2;
Merge the nathanw_sa branch.
 1.7 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.6 28-Jun-2000  mrg branches: 1.6.2; 1.6.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 25-Jun-2000  mrg remove some redundant <vm/vm_xxx.h> includes
 1.4 30-Mar-2000  augustss Kill register declarations.
 1.3 29-Mar-2000  simonb Don't need to include <sys/conf.h> here.
 1.2 01-Apr-1999  drochner branches: 1.2.8;
remove unneeded <vm/*> includes
 1.1 05-Feb-1996  christos Extracted vm compat functions from vm and added them here where they belong.
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.6.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.6.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.8.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 12-Nov-2004  jmc Pullup rev 1.10 (requested by david in ticket #946)

Bounds check syscall arguments where appropriate.
 1.10.12.4 21-Jan-2008  yamt sync with head
 1.10.12.3 03-Sep-2007  yamt sync with head.
 1.10.12.2 26-Feb-2007  yamt sync with head.
 1.10.12.1 30-Dec-2006  yamt sync with head.
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.14.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.28.1 02-Jan-2008  bouyer Sync with HEAD
 1.15.24.1 26-Dec-2007  ad Sync with head.
 1.15.16.1 09-Jan-2008  matt sync with HEAD
 1.16.38.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.32.1 05-Mar-2011  rmind sync with head
 1.16.12.2 14-May-2008  wrstuden 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.
 1.16.12.1 10-May-2008  wrstuden 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.
 1.17.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.18.46.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.18.32.1 28-Aug-2017  skrll Sync with HEAD
 1.18.14.1 03-Dec-2017  jdolecek update from HEAD
 1.20.10.1 10-Jun-2019  christos Sync with HEAD
 1.20.8.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.20.8.1 17-Apr-2018  pgoyette First pass at compat modules for 4.3BSD, NetBSD-0.9, and NetBSD-1.0

XXX Still need to deal with the sysctl stuff and other code shared
XXX between 09 and 43
 1.7 16-Oct-1997  christos Rename to vm_12.c
 1.6 10-Oct-1997  mrg remove advertising clause from all my licenses.
 1.5 13-Jun-1997  thorpej branches: 1.5.4;
Don't #ifdef compat_12_sys_swapon() so that it can be used by other compat
modules.
 1.4 12-Jun-1997  mrg put the front end into libc.
 1.3 12-Jun-1997  mrg make this sys_swapon() for now.
 1.2 12-Jun-1997  mrg bring mrg-vm-swap2 onto mainline.
 1.1 14-Feb-1997  mrg branches: 1.1.2;
file vm_swap_12.c was initially added on branch mrg-vm-swap.
 1.1.2.2 14-Feb-1997  mrg branches: 1.1.2.2.2;
make this more likely to work; follow naming conventions
 1.1.2.1 14-Feb-1997  mrg emulate old swapon().
 1.1.2.2.2.3 01-Jun-1997  mrg it is called sys_swapctl() now.
 1.1.2.2.2.2 06-May-1997  pk Cast away `const' from old swapon's `name' argument.
Include <sys/systm.h>
 1.1.2.2.2.1 06-May-1997  mrg add <sys/syscallargs.h> as required, and <sys/mount.h> as previous requires.
 1.5.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.3 01-Mar-2019  pgoyette branches: 1.3.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 28-Mar-2018  pgoyette branches: 1.1.2;
file vnd_30.c was initially added on branch pgoyette-compat.
 1.1.2.5 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.4 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.1.2.1 28-Mar-2018  pgoyette Split vnd compat_30 code out of the main driver and into the compat_30
module
 1.3.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 01-Mar-2019  christos file vnd_30.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 14-Apr-2019  pgoyette branches: 1.4.4;
Only need to #include sys/vnode.h once
 1.3 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 19-Sep-2018  pgoyette branches: 1.1.2;
file vnd_50.c was initially added on branch pgoyette-compat.
 1.1.2.3 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.2 22-Sep-2018  pgoyette #include "opt_compat_netbsd.h" for all sources that provide compat code.
 1.1.2.1 19-Sep-2018  pgoyette Split out the vnd COMPAT_50 code
 1.4.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 14-Apr-2019  christos file vnd_50.c was added on branch phil-wifi on 2019-06-10 22:06:58 +0000

RSS XML Feed