Home | History | Annotate | only in /src/lib/libc/gen
History log of /src/lib/libc/gen
RevisionDateAuthorComments
 1.3 09-Apr-2005  dsl KNF
 1.2 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 26-Sep-1998  christos branches: 1.1.8;
Adapt to new signal changes (from Jason)
 1.1.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 26-Sep-1998  christos branches: 1.1.8;
Adapt to new signal changes (from Jason)
 1.1.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint__setjmp.c was added on branch netbsd-1-3 on 1997-11-08 21:58:12 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_alloca.c was added on branch netbsd-1-3 on 1997-11-08 21:58:16 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.3 27-Feb-2001  cgd branches: 1.3.114;
fix NetBSD RCS id tags
 1.2 06-Jul-2000  christos mark the prototype mismatch as linted. We cannot do better because of the
widening ansi rules.
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.3.114.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 27-Feb-2001  cgd branches: 1.2.114;
fix NetBSD RCS id tags
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.2.114.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 27-Feb-2001  cgd branches: 1.2.114;
fix NetBSD RCS id tags
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.2.114.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_fabs.c was added on branch netbsd-1-3 on 1997-11-08 21:58:18 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.5 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.4 20-Jan-2024  christos branches: 1.4.2;
Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.3 24-Jun-2012  christos fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.2 14-Jun-2000  cgd branches: 1.2.62;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_flt_rounds.c was added on branch netbsd-1-3 on 1997-11-08 21:58:21 +0000
 1.2.62.1 30-Oct-2012  yamt sync with head
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.3 24-Jun-2012  christos branches: 1.3.44;
fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.2 14-Jun-2000  cgd branches: 1.2.62;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_fpgetmask.c was added on branch netbsd-1-3 on 1997-11-08 21:58:13 +0000
 1.2.62.1 30-Oct-2012  yamt sync with head
 1.3.44.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.3 24-Jun-2012  christos branches: 1.3.44;
fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.2 14-Jun-2000  cgd branches: 1.2.62;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_fpgetround.c was added on branch netbsd-1-3 on 1997-11-08 21:58:17 +0000
 1.2.62.1 30-Oct-2012  yamt sync with head
 1.3.44.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.3 24-Jun-2012  christos branches: 1.3.44;
fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.2 14-Jun-2000  cgd branches: 1.2.62;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_fpgetsticky.c was added on branch netbsd-1-3 on 1997-11-08 21:58:19 +0000
 1.2.62.1 30-Oct-2012  yamt sync with head
 1.3.44.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_fpsetmask.c was added on branch netbsd-1-3 on 1997-11-08 21:58:22 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_fpsetround.c was added on branch netbsd-1-3 on 1997-11-08 21:58:14 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_fpsetsticky.c was added on branch netbsd-1-3 on 1997-11-08 21:58:17 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 02-Dec-1998  christos branches: 1.2.124;
PR/6251: ``TheMan'': Delint.
 1.1 07-Dec-1997  matthias add lint stubs for files that are implemented in assembler on the pc532.
 1.2.124.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 02-Dec-1998  christos branches: 1.2.124;
PR/6251: ``TheMan'': Delint.
 1.1 07-Dec-1997  matthias add lint stubs for files that are implemented in assembler on the pc532.
 1.2.124.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 14-Jun-2000  cgd branches: 1.2.116;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.1 06-Nov-1997  cgd branches: 1.1.2; 1.1.10;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_modf.c was added on branch netbsd-1-3 on 1997-11-08 21:58:20 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.3 19-Sep-2011  joerg branches: 1.3.54;
Mark _resumecontext as dead. ANSIfy all declarations for it.
 1.2 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1 05-Mar-2001  nathanw branches: 1.1.2;
file Lint_resumecontext.c was initially added on branch nathanw_sa.
 1.1.2.1 05-Mar-2001  nathanw User-level support for LWPs and scheduler activations.
SVR4-style ucontext code by Klaus Klein.
 1.3.54.1 02-Aug-2025  perseant Sync with HEAD
 1.2 27-Sep-1998  christos Remove old lint files.
 1.1 06-Nov-1997  cgd branches: 1.1.2;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_setjmp.c was added on branch netbsd-1-3 on 1997-11-08 21:58:23 +0000
 1.2 27-Sep-1998  christos Remove old lint files.
 1.1 06-Nov-1997  cgd branches: 1.1.2;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_sigsetjmp.c was added on branch netbsd-1-3 on 1997-11-08 21:58:15 +0000
 1.3 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.2 18-Jan-2003  thorpej branches: 1.2.110;
Merge the nathanw_sa branch.
 1.1 05-Mar-2001  nathanw branches: 1.1.2;
file Lint_swapcontext.c was initially added on branch nathanw_sa.
 1.1.2.1 05-Mar-2001  nathanw User-level support for LWPs and scheduler activations.
SVR4-style ucontext code by Klaus Klein.
 1.2.110.1 02-Aug-2025  perseant Sync with HEAD
 1.226 22-Oct-2025  roy rbtree: Rename rb.c to rbtree.c to match it's header rbtree.h

While here rename RBTEST to RBLOCAL to give a better meaning as we
want to include the local rbtest.h rather than the system one.

Also allow to compile outside of NetBSD source tree by guarding some
things we would otherwise expect to be defined.
 1.225 22-Apr-2025  nia Merge the manual pages for timespec_get(3) and timespec_getres(3).
 1.224 21-Apr-2025  nia libc: C23: add timespec_getres(3) function

timespec_getres is to timespec_get as clock_getres is to clock_gettime.

PR standards/58608
PR lib/59140
 1.223 09-Mar-2025  christos remove extattrn_namespace_to_string.3 it is in extattr.3 now
 1.222 09-Mar-2025  christos move the man page in the same place as FreeBSD for consistency.
 1.221 02-Oct-2024  christos Add workaround for clang atomics
 1.220 29-Aug-2024  rillig arc4random: suppress another lint warning
 1.219 29-Aug-2024  riastradh arc4random(3): Pacify some of lint's complaints.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.218 08-Jul-2024  christos PR/58391: Noriyuki Soda: re-adding syslog_ss() to syslog.h and syslog.3
 1.217 20-Jan-2024  christos branches: 1.217.2;
Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.216 31-May-2022  riastradh branches: 1.216.2;
libc: Reintroduce getentropy.

This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing. Now getentropy is more widely adopted and soon to be in
POSIX. So reintroduce the symbol into libc since we'll be keeping it
anyway. Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch. The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

SYNOPSIS
#include <unistd.h>

int getentropy(void *buffer, size_t length);

DESCRIPTION
The getentropy() function shall write length bytes of data
starting at the location pointed to by buffer. The output
shall be unpredictable high quality random data, generated by
a cryptographically secure pseudo-random number
generator. The maximum permitted value for the length
argument is given by the {GETENTROPY_MAX} symbolic constant
defined in <limits.h>.

RETURN VALUES
Upon successful completion, getentropy() shall return 0;
otherwise, -1 shall be retunred and errno set to indicate the
error.

ERRORS
The getentropy() function shall fail if:

[EINVAL] The value of length is greater than
{GETENTROPY_MAX}.

The getentropy() function may fail if:

[ENOSYS] The system does not provide the necessary
source of entropy.

RATIONALE
The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE. When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.
 1.215 15-Nov-2021  christos Add man pages for posix_spawn_file_actions_add{f,}chdir from piyush
 1.214 03-May-2021  simonb Add links for the other functions documented in arc4random(3).
 1.213 03-May-2021  simonb Whitespace police.
 1.212 20-Apr-2021  christos Instead of compiling files with -fcommon, create an include file and declare
the 3 symbols that need to be common using an attribute. Put all the 3 symbol
definitions in libc in one place (initfini.c). Reviewed by joerg@
 1.211 12-Apr-2021  mrg use -fcommon where necessary.
 1.210 10-Mar-2021  simonb Add manpage links for asysctl(3) and asysctlbyname(3), already described
in sysctl(3).
 1.209 26-Feb-2021  rin Add missing endutent.3 to MAN.
 1.208 26-Feb-2021  christos put back line accidentally removed.
 1.207 26-Feb-2021  christos PR/56012: Kouichi Hashikawa: getutent(3) man page is missing
 1.206 22-Sep-2020  nia remove getentropy bits
 1.205 05-Jul-2020  christos revert previous; utmpxname is already documented in getlastlogx.3. Should
probably be moved.
 1.204 05-Jul-2020  christos document utmpxname(3)
 1.203 10-May-2020  maya Don't add getentropy.c to the build (remove symbol from libc)

Still being discussed in tech-userlevel. If we wait any longer someone
is going to try the excuse that the discussion is entirely pointless, since
removing symbols is too hard.
 1.202 06-May-2020  nia Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.

Posted to tech-userlevel@ a week ago and reviewed by riastradh@.

GETENTROPY(3) Library Functions Manual GETENTROPY(3)

NAME
getentropy - fill a buffer with high quality random data

LIBRARY
Standard C Library (libc, -lc)

SYNOPSIS
#include <unistd.h>

int
getentropy(void *buf, size_t buflen);

DESCRIPTION
The getentropy() function fills a buffer with high quality random data,
suitable for seeding cryptographically secure psuedorandom number
generators.

getentropy() is only intended for seeding random number generators and is
not intended for use by regular code which simply needs secure random
data. For this purpose, please use arc4random(3).

The maximum value for buflen is 256 bytes.

IMPLEMENTATION NOTES
getentropy() reads from the sysctl(7) variable kern.arandom.

RETURN VALUES
The getentropy() function returns 0 on success, and -1 if an error
occurred.

ERRORS
getentropy() will succeed unless:

[EFAULT] The buf argument points to an invalid memory address.

[EIO] Too many bytes were requested.

SEE ALSO
arc4random(3), rnd(4)

STANDARDS
The getentropy() function is non-standard.

HISTORY
The getentropy() function first appeared in OpenBSD 5.6, then in
FreeBSD 12.0, and NetBSD 10.
 1.201 22-Apr-2020  joerg Explicitly use -fcommon for globals shared between libc and CSU.
 1.200 09-Sep-2017  kamil Install new man-page devname_r(3).

This is a link to devname(3).
 1.199 09-May-2017  kre Add the new signalname/signalnext/signalnumber interface to libc.

This as discussed on current-users in the thread
entitled:
Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"
that can be found (starting at):
http://mail-index.netbsd.org/current-users/2017/04/28/msg031600.html

These functions provide the mechanism to enable applications
to divorce themselves from internal details of the signal
implementation.

Libc minor bumped, prototypes in <signal.h>, sets lists updated (and sorted).

One and all: feel free to improve the sources & man page (etc), but
please do not change the function signatures without discussion.
 1.198 07-Feb-2017  kamil branches: 1.198.2;
Mark exect(3) obsolete and bind it to plain execve(2) on all platforms

The original exect(2) from BSD4.2 was enabling bit for tracing
(single-step mode) and calling execve(2). The purpose of it was to generate
a signal for a tracer once the application will change its image to a new
program.

This approach no longer works as:
- exect(2) traces (single-steps) libc and it requires hundreds or
thousands steps before entering a new image
- it's vax and x86 specific code
- this functionality has been moved to the kernel - once a process is
traced it will generate SIGTRAP with si_code TRAP_EXEC and route it to
its debugger
- the side effects and unportability make this interface unusable
- there are no known users of this interface
- it apparently never worked better since day0 of NetBSD ("day0 bug")

Users are requested to move to other execve(2) variants. Calling current
execve(2) as it is the most similar behavior to this one from BSD4.2.

Discussed several times on mailing lists and in PR/51700.

Add warning to exect(3) telling about marking this function obsolete.

This function is prepared to be removed in next libc major bump.

Sponsored by <The NetBSD Foundation>
 1.197 12-Jan-2017  christos branches: 1.197.2;
Split syslog.c to:

- syslog_ss.c *_ss api functions (don't use stdio, time)
- syslog.c: *syslog* non _ss api functions (use stdio, time)
- xsyslog.c> common guts.

The motivation for this is not to drag in stdio/locale/floating point/time
for every binary, since syslog_ss() is used in __stack_check_fail() for SSP.
 1.196 04-Oct-2016  kamil Add timespec_get(3) in <time.h> and enable unconditionally struct timespec

These changes conforms to the C11 standard
References:
- 7.27.1/3 Components of time (struct timespec)
- 7.27.2.5 The timespec_get function

According to ISO/IEC 9899:201x (draft) <time.h> defines the timespec
structure and declares the timespec_get(3) function with TIME_UTC
definition.

According to a C++17 standard draft <ctime> offers the same interface in
the std:: namespace.

The timespec_get function modifies the timespec object pointed by ts
to hold the current calendar time in the given base. The standard notes
only the TIME_UTC base with implementation defined value, set it to 1
as zero is reserved for error handling. Once operation was successful this
function returns passed base, otherwise exits with zero.

The timespec struct was already part of the POSIX standard in <time.h>.

Enable this interface unconditionally in the header to allow to use it
in a code prior C11 and C++17 as an extension.

Review notes from <christos>
 1.195 05-Jun-2016  christos branches: 1.195.2;
Document bsd_signal (From GSoC 2016 by Charles Cui)
 1.194 03-Apr-2016  christos userland bits for wait6/waitid.
 1.193 14-Jan-2016  christos add stravis(3) from OpenBSD
 1.192 25-Oct-2015  pooka Don't include daemon.c in RUMPRUN=yes mode.

The standard implementation uses fork(), needs an alternative
implementation for Rumprun.
 1.191 20-Jan-2015  christos Factor out popen() code into separate functions and create popenve()
using the new functions, a safer version of popen() that does not
involve a shell. Correct manual page inaccuracies.
 1.190 10-Dec-2014  pooka Add two more Makefile conditionals required for RUMPRUN=yes

* do not build _errno.c (different thread/tls handling)
* do not build either phk- or jemalloc (different backing page allocation)

Somehow I missed these in the previous commit, but now libc built with
RUMPRUN=yes works also with rumprun-posix, so there's reasonably high
confidence that I didn't miss anything anymore.
 1.189 26-Sep-2014  christos add execvpe, execlpe (reviewed by phone)
 1.188 13-Jun-2014  joerg Add asysctl(3) and asysctlbyname(3) wrappers for the common idiom of
fetching dynamically sized data via sysctl.
 1.187 16-Jan-2014  christos branches: 1.187.2;
"soon" is "now". Remove all __indr_reference crap.
 1.186 16-Jan-2014  christos Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.185 03-Nov-2012  christos add utimens and lutimens wrappers using utimensat.
 1.184 12-Apr-2012  christos branches: 1.184.2;
man page for getpassfd
 1.183 12-Apr-2012  christos Add a new getpass implementation that does not mess with signals, and
include getpass_r
 1.182 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.181 16-Dec-2011  wiz Split extattr(3) into two man pages to get rid of ugly duplicate Nd.
Work done by Abhinav Upadhyay with minimal cleanup.
 1.180 25-Aug-2011  joerg branches: 1.180.2;
Uses non-literal format strings
 1.179 03-Aug-2011  manu Make cp -p and mv preverve extended attributes, and complain if they cannot.

Also introduce library functions for copying extended attributes from one
file to another:
- extattr_copy_file, extattr_copy_fd, extattr_copy_link, with FreeBSD style,
where a namespace is to be supplied
- cpxattr, fcpxattr, lcpxattr, with Linux style, where all namespaces
accessible to the caller are copied, and the others are silently ignored.
 1.178 26-Mar-2011  christos add fpgetprec/fpsetprec
 1.177 16-Mar-2011  erh Remove one last reference to commaize_number.3
 1.176 16-Mar-2011  christos goodbye short-live commaize_number(3), if you liked it:
#define commaize_number(s, l, n) snprintf(s, l, "%'llu", (unsigned long long)n)
 1.175 15-Mar-2011  erh PR#7540, add a commaize_number function, which inserts comma into a string
of digits to make it more readable. This is soon to be used in /bin/ls.
 1.174 12-Mar-2011  christos Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
 1.173 12-Dec-2010  christos errlist.c is automatically generated now.
 1.172 26-Sep-2010  yamt fix rewinddir on nfs. fix PR/42879 (and probably PR/40229.)
 1.171 27-Aug-2010  christos add psiginfo.
 1.170 22-May-2010  tnozaki 1. hide _CTYPE_PRIVATE section in ctype.h, move them to private header ctype_local.h.
2. do not use _CTYPE_NUM_CHARS macro to read data from LC_CTYPE(old BSDCTYPE style) database.
because 1<<CHAR_BIT is MD, so i added MI macro _CTYPE_CACHE_SIZE(1<<8).
3. remove _NB_CACHED_RUNE macro, use _CTYPE_CACHE_SIZE instead.
 1.169 13-May-2010  jruoho Build links for syslogp(3), syslogp_r(3), vsyslogp(3), and vsyslogp_r(3).

From Takahiro Kambe in PR lib/43301.
 1.168 08-Apr-2009  wiz Link glob(3) to glob_pattern_p(3).
 1.167 11-Jan-2009  christos branches: 1.167.2;
merge christos-time_t
 1.166 02-Jan-2009  tnozaki Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES} db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).

[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].

[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().

[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<

old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.165 05-Dec-2008  ad Add fdopendir(), from Solaris/Linux.
 1.164 20-Nov-2008  matt Add new ptree (Patricia / RADIX tree) implementation to NetBSD.
 1.163 05-Sep-2008  lukem branches: 1.163.4; 1.163.6;
Add strunvisx(3) as a link to unvis(3)
 1.162 30-Jun-2008  matt Move rb.c from sys/lib/libkern to common so it can be in both libc and libkern.
 1.161 17-Jun-2008  he Correct the use of MLINKS for the cpuset_* manual page links.
The value for MLINKS is a list of pairs, where the original manpage
is listed first in each pair...
 1.160 16-Jun-2008  rmind - Add affinity(3) manual page, which describes thread affinity,
pthread_setaffinity_np(3) and pthread_getaffinity_np(3) functions,
provides simple code example.
- Add cpuset(3) manual page, which describes API of CPU-sets.

Thanks <wiz> for many improvements!
 1.159 14-Dec-2007  christos branches: 1.159.4; 1.159.6;
- add dehumanize_number
- decls for humanize_number and dehumanize_number are in stdlib.h
 1.158 22-Feb-2007  drochner branches: 1.158.4;
-get cabs() and cabsf() out of public view - these are historical and
conflict with C99 functions which are builtins in newer gcc
(actually, the old cabs() is ABI compatible with the new _complex one
on i386, but this is purely accidental)
remove public prototypes and manpages, move the code into a compat
subdirectory as libc does so that binary compatibility is kept
-add a manpage for the isgreater() etc macros, borrowed from FreeBSD
 1.157 22-Nov-2006  christos Don't expose _ss functions for 4.0. Requested by core.
 1.156 11-Nov-2006  christos on non-x86 execl*.c needs alloca.
 1.155 09-Nov-2006  christos no stack protector warning for execvp
 1.154 27-Oct-2006  christos add async-signal-safe versions: syslog_ss and vsyslog_ss
multithread-safe syslog_r and vsyslog_r are not async-signal-safe.
 1.153 27-Oct-2006  uwe Add syslog_r.3 link (hi christos).
 1.152 25-Oct-2006  christos add _r functions for syslog from OpenBSD
 1.151 03-Jul-2006  drochner move manpages for frexp/ldexp/modf to libm -- the (most) implementation is
already there
 1.150 27-Jun-2006  drochner First step to clean up the variety of frexp(), ldexp() and modf()
implementations.
Long term goal is to use the implementation in libm and get rid of
the libc instances. For now, we need to keep one in libc for compatibility,
it belongs into the compat subtree.
The switch is per-arch. Should be painless for ieee754 boxes.
If all ieee754 archs are switched, libc/gen/{frexp,ldexp,modf}_ieee754.c
can be removed.
 1.149 17-Apr-2006  salo Add setttyentpath(), functionally equivalent to setttyent() but takes an
additional argument to read the ttys information from an alternate path
istead of _PATH_TTYS.

Required for upcoming init(8) changes.

Mostly from <apb>.

Bump libc minor.
 1.148 30-Dec-2005  agc Add Todd Miller's ftw(3) and nftw(3) file-tree walking functionality,
from OpenBSD.

Bump libc minor to 136.
 1.147 03-Oct-2005  wiz getfsent(3) does not contain any information about the (nonexisting)
function getfstype(), so don't MLINK it. Remove getfstype from other
places that reference it too.

Noted by jmc@openbsd.
 1.146 25-Sep-2005  christos add getenv_r and ttyname_r
 1.145 13-Sep-2005  christos compat core reorg.
 1.144 19-Aug-2005  christos 64 bit inode changes
 1.143 12-Apr-2005  drochner Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.142 05-Apr-2005  kleink Fix typo in previous.
 1.141 04-Apr-2005  christos mlinks for get{gr,pw}ent_r.3
 1.140 06-Jan-2005  lukem branches: 1.140.2; 1.140.4; 1.140.6;
document getgroupmembership(3)
 1.139 06-Jan-2005  lukem Implement getgroupmembership(3). This is similar to getgrouplist(3), except
that the "int maxgroups" and "int *ngroups" parameters are separated into
two separate parameters which makes it possible to call multiple nsswitch
back-ends and have the results correctly merged.
getgrouplist(3) is now implemented using getgroupmembership(3).

Proposed on tech-userlevel on December 1, 2004.
 1.138 02-Jan-2005  thorpej System calls and support routines for file system extended attributes. Libc
version is bumped to 12.125.

From FreeBSD.
 1.137 16-Dec-2004  atatat Add a function called getdevmajor().

It tells you the major device number for whatever character or block
device you ask it. This is sort of the inverse of devname(3) but not
quite, since it's backed by the kernel (sysctl's kern.drivers
information) and not a database cobbled together from the contents of
the filesystem.
 1.136 10-Nov-2004  lukem whitespace cleanup
 1.135 10-Nov-2004  lukem Add: getgrgid_r(3) getgrnam_r(3) getpwnam_r(3) getpwuid_r(3)
 1.134 13-Jul-2004  seb Add wordexp(3). The wordexp function performs shell-style word expansions.
This implementation is wrapper around the undocumented wordexp sh(1)
built-in command.

From FreeBSD.
Provided in PR lib/26123.
Approved by kleink@.
 1.133 31-May-2004  itojun oops, i've committed BSD auth stuff by mistake.
 1.132 31-May-2004  itojun closefrom(3)
 1.131 31-May-2004  itojun implement closefrom(3).
 1.130 09-May-2004  kleink There are two instances of getsubopt.c, one in gen, which came by the
ways of 386BSD, and one in stdlib, which is from Lite-2. The former was
picked up by the build process and has seen a little more maintenance
while the latter's location is "right", so bring the latter up to par
with the former and dispose of the (now) latter.

Reported by David A. Holland in PR lib/25160, which is worded in a
far less mind-boggling fashion than the above.
 1.129 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.128 25-Mar-2004  atatat Move sysctlbyname(), sysctlnametomib(), and sysctlgetmibinfo() from
sysctl(8) into libc, making the minor number jump. Add prototypes to
sys/sysctl.h, fix sets, modify man pages, etc. That oughta cover it.
 1.127 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.126 15-Jan-2004  kleink Add C99 fpclassify(), isfinite(), isnormal(), and signbit() macros.
 1.125 18-Sep-2003  jdolecek remove pw_dup(3), for now at least
follows discussion on mailing lists, discussed in private e-mail with Itojun
 1.124 09-Sep-2003  itojun add randomid(3).
 1.123 09-Sep-2003  itojun have pw_dup(3). from openbsd
 1.122 26-Aug-2003  wiz Add man page for getlastlogx and friends.
 1.121 28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.120 13-Feb-2003  nathanw Add pthread_atfork() man page.
 1.119 13-Feb-2003  nathanw Implement pthread_atfork() (in libc, because the required threadlib
stub behavior is exactly the same as the usual behavior).
 1.118 21-Jan-2003  wiz Add makecontext(3) from Klaus Klein.
 1.117 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.116 15-Jan-2003  kleink Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.115 27-Sep-2002  wiz Add documentation for utmpx and some related functions.
Thanks for some explanations to christos, and for some STANDARDS hints
to Klaus Klein.
 1.114 22-Aug-2002  abs Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.113 27-Jul-2002  christos Add utmp processing functions
 1.112 30-Jun-2002  bjh21 Version times() so that programs compiled before the recent change to make
sysconf(_SC_CLK_TCK) return hz will work.

In detail:
__times13() returns values scaled by hz.
times() returns values scaled by 100.
<sys/times.h> renames times() to __times13().

_SC_CLK_TCK has changed from 3 to 39.
sysconf(3) returns 100.
sysconf(39) returns hz.
CLK_TCK is defined as sysconf(39).
 1.111 24-May-2002  itojun add arc4random(3). from openbsd
 1.110 22-Feb-2002  christos branches: 1.110.2;
A simple utmpx implementation. Nothing uses it yet.
TODO: write the lastlog*() stuff.
 1.109 24-Jan-2002  lukem - Implement pwcache_userdb(3), which changes the routines that
user_from_uid(3) and uid_from_user(3) use to lookup user information.
- Implement pwcache_groupdb(3), which changes the routines that
group_from_gid(3) and gid_from_group(3) use to lookup group information.
- Ensure that private functions in pwcache.c are declared static
- Use strlcpy(3) instead of strncpy(3)
 1.108 07-May-2001  kleink Internally rename sysconf() to __sysconf() to make its latter name suitable
for use from public headers. Also, do so on all platforms.
 1.107 10-Mar-2001  cgd Add shquote() and shquotev(). From the manual page:
The shquote() and shquotev() functions copy strings and transform the
copies by adding shell escape and quoting characters. They are used to
encapsulate arguments to be included in command strings passed to the
system() and popen() functions, so that the arguments will have the cor-
rect values after being evaluated by the shell.
 1.106 19-Feb-2001  cgd branches: 1.106.2;
add getprogname() and setprogname()
 1.105 20-Oct-2000  briggs Add {__,}fmtcheck(), a function specified by Bill Sommerfeld to check
a user-supplied format string against a fallback format string to ensure
that they will consume arguments of the same type.

libc minor bump for new API entry point.
 1.104 29-Aug-2000  wennmach Added MLINKS for svis, strsvis, and strsvisx
 1.103 03-Jan-2000  msaitoh branches: 1.103.4;
nlist for COFF
 1.102 13-Sep-1999  kleink Add an XSH5 ulimit()/<ulimit.h> implementation.
 1.101 12-Sep-1999  kleink Add an XSH5 fmtmsg() implementation.
 1.100 12-Sep-1999  kleink Move the function implementations of (the non-ANSI) isascii() and toascii()
into separate modules to avoid namespace clashes.
 1.99 01-May-1999  ross Fix fpgetmask.3 MLINKS braino.
 1.98 30-Apr-1999  ross * New MI man page for fp{set,get}{round,sticky,mask}(3).
* Implement fpgetsticky() for alpha.
* Direct fpsetsticky() and fp{get,set}mask() into alpha kernel via sysarch(2).
* Define new sysarch(2) stub for above and install and distribute sysarch.h
for alpha. (The fpcr IS user mode r/w, but for reasons beyond the scope
of a commit message kernel calls are needed.) And much kernel Magick is
required before these do anything, but this way programs compiled under
1.4 will DTRT on future snapshots and releases.
 1.97 24-Feb-1999  drochner branches: 1.97.2;
use ${ARCHDIR} instead of ${.CURDIR}/arch/${MACHINE_ARCH} where appropriate
libc builds on pmax again
 1.96 19-Jan-1999  abs Add '-f disktab' option to disklabel, via lib/6623 from
Greg A. Woods <woods@most.weird.com>. (Very) slightly tweaked disklabel.8
 1.95 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.94 30-Nov-1998  thorpej Build __errlist14.c, __siglist14.c, and __signame14.c
 1.93 26-Sep-1998  christos Adapt to new signal changes (from Jason)
 1.92 28-Jul-1998  mycroft Add links for uid_from_user(3) and gid_from_group(3).
 1.91 08-Jun-1998  lukem * move pw_scan() from libutil to libc
* add support for YP "master.passwd.by*" (master.passwd in YP, including
pw_passwd) and "passwd.adjunct.by*" (SunOS `secure' maps (?)), based
on code in FreeBSD and partially from OpenBSD.
this is only used if euid == 0.
with this, the YP "passwd.by*" maps can have `*' in the pw_passwd field.
* use pw_scan() to parse YP "passwd.by*" and "master.passwd.by*" entries

XXX: i didn't test the "passwd.adjunct" support...
 1.90 28-Apr-1998  fair make explicit why an MLINKS for setpwfile.3 is commented out
 1.89 19-Mar-1998  fair remove getsubopt.3 - there is another man page for this in ../stdlib that came from the Lite2 merge. This closes PR4600
 1.88 02-Feb-1998  perry add realpath.3, getsubopt.[c3]
 1.87 02-Feb-1998  perry it turns out we don't want getvfsbyname after all.
 1.86 02-Feb-1998  perry merge/update to lite-2
 1.85 20-Dec-1997  kleink Add lockf(), an alternate interface to perform advisory record locking;
per XPG4.2.
 1.84 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.83 03-Nov-1997  kleink Forgot to add basename()/dirname() manpages in last commit.
 1.82 02-Nov-1997  kleink Add basename() and dirname(), from XPG4.2.
 1.81 21-Oct-1997  fvdl branches: 1.81.2;
Hacks to enable libc to work without bumping the major.
 1.80 20-Oct-1997  christos Bring timezone back to libc.
 1.79 16-Oct-1997  christos timezone moved to libcompat
 1.78 16-Jul-1997  mikel add toascii(3)
 1.77 24-Feb-1997  lukem branches: 1.77.2;
man page for stringlist functions
 1.76 17-Jan-1997  lukem Add stringlist implementation
Convert getnetgrent from private stringlist to public version
 1.75 07-Nov-1996  jtc New __errno() function, returns the address of the errno variable.
 1.74 16-Oct-1996  perry branches: 1.74.2;
Nuked tahoe machine specific conditionals.
 1.73 27-Sep-1996  cgd Seriously revamp libc's nlist()/__fdnlist() support:
(1) split nlist() into multiple files, for clarity and to make
ELF 32/64 support easier,
(2) support multiple executable types at the same time, and
(3) add support for 32- and 64-bit ELF (32-bit ELF support
originally from OpenBSD, but with several bug fixes so
that it actually handles symbols types more correctly
(and therefore _works_ for some of the more tricky uses
of the nlist routines) and changes for 64-bit ELF support).
 1.72 03-Jul-1996  jtc branches: 1.72.2;
Split all exec*() functions out of exec.c into their own files.
 1.71 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.70 25-Apr-1995  jtc termios code has been moved to new libc/termios directory.
 1.69 17-Apr-1995  ragge Removed VAX specific definitions.
 1.68 10-Mar-1995  jtc Removed references to ctime.3 and tzset.3 manpages and associated manpage
links (they have been moved to libc/time).
 1.67 09-Mar-1995  jtc date and time functions have been moved
 1.66 25-Feb-1995  cgd typo
 1.65 25-Feb-1995  cgd oops; biffed path
 1.64 25-Feb-1995  cgd update from Lite, clean up a bit, seperate arch-specific file list.
 1.63 10-Feb-1995  cgd branches: 1.63.2;
list the files needed on the alpha.
 1.62 11-Jan-1995  pk Add sigsetjmp() for sparc.
 1.61 23-Dec-1994  jtc 4.4lite's C language sigsetjmp() implementation is bogus, restore
machine dependant versions.
 1.60 22-Dec-1994  cgd specify man pages the new way.
 1.59 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.58 11-Dec-1994  christos - Changed all internal libc references of {v,}err{x,} and {v,}warn{x,} to
__{v,}err{x,} and __{v,}warn{x,}
- moved err.c to __err.c and added err.c which contains weak references for
the above functions.
- Reordered the functions in __err.c to avoid redeclarations and changed
the varargs declarations to conform with the K&R style.
 1.57 10-Dec-1994  jtc Use 44lite's clever sigsetjmp()/siglongjmp() implementation I just imported.
 1.56 07-Dec-1994  deraadt remove duplicate infinity.c
 1.55 07-Dec-1994  phil Adding sigsetjmp.S for ns32k.
 1.54 14-Nov-1994  dean Include files for pmax
 1.53 20-Oct-1994  cgd make the sysv functions real syscalls.
 1.52 10-Oct-1994  jtc Renamed sys_errlist[] and sys_nerr to __sys_errlist[] and __sys_nerr.
The traditional API of sys_errlist[] and sys_nerr is provided by weak
references if they are supported. Otherwise, we're forced to have to
have two copies of the error message string table in the library.
Fortunately, unless a program uses both sys_errlist[] and strerror(),
only one of the copies will be linked into the executable.

This is all to provide an clean namespace as required by ANSI. I've
done the same for sys_siglist[], even though it is not required, to
be consistant.
 1.51 29-Aug-1994  mycroft branches: 1.51.2;
Fix broken import of Lite directory code.
 1.50 19-Aug-1994  cgd frexp.? is machine-dependent, as suggested by phil.
 1.49 28-Jun-1994  jtc branches: 1.49.2;
install getnetgrent() manpage
 1.48 26-Jun-1994  jtc Ftok() routine, needed by most programs that use SysV IPC.
 1.47 11-Jun-1994  jtc Replace my version of confstr() with 4.4 lite's, which gets its values
with sysctl().
 1.46 28-May-1994  mycroft We have shm again.
 1.45 21-May-1994  chopps no more lsearch.3.
 1.44 19-May-1994  jtc cuserid() was moved to libcompat w/4.4 lite.
 1.43 19-May-1994  jtc 4.4lite's libcompat provided a lsearch() and lfind() implementation which
has been already integrated into NetBSD, so we don't need/want mine anymore.
 1.42 17-May-1994  mycroft Add {set,get,end}netgrent().
 1.41 11-May-1994  cgd shm sources won't compile; no more shm.h
 1.40 07-May-1994  cgd update for present reality. shlib version number bump (last for a bit)
 1.39 05-May-1994  cgd add getgrouplist
 1.38 14-Apr-1994  cgd setproctitle(); no reason to have this code spread into N utils...
 1.37 09-Apr-1994  mycroft And strunvis(3), too.
 1.36 09-Apr-1994  mycroft Add links for strvis(3) and strvisx(3).
 1.35 06-Apr-1994  cgd M-x shuffle-functions-and-documentation
basically, move things around so documentation is in the correct place,
and bump appropriate functions into the 'compat' section.
 1.34 27-Jan-1994  cgd add two man pages
 1.33 27-Jan-1994  cgd stuff moved into libc
 1.32 12-Jan-1994  cgd moved to libcompat, where they belong.
 1.31 08-Dec-1993  pk Added some Sparc sources.
 1.30 05-Dec-1993  cgd get pc532 moved into ns32k; that's is MACHINE_ARCH
 1.29 04-Dec-1993  cgd update for .S and MACHINE_ARCH
 1.28 03-Dec-1993  jtc Add common definition of errno back to the C library. One notable program
uses its own crt0.c, so it can't pick it up from there.
 1.27 02-Dec-1993  mycroft Remove hack for errlst.o.
 1.26 02-Dec-1993  mycroft Get rid of dated MLINKS for regexp man pages.
Reported by Mark_Weaver@brown.edu.
 1.25 29-Nov-1993  jtc install cuserid(3) manpage.
 1.24 17-Nov-1993  jtc If _CS_PATH is defined in <unistd.h>, the latest bash assumes that confstr()
will be present as well. Here is a quick implementation based on my online
copy of 1003.2 (D11.2). I'll confirm that nothing has been changed in the
final standard and write up a manual page soon.
 1.23 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.22 11-Nov-1993  jtc Enable Henry Spencer's POSIX.2 compatible regular expression routines.
Disable his earlier V8-style routines.
 1.21 22-Oct-1993  jtc Add my lsearch & lfind implementations.
 1.20 19-Oct-1993  jtc Use i386 sigsetjmp()/siglongjmp() implementation.
Install sigsetjmp()/siglongjmp() links to setjmp manpage.
Note that sigsetjmp() and siglongjmp() are 1003.1 compliant.
 1.19 11-Oct-1993  jtc Moved cuserid() from getlogin.c to its own file, cuserid.c.
getlogin() and cuserid() do very different things, getlogin() is POSIX,
while cuserid() is not (it was removed in the 1990 revision).
 1.18 07-Oct-1993  cgd always create libcrypt, and link with it where necessary. this will
make life with shared libraries happier. also, get dummy crypt out
of libc.
 1.17 07-Oct-1993  cgd make an arch directory in libc, and move all machine dirs into it
 1.16 04-Oct-1993  jtc Install isblank() manpage.
Fix title of isblank() manpage (was isspace(), the manpage I started with).
 1.15 01-Oct-1993  jtc Install fts manpage as fts_open, fts_read, fts_children, fts_set and
fts_close too.
 1.14 17-Sep-1993  phil pc532 specifics.
 1.13 25-Aug-1993  brezak Add syscall stubs for SYSV Shared Memory.
 1.12 23-Aug-1993  jtc Moved toupper and tolower tables from ctype_.c to their own files --- I
received complaints about using shorts in the table (but i need a range
of -1..255), so now the tables will not be used unless either toupper()
or tolower() (and soon, setlocale()) are used. This can save up to 514
bytes.

In toupper_.c and tolower_.c make sure that our assumption of EOF == -1
holds.

Fixed bug where _toupper_tab_ was initialized pointing to _C_tolower_tab.
 1.11 13-Aug-1993  brezak Machine independent version of insque/remque
 1.10 06-Aug-1993  mycroft Add sys_signame[].
 1.9 01-Aug-1993  mycroft Add RCS identifiers.
 1.8 25-Jul-1993  glass Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.
 1.7 09-Jul-1993  cgd update for better FP routines, from AT&T & elsewhere
 1.6 16-Jun-1993  jtc Make assert macro ansi complient.
 1.5 04-Jun-1993  proven Removed bugs and memory leaks from the directory function.
 1.4 18-May-1993  cgd bring in getcap routines, supplied by CSRG, from 4.4...
 1.3 30-Apr-1993  glass new err stuff
 1.2 22-Mar-1993  cgd added support for using real crypt
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.49.2.1 19-Aug-1994  cgd make frexp.c machine-dependent, as ns32k has frexp.S
 1.51.2.2 29-Aug-1994  mycroft Fix broken import of Lite directory code.
 1.51.2.1 29-Aug-1994  mycroft file Makefile.inc was added on branch netbsd-1-0 on 1994-08-29 04:47:32 +0000
 1.63.2.2 02-May-1995  jtc #include "namespace.h"
 1.63.2.1 17-Feb-1995  jtc Removed indirect reference stub files.
 1.72.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.74.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.77.2.2 10-Jan-1999  lukem sync with current
 1.77.2.1 02-Nov-1998  lukem sync with current
 1.81.2.4 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.81.2.3 09-Nov-1997  lukem back out incorrect sync with trunk
 1.81.2.2 09-Nov-1997  lukem sync with trunk (approved by thorpej)
 1.81.2.1 21-Oct-1997  lukem file Makefile.inc was added on branch netbsd-1-3 on 1997-11-09 00:59:56 +0000
 1.97.2.2 01-May-1999  perry pullup 1.98->1.99 (ross) -- 100 lashes with a wet noodle for this one.
 1.97.2.1 30-Apr-1999  perry pullup 1.97->1.98 (ross)
 1.103.4.1 30-Aug-2000  wennmach Pull up revision 1.103->1.104 (requested by wennmach)

Three routines (svis, strsvis, strsvisx) were added to vis.c in revision
1.15 and will be available in NetBSD-1.5. They are documented in vis.3
but should also get links to vis.3

Approved by thorpej and jhawk.
 1.106.2.10 17-Jan-2003  thorpej Sync with HEAD.
 1.106.2.9 17-Jan-2003  thorpej Document _lwp_makecontext(3).
 1.106.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.106.2.7 27-Aug-2002  nathanw Catch up to -current.
 1.106.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.106.2.5 21-Jun-2002  nathanw Catch up to -current.
 1.106.2.4 22-Mar-2002  nathanw Catch up to -current.
 1.106.2.3 08-Mar-2002  nathanw Catch up to -current.
 1.106.2.2 28-Jan-2002  nathanw Catch up to -current.
 1.106.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.110.2.1 26-Mar-2004  jmc Pullup rev 1.111 (requested by provos in ticket #1386)

Introduce bcrypt password scheme. Adds the arc4random API for creating
cryptographically strong random numbers.
 1.140.6.1 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.140.4.1 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.140.2.1 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.158.4.1 09-Jan-2008  matt sync with HEAD
 1.159.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.159.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.159.4.1 17-Jun-2008  yamt sync with head.
 1.163.6.2 04-Jan-2009  christos merge with head.
 1.163.6.1 05-Sep-2008  christos file Makefile.inc was added on branch christos-time_t on 2009-01-04 17:02:19 +0000
 1.163.4.1 15-Jan-2009  snj Pull up following revision(s) (requested by tnozaki in ticket #222):
distrib/sets/lists/base/mi: revision 1.788
distrib/utils/libhack/Makefile.inc: revision 1.23
distrib/utils/libhack/Makefile: revision 1.22
etc/mtree/NetBSD.dist: revision 1.387
include/locale.h: revision 1.15
lib/libc/citrus/Makefile.inc: revision 1.6
lib/libc/citrus/citrus_aliasname_local.h: revision 1.1
lib/libc/citrus/citrus_bcs.h: revision 1.5
lib/libc/citrus/citrus_bcs_strtol.c: revision 1.1
lib/libc/citrus/citrus_bcs_strtoul.c: revision 1.1
lib/libc/citrus/citrus_csmapper.c: revision 1.9
lib/libc/citrus/citrus_fix_grouping.h: revision 1.1
lib/libc/citrus/citrus_lc_ctype.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.h: revision 1.1
lib/libc/citrus/citrus_lc_monetary.c: revision 1.1
lib/libc/citrus/citrus_lc_monetary.h: revision 1.1
lib/libc/citrus/citrus_lc_numeric.c: revision 1.1
lib/libc/citrus/citrus_lc_numeric.h: revision 1.1
lib/libc/citrus/citrus_lc_template.h: revision 1.1
lib/libc/citrus/citrus_lc_template_decl.h: revision 1.1
lib/libc/citrus/citrus_lc_time.c: revision 1.1
lib/libc/citrus/citrus_lc_time.h: revision 1.1
lib/libc/citrus/citrus_module.c: revision 1.8
lib/libc/citrus/citrus_namespace.h: revision 1.7
lib/libc/citrus/modules/citrus_euc.c: revision 1.13
lib/libc/gen/Makefile.inc: revision 1.166
lib/libc/gen/isctype.c: revision 1.17 via patch
lib/libc/gen/tolower_.c: revision 1.10
lib/libc/gen/toupper_.c: revision 1.10
lib/libc/iconv/Makefile.inc: revision 1.3
lib/libc/iconv/iconv.c: revision 1.7
lib/libc/locale/Makefile.inc: revision 1.53
lib/libc/locale/___runetype_mb.c: file removal
lib/libc/locale/_wctrans.c: revision 1.7
lib/libc/locale/_wctrans_local.h: revision 1.3
lib/libc/locale/_wctype.c: revision 1.1
lib/libc/locale/_wctype_local.h: revision 1.1
lib/libc/locale/aliasname.c: revision 1.3
lib/libc/locale/aliasname_local.h: revision 1.2
lib/libc/locale/bsdctype.c: revision 1.1
lib/libc/locale/bsdctype.h: revision 1.1
lib/libc/locale/ctypeio.c: revision 1.8
lib/libc/locale/ctypeio.h: revision 1.2
lib/libc/locale/current_locale.c: revision 1.1
lib/libc/locale/dummy_lc_collate.c: revision 1.1
lib/libc/locale/dummy_lc_template.h: revision 1.1
lib/libc/locale/fix_grouping.c: revision 1.1
lib/libc/locale/fix_grouping.h: revision 1.1
lib/libc/locale/generic_lc_all.c: revision 1.1
lib/libc/locale/generic_lc_template.h: revision 1.1
lib/libc/locale/generic_lc_template_decl.h: revision 1.1
lib/libc/locale/global_locale.c: revision 1.1
lib/libc/locale/iswctype.c: file removal
lib/libc/locale/iswctype_mb.c: revision 1.1
lib/libc/locale/iswctype_sb.c: revision 1.6
lib/libc/locale/lcmessages.c: file removal
lib/libc/locale/lcmessages.h: file removal
lib/libc/locale/lcmonetary.c: file removal
lib/libc/locale/lcmonetary.h: file removal
lib/libc/locale/lcnumeric.c: file removal
lib/libc/locale/lcnumeric.h: file removal
lib/libc/locale/lctime.c: file removal
lib/libc/locale/lctime.h: file removal
lib/libc/locale/localeconv.c: revision 1.15
lib/libc/locale/localeio.c: revision 1.2
lib/libc/locale/localeio.h: revision 1.2
lib/libc/locale/localeio_lc_ctype.c: revision 1.1
lib/libc/locale/localeio_lc_messages.c: revision 1.1
lib/libc/locale/localeio_lc_monetary.c: revision 1.1
lib/libc/locale/localeio_lc_numeric.c: revision 1.1
lib/libc/locale/localeio_lc_time.c: revision 1.1
lib/libc/locale/multibyte.h: revision 1.4
lib/libc/locale/multibyte_amd1.c: revision 1.6
lib/libc/locale/multibyte_c90.c: revision 1.5
lib/libc/locale/nb_lc_messages_misc.h: revision 1.1
lib/libc/locale/nb_lc_monetary_misc.h: revision 1.1
lib/libc/locale/nb_lc_numeric_misc.h: revision 1.1
lib/libc/locale/nb_lc_template.h: revision 1.1
lib/libc/locale/nb_lc_template_decl.h: revision 1.1
lib/libc/locale/nb_lc_time_misc.h: revision 1.1
lib/libc/locale/nl_langinfo.c: revision 1.12
lib/libc/locale/rune.c: revision 1.31
lib/libc/locale/rune.h: revision 1.13
lib/libc/locale/rune_local.h: revision 1.11
lib/libc/locale/runeglue.c: revision 1.14
lib/libc/locale/runetable.c: revision 1.18
lib/libc/locale/setlocale.c: revision 1.55 via patch
lib/libc/locale/setlocale_local.h: revision 1.1
lib/libc/locale/setrunelocale.c: file removal
lib/libc/nls/Makefile.inc: revision 1.9
lib/libc/nls/catopen.c: revision 1.26
lib/libc/string/Makefile.inc: revision 1.68
lib/libc/string/wcscmp.c: revision 1.6
lib/libc/string/wcsncmp.c: revision 1.6
lib/libc/string/wcswidth.c: file removal
lib/libc/string/wmemcmp.c: revision 1.4
regress/lib/libc/locale/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/en_US.UTF-8.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.exp.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.in.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.exp.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.in.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.SJIS.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.eucJP.exp.uue: revision 1.2
regress/lib/libc/locale/ctype2/Makefile: revision 1.5
regress/lib/libc/locale/ctype2/ja_JP.ISO-2022-JP-2.in.uue: revision 1.1
regress/lib/libc/locale/ctype2/ja_JP.ISO2022-JP2.in.uue: file removal
regress/lib/libc/locale/ctype3/Makefile: revision 1.5
regress/lib/libc/locale/mbtowc/Makefile: revision 1.3
regress/lib/libc/locale/mbtowc/ja_JP.ISO-2022-JP: revision 1.1
regress/lib/libc/locale/mbtowc/ja_JP.ISO2022-JP: file removal
regress/lib/libc/locale/wcstod/wcstod_test.c: revision 1.2
share/locale/Makefile.locale: revision 1.1
share/locale/Makefile: revision 1.5
share/locale/ctype/Makefile: revision 1.28
share/locale/locale.alias: revision 1.11
share/locale/messages/Makefile: revision 1.5
share/locale/messages/en_US.ISO8859-1.src: file removal
share/locale/messages/en_US.US-ASCII.src: revision 1.1
share/locale/messages/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/messages/ja_JP.ct.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-2.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-5.src: revision 1.1
share/locale/messages/sr_YU.ISO8859-2.src: file removal
share/locale/messages/sr_YU.ISO8859-5.src: file removal
share/locale/messages/sr_YU.UTF-8.src: file removal
share/locale/messages/zh_CN.GB18030.src: file removal
share/locale/messages/zh_TW.eucTW.src: revision 1.1
share/locale/monetary/Makefile: revision 1.5
share/locale/monetary/af_ZA.ISO8859-1.src: revision 1.2
share/locale/monetary/am_ET.UTF-8.src: revision 1.2
share/locale/monetary/be_BY.CP1131.src: file removal
share/locale/monetary/be_BY.CP1251.src: revision 1.2
share/locale/monetary/be_BY.ISO8859-5.src: revision 1.2
share/locale/monetary/be_BY.UTF-8.src: revision 1.2
share/locale/monetary/bg_BG.CP1251.src: revision 1.2
share/locale/monetary/bg_BG.UTF-8.src: revision 1.2
share/locale/monetary/ca_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/cs_CZ.ISO8859-2.src: revision 1.2
share/locale/monetary/cs_CZ.UTF-8.src: revision 1.2
share/locale/monetary/da_DK.ISO8859-1.src: revision 1.2
share/locale/monetary/de_AT.ISO8859-1.src: revision 1.2
share/locale/monetary/de_CH.ISO8859-1.src: revision 1.2
share/locale/monetary/de_DE.ISO8859-1.src: revision 1.2
share/locale/monetary/el_GR.ISO8859-7.src: revision 1.2
share/locale/monetary/en_AU.ISO8859-1.src: revision 1.2
share/locale/monetary/en_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.UTF-8.src: revision 1.2
share/locale/monetary/en_IE.UTF-8.src: revision 1.2
share/locale/monetary/en_NZ.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.US-ASCII.src: revision 1.1
share/locale/monetary/es_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/et_EE.ISO8859-15.src: revision 1.2
share/locale/monetary/fi_FI.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_FR.ISO8859-1.src: revision 1.2
share/locale/monetary/he_IL.UTF-8.src: revision 1.2
share/locale/monetary/hi_IN.ISCII-DEV.src: revision 1.2
share/locale/monetary/hr_HR.ISO8859-2.src: revision 1.2
share/locale/monetary/hu_HU.ISO8859-2.src: revision 1.2
share/locale/monetary/hy_AM.ARMSCII-8.src: revision 1.2
share/locale/monetary/hy_AM.UTF-8.src: revision 1.2
share/locale/monetary/is_IS.ISO8859-1.src: revision 1.2
share/locale/monetary/it_IT.ISO8859-1.src: revision 1.2
share/locale/monetary/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/monetary/ja_JP.UTF-8.src: revision 1.2
share/locale/monetary/ja_JP.eucJP.src: revision 1.2
share/locale/monetary/kk_KZ.PT154.src: revision 1.2
share/locale/monetary/kk_KZ.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.eucKR.src: revision 1.2
share/locale/monetary/lt_LT.ISO8859-13.src: revision 1.2
share/locale/monetary/mn_MN.UTF-8.src: revision 1.2
share/locale/monetary/nl_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/nl_NL.ISO8859-1.src: revision 1.2
share/locale/monetary/no_NO.ISO8859-1.src: revision 1.2
share/locale/monetary/pl_PL.ISO8859-2.src: revision 1.2
share/locale/monetary/pl_PL.UTF-8.src: revision 1.2
share/locale/monetary/pt_BR.ISO8859-1.src: revision 1.2
share/locale/monetary/pt_PT.ISO8859-1.src: revision 1.2
share/locale/monetary/ro_RO.ISO8859-2.src: revision 1.2
share/locale/monetary/ru_RU.CP1251.src: revision 1.2
share/locale/monetary/ru_RU.CP866.src: revision 1.2
share/locale/monetary/ru_RU.ISO8859-5.src: revision 1.2
share/locale/monetary/ru_RU.KOI8-R.src: revision 1.2
share/locale/monetary/ru_RU.UTF-8.src: revision 1.2
share/locale/monetary/sk_SK.ISO8859-2.src: revision 1.2
share/locale/monetary/sl_SI.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_ME.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_RS.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_YU.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_YU.ISO8859-5.src: revision 1.2
share/locale/monetary/sr_YU.UTF-8.src: revision 1.2
share/locale/monetary/sv_SE.ISO8859-1.src: revision 1.2
share/locale/monetary/tr_TR.ISO8859-9.src: revision 1.2
share/locale/monetary/uk_UA.CP1251.src: revision 1.2
share/locale/monetary/uk_UA.ISO8859-5.src: revision 1.2
share/locale/monetary/uk_UA.KOI8-U.src: revision 1.2
share/locale/monetary/uk_UA.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.GB18030.src: revision 1.2
share/locale/monetary/zh_CN.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.eucCN.src: revision 1.2
share/locale/monetary/zh_HK.Big5hkscs.src: revision 1.1
share/locale/monetary/zh_HK.UTF-8.src: revision 1.2
share/locale/monetary/zh_TW.Big5.src: revision 1.2
share/locale/numeric/Makefile: revision 1.4
share/locale/numeric/am_ET.UTF-8.src: file removal
share/locale/numeric/en_US.ISO8859-1.src: file removal
share/locale/numeric/en_US.US-ASCII.src: revision 1.1
share/locale/numeric/ja_JP.eucJP.src: file removal
share/locale/numeric/ko_KR.eucKR.src: file removal
share/locale/numeric/mn_MN.UTF-8.src: file removal
share/locale/numeric/sr_ME.ISO8859-2.src: revision 1.1
share/locale/numeric/sr_YU.ISO8859-2.src: file removal
share/locale/numeric/sr_YU.ISO8859-5.src: file removal
share/locale/numeric/zh_CN.eucCN.src: file removal
share/locale/time/Makefile: revision 1.5
share/locale/time/en_US.ISO8859-1.src: file removal
share/locale/time/en_US.US-ASCII.src: revision 1.1
share/locale/time/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/time/ja_JP.ct.src: revision 1.1
share/locale/time/sr_ME.ISO8859-2.src: revision 1.1
share/locale/time/sr_ME.ISO8859-5.src: revision 1.1
share/locale/time/sr_ME.UTF-8.src: revision 1.1
share/locale/time/sr_YU.ISO8859-2.src: file removal
share/locale/time/sr_YU.ISO8859-5.src: file removal
share/locale/time/sr_YU.UTF-8.src: file removal
share/locale/time/zh_CN.GB18030.src: file removal
share/locale/time/zh_TW.eucTW.src: revision 1.1
usr.bin/locale/locale.c: revision 1.6
usr.bin/mklocale/Makefile: revision 1.12
usr.bin/mklocale/lex.l: revision 1.14
usr.bin/mklocale/mklocaledb.c: revision 1.1
usr.bin/mklocale/yacc.y: revision 1.25
usr.sbin/chrtbl/Makefile: revision 1.8
usr.sbin/chrtbl/ctypeio.c: revision 1.1
usr.sbin/chrtbl/ctypeio.h: revision 1.1
Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES}
db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).
[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].
[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().
[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<
old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.167.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.180.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.180.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.180.2.1 17-Apr-2012  yamt sync with head
 1.184.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.184.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.187.2.1 10-Aug-2014  tls Rebase.
 1.195.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.195.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.197.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.198.2.1 11-May-2017  pgoyette Sync with HEAD
 1.216.2.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.216.2.1 08-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #930):

lib/libc/include/extern.h: revision 1.30
distrib/sets/lists/base/shl.mi: revision 1.987 (patch)
external/bsd/blocklist/bin/support.c: revision 1.2
external/bsd/blocklist/bin/blocklistd.c: revision 1.5
external/bsd/blocklist/bin/blocklistd.8: revision 1.3
sys/sys/syslog.h: revision 1.42
external/bsd/blocklist/bin/support.h: revision 1.2
external/bsd/blocklist/include/blocklist.h: revision 1.3
crypto/external/bsd/openssh/dist/pfilter.c: revision 1.9
external/bsd/blocklist/lib/shlib_version: revision 1.2
lib/libc/gen/syslog_ss.c: revision 1.4
lib/libc/gen/Makefile.inc: revision 1.218
external/bsd/blocklist/lib/bl.c: revision 1.3
external/bsd/blocklist/README: revision 1.3
external/bsd/blocklist/include/bl.h: revision 1.2
distrib/sets/lists/debug/shl.mi: revision 1.347 (patch)
distrib/sets/lists/comp/mi: revision 1.2462
lib/libc/gen/syslog.3: revision 1.34
lib/libc/gen/syslog.3: revision 1.35
external/bsd/blocklist/libexec/blocklistd-helper: revision 1.8
external/bsd/blocklist/lib/libblocklist.3: revision 1.4
external/bsd/blocklist/lib/libblocklist.3: revision 1.5
external/bsd/blocklist/lib/libblocklist.3: revision 1.6
external/bsd/blocklist/lib/blocklist.c: revision 1.3

Spelling fixes

PR/58391: Noriyuki Soda: re-adding syslog_ss() to syslog.h and syslog.3

syslog(3): Nix trailing whitespace in man page.
No functional change intended.

reference sockpath instead of sockspath

Add blocklist_open2() that can pass a custom logger or NULL for no logging.
Switch internally to use syslog_r. Add compatibility for systems that don't
have syslog_r.

Switch blocklist to use syslog_ss since we are being called from a
signal handler.

bump libblocklist
remove trailing space

Silence a bogus warning when starting up:
NetBSD pf:
No ALTQ support in kernel
ALTQ related functions disabled
FreeBSD pf:
Anchor 'blacklistd' not found.
The anchor is indeed found and working correctly. This patch just
discards stderr's output, like in other places.
(jlduran@github)

update markup (Ed Maste)
 1.217.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 12-Dec-1994  mycroft Clean up deleted files.
 1.1 11-Dec-1994  christos - Changed all internal libc references of {v,}err{x,} and {v,}warn{x,} to
__{v,}err{x,} and __{v,}warn{x,}
- moved err.c to __err.c and added err.c which contains weak references for
the above functions.
- Reordered the functions in __err.c to avoid redeclarations and changed
the varargs declarations to conform with the K&R style.
 1.10 13-Sep-2005  christos compat core reorg.
 1.9 20-Jan-2005  kleink Add ENOATTR (and a missing comma); noted by Takehiko NOZAKI.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 27-May-2003  kleink Add ETIME, per POSIX-2001.
 1.6 09-Apr-2003  kleink Change the strerror() string for ERANGE consistently to "Result too
large or too small" and reword its intro(2) description to reflect
the present use for non-numerical out-of-range errors; resolves
Andrew Brown's PR standards/21004, the discussion of which was
dramatically sped up by repeated whipping from Perry Metzger. :-)
 1.5 12-Nov-2002  kleink Review oversight: ENOSR: resource -> resources, which is what the
standard says, and which fits the resource allocation failure better.
 1.4 12-Nov-2002  skrll Add the missing errno symbols that are defined in IEEE Std 1003.1-2001.
The language message files need updating.

Change reviewed and OK'd by Klaus Klein.
 1.3 10-Mar-2000  kleink branches: 1.3.6;
Add an EILSEQ code (C99, first appeared in C90/AMD1), and update message
catalogs where possible.
 1.2 22-Mar-1999  kleink Introduce EOVERFLOW.
 1.1 30-Nov-1998  thorpej Renamed sys_errlist, exported as a pointer, not an array, so that as new
errors are added, the exported symbol size does not change. Update to
include new errors.
 1.3.6.1 12-Nov-2002  skrll Catch up to -current.
 1.46 13-Sep-2005  christos compat core reorg.
 1.45 19-Aug-2005  christos 64 bit inode changes
 1.44 19-Jan-2005  mycroft Use FD_CLOEXEC.
 1.43 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.42 27-Oct-2003  lukem branches: 1.42.2;
Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.41 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.40 16-Sep-2002  briggs Always use NetBSD's fts(3) in compat builds. Some systems (notably
Red Hat 7.3, at least) do not have fts(3) implementations that work
correctly with -D_FILE_OFFSET_BITS=64.
 1.39 26-Feb-2002  tv branches: 1.39.2;
Add some more bits of host compatibility.
 1.38 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.37 28-Jan-2002  tv Add hooks to make this compilable from src/tools/compat.
 1.36 28-Nov-2001  christos using -Wcast-qual and -Wwrite-strings reveals that we need to use const
char * when we pass "" as an argument to a function. Too bad that they
produce too many other spurious warnings too.
 1.35 09-Jul-2001  christos add fts_safe_changedir() function and use it everywhere.
Idea from Todd Miller <millert@openbsd.org>
 1.34 06-Jun-2001  christos oops, make sure we close the file descriptor...
 1.33 05-Jun-2001  christos Fix problem reported by Kris Kennaway <kris@obsecurity.org>; In
the default case fts(3) uses chdir("..") to ascend the tree. The
sequence of chdir's can be intercepted by a malicious user who
moves a subtree that fts is currently traversing to a higher level,
thus making fts operate outside it's original starting directory.
 1.32 05-Nov-2000  christos branches: 1.32.2;
add a lint comment.
 1.31 07-Aug-2000  enami - Test allocation failure.
- Don't leave a pointer dangling on failure case.
- Don't leak a file descriptor on failure case.
 1.30 07-Aug-2000  enami Nuke redundant test (though, gcc optimizer was clever enough not to emit
redundant code).
 1.29 07-Aug-2000  enami - Wrap long lines.
- Protect multi-statement macro with do {} while (0)
 1.28 22-Jan-2000  mycroft branches: 1.28.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.27 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.26 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.25 27-Aug-1999  mycroft Readd my change from fts.c rev 1.10, which was incorrectly removed in rev 1.19
(HI CHRISTOS!):
Avoid extra stat()s if a link count of 1 is returned for directories but the
d_type field is filled in.
 1.24 27-Aug-1999  mycroft Adjust fts_pow2() for LP64 before Ross bricks me.
 1.23 27-Aug-1999  mycroft GC one line of unneeded code.
 1.22 27-Aug-1999  mycroft Fix the comment above fts_palloc().
Also, fail with ENOMEM if fts_pathlen would overflow, rather than silently truncating the
path.
 1.21 27-Aug-1999  mycroft Avoid memory leaks when realloc() fails (by storing the return value in a temporary, and
testing it before assigning it; fts_close(3) will deallocate the old memory).
 1.20 27-Aug-1999  mycroft Fix multiple problems in the FTS_NOCHDIR case:
* There was an off-by-one error that caused the addition of a NUL or slash in fts_build() to
overwrite other memory.
* After fts_palloc(), we need to reset `cp' so that it points to the new path name buffer;
otherwise the addition of the file name before calling fts_stat() could lose.
Also, fix stupidity in the fts_palloc() interface. We don't want N bytes more than the
current buffer size; we want N bytes more than the current length. Just pass in the new
size, since we can't figure it out easily here.
 1.19 27-Aug-1999  mycroft Allocate the path name buffer by powers of 2.
 1.18 26-Aug-1999  mycroft Minor change to previous.
 1.17 26-Aug-1999  mycroft Fix 3 bugs:
* When not using FTS_NOCHDIR, fts_accpath == fts_name. fts_padjust should not
try to move fts_accpath in this case.
* Previous entries at the same level also need to be adjusted.
* A bug was introduced in rev 1.8 (HI CHRISTOS!!) that caused the maxlen
comparison to always fail (due to type promotions) when sp->fts_pathlen ==
cur->fts_pathlen -- thus causing memory stompage.
 1.16 10-Jun-1999  christos make this compile under linux too.
 1.15 16-Mar-1999  christos branches: 1.15.2;
Fix gcc-2.8.1 warnings.
 1.14 01-Dec-1998  thorpej Warn about references to the old fts functions, and direct the user to
include <fts.h> to generate the correct references.

Suggestion from Christoph Badura.
 1.13 12-Nov-1998  christos delint
 1.12 06-Nov-1998  christos qsort cast.
 1.11 05-Nov-1998  christos minor performance improvement.
 1.10 05-Nov-1998  christos rename len to dlen...
 1.9 05-Nov-1998  frueauf Make this compile again: dp->dp_namlen -> dp->d_namlen.
 1.8 03-Nov-1998  christos compile under svr4; no dp->d_namlen, and no whiteouts.
 1.7 17-Oct-1998  itohy Fix fts_close() not to (implicitly) read free()'ed memory.
This fix closes PR #6181.
 1.6 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.5 27-Feb-1998  perry trivial changes to quiet lint.
 1.4 03-Feb-1998  perry remove obsolete register declarations
 1.3 22-Oct-1997  thorpej Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.2 22-Oct-1997  fvdl New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.
 1.1 21-Oct-1997  fvdl branches: 1.1.1; 1.1.2;
Hacks to enable libc to work without bumping the major.
 1.1.2.2 22-Oct-1997  thorpej Pull up from trunk:

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.1.2.1 21-Oct-1997  thorpej file __fts13.c was added on branch netbsd-1-3 on 1997-10-22 06:41:23 +0000
 1.1.1.1 02-Feb-1998  perry import lite-2
 1.15.2.1 03-Sep-1999  he Pull up revisions 1.16-1.25:
Fix various bug in fts(3), preventing a buffer overflow on a very
deep tree, and a silent trucation of the path when fts_pathlen
overflows. Also, make this compile on Linux. (bouyer)
 1.28.4.2 22-Aug-2001  tv Pullup [tv]:

lib/libc/gen/__fts13.c 1.35

Add a fts_safe_changedir() function to do sanity checking of paths
passed to chdir(). Avoids a race condition when parent paths or
symlinks are moved mid-traversal.
 1.28.4.1 10-Jun-2001  he Pull up revisions 1.29-1.34 (requested by christos):
Make sure we ascend in the same tree we descended, to counter
the effects of otherwise possibly malicious directory tree moves.
Also improve error handling.
 1.32.2.5 17-Sep-2002  nathanw Catch up to -current.
 1.32.2.4 22-Mar-2002  nathanw Catch up to -current.
 1.32.2.3 08-Mar-2002  nathanw Catch up to -current.
 1.32.2.2 28-Jan-2002  nathanw Catch up to -current.
 1.32.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.39.2.1 01-Dec-2002  he Pull up revision 1.40 (requested by thorpej in ticket #834):
Always NetBSD's own fts(3) in compat builds. Some systems
(among them RedHat 7.3) do not have fts(3) implementations
which work correctly with -D_FILE_OFFSET_BITS=64.
 1.42.2.1 22-Jun-2004  tron Pull up revision 1.43 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.2 13-Sep-2005  christos compat core reorg.
 1.1 19-Aug-2005  christos 64 bit inode changes
 1.3 13-Sep-2005  christos compat core reorg.
 1.2 12-Apr-2005  drochner the real reason behind PR lib/29919 was that there was a __weak_alias,
obviously copied from getmntinfo.c, referencing the compatibility
getmntinfo()
 1.1 21-Apr-2004  christos branches: 1.1.2;
Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.1.2.1 01-Mar-2006  riz Pull up following revision(s) (requested by drochner in ticket #1187):
lib/libc/gen/__getmntinfo13.c: revision 1.2
the real reason behind PR lib/29919 was that there was a __weak_alias,
obviously copied from getmntinfo.c, referencing the compatibility
getmntinfo()
 1.29 13-Sep-2005  christos compat core reorg.
 1.28 19-Apr-2005  christos check for pwd != NULL
 1.27 31-Mar-2005  christos detect when this is used as a tool and don't use the _r getpw functions.
 1.26 30-Mar-2005  christos use re-entrant versions of getpw*(). In libc only pwcache remains and this
cannot be changed easily because it involves an API change.
 1.25 07-Aug-2003  agc branches: 1.25.2; 1.25.4; 1.25.6; 1.25.8;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.24 17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.23 18-Sep-2001  christos From Brian Ginsbach: Fix overflow detection, and only abort on long paths
when GLOB_ERR is set.
 1.22 08-Sep-2001  christos Selected fixes from Brian Ginsbach <ginsbach@cray.com>, modified by me.
- handle globbing of patterns that contain unmatched braces. Globbing
a pattern "foo{" in a directory that contains "foo{" now works.
- check for MAXPATHLEN overflows during filename generation (security problem).
- Posix/XOpen fixes to always return GLOB_ABORTED when a directory open fails
or when a file access fails.
- pathc was not initialized to 0 in one case.
Also
- rename err to error, so that it does not conflict with the libc function.
 1.21 03-Apr-2001  christos Fix sentinel for the buffer in globtilde. It was off by x 2. Noted by Theo.
 1.20 28-Mar-2001  christos try to make this compile on 1.4.x
 1.19 28-Mar-2001  christos deal with buffer overflows for fixed length buffers.
 1.18 28-Mar-2001  christos KNF. no functional differences.
 1.17 18-Mar-2001  christos set gl_pathv to NULL after we free it.
 1.16 16-Mar-2001  christos limit the amount of memory used, not the number of arguments used.
 1.15 16-Mar-2001  christos Implement GLOB_LIMIT that limits number of matches to ARG_MAX.
 1.14 16-Oct-2000  erh branches: 1.14.2;
Squash lint errors by using size_t instead of u_int to avoid differing sizes of data.
 1.13 22-Jan-2000  mycroft branches: 1.13.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.12 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.11 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.10 07-Feb-1999  lukem branches: 1.10.2;
fix bug introduced in rev 1.8 during delint(1)ing which broke globbing ~/
(hi christos! ;)
 1.9 01-Dec-1998  thorpej Warn about references to the old glob functions, and direct the user to
include <glob.h> to generate the correct references.

Suggestion from Christoph Badura.
 1.8 13-Nov-1998  christos delint! -- actually fix a bug lint found, globtilde could never have worked...
 1.7 26-Jul-1998  mycroft const poisoning.
 1.6 19-Jun-1998  kleink * Remove GLOB_QUOTE, add GLOB_NOESCAPE. Per POSIX, backslash quoting of
special characters is the default behaviour, which may be disabled by
setting GLOB_NOESCAPE.
* If no matching pathnames have been found and GLOB_NOCHECK was not set
(or special csh(1)-specific treatment of magic characters was requested),
return GLOB_NOMATCH instead of 0; the latter would indicate a successful
operation.
* Use strcoll() instead of strcmp() to sort globbed pathnames.
 1.5 31-Mar-1998  kleink Replace the old GLOB_ABEND constant with (the standardized) GLOB_ABORTED.
 1.4 03-Feb-1998  perry remove obsolete register declarations
 1.3 22-Oct-1997  thorpej Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.2 22-Oct-1997  fvdl New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.
 1.1 21-Oct-1997  fvdl branches: 1.1.2;
Hacks to enable libc to work without bumping the major.
 1.1.2.2 22-Oct-1997  thorpej Pull up from trunk:

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.1.2.1 21-Oct-1997  thorpej file __glob13.c was added on branch netbsd-1-3 on 1997-10-22 06:41:27 +0000
 1.10.2.2 04-Apr-2001  he Pull up revision 1.21 (requested by christos):
Globtilde buffer sentinel was off by a factor of 2.
 1.10.2.1 01-Apr-2001  he Pull up revisions 1.11-1.20 (requested by christos):
Fixes buffer overflow problems in glob(3). Adds and uses GLOB_LIMIT
to prevent denial of service attacks.
(syncs to current head of trunk).
 1.13.4.2 04-Apr-2001  he Pull up revision 1.21 (requested by christos):
Fix sentinel for the buffer in globtilde. It was off by x 2.
 1.13.4.1 29-Mar-2001  lukem pull up revs 1.13 - 1.20 (for christos):
* deal with buffer overflows for fixed length buffers
* set gl_pathv to NULL after we free it
* implement GLOB_LIMIT to limit the amount of memory used to ARG_MAX
* squash lint errors by using size_t instead of u_int
 1.14.2.2 10-Dec-2002  thorpej Sync with HEAD.
 1.14.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.25.8.1 02-Dec-2006  bouyer Pull up following revision(s) (requested by joerg in ticket #10789):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
 1.25.6.4 02-Dec-2006  bouyer Pull up following revision(s) (requested by joerg in ticket #1596):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
 1.25.6.3 09-Jul-2005  tron branches: 1.25.6.3.2; 1.25.6.3.4;
Pull up revision 1.28 (requested by lukem in ticket #533):
check for pwd != NULL
 1.25.6.2 04-Apr-2005  tron Pull up revision 1.27 (requested by thorpej in ticket #98):
detect when this is used as a tool and don't use the _r getpw functions.
 1.25.6.1 04-Apr-2005  tron Pull up revision 1.26 (requested by thorpej in ticket #97):
use re-entrant versions of getpw*(). In libc only pwcache remains and this
cannot be changed easily because it involves an API change.
 1.25.6.3.4.1 02-Dec-2006  bouyer Pull up following revision(s) (requested by joerg in ticket #1596):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
 1.25.6.3.2.1 02-Dec-2006  bouyer Pull up following revision(s) (requested by joerg in ticket #1596):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
 1.25.4.1 02-Dec-2006  bouyer Pull up following revision(s) (requested by joerg in ticket #10789):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
 1.25.2.1 02-Dec-2006  bouyer Pull up following revision(s) (requested by joerg in ticket #10789):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
 1.2 13-Sep-2005  christos compat core reorg.
 1.1 19-Aug-2005  christos 64 bit inode changes
 1.2 13-Sep-2005  christos compat core reorg.
 1.1 19-Aug-2005  christos 64 bit inode changes
 1.2 13-Sep-2005  christos compat core reorg.
 1.1 19-Aug-2005  christos 64 bit inode changes
 1.4 13-Sep-2005  christos compat core reorg.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.2 20-Mar-2002  christos add signals 33-63, so that stupid loserland programs that access the array
directly don't lose!
 1.1 30-Nov-1998  thorpej branches: 1.1.12;
Renamed sys_siglist and sys_signame, exported as a pointer, not an array,
so that as new signals are added, the exported symbol size does not change.
Update to include new signals.
 1.1.12.1 22-Mar-2002  nathanw Catch up to -current.
 1.4 13-Sep-2005  christos compat core reorg.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.2 20-Mar-2002  christos add the rt signals so we don't core-dump.
 1.1 30-Nov-1998  thorpej branches: 1.1.12;
Renamed sys_siglist and sys_signame, exported as a pointer, not an array,
so that as new signals are added, the exported symbol size does not change.
Update to include new signals.
 1.1.12.1 22-Mar-2002  nathanw Catch up to -current.
 1.3 13-Sep-2005  christos compat core reorg.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 26-Sep-1998  christos Adapt to new signal changes (from Jason)
 1.4 13-Sep-2005  christos compat core reorg.
 1.3 09-Apr-2005  dsl Change some integral types, long => clock_t.
IIRC this stops some warnings on 64bit systems
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 30-Jun-2002  bjh21 branches: 1.1.2;
Version times() so that programs compiled before the recent change to make
sysconf(_SC_CLK_TCK) return hz will work.

In detail:
__times13() returns values scaled by hz.
times() returns values scaled by 100.
<sys/times.h> renames times() to __times13().

_SC_CLK_TCK has changed from 3 to 39.
sysconf(3) returns 100.
sysconf(39) returns hz.
CLK_TCK is defined as sysconf(39).
 1.1.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 30-Jun-2002  nathanw file __times13.c was added on branch nathanw_sa on 2002-08-01 03:28:09 +0000
 1.13 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.12 17-Jul-2011  joerg branches: 1.12.2; 1.12.8;
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.11 13-Sep-2005  christos compat core reorg.
 1.10 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.9 12-Jun-2005  lukem Add missing __RCSID()
 1.8 09-Jan-1998  perry RCS Id Police.
 1.7 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.6 17-Jul-1997  thorpej branches: 1.6.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.5 17-Apr-1996  cgd #define _verr* to verr*, to make these use prototypes correctly
and compile in the "no indr_references" case.
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.6.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.12.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.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.2 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.1 16-Jan-2014  christos Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.2 12-Dec-1994  mycroft Clean up deleted files.
 1.1 10-Oct-1994  jtc Renamed sys_errlist[] and sys_nerr to __sys_errlist[] and __sys_nerr.
The traditional API of sys_errlist[] and sys_nerr is provided by weak
references if they are supported. Otherwise, we're forced to have to
have two copies of the error message string table in the library.
Fortunately, unless a program uses both sys_errlist[] and strerror(),
only one of the copies will be linked into the executable.

This is all to provide an clean namespace as required by ANSI. I've
done the same for sys_siglist[], even though it is not required, to
be consistant.
 1.14 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.13 28-Apr-2008  martin branches: 1.13.8;
Remove clause 3 and 4 from TNF licenses
 1.12 12-Jun-2005  lukem branches: 1.12.18;
Add missing __RCSID()
 1.11 28-May-2003  christos no need to declare __isthreaded.
 1.10 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.9 10-Dec-2000  christos branches: 1.9.2;
-Wredundant-declarations does not like nested extern declarations.
 1.8 10-Dec-1999  explorer revert this file, the changes I made were quite unnecessary.
 1.7 03-Dec-1999  explorer Put the function prototype back. Grr.
 1.6 03-Dec-1999  explorer Do this a bit differently.

On platforms where we can use weak aliases, use
__weak_alias(__errno, __errno_func);
and on platforms where we cannot, just compile the function as
__errno, since on those platforms we cannot make libc thread-safe,
at least using this trick.

Are there any platforms where we cannot do __weak_alias() anymore?
 1.5 03-Dec-1999  explorer Make __errno() be a weak alias for __errno_func(), so thread packages
can actually override what plain old 'errno' looks like.
 1.4 30-Jul-1997  jtc branches: 1.4.8;
Fix files using old TNF copyright notice
 1.3 13-Jul-1997  christos Move the #undef errno where it is actually needed.
 1.2 08-Nov-1996  jtc Declare global errno
 1.1 07-Nov-1996  jtc New __errno() function, returns the address of the errno variable.
 1.4.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.2.2 30-Dec-2001  nathanw Instead of doing the thread-specific-date and once-initializer song
and dance here, just call the new thr_errno() when in threaded mode.

This avoids an ugly interdependancy between malloc(), which wants to
set errno (during initialization and errors), and errno, which used to
want to malloc() the thread-specific storage.
 1.9.2.1 08-Aug-2001  nathanw Make errno thread-specific when necessary.
 1.12.18.1 18-May-2008  yamt sync with head.
 1.13.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.13.8.1 28-Apr-2008  martin file _errno.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.13 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.12 17-Jul-2011  joerg branches: 1.12.2; 1.12.8;
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.11 13-Sep-2005  christos compat core reorg.
 1.10 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.9 12-Jun-2005  lukem Add missing __RCSID()
 1.8 09-Jan-1998  perry RCS Id Police.
 1.7 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.6 17-Jul-1997  thorpej branches: 1.6.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.5 17-Apr-1996  cgd #define _verr* to verr*, to make these use prototypes correctly
and compile in the "no indr_references" case.
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.6.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.12.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.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.4 30-Apr-2008  martin branches: 1.4.8;
Convert TNF licenses to new 2 clause variant
 1.3 16-Apr-2003  wiz branches: 1.3.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1 17-Jan-2003  thorpej branches: 1.1.2;
file _lwp_makecontext.3 was initially added on branch nathanw_sa.
 1.1.2.2 17-Jan-2003  wiz Drop trailing whitespace.
 1.1.2.1 17-Jan-2003  thorpej Document _lwp_makecontext(3).
 1.3.30.1 18-May-2008  yamt sync with head.
 1.4.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.4.8.1 30-Apr-2008  martin file _lwp_makecontext.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 12-Dec-1994  mycroft Clean up deleted files.
 1.1 10-Oct-1994  jtc Renamed sys_errlist[] and sys_nerr to __sys_errlist[] and __sys_nerr.
The traditional API of sys_errlist[] and sys_nerr is provided by weak
references if they are supported. Otherwise, we're forced to have to
have two copies of the error message string table in the library.
Fortunately, unless a program uses both sys_errlist[] and strerror(),
only one of the copies will be linked into the executable.

This is all to provide an clean namespace as required by ANSI. I've
done the same for sys_siglist[], even though it is not required, to
be consistant.
 1.10 13-Sep-2005  christos compat core reorg.
 1.9 30-Jul-2005  christos - Fix the remaining indr_references so that they define lint symbols.
- Add an internal symbol for strerror_r (thanks klaus for noticing)
- Remove internal __strerror
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 06-Dec-1998  jonathan Move warnings about sys_errlist[], sys_nerr, __sys_errlist, _sys_nerr
to _sys_siglist.c, so the warning is shown once at link time, not three times
(once for errlist.c itself, once each for the two includes in _sys_siglist.c).
 1.6 09-Jan-1998  perry RCS Id Police.
 1.5 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.4 23-Mar-1995  jtc branches: 1.4.8;
Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.3 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.2 17-Dec-1994  pk Provide backwards compatibility with previous "doubly-underscored"
symbols. Avoids updating libc's major version number for this internal change.
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.4.8.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.10 13-Sep-2005  christos compat core reorg.
 1.9 30-Jul-2005  christos - Fix the remaining indr_references so that they define lint symbols.
- Add an internal symbol for strerror_r (thanks klaus for noticing)
- Remove internal __strerror
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 13-Nov-1998  christos delint
 1.6 09-Jan-1998  perry RCS Id Police.
 1.5 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.4 23-Mar-1995  jtc branches: 1.4.8;
Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.3 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.2 17-Dec-1994  pk Provide backwards compatibility with previous "doubly-underscored"
symbols. Avoids updating libc's major version number for this internal change.
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.4.8.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.11 13-Sep-2005  christos compat core reorg.
 1.10 30-Jul-2005  christos - Fix the remaining indr_references so that they define lint symbols.
- Add an internal symbol for strerror_r (thanks klaus for noticing)
- Remove internal __strerror
 1.9 12-Jun-2005  lukem Add missing __RCSID()
 1.8 06-Dec-1998  jonathan Move warnings about sys_siglist[] and __sys_siglist to _sys_siglist.c,
so that the warning is shown once at link time, not three times.
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.5 23-Mar-1995  jtc branches: 1.5.8;
Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.4 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.3 17-Dec-1994  pk Provide backwards compatibility with previous "doubly-underscored"
symbols. Avoids updating libc's major version number for this internal change.
 1.2 17-Dec-1994  pk Refer to _sys_siglist with just one underscore.
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5.8.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.7 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.6 20-Mar-2012  matt branches: 1.6.2;
Use C89 definitions.
Remove use of __P
 1.5 21-Oct-2009  snj branches: 1.5.6;
Remove 3rd and 4th clauses in christos' license. OK christos.
 1.4 13-Sep-2005  christos compat core reorg.
 1.3 30-Jul-2005  christos - Fix the remaining indr_references so that they define lint symbols.
- Add an internal symbol for strerror_r (thanks klaus for noticing)
- Remove internal __strerror
 1.2 12-Jun-2005  lukem Add missing __RCSID()
 1.1 07-May-2001  kleink branches: 1.1.2;
Internally rename sysconf() to __sysconf() to make its latter name suitable
for use from public headers. Also, do so on all platforms.
 1.1.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.2.1 07-May-2001  nathanw file _sysconf.c was added on branch nathanw_sa on 2001-10-08 20:18:42 +0000
 1.5.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.5.6.1 17-Apr-2012  yamt sync with head
 1.6.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.11 17-Jul-2011  joerg branches: 1.11.2; 1.11.8;
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.10 13-Sep-2005  christos compat core reorg.
 1.9 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.5 17-Jul-1997  thorpej branches: 1.5.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.11.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.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.2 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.1 16-Jan-2014  christos Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.12 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.11 17-Jul-2011  joerg branches: 1.11.2; 1.11.8;
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.10 13-Sep-2005  christos compat core reorg.
 1.9 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.5 17-Jul-1997  thorpej branches: 1.5.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.11.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.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.12 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.11 17-Jul-2011  joerg branches: 1.11.2; 1.11.8;
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.10 13-Sep-2005  christos compat core reorg.
 1.9 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.5 17-Jul-1997  thorpej branches: 1.5.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.11.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.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.2 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.1 16-Jan-2014  christos Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.12 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.11 17-Jul-2011  joerg branches: 1.11.2; 1.11.8;
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.10 13-Sep-2005  christos compat core reorg.
 1.9 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.5 17-Jul-1997  thorpej branches: 1.5.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.11.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.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.12 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.11 17-Jul-2011  joerg branches: 1.11.2; 1.11.8;
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.10 13-Sep-2005  christos compat core reorg.
 1.9 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.5 17-Jul-1997  thorpej branches: 1.5.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.11.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.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.2 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.1 16-Jan-2014  christos Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.12 16-Jan-2014  christos "soon" is "now". Remove all __indr_reference crap.
 1.11 17-Jul-2011  joerg branches: 1.11.2; 1.11.8;
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.10 13-Sep-2005  christos compat core reorg.
 1.9 16-Jul-2005  christos Ignore indirect references when linting.
XXX: All this is done backwards, and is a mess. Really the _foo.c files should
include the _foo function definition, not the foo.c files, like everywhere
else.
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.5 17-Jul-1997  thorpej branches: 1.5.2;
"Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.4 15-Apr-1996  jtc Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.3 23-Mar-1995  jtc Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.2 18-Dec-1994  cgd make libc work again, on systems that don't support __warn_reference
 1.1 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.11.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.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.22 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.21 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.20 02-Oct-2002  wiz process only has one c.
 1.19 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.18 07-Feb-2002  ross Generate <>& symbolically.
 1.17 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.16 16-Sep-2001  wiz Boring whitespace fixes.
 1.15 22-Mar-1999  garbled branches: 1.15.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.14 12-Nov-1998  christos Document error return.
 1.13 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.12 05-Feb-1998  perry add LIBRARY section to man page
 1.11 17-Jan-1997  perry change sigpause(2) to sigsuspend(2) or sigpause(3), depending
Also try to fix other bad references to sig* man pages.
Fixes pr-2885 from Jonathan Stone
These SEE ALSO sections are still bloody messes (sigh)
 1.10 01-Feb-1996  phil Rewrite the description of alarm(3) to match reality.
 1.9 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.8 17-Oct-1994  cgd either change or update references to sigvec(), as appropriate
 1.7 28-Jan-1994  jtc branches: 1.7.2;
More spelling errors
 1.6 10-Jan-1994  jtc Fix spelling errors.
 1.5 14-Oct-1993  jtc Change SYNOPSIS section to use "unsigned" instead of "u_int".
 1.4 04-Oct-1993  jtc Note that alarm() conforms to 1003.1-90.
 1.3 01-Aug-1993  mycroft Add RCS indentifiers.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 17-Oct-1994  cgd from trunk.
 1.15.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.15.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.15.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.15.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.11 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.10 07-Aug-2003  agc branches: 1.10.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 12-Nov-1998  christos delint
 1.7 03-Feb-1998  perry remove obsolete register declarations
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.56.1 30-Oct-2012  yamt sync with head
 1.3 16-Dec-2016  mrg scandir/alphasort take "const struct dirent **" not "const void *" in
modern unix. since we claim to be 'IEEE Std 1003.1-2008', make it so.
 1.2 01-Mar-2009  christos branches: 1.2.28;
no more weak here.
 1.1 19-Aug-2005  christos branches: 1.1.30;
64 bit inode changes
 1.1.30.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.2.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.23 28-Aug-2024  riastradh Bump dates on man pages recently updated to mention VM clones.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.22 27-Aug-2024  riastradh arc4random(3): Note that arc4random respects kern.entropy.epoch.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.21 15-Jul-2016  wiz branches: 1.21.24; 1.21.26;
Fix mdoclint warnings.
 1.20 15-Jul-2016  riastradh Number the properties. Identify the key erasure property by name.
 1.19 17-Nov-2014  riastradh branches: 1.19.2;
Tweak wording, define `output', remove misplaced scaremongering.
 1.18 17-Nov-2014  riastradh Fix Google Groups link.
 1.17 17-Nov-2014  wiz Remove unnecessary Ns before punctuation. Fix a line.
 1.16 17-Nov-2014  riastradh Cross-reference rnd(4).
 1.15 17-Nov-2014  riastradh Markup for BUGS note about arc4random_uniform.
 1.14 17-Nov-2014  riastradh Amplify comment about how quickly RC4 was known to be bad.
 1.13 17-Nov-2014  riastradh Ruminate on security model choices and API design in arc4random(3).
 1.12 17-Nov-2014  riastradh Note relation of arc4random(3) to rand(3)/random(3).
 1.11 16-Nov-2014  wiz Grammar.
 1.10 16-Nov-2014  riastradh Rewrite arc4random(3) with ChaCha20-based PRNG and per-thread state.

Explain the security model in the man page.

No more RC4!

XXX pullup to netbsd-6, netbsd-5
 1.9 05-Feb-2011  wiz branches: 1.9.22;
Remove trailing whitespace.
 1.8 04-Feb-2011  christos add arc4random_{buf,uniform}, from OpenBSD.
 1.7 26-Dec-2005  perry branches: 1.7.40;
u_intN_t -> uintN_t
 1.6 16-Apr-2003  wiz branches: 1.6.2;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.5 28-May-2002  itojun branches: 1.5.2;
add LIBRARY section
 1.4 24-May-2002  itojun refer rnd(4), not random(4).
 1.3 24-May-2002  wiz Quote <> for HTML output.
 1.2 24-May-2002  itojun use /dev/urandom, not /dev/arandom
 1.1 24-May-2002  itojun add arc4random(3). from openbsd
 1.5.2.2 21-Jun-2002  nathanw Catch up to -current.
 1.5.2.1 28-May-2002  nathanw file arc4random.3 was added on branch nathanw_sa on 2002-06-21 18:18:07 +0000
 1.6.2.2 26-Mar-2004  jmc Pullup rev 1.1-1.6 (requested by provos in ticket #1386)

Introduce bcrypt password scheme. Adds the arc4random API for creating
cryptographically strong random numbers.
 1.6.2.1 16-Apr-2003  jmc file arc4random.3 was added on branch netbsd-1-6 on 2004-03-26 22:52:53 +0000
 1.7.40.1 08-Feb-2011  bouyer Sync with HEAD
 1.9.22.1 18-Mar-2015  snj Pull up following revision(s) (requested by riastradh in ticket #597):
lib/libc/gen/arc4random.c: revisions 1.26-1.28
lib/libc/gen/arc4random.3:: revisions 1.10-1.19
Rewrite arc4random(3) with ChaCha20-based PRNG and per-thread state.
Explain the security model in the man page.
No more RC4!
--
Grammar.
--
Note relation of arc4random(3) to rand(3)/random(3).
--
Ruminate on security model choices and API design in arc4random(3).
--
Amplify comment about how quickly RC4 was known to be bad.
--
Markup for BUGS note about arc4random_uniform.
--
Cross-reference rnd(4).
--
Remove unnecessary Ns before punctuation. Fix a line.
--
Fix Google Groups link.
--
Tweak wording, define `output', remove misplaced scaremongering.
--
Fix non _REENTRANT build.
--
Use ChaCha20 here as advertised, not ChaCha8.
Oops.
Fortunately, there is no public cryptanalysis even of ChaCha8: the
best published attack is on ChaCha7 with time complexity 2^248.
 1.19.2.1 26-Jul-2016  pgoyette Sync with HEAD
 1.21.26.1 02-Aug-2025  perseant Sync with HEAD
 1.21.24.1 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.50 11-Mar-2025  riastradh Assign static MIB numbers for kern.entropy.epoch.

This sidesteps any need for dynamically sized memory in userland to
resolve sysctl names to read it out, or for a new syscall interface
to sysctl resolution by name.

It would really be better to expose this through a page shared with
userland, so querying it doesn't cost a syscall, but this will serve
for now.

PR lib/59148: arc4random calls malloc so it can't be used in an ELF
constructor
 1.49 11-Mar-2025  riastradh arc4random(3): Isolate endian-dependence of crypto_onetimestream.

Make it all happen in crypto_le32enc/dec (which in this file is
actually just memcpy). This way you can swap out crypto_le32enc/dec
to test either byte order on any machine, e.g. for generating the
test vectors. And if we ever decide that it's not worthwhile to take
advantage of the purely nondeterministic nature of the API to make
this have potentially less performance penalty on big-endian systems
(which I'm not sure has ever been measured anyway), it'll all
continue to work under

#define crypto_le32enc le32enc
#define crypto_le32dec le32dec

with all the _BYTE_ORDER == _BIG_ENDIAN conditionals removed from the
self-tests.

No change to the code of crypto_onetimstream on hppa under tools gcc.
 1.48 11-Mar-2025  riastradh arc4random(4): Fix crypto_onetimestream_selftest on big-endian.

Had computed the nonce increment the wrong way around when simulating
a big-endian machine to generate this.
 1.47 10-Mar-2025  riastradh arc4random(3): Add self-tests for PRNG algorithm.

Independently generated by running:

head -c 64 </dev/zero \
| openssl enc -chacha -20 \
-K 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f \
-iv -iv 00000000000000000000000000000000 \
| hexdump -C

and then repeating with the first 32 bytes of output as the updated
key for -K, extracting bytes [32, 32 + n) for the n-byte output in
each call.
 1.46 09-Mar-2025  riastradh arc4random(3): Provide a fallback in case pthread_atfork fails.

This is considerably more work and burden on testing than simply
statically preallocating a bit of storage for pthread_atfork to
eliminate the failure mode altogether, but it is less work than
arguing further over the atfork interface:
https://mail-index.NetBSD.org/source-changes-d/2025/03/02/msg014387.html

PR lib/59117: arc4random has some failure modes it shouldn't
 1.45 06-Mar-2025  riastradh t_arc4random: Test arc4random_global.per_thread, not .initialized.

If arc4random_initialize has been called, and thr_keycreate failed,
then .initialized will be true but .per_thread will be false -- and
.thread_key will be garbage (some other thread key for another
purpose, most likely). This path was enabled by allowing
thr_keycreate to fail instead of aborting the process.

This hasn't caused trouble yet, mainly because we don't do anything
to inject faults into thr_keycreate in these tests. Tweak the
global_threadkeylimit test while here to provoke a crash with the
wrong conditional.

Fix a similar edge case in the little test program embedded in
arc4random.c (which should maybe just go away now that we have atf
tests).

PR lib/59117: arc4random has some failure modes it shouldn't
 1.44 06-Mar-2025  riastradh arc4random(3): Switch to use thr_once (libc pthread_once symbol).

This way, we reduce the problem of arc4random initialization
fork-safety to the problem of pthread_once fork-safety -- and
anything else to do with one-time lazy initialization.

PR lib/59124: arc4random(3): first call in process races with
concurrent fork
 1.43 04-Mar-2025  riastradh Revert __libc_atfork addition.

This reverts the following revisions:

lib/libc/gen/arc4random.c 1.40-41 (but not 1.42 which is independent)
lib/libc/gen/pthread_atfork.c 1.24
lib/libc/include/atfork.h 1.1

This additionally updates the comments in arc4random.c to reflect the
current state.

Requested by kre:
https://mail-index.netbsd.org/source-changes-d/2025/03/03/msg014388.html

Since the new symbol __libc_atfork has not been used outside libc,
this poses no ABI compatibility issues.
 1.42 02-Mar-2025  riastradh arc4random(3): Don't ifdef out the self-test.

The runtime cost of this test is negligible (64 bytes of data and a
handful of instructions for the subroutine) and the security value of
verifying a known input/output for the deterministic cryptographic
function on whose security the whole API relies is high.
 1.41 02-Mar-2025  riastradh arc4random(3): Update comments to reflect removal of failure modes.

PR lib/59117: arc4random has some failure modes it shouldn't
 1.40 02-Mar-2025  riastradh libc: New __libc_atfork.

This uses caller-provided storage for the callback queues.

Use it in arc4random(3) in order to avoid possible failure modes.

This is a private symbol, not designed for use outside NetBSD, and
the API is not intended to be stable (yet) -- I just took the
existing purely internal structure (struct atfork_callback) and
reused it for this API without changing any of the calling-side
logic. We could change it, e.g. to use a single structure per call,
to make the API a little less unwieldy, at the cost of
microscopically more storage and runtime for the users that don't use
all three callbacks; to be considered in a future change.

We might reasonably use __libc_atfork in libpthread for use in the
pthread_tsd_init constructor, in order to be confident it never
attempts malloc(3), but let's do that in a separate commit just in
case anything goes awry with that plan.

PR lib/59112: libpthread constructors use malloc
PR lib/59117: arc4random has some failure modes it shouldn't
 1.39 02-Mar-2025  riastradh arc4random(3): Avoid failure due to thread key limits.

If thr_keycreate (a.k.a. pthread_key_create) fails, fall back to
using globally serialized state instead of per-thread state. This is
unlikely to happen but arc4random(3) should work even if it does.
New test case forces exercising this path (at least, simulating the
effect of key creation failure).

PR lib/59117: arc4random has some failure modes it shouldn't
 1.38 29-Aug-2024  riastradh arc4random(3): Pacify some of lint's complaints.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.37 27-Aug-2024  riastradh arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.36 26-Aug-2024  riastradh arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.35 26-Aug-2024  riastradh arc4random(3): Reseed if system entropy epoch changes.

This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but

1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and

2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by

(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and

(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.

So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.34 20-Jan-2024  christos branches: 1.34.2;
Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.33 19-Apr-2022  rillig branches: 1.33.2;
lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.32 23-Sep-2019  christos lint is not smart enough to figure out that ilog2() is constant.
 1.31 25-Mar-2016  riastradh branches: 1.31.16;
KNF
 1.30 13-May-2015  justin Missing MAP_PRIVATE on mmap
 1.29 19-Mar-2015  riastradh Remove #ifdef MAP_INHERIT_ZERO.

This is essential for fork-safety, so don't merely #warn about it.
Attaining fork-safety without it requires restructuring things -- in
particular, there's no clear way to make it per-thread and fork-safe
without some global list of states to zero on fork.
 1.28 21-Jan-2015  riastradh Use ChaCha20 here as advertised, not ChaCha8.

Oops.

Fortunately, there is no public cryptanalysis even of ChaCha8: the
best published attack is on ChaCha7 with time complexity 2^248.
 1.27 20-Jan-2015  christos Fix non _REENTRANT build.
 1.26 16-Nov-2014  riastradh Rewrite arc4random(3) with ChaCha20-based PRNG and per-thread state.

Explain the security model in the man page.

No more RC4!

XXX pullup to netbsd-6, netbsd-5
 1.25 19-Jul-2014  roy branches: 1.25.2;
Document that our use of pthread_mutex_unlock(3) is async-signal-safe
and as such can be used in a phtread_atfork(3) child handler.
 1.24 12-Jun-2014  apb fix missing backslash in previous
 1.23 12-Jun-2014  apb Wrap complex macros in do { ... } while (0). Also replace the magic
number 1600000 with a macro.
 1.22 07-Jun-2014  roy Re-stir after forking, fixes PR lib/25367.
Re-stir after consuming 1600000 bytes, fixes PR lib/45952.
 1.21 17-Oct-2013  christos branches: 1.21.2;
remove always inline because new gcc bitches.
 1.20 20-Aug-2012  dsl branches: 1.20.2;
I'm fairly sure the libc rules require that arc4random_addrandom,
arc4random_buf, arc4random_stir and arc4random_uniform be weak.
 1.19 20-Aug-2012  dsl arc4 is a random number sequence, there is no point using its own
output values to determine a number of output values to skip.
Skipping values on any possibly random event might be worth while, as
might using the keying algorithm to stir in a possibly random value.
 1.18 20-Aug-2012  dsl Since 'rs' is statically initialised (not bss) its s[] might as well be
compile-time initialised as well.
arc4_init) is the same as arc4_stir().
Initialise rs.i to 0xff (not 0) so that the first key byte is processed
with rs.i == 0 without the splurios rs.i-- in arc4_addrandom().
Remove the assignment rs.j = rs.i at the end of arc4_addrandom(), it isn't
necessary and I can see no justificationm for it.
Replace RSIZE with __arraycount(as->s), however it is manifestly 256 (more
correctly the number of values in rs.i and rs.j).
 1.17 18-Aug-2012  dsl cache rs.i and rs.j in arc4random_buf() since the compiler can't be
told that buf[] dosn't alias them.
Reduces the number of instructions inside the loop.
All the other functions are ok.
 1.16 18-Aug-2012  dsl Change the logic used for thread locking to make the code more readable.
The effect on the object code is to replace a function call with a
branch that will predict correctly in the non-threaded case.
Minor optimise of some other paths.
 1.15 18-Aug-2012  dsl Use an inline function to check for initialisation, and an non-inlined
one to do the actual initialise.
Fixes lib/46751 by removing all the replicated tests in each function.
 1.14 29-Jul-2012  dsl Make this compile with the compiler I'm using.
Move variable defs to top of function.
Don't use const static mib[] - run time initialisation won't matter,
and not using static data may actually help in a .so.
 1.13 05-Mar-2012  christos misc cleanups:
- const for mibs
- #define for magic constants
- casts
 1.12 04-Mar-2012  tls Fix bug in previous: don't reinitialize on every call! Fix arc4random_buf so it actually ever initializes -- a security problem with revisions 1.9 and 1.10.
 1.11 27-Feb-2012  tls Make arc4random far less greedy for entropy. Make arc4random actually
implement arc4 when used by threaded programs.
 1.10 04-Feb-2011  christos branches: 1.10.4; 1.10.6;
add arc4random_{buf,uniform}, from OpenBSD.
 1.9 24-Dec-2005  perry branches: 1.9.40;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 09-Feb-2005  kleink A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.6 09-Feb-2005  kleink Declare rs_initialized static.
 1.5 11-Nov-2002  thorpej branches: 1.5.2;
Fix signed/unsigned comparison warnings.
 1.4 02-Jul-2002  itojun use sysctl(kern.urandom) if /dev/urandom is not present (like chroot jail)
 1.3 14-Jun-2002  itojun branches: 1.3.2;
discard first 256 words when we stir.
 1.2 24-May-2002  itojun /dev/arandom does not exist in netbsd. use /dev/urandom.
 1.1 24-May-2002  itojun add arc4random(3). from openbsd
 1.3.2.4 11-Nov-2002  nathanw Catch up to -current
 1.3.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.3.2.2 21-Jun-2002  nathanw Catch up to -current.
 1.3.2.1 14-Jun-2002  nathanw file arc4random.c was added on branch nathanw_sa on 2002-06-21 18:18:07 +0000
 1.5.2.2 26-Mar-2004  jmc Pullup rev 1.1-1.5 (requested by provos in ticket #1386)

Introduce bcrypt password scheme. Adds the arc4random API for creating
cryptographically strong random numbers.
 1.5.2.1 11-Nov-2002  jmc file arc4random.c was added on branch netbsd-1-6 on 2004-03-26 22:52:50 +0000
 1.9.40.1 08-Feb-2011  bouyer Sync with HEAD
 1.10.6.1 08-Mar-2012  riz Pull up following revision(s) (requested by tls in ticket #92):
lib/libc/gen/arc4random.c: revision 1.11
lib/libc/gen/arc4random.c: revision 1.12
Make arc4random far less greedy for entropy. Make arc4random actually
implement arc4 when used by threaded programs.
Fix bug in previous: don't reinitialize on every call! Fix arc4random_buf so it actually ever initializes -- a security problem with revisions 1.9 and 1.10.
 1.10.4.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.10.4.2 30-Oct-2012  yamt sync with head
 1.10.4.1 17-Apr-2012  yamt sync with head
 1.20.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 10-Aug-2014  tls Rebase.
 1.25.2.1 18-Mar-2015  snj Pull up following revision(s) (requested by riastradh in ticket #597):
lib/libc/gen/arc4random.c: revisions 1.26-1.28
lib/libc/gen/arc4random.3:: revisions 1.10-1.19
Rewrite arc4random(3) with ChaCha20-based PRNG and per-thread state.
Explain the security model in the man page.
No more RC4!
--
Grammar.
--
Note relation of arc4random(3) to rand(3)/random(3).
--
Ruminate on security model choices and API design in arc4random(3).
--
Amplify comment about how quickly RC4 was known to be bad.
--
Markup for BUGS note about arc4random_uniform.
--
Cross-reference rnd(4).
--
Remove unnecessary Ns before punctuation. Fix a line.
--
Fix Google Groups link.
--
Tweak wording, define `output', remove misplaced scaremongering.
--
Fix non _REENTRANT build.
--
Use ChaCha20 here as advertised, not ChaCha8.
Oops.
Fortunately, there is no public cryptanalysis even of ChaCha8: the
best published attack is on ChaCha7 with time complexity 2^248.
 1.31.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.33.2.1 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.34.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 15-May-2017  christos Don't make assert use stdio; saves >100K on an empty static binary.
 1.17 25-Jun-2012  abs branches: 1.17.22;
Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.16 09-Feb-2005  kleink branches: 1.16.50;
A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 20-Feb-2001  cgd nuke a last-minute addition in the getprogname() cleanup that didn't work.
 1.13 19-Feb-2001  cgd convert from __progname to getprogname()
 1.12 03-Jan-2001  lukem * Change __diagassert13() so that by default it only syslogs the error (it
used to syslog and also send to stderr).

This behaviour can be changed by setting $LIBC_DIAGASSERT to a
string containing one or more of the following letters:
a abort() after syslog and/or print to stderr
A opposite of a
e print assertion message to stderr
E opposite of e
l log assertion message to syslog
L opposite of l

This allows per-process control of the _DIAGASSERT() behaviour (e.g,
if you want to abort() after the assertion is raised) by modifying the
environment before starting the process.

Note that __DIAGASSERT() is still a no-op unless libc is compiled
with -D_DIAGNOSTIC.

* Implement __assert()/__diagassert() by calling __assert13()/__diagassert13()
with a function of NULL, reducing unnecessary code duplication
 1.11 19-Dec-2000  christos fix missing formatting escape.
 1.10 19-Dec-2000  kleink C99: Print the name of the function enclosing the assertion, if possible.
 1.9 10-Dec-2000  christos unnest nested extern declaration.
 1.8 15-Sep-1999  lukem implement __diagassert(). currently this just prints the assertion to
stderr and syslog()s to user.debug. (it does not abort).

XXX: implement a scheme similar to $MALLOC_OPTIONS which gives the
user control over whether to stderr, syslog, abort, do nothing, etc...
 1.7 13-Jul-1997  christos Fix RCSID's
 1.6 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.5 17-May-1994  cgd new assert helper
 1.4 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 16-Jun-1993  jtc branches: 1.1.1;
Make assert macro ansi complient.
 1.1.1.1 16-May-1994  cgd 4.4-Lite assert helper
 1.16.50.1 30-Oct-2012  yamt sync with head
 1.17.22.1 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.2 10-Jan-2017  christos cast for size_t
 1.1 13-Jun-2014  joerg branches: 1.1.2; 1.1.6; 1.1.10;
Add asysctl(3) and asysctlbyname(3) wrappers for the common idiom of
fetching dynamically sized data via sysctl.
 1.1.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.1.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 13-Jun-2014  tls file asysctl.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 13-Jun-2014  tls file asysctl.c was added on branch tls-earlyentropy on 2014-08-10 06:51:50 +0000
 1.14 10-May-2008  christos branches: 1.14.6;
undo the constification of the argument. Per opengroup.
 1.13 30-Apr-2008  martin branches: 1.13.2;
Convert TNF licenses to new 2 clause variant
 1.12 23-Apr-2008  plunky constify dirname(3) and basename(3)
 1.11 06-Sep-2003  kleink branches: 1.11.30;
Add Xref to basename(1).
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 17-Oct-2002  wiz Use .Dq and .Sq. Fix some typos.
 1.8 17-Oct-2002  thorpej Change basename(3) and dirname(3) to return a pointer to static
storage, rather than modifying their input arguments. While not
reentrant, this is explcitly allowed by IEEE Std 1003.1-2001 (which
allows either behavior, stating that it is implementation-dependent).

The new semantics are considered less hostile/more useful by most programs
which use basename(3) and/or dirname(3) (several programs in the NetBSD
tree reimplement basename()/dirname() themselves to avoid modification
of the input argument).

This new implementation truncates results to PATH_MAX. The Std does
not address this in the static storage case. However since PATH_MAX
is the maximum pathname length in the Std, this should not be a problem
in practice. Nontheless, it is noted in the BUGS section.

See the basename(3)/dirname(3) regression tests in src/regress/lib/libc.

Inspired by discussion with Niels Provos, related to PR 18647.
 1.7 07-Feb-2002  ross branches: 1.7.2;
Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 16-Sep-2001  wiz Boring whitespace fixes.
 1.4 12-Sep-1999  kleink branches: 1.4.10;
Use full month names with .Dd, as per mdoc.samples(7).
 1.3 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.2 05-Feb-1998  perry add LIBRARY section to man page
 1.1 02-Nov-1997  kleink Add basename() and dirname(), from XPG4.2.
 1.4.10.4 11-Nov-2002  nathanw Catch up to -current
 1.4.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.7.2.1 07-Dec-2002  he Pull up revision 1.8 (requested by thorpej in ticket #918):
Change basename(3) and dirname(3) to return a pointer to
static storage instead of modifying their arguments. Fixes
PR#18647.
 1.11.30.1 18-May-2008  yamt sync with head.
 1.13.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.6.2 10-May-2008  christos undo the constification of the argument. Per opengroup.
 1.14.6.1 10-May-2008  christos file basename.3 was added on branch christos-time_t on 2008-05-10 22:39:41 +0000
 1.12 18-Jan-2023  simonb KNF nit: opening brace of a function on next line.
 1.11 16-Jul-2014  christos basename_r and dirname_r are non-standard and different from what we define
here on FreeBSD. Their libgen.h exposes them unconditionally, so hide ours
for now.
 1.10 14-Jul-2014  christos Factor out the basename and dirname code into basename_r and dirname_r
which are static for now. Inspired by similar changes to android(bionic).
 1.9 24-Nov-2009  tnozaki branches: 1.9.12; 1.9.22;
guard single-dot from modification by the application
(SUSv3 spec don't forbid this brutal operation).
this idea taken from OpenBSD's version of basename(3) and dirname(3).
 1.8 10-May-2008  christos branches: 1.8.6;
undo the constification of the argument. Per opengroup.
 1.7 28-Apr-2008  martin branches: 1.7.2;
Remove clause 3 and 4 from TNF licenses
 1.6 23-Apr-2008  plunky constify dirname(3) and basename(3)
 1.5 17-Oct-2002  thorpej branches: 1.5.30;
Change basename(3) and dirname(3) to return a pointer to static
storage, rather than modifying their input arguments. While not
reentrant, this is explcitly allowed by IEEE Std 1003.1-2001 (which
allows either behavior, stating that it is implementation-dependent).

The new semantics are considered less hostile/more useful by most programs
which use basename(3) and/or dirname(3) (several programs in the NetBSD
tree reimplement basename()/dirname() themselves to avoid modification
of the input argument).

This new implementation truncates results to PATH_MAX. The Std does
not address this in the static storage case. However since PATH_MAX
is the maximum pathname length in the Std, this should not be a problem
in practice. Nontheless, it is noted in the BUGS section.

See the basename(3)/dirname(3) regression tests in src/regress/lib/libc.

Inspired by discussion with Niels Provos, related to PR 18647.
 1.4 31-Jan-2002  tv branches: 1.4.2;
Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.3 21-Jan-2002  tv Add hooks for reachover builds from src/tools/compat.
 1.2 22-Jan-2000  mycroft branches: 1.2.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.1 02-Nov-1997  kleink Add basename() and dirname(), from XPG4.2.
 1.2.6.4 11-Nov-2002  nathanw Catch up to -current
 1.2.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.2.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.2.6.1 28-Jan-2002  nathanw Catch up to -current.
 1.4.2.1 07-Dec-2002  he Pull up revision 1.5 (requested by thorpej in ticket #918):
Change basename(3) and dirname(3) to return a pointer to
static storage instead of modifying their arguments. Fixes
PR#18647.
 1.5.30.1 18-May-2008  yamt sync with head.
 1.7.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.6.2 10-May-2008  christos undo the constification of the argument. Per opengroup.
 1.8.6.1 10-May-2008  christos file basename.c was added on branch christos-time_t on 2008-05-10 22:39:41 +0000
 1.9.22.1 10-Aug-2014  tls Rebase.
 1.9.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2 06-Jun-2016  wiz Remove trailing whitespace. Fix Xr. Fix Dd argument.
 1.1 05-Jun-2016  christos Document bsd_signal (From GSoC 2016 by Charles Cui)
 1.11 22-Oct-2009  bouyer Remove closes 3 and 4 from my copyright.
 1.10 26-Dec-2005  perry u_intN_t -> uintN_t
 1.9 05-Oct-2003  bouyer Remove references to University of California from my copyright notices.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 05-Jun-2001  wiz Uppercase Dt argument, fix typos, remove an empty line.
 1.4 15-May-2000  bouyer branches: 1.4.6;
Use the same copyrigth notice everywhere.
 1.3 24-Mar-1999  mycroft Remove blank lines.
 1.2 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.4.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.3 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.2 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.3 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.2 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.6 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.5 10-Aug-2003  mrg avoid some lint errors in the previous
 1.4 09-Aug-2003  martin Split into a 64 bit version (straight forward shifting and masking) and
a 32 bit one with two 32 bit operations with two temporaries later
combined.

This avoids the strict alias violating magic used before, thereby
probably fixing PR bin/22313.
 1.3 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.2 18-Jan-1999  christos delint
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.10 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.9 24-Oct-2017  abhinav Fix typo: s/cexpandtc/csetexpandtc

The synopsis and description mention only csetexpandtc function.
nxr also only shows csetexpandtc while no matches for cexpandtc.
 1.8 22-Apr-2012  wiz Sort SEE ALSO.
 1.7 21-Apr-2012  roy Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.6 19-Aug-2009  joerg branches: 1.6.6;
Fix markup.
 1.5 26-Aug-2008  lukem branches: 1.5.6;
Use Qq instead of Qc to quote a single word
 1.4 02-Feb-2008  christos branches: 1.4.6;
Add csetexpandtc()
 1.3 17-Jun-2005  enami branches: 1.3.10; 1.3.12; 1.3.14; 1.3.16;
Changes done in rev. 1.21 of getcap.3 (former name of this file) is
not correct since, as far as reading the source, it is impossible for
cgetset() to set such errno. I guess `seq' is not a typo of `set' but
abbreviation of `sequen...'.
 1.2 12-Apr-2005  wiz Adapt .Dt argument for man page renaming, and use more macros.
 1.1 12-Apr-2005  drochner Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.3.16.1 23-Mar-2008  matt sync with HEAD
 1.3.14.2 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.3.14.1 17-Jun-2005  bouyer file cgetcap.3 was added on branch netbsd-3-0 on 2007-08-26 20:03:26 +0000
 1.3.12.2 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.3.12.1 17-Jun-2005  bouyer file cgetcap.3 was added on branch netbsd-3-1 on 2007-08-26 20:03:23 +0000
 1.3.10.2 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.3.10.1 17-Jun-2005  bouyer file cgetcap.3 was added on branch netbsd-3 on 2007-08-26 20:01:20 +0000
 1.4.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.6.2 26-Aug-2008  lukem Use Qq instead of Qc to quote a single word
 1.5.6.1 26-Aug-2008  lukem file cgetcap.3 was added on branch christos-time_t on 2008-08-26 05:04:20 +0000
 1.6.6.1 23-May-2012  yamt sync with head.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 05-Feb-1998  perry branches: 1.6.12;
add LIBRARY section to man page
 1.5 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.4 04-Oct-1993  jtc Changed SYNOPSIS. You're supposed to include <time.h>, not <sys/types.h>
before using clock().
 1.3 17-Aug-1993  jtc The result of clock() is measured in CLOCKS_PER_SECs, not CLK_TCKs.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.10 11-Jan-2009  christos merge christos-time_t
 1.9 19-Aug-2003  dsl branches: 1.9.40;
Significantly reduce the non-monotonicity of this function.
The way time is apportioned to interrupt/system/user makes it impossible
to guarantee monotonicity except by saving the previous value!
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 30-Mar-1998  kleink Need <time.h> for clock() prototype.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 25-Feb-1995  cgd branches: 1.5.4;
merge with Lite, keep local changes. clean up id usage
 1.4 26-Aug-1993  jtc branches: 1.4.4;
Declare rcsid strings so they are stored in text segment.
 1.3 17-Aug-1993  jtc The result of clock() is measured in CLOCKS_PER_SECs, not CLK_TCKs.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.40.1 08-Nov-2008  christos time_t changes
 1.16 26-Sep-2010  yamt fix rewinddir on nfs. fix PR/42879 (and probably PR/40229.)
 1.15 17-May-2006  christos PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.14 24-Jan-2006  christos rename __func to _func_unlocked, and add their prototypes in extern.h
instead of exposing them in dirent.h. More locking consistency fixes.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 23-Jun-2003  christos PR/21963: MAEKAWA Masahide: Don't free(dirp) before its last use.
 1.11 28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 03-Feb-1998  perry remove obsolete register declarations
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 16-Jun-1995  jtc branches: 1.4.4;
Don't cast void functions to void.
 1.3 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.2 27-Jul-1994  jtc branches: 1.2.2; 1.2.4;
Add RCS Id's
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.3 02-May-1995  jtc #include "namespace.h"
 1.2.4.2 26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.2.4.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.2.2.2 27-Jul-1994  jtc Add RCS Id's
 1.2.2.1 27-Jul-1994  jtc file closedir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:45 +0000
 1.4.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.6 10-Nov-2022  gutteridge closefrom.3: add a history section
 1.5 01-Jun-2004  kleink Don't refer to errno as "global integer variable".
 1.4 01-Jun-2004  kleink Sync section number with reality.
 1.3 01-Jun-2004  wiz Use "In" instead of "Fd #include <...>".
 1.2 31-May-2004  itojun EBADF is returned when fd < 0, so change text to tell the truth
 1.1 31-May-2004  itojun closefrom(3)
 1.4 17-Jan-2018  kamil Revert to commits as they broke few rump tests

"Include namespace.h in a few of libc source files
[...]
This change finishes elimination of usage of the global name of the
following symbols:
- close -> _close
- execve -> _execve
- fcntl -> _fcntl
- setcontext -> _setcontext
- wait6 -> _wait6
- write -> _write
- writev -> _writev"

"Register more syscalls in namespace.h (of libc)

Add weak symbols for:
- fcntl
- close
- execve
- setcontext
- wait6
- write
- writev"

These changes broke:

fs/nfs/t_rquotad:get_nfs_be_1_both
fs/nfs/t_rquotad:get_nfs_be_1_group
fs/nfs/t_rquotad:get_nfs_be_1_user
fs/nfs/t_rquotad:get_nfs_le_1_both
fs/nfs/t_rquotad:get_nfs_le_1_group
fs/nfs/t_rquotad:get_nfs_le_1_user
lib/librumphijack/t_config:fdoff
lib/librumphijack/t_tcpip:http
lib/librumphijack/t_tcpip:nfs
lib/librumphijack/t_vfs:cpcopy
lib/librumphijack/t_vfs:mv_x
lib/librumphijack/t_vfs:paxcopy
net/net/t_forwarding:ipforwarding_fastforward_v4
net/net/t_forwarding:ipforwarding_fastforward_v6
net/net/t_forwarding:ipforwarding_fragment_v4
net/net/t_forwarding:ipforwarding_misc
net/net/t_mtudisc6:mtudisc6_basic

This revert fixes the failures, except lib/librumphijack/t_vfs.

The original changes were added in order to facilitate a usage of
sanitizers against programs linked with NetBSD's libc. It is no longer
needed, so abandon these changes.

Sponsored by <The NetBSD Foundation>
 1.3 05-Jan-2018  kamil Include namespace.h in a few of libc source files

The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

This change finishes elimination of usage of the global name of the
following symbols:
- close -> _close
- execve -> _execve
- fcntl -> _fcntl
- setcontext -> _setcontext
- wait6 -> _wait6
- write -> _write
- writev -> _writev

Sponsored by <The NetBSD Foundation>
 1.2 22-Jun-2004  atatat Reverse arguments to fcntl(2).
 1.1 31-May-2004  itojun implement closefrom(3).
 1.3 16-Mar-2011  christos goodbye short-live commaize_number(3), if you liked it:
#define commaize_number(s, l, n) snprintf(s, l, "%'llu", (unsigned long long)n)
 1.2 15-Mar-2011  wiz Shorten Nd by putting the comment there in a paragraph in the body.
Use more markup. Sort SEE ALSO. Fix typo. Capitalize NetBSD like
we all love it.
 1.1 15-Mar-2011  erh PR#7540, add a commaize_number function, which inserts comma into a string
of digits to make it more readable. This is soon to be used in /bin/ls.
 1.2 16-Mar-2011  christos goodbye short-live commaize_number(3), if you liked it:
#define commaize_number(s, l, n) snprintf(s, l, "%'llu", (unsigned long long)n)
 1.1 15-Mar-2011  erh PR#7540, add a commaize_number function, which inserts comma into a string
of digits to make it more readable. This is soon to be used in /bin/ls.
 1.20 22-Apr-2010  jruoho Use .In for includes.
 1.19 10-Mar-2009  joerg Remove redundant .Pp
 1.18 23-Dec-2006  wiz branches: 1.18.22;
Sort sections.
 1.17 08-Dec-2006  mjf Update to reflect recent changes to confstr(3).
 1.16 03-Dec-2006  christos PR/35170: Guy Harris: confstr() should return 0, not -1, on errors
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 07-Feb-2002  ross Generate <>& symbolically.
 1.12 16-Sep-2001  wiz Boring whitespace fixes.
 1.11 22-Mar-1999  garbled branches: 1.11.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.10 09-Mar-1999  erh Add missing .El lines.
 1.9 12-Nov-1998  christos document the return value as (size_t)-1 instead of -1, and do the same in
the source to avoid lint warnings.
 1.8 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 03-Feb-1998  perry .Bx'ize
 1.5 09-Sep-1997  jtc Changed order of STANDARDS and HISTORY subheads to conform with
specification in mdoc(7).
 1.4 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.3 11-Jun-1994  jtc Note that confstr() is POSIX.2 compliant.
 1.2 11-Jun-1994  jtc Replace my version of confstr() with 4.4 lite's, which gets its values
with sysctl().
 1.1 11-Jun-1994  jtc branches: 1.1.1;
Initial revision
 1.1.1.1 11-Jun-1994  jtc from 44lite
 1.11.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.18.22.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 03-Dec-2006  christos branches: 1.12.36;
PR/35170: Guy Harris: confstr() should return 0, not -1, on errors
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 12-Nov-1998  christos document the return value as (size_t)-1 instead of -1, and do the same in
the source to avoid lint warnings.
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 13-Jul-1997  christos Fix RCSID's
 1.6 13-May-1995  jtc branches: 1.6.4;
#include appropriate header files to bring prototypes into scope
 1.5 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.4 11-Jun-1994  jtc Replace my version of confstr() with 4.4 lite's, which gets its values
with sysctl().
 1.3 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.2 22-Dec-1993  jtc #include <string.h> to bring prototypes into scope.
 1.1 17-Nov-1993  jtc branches: 1.1.1;
If _CS_PATH is defined in <unistd.h>, the latest bash assumes that confstr()
will be present as well. Here is a quick implementation based on my online
copy of 1003.2 (D11.2). I'll confirm that nothing has been changed in the
final standard and write up a manual page soon.
 1.1.1.1 11-Jun-1994  jtc from 44lite
 1.6.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.12.36.1 30-Oct-2012  yamt sync with head
 1.6 02-Nov-2011  wiz Fix typo.
 1.5 02-Nov-2011  yamt branches: 1.5.2;
fix a function prototype.
 1.4 06-Oct-2011  jruoho Xref kcpuset(9).
 1.3 12-Sep-2008  rmind branches: 1.3.6;
Arguments were swapped for cpuset_set(), cpuset_clr(), cpuset_isset()
functions, but man pages were not updated (hi Christos!).
 1.2 22-Jun-2008  wiz branches: 1.2.2;
Clarify a sentence.
 1.1 16-Jun-2008  rmind branches: 1.1.2;
- Add affinity(3) manual page, which describes thread affinity,
pthread_setaffinity_np(3) and pthread_getaffinity_np(3) functions,
provides simple code example.
- Add cpuset(3) manual page, which describes API of CPU-sets.

Thanks <wiz> for many improvements!
 1.1.2.2 17-Jun-2008  yamt sync with head.
 1.1.2.1 16-Jun-2008  yamt file cpuset.3 was added on branch yamt-pf42 on 2008-06-17 09:13:33 +0000
 1.2.2.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.2.2.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.2.2.1 22-Jun-2008  wrstuden file cpuset.3 was added on branch wrstuden-revivesa on 2008-06-23 05:02:09 +0000
 1.3.6.2 12-Sep-2008  rmind Arguments were swapped for cpuset_set(), cpuset_clr(), cpuset_isset()
functions, but man pages were not updated (hi Christos!).
 1.3.6.1 12-Sep-2008  rmind file cpuset.3 was added on branch christos-time_t on 2008-09-12 13:39:05 +0000
 1.5.2.1 10-Nov-2011  yamt sync with head
 1.3 07-Oct-1993  mycroft Clean up deleted files.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5 07-Oct-1993  mycroft Clean up deleted files.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 30-Jul-1993  mycroft Add even more RCS frobs.
 1.2 26-Apr-1993  cgd make crypt in libc back into a dummy, but a full-featured dummy.

to get crypt now, use -lcrypt, or LIBCRYPT as part of LDADD.
 1.1 22-Mar-1993  cgd added crypt.c and deleted crypt_dummy.c
 1.11 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 28-Apr-1998  fair branches: 1.7.12;
fix mdoc reference, plus some other mdoc problems
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.4 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.3 29-Nov-1993  jtc Make it clear that ctermid's argument is a pointer to an array.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.11 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.10 07-Aug-2003  agc branches: 1.10.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 26-Jul-1998  mycroft Nit; use strncpy() rather than bcopy().
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 14-Jul-1997  kleink KNF.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.56.1 30-Oct-2012  yamt sync with head
 1.5 10-Mar-1995  jtc ctime.3 and tzset.3 manpages have been moved to libc/time.
 1.4 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.3 04-Oct-1993  jtc Changed SYNOPSIS. <sys/types.h> need never be included as <time.h>
defines time_t too.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11 09-Mar-1995  jtc date and time functions have been moved
 1.10 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.9 25-Feb-1995  cgd update to 4.4-Lite and/or clean up Id
 1.8 10-Feb-1995  cgd make this 64-bit-safe.
 1.7 01-Feb-1995  jtc Merged with 4.4lite, with hopes that it would fix the bug where mktime()
would spin in an infinate loop when passed a tm struct with all fields
set to INT_MIN. It isn't a complete fix, the loop now terminates but
mktime() does not return (time_t) -1.

I sent mail to bostic about this, who replied that the changes in 4.4BSD
were to fix this exact problem. My next step is to send mail to Arthur
David Olson, the original author and maintainer of this code.
 1.6 18-Dec-1994  cgd make type-size safe.
 1.5 17-Nov-1994  jtc Unconditionally call tzset() in internal function localsub(), so that
localtime() and mktime() conform to POSIX.1.
 1.4 28-Jan-1994  jtc Fix printf formatting directive %02.2d -> %02d
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.35 05-Oct-2025  riastradh ctype(3): Fix versions and clarify what LIBC_ALLOWCTYPEABUSE does.

Both the extra diagnostics _and_ LIBC_ALLOWCTYPEABUSE are new in 11.
The extra diagnostics were not added in 10 (unless someone went ahead
and pulled them up while I wasn't looking!).

LIBC_ALLOWCTYPEABUSE doesn't guarantee that the program won't crash;
it just makes that depend on factors such as address space layout
randomization -- where the ctype tables appear in memory relative to
non-readable pages.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.34 05-Oct-2025  riastradh ctype(3): Clarify test program output. Update compiler warning.

Should be a little easier to read. The fact that isprint returns
_any_ nonzero value, not necessarily 1, isn't germane to the point
here, so showing it return 5 or 2 doesn't really help to illustrate
anything.
 1.33 01-Oct-2025  martin Tweak version numbers, the LIBC_ALLOWCTYPEABUSE env support
has been pulled up.
 1.32 15-Sep-2025  riastradh ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.31 15-Jan-2019  wiz branches: 1.31.14;
Use \- for minus.
 1.30 15-Jan-2019  uwe Fly, nasal demons, fly away...
 1.29 15-Jan-2019  riastradh Use the same variable for the locale example.
 1.28 15-Jan-2019  uwe Don't talk about "the first argument" when there's only one.
 1.27 15-Jan-2019  uwe Fix markup pasto.
 1.26 15-Jan-2019  uwe Remove the extra cast to int in the CAVEATS example.
We removed it from EXAMPLES a few releases ago.
 1.25 15-Jan-2019  uwe Fix typo in macro flag.
 1.24 15-Jan-2019  riastradh Expand on correct and incorrect usage, and on compiler warnings.

Give an example program with the warning, and some example nonsense
outputs. Also note why glibc's approach doesn't solve the problem.
 1.23 12-Dec-2017  abhinav branches: 1.23.2; 1.23.4;
Add ctype to the NAME section (as this is a man page for ctype)
Remove rest of the names from the NAME section
(These names have their own individual man pages, as such it doesn't make sense
to have their names in the NAME section in this man page as well. Moreover,
we have been trying to fix such man pages so that apropos(1)/whatis(1) are
able to search these man pages. Other examples of such fixed man pages include
memory(3), string(3) etc.)

ok wiz@
 1.22 25-Feb-2015  wiz Remove sentence about casting to int (also from example).
Bump date.

ok joerg@
 1.21 06-May-2010  jruoho Note POSIX compliance. Reword a little around the example.
 1.20 05-Apr-2010  joerg \\ -> \e
 1.19 11-Mar-2009  joerg Give the full prototype for all ctype functions/macros.
Remove redundant .br.
 1.18 17-Apr-2008  apb branches: 1.18.10; 1.18.12;
* Expand the CAVEATS section with a lot more detail on how to safely
use the ctype functions.
* Use toupper((int)(unsigned char)*s)) instead of just
toupper((unsigned char)*s) in an example.
 1.17 20-Jan-2007  wiz Sort sections.
 1.16 18-Jan-2007  cbiere isascii() and toascii() are defined for all integers unlike the other
functions. Explicitely mention "undefined behavior".
 1.15 18-Jan-2007  rillig Added a warning about a wrong usage, which is nevertheless often found
in real code, and an example code that does it correctly.
 1.14 04-Feb-2006  wiz Serial comma; bump date for previous.
 1.13 26-Jan-2006  rillig .St -ansiC doesn't know about isascii().
 1.12 26-Jan-2006  rillig s/macro/function/g
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.7 05-Feb-1998  perry branches: 1.7.12;
add LIBRARY section to man page
 1.6 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.5 01-Dec-1993  jtc Manpage formatting tweaks.
 1.4 25-Nov-1993  jtc Misc manpage fixes.
 1.3 14-Sep-1993  jtc Document isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.18.12.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.18.10.2 17-Apr-2008  apb * Expand the CAVEATS section with a lot more detail on how to safely
use the ctype functions.
* Use toupper((int)(unsigned char)*s)) instead of just
toupper((unsigned char)*s) in an example.
 1.18.10.1 17-Apr-2008  apb file ctype.3 was added on branch christos-time_t on 2008-04-17 16:24:41 +0000
 1.23.4.1 10-Jun-2019  christos Sync with HEAD
 1.23.2.1 18-Jan-2019  pgoyette Synch with HEAD
 1.31.14.2 19-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #59):

lib/libc/gen/ctype.3: revision 1.34
lib/libc/gen/ctype.3: revision 1.35

ctype(3): Clarify test program output. Update compiler warning.

Should be a little easier to read. The fact that isprint returns
_any_ nonzero value, not necessarily 1, isn't germane to the point
here, so showing it return 5 or 2 doesn't really help to illustrate
anything.


ctype(3): Fix versions and clarify what LIBC_ALLOWCTYPEABUSE does.

Both the extra diagnostics _and_ LIBC_ALLOWCTYPEABUSE are new in 11.

The extra diagnostics were not added in 10 (unless someone went ahead
and pulled them up while I wasn't looking!).
LIBC_ALLOWCTYPEABUSE doesn't guarantee that the program won't crash;
it just makes that depend on factors such as address space layout
randomization -- where the ctype tables appear in memory relative to
non-readable pages.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.31.14.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.24 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.23 30-Mar-2025  riastradh branches: 1.23.2;
ctype(3): Simplify definitions of ctype/tolower/toupper tables.

Clarify comment while here.

No functional change intended. No change to `readelf -a' output on
amd64 or aarch64.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.22 29-Mar-2025  riastradh libc: Restore ELF symbol sizes for _C_ctype_tab_ &c.

This is needed for dynamic position-dependent executables that refer
directly to _C_type_tab_ to get correct copy relocations to see the
table content.

Unfortunately, such executables won't get a guard page.

Fortunately, referring to _C_ctype_tab_ directly (and not the
indirection _ctype_tab_ as the ctype(3) macros do) is very weird and
unlikely to happen in the real world (none of the public interfaces
use it; it is exported for libc++.so/libstdc++.so to use, but those
aren't pies). So missing the guard page in this case is probably not
so bad.

The symbol sizes are also needed for, e.g., gdb to nicely identify
addresses that lie in the table.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.21 29-Mar-2025  riastradh ctype(3): Put guard pages before the C ctype/tolower/toupper tables.

This also only affects machines where char is signed for now. (But
maybe it would be worth doing unconditionally; users could still try
to pass in explicit `signed char' inputs.)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.20 13-Apr-2013  joerg branches: 1.20.40;
Extend ctype classification table to 16bit. Based on patch by
Takehiko Nozaki, with changes to compile fail when using the old names
and to exploit __BUILD_LEGACY
 1.19 14-Dec-2010  joerg branches: 1.19.6; 1.19.12;
Prefix ctype bitmask macros with _CTYPE
 1.18 01-Jun-2010  tnozaki more split ctype.h -> sys/ctype_inline.h, sys/ctype_bits.h
 1.17 22-May-2010  tnozaki 1. hide _CTYPE_PRIVATE section in ctype.h, move them to private header ctype_local.h.
2. do not use _CTYPE_NUM_CHARS macro to read data from LC_CTYPE(old BSDCTYPE style) database.
because 1<<CHAR_BIT is MD, so i added MI macro _CTYPE_CACHE_SIZE(1<<8).
3. remove _NB_CACHED_RUNE macro, use _CTYPE_CACHE_SIZE instead.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 17-Apr-2001  kleink Need <limits.h> in _CTYPE_PRIVATE environments.
 1.14 13-Jul-1997  christos branches: 1.14.14;
Fix RCSID's
 1.13 02-Jun-1997  kleink Add support for localized character sets (a.k.a. LC_CTYPE).

Thanks go to Matthias Scheler <tron@lyssa.owl.de> for contributing his initial
work in PR/3592, and to Christos Zoulas for refining it!
 1.12 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.11 17-May-1994  cgd copyright foo
 1.10 05-Oct-1993  jtc Due to an 8-bit attribute table and 9 bits of attributes, I've had to
remove the _B attribute from the "horizontal tab" position, and change
the isblank function to explicitly test against space and tab.

When I finish merging the 4.4 runes code, this table will have to grow
to 16 bit entries, as several more attributes have been introduced.
I'm making this change so existing libraries will continue working
for the next (little) while.
 1.9 14-Sep-1993  jtc Both space and tab are in the blank character class.
 1.8 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.7 23-Aug-1993  jtc Moved toupper and tolower tables from ctype_.c to their own files --- I
received complaints about using shorts in the table (but i need a range
of -1..255), so now the tables will not be used unless either toupper()
or tolower() (and soon, setlocale()) are used. This can save up to 514
bytes.

In toupper_.c and tolower_.c make sure that our assumption of EOF == -1
holds.

Fixed bug where _toupper_tab_ was initialized pointing to _C_tolower_tab.
 1.6 21-Aug-1993  jtc _ctype_, _tolower_tab_, and _toupper_tab_ are now pointers to the tables.
The tables have been renamed to _C_ctype_, _C_tolower_, and _C_toupper_
as they are tables for the C locale. When switching to a new locale, the
pointers will be set to point to tables specific to the new locale.
 1.5 09-Aug-1993  jtc Oops! I used EOF but didn't include <stdio.h>.
 1.4 06-Aug-1993  jtc Added C locale specific translation tables for toupper and tolower. When
locales are fully supported, toupper and tolower will refer to this, or
a locale specific table, through pointers.
 1.3 06-Aug-1993  jtc Use const qualifier with _ctype_ table. Smart compilers can then store it
in the text segment. When we implement locales, the isctype macros/functions
will reference this table (or a locale specific table) through a pointer, but
for right now, it continues to reference the _ctype_ table directly.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14.14.1 08-Oct-2001  nathanw Catch up to -current.
 1.19.12.1 23-Jun-2013  tls resync from head
 1.19.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.20.40.1 02-Aug-2025  perseant Sync with HEAD
 1.23.2.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.8 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.7 31-Mar-2025  riastradh branches: 1.7.2; 1.7.4;
ctype(3): __strong_alias takes no semicolon, apparently.

Pacifies lint complaint:

/home/riastradh/netbsd/current/src/lib/libc/gen/ctype_.c(90): warning: empty declaration [0]
/home/riastradh/netbsd/current/src/lib/libc/gen/ctype_.c(158): warning: empty declaration [0]

(Maybe we should change __strong_alias and __weak_alias so they do
take semicolons like other top-level declarations...)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.6 30-Mar-2025  riastradh ctype(3): Sprinkle _C_LABEL_STRING in a few more places.

Mostly for hygiene and to avoid raising questions about inconsistent
usage; this doesn't actually affect the build any more.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.5 30-Mar-2025  riastradh ctype(3): Actually conditionalize guard page on shared libc.

Apparently we build the libc .o files with -fPIC too (I guess this is
so that libc.a works in position-independent executables? but why
don't they just use libc_pic.a?), so use a purpose-built cpp macro
_CTYPE_DYNAMIC for this instead of using __PIC__.

Now this shows the right symbol sizes:

$ readelf -s ctype_.pico | grep _C_ctype_tab_guarded_
3: 0000000000000000 4610 OBJECT LOCAL DEFAULT 11 _C_ctype_tab_guarded_
$ readelf -s ctype_.po | grep _C_ctype_tab_guarded_
3: 0000000000000000 514 OBJECT LOCAL DEFAULT 7 _C_ctype_tab_guarded_
$ readelf -s ctype_.o | grep _C_ctype_tab_guarded_
3: 0000000000000000 514 OBJECT LOCAL DEFAULT 7 _C_ctype_tab_guarded_

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.4 30-Mar-2025  riastradh ctype(3): Disable guard page in static libc.

Adding the guard page may have overflown several small installation
media. Let's try to keep this case small.

Update the tests to detect the cases where we will be running against
a libc without a guard page on the LC_CTYPE=C tables, and skip
testing abuse detection when it would rely on the guard page.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.3 30-Mar-2025  riastradh ctype(3): Simplify definitions of ctype/tolower/toupper tables.

Clarify comment while here.

No functional change intended. No change to `readelf -a' output on
amd64 or aarch64.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.2 29-Mar-2025  riastradh libc: Restore ELF symbol sizes for _C_ctype_tab_ &c.

This is needed for dynamic position-dependent executables that refer
directly to _C_type_tab_ to get correct copy relocations to see the
table content.

Unfortunately, such executables won't get a guard page.

Fortunately, referring to _C_ctype_tab_ directly (and not the
indirection _ctype_tab_ as the ctype(3) macros do) is very weird and
unlikely to happen in the real world (none of the public interfaces
use it; it is exported for libc++.so/libstdc++.so to use, but those
aren't pies). So missing the guard page in this case is probably not
so bad.

The symbol sizes are also needed for, e.g., gdb to nicely identify
addresses that lie in the table.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.1 29-Mar-2025  riastradh ctype(3): Put guard pages before the C ctype/tolower/toupper tables.

This also only affects machines where char is signed for now. (But
maybe it would be worth doing unconditionally; users could still try
to pass in explicit `signed char' inputs.)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.7.4.2 02-Aug-2025  perseant Sync with HEAD
 1.7.4.1 31-Mar-2025  perseant file ctype_guard.h was added on branch perseant-exfatfs on 2025-08-02 05:54:36 +0000
 1.7.2.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.3 19-May-1994  mycroft Clean up deleted files.
 1.2 10-Jan-1994  jtc Fix spelling errors.
 1.1 29-Nov-1993  jtc A manpage for cuserid(3) (hacked up from ctermid(3)).
 1.3 19-May-1994  mycroft Clean up deleted files.
 1.2 29-Nov-1993  jtc Cuserid() is specified in such a way that it can overwrite the buffer used
by getpwent(), getpwnam() & getpwuid() --- but not the other way around.
This requires that cuserid() have its own static buffer.
 1.1 11-Oct-1993  jtc Moved cuserid() from getlogin.c to its own file, cuserid.c.
getlogin() and cuserid() do very different things, getlogin() is POSIX,
while cuserid() is not (it was removed in the 1990 revision).
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 01-Oct-2002  wiz New sentence, new line; -1 -> \-1; simplify mdoc in one place.
 1.12 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 12-Sep-1999  kleink branches: 1.8.10;
Use full month names with .Dd, as per mdoc.samples(7).
 1.7 03-Sep-1999  proff Document return values and bugs
 1.6 14-Mar-1999  kristerw daemon returns int. From OpenBSD.
 1.5 06-Oct-1998  hwr Fixes lib/6252 by Greg A. Woods
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.2 18-Dec-1994  cgd add #include description, from Jim Jegers
 1.1 27-Jan-1994  cgd branches: 1.1.1;
add two man pages
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.8.10.5 18-Oct-2002  nathanw Catch up to -current.
 1.8.10.4 01-Aug-2002  nathanw Catch up to -current.
 1.8.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.10 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.9 07-Aug-2003  agc branches: 1.9.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 19-Jul-1997  kleink Substitute a `2' with STDERR_FILENO for clarity; minor KNF.
 1.5 13-Jul-1997  christos Add missing stdlib.h include
Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.3 19-Dec-1993  pk branches: 1.3.4;
Return a well-known constant after becoming a daemon.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.56.1 30-Oct-2012  yamt sync with head
 1.8 18-Aug-2020  christos make sure errno is always set when we return -1 (Anon Ymous)
 1.7 01-Oct-2014  apb include "nbtool_config.h", not "nbtools_config.h".
 1.6 01-Oct-2014  apb It's HAVE_NBTOOL_CONFIG_H, not HAVE_NBTOOLS_CONFIG_H
 1.5 30-Sep-2014  christos toolize
 1.4 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.3 28-Apr-2008  martin branches: 1.3.4; 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 14-Dec-2007  xtraeme branches: 1.2.2; 1.2.6;
Fix up a comment.
 1.1 14-Dec-2007  christos - add dehumanize_number
- decls for humanize_number and dehumanize_number are in stdlib.h
 1.2.6.1 18-May-2008  yamt sync with head.
 1.2.2.2 09-Jan-2008  matt sync with HEAD
 1.2.2.1 14-Dec-2007  matt file dehumanize_number.c was added on branch matt-armv6 on 2008-01-09 01:34:04 +0000
 1.3.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3.8.1 28-Apr-2008  martin file dehumanize_number.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.3.4.1 17-Apr-2012  yamt sync with head
 1.17 10-Sep-2017  wiz Fix typo.
 1.16 10-Sep-2017  wiz Sort sections. Make error descriptions complete sentences.
 1.15 10-Sep-2017  kre Fix a typo, and some wording improvements.
 1.14 09-Sep-2017  kamil Remove the BUGS section from devname(3)

devname(3) does not report type of error on purpose.

Suggested by <kre>
 1.13 09-Sep-2017  kamil Document devname_r(3) in devname(3).

Improve clarity of devname(3) mentioning that it returns a pointer to the
buffer pointer. This approach is not thread-safe and not reentrant.

Not that devname(3) does not set errno on failure and document it as a bug.
 1.12 03-Jun-2012  joerg Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
 1.11 07-Aug-2003  agc branches: 1.11.56; 1.11.58;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 05-Jun-2000  simonb branches: 1.7.4;
Add a cache ala pwcache(3). Gives a small but measurable performance
improvement for callers to devname(3) (eg ps(1)) under most circumstances.
 1.6 22-Mar-1999  garbled branches: 1.6.8;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 02-Feb-1998  perry merge/update to lite-2
 1.3 23-Dec-1997  hubertf sys/stat.h needed for S_IFBLK/S_IFCHR.
 1.2 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.1 06-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 06-May-1994  cgd devname() routine
 1.6.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.7.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.7.4.2 22-Mar-2002  nathanw Catch up to -current.
 1.7.4.1 08-Mar-2002  nathanw Catch up to -current.
 1.11.58.1 23-Jun-2012  riz Pull up following revision(s) (requested by joerg in ticket #328):
lib/libc/gen/devname.c: revision 1.22
distrib/sparc64/instfs/dot.profile: revision 1.7
distrib/i386/cdroms/install.sh: revision 1.3
tests/lib/libcurses/director/director.c: revision 1.10
lib/libc/include/reentrant.h: revision 1.15
distrib/amd64/cdroms/install.sh: revision 1.3
tests/include/t_paths.c: revision 1.12
share/man/man7/hier.7: revision 1.101
etc/rc.d/sysdb: revision 1.24
include/stdlib.h: revision 1.99
tests/lib/libcurses/Makefile: revision 1.3
distrib/sparc64/cdroms/installcd/install.sh: revision 1.3
distrib/i386/cdroms/Makefile.cdrom: revision 1.27
lib/libc/gen/ttyname.c: revision 1.25
usr.bin/tic/Makefile: revision 1.2
tools/compat/Makefile: revision 1.57
lib/libterminfo/compile.c: revision 1.7
lib/libc/gen/ttyname.c: revision 1.26
lib/libterminfo/compile.c: revision 1.8
tools/compat/Makefile: revision 1.59
tools/compat/cdbw.h: revision 1.1
distrib/i386/installimage/install.sh: revision 1.2
lib/libc/include/namespace.h: revision 1.154
usr.bin/tic/tic.c: revision 1.13
usr.bin/tic/tic.c: revision 1.14
usr.bin/tic/tic.c: revision 1.15
distrib/sets/lists/base/mi: revision 1.996
usr.bin/tic/tic.c: revision 1.16
usr.sbin/dev_mkdb/dev_mkdb.8: revision 1.13
usr.bin/tic/tic.c: revision 1.17
usr.bin/tic/tic.c: revision 1.18
tools/compat/cdbr.h: revision 1.1
distrib/sparc64/instfs/list: revision 1.25
usr.bin/tic/tic.c: revision 1.19
lib/libc/cdb/cdbw.c: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.5
share/terminfo/Makefile: revision 1.3
usr.sbin/dev_mkdb/dev_mkdb.c: revision 1.29
usr.sbin/dev_mkdb/Makefile: revision 1.8
lib/libc/gen/ttyname.3: revision 1.23
lib/libc/gen/ttyname.3: revision 1.24
lib/libc/cdb/cdbr.c: revision 1.3
include/cdbw.h: revision 1.2
distrib/sparc64/cdroms/installcd/Makefile: revision 1.15
lib/libc/gen/devname.3: revision 1.12
tools/compat/compat_defs.h: revision 1.85
tools/compat/compat_defs.h: revision 1.86
lib/libterminfo/term_private.h: revision 1.10
lib/libterminfo/term.c: revision 1.14
usr.bin/tic/tic.1: revision 1.10
lib/libterminfo/term.c: revision 1.15
lib/libterminfo/Makefile.hash: revision 1.5
lib/libterminfo/term.c: revision 1.16
distrib/amd64/installimage/install.sh: revision 1.2
share/man/man5/rc.conf.5: revision 1.152
distrib/sets/lists/tests/mi: revision 1.472
distrib/amd64/cdroms/Makefile.cdrom: revision 1.7
include/paths.h: revision 1.41
bin/ps/ps.1: revision 1.101
lib/libterminfo/terminfo.5.in: revision 1.16
usr.bin/tic/tic.c: revision 1.20
lib/libterminfo/terminfo.5.in: revision 1.17
Prefer __printflike.
Use queue(3)
Replace linear lookup with hash table, reducing runtime by 60%.
Use e* from util.h.
One more strdup -> estrdup.
Maintain nalias and nterm on the fly.
Add void for ttyslot prototype.
Use memcmp in place of strncmp, since length is known to no longer than
either of the arguments.
Fix a number of memory leaks. Keep final loop of the cleanup in tic(1)
under #ifdef __VALGRIND__ though.
Add __predict_true / __predict_false definitions.
Add a special seeder for cdbw_output that gives stable results.
Hook up cdbw(3) for the tool build.
Prototype for cdbw_stable_seeder.
Provide a usable thr_once for !_REENTRANT
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
Switch terminfo(3) to cdb(5).
Fix typos.
Make Alan Barrett happy and add ().
Add cdbr(3) support to tools/compat.
Bump date for previous.
Relax consistency to make it possible to match valid entries.
Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.
 1.11.56.1 30-Oct-2012  yamt sync with head
 1.23 18-Feb-2019  christos appease string + int warning.
 1.22 03-Jun-2012  joerg branches: 1.22.32;
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
 1.21 23-Mar-2010  drochner branches: 1.21.6; 1.21.8;
remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable
 1.20 19-Apr-2009  mrg add some code to cope with dev.db's that have 32 bit time_t's in them.

shouldn't be relevant very much as dev.db should be re-created at boot,
but it helped me at least twice so far...
 1.19 20-Jan-2009  drochner branches: 1.19.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.
 1.18 11-Jan-2009  christos merge christos-time_t
 1.17 28-Apr-2008  martin branches: 1.17.8;
Remove clause 3 and 4 from TNF licenses
 1.16 16-Dec-2004  atatat branches: 1.16.24;
Put caching back on the pts major number. It's worth the code
overhead not to go look it up a zillion times when running fstat or ps
on a machine with a billion people logged in. fstat mostly.
 1.15 16-Dec-2004  atatat Get rid of the private getptsname() function and use getdevmajor()
instead. It's really much better that way, you'll see.
 1.14 14-Dec-2004  atatat Properly return the constructed name for ptyfs nodes. Otherwise we
accidentally return NULL on the first call and find it in the cache on
all subsequent calls.
 1.13 11-Nov-2004  christos More error checking.
 1.12 11-Nov-2004  christos Recognize ptyfs ptys.
 1.11 13-Oct-2003  agc Move Keith Muller's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22397 by Joel Baker, confirmed
to the board by Keith Muller.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 05-Jun-2000  simonb Add a cache ala pwcache(3). Gives a small but measurable performance
improvement for callers to devname(3) (eg ps(1)) under most circumstances.
 1.8 22-Jan-2000  mycroft branches: 1.8.2;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.7 02-Feb-1998  perry merge/update to lite-2
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Use "namespace.h"
Add missing stdlib.h
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up Id's on files previously imported...
 1.3 12-Dec-1994  jtc branches: 1.3.2;
Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.2 11-Dec-1994  christos - Changed all internal libc references of {v,}err{x,} and {v,}warn{x,} to
__{v,}err{x,} and __{v,}warn{x,}
- moved err.c to __err.c and added err.c which contains weak references for
the above functions.
- Reordered the functions in __err.c to avoid redeclarations and changed
the varargs declarations to conform with the K&R style.
 1.1 06-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 06-May-1994  cgd devname() routine
 1.3.2.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.4.4.2 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.4.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.8.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.16.24.1 18-May-2008  yamt sync with head.
 1.17.8.2 08-Nov-2008  christos time_t changes
 1.17.8.1 28-Apr-2008  christos file devname.c was added on branch christos-time_t on 2008-11-08 21:45:38 +0000
 1.19.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.21.8.1 23-Jun-2012  riz Pull up following revision(s) (requested by joerg in ticket #328):
lib/libc/gen/devname.c: revision 1.22
distrib/sparc64/instfs/dot.profile: revision 1.7
distrib/i386/cdroms/install.sh: revision 1.3
tests/lib/libcurses/director/director.c: revision 1.10
lib/libc/include/reentrant.h: revision 1.15
distrib/amd64/cdroms/install.sh: revision 1.3
tests/include/t_paths.c: revision 1.12
share/man/man7/hier.7: revision 1.101
etc/rc.d/sysdb: revision 1.24
include/stdlib.h: revision 1.99
tests/lib/libcurses/Makefile: revision 1.3
distrib/sparc64/cdroms/installcd/install.sh: revision 1.3
distrib/i386/cdroms/Makefile.cdrom: revision 1.27
lib/libc/gen/ttyname.c: revision 1.25
usr.bin/tic/Makefile: revision 1.2
tools/compat/Makefile: revision 1.57
lib/libterminfo/compile.c: revision 1.7
lib/libc/gen/ttyname.c: revision 1.26
lib/libterminfo/compile.c: revision 1.8
tools/compat/Makefile: revision 1.59
tools/compat/cdbw.h: revision 1.1
distrib/i386/installimage/install.sh: revision 1.2
lib/libc/include/namespace.h: revision 1.154
usr.bin/tic/tic.c: revision 1.13
usr.bin/tic/tic.c: revision 1.14
usr.bin/tic/tic.c: revision 1.15
distrib/sets/lists/base/mi: revision 1.996
usr.bin/tic/tic.c: revision 1.16
usr.sbin/dev_mkdb/dev_mkdb.8: revision 1.13
usr.bin/tic/tic.c: revision 1.17
usr.bin/tic/tic.c: revision 1.18
tools/compat/cdbr.h: revision 1.1
distrib/sparc64/instfs/list: revision 1.25
usr.bin/tic/tic.c: revision 1.19
lib/libc/cdb/cdbw.c: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.5
share/terminfo/Makefile: revision 1.3
usr.sbin/dev_mkdb/dev_mkdb.c: revision 1.29
usr.sbin/dev_mkdb/Makefile: revision 1.8
lib/libc/gen/ttyname.3: revision 1.23
lib/libc/gen/ttyname.3: revision 1.24
lib/libc/cdb/cdbr.c: revision 1.3
include/cdbw.h: revision 1.2
distrib/sparc64/cdroms/installcd/Makefile: revision 1.15
lib/libc/gen/devname.3: revision 1.12
tools/compat/compat_defs.h: revision 1.85
tools/compat/compat_defs.h: revision 1.86
lib/libterminfo/term_private.h: revision 1.10
lib/libterminfo/term.c: revision 1.14
usr.bin/tic/tic.1: revision 1.10
lib/libterminfo/term.c: revision 1.15
lib/libterminfo/Makefile.hash: revision 1.5
lib/libterminfo/term.c: revision 1.16
distrib/amd64/installimage/install.sh: revision 1.2
share/man/man5/rc.conf.5: revision 1.152
distrib/sets/lists/tests/mi: revision 1.472
distrib/amd64/cdroms/Makefile.cdrom: revision 1.7
include/paths.h: revision 1.41
bin/ps/ps.1: revision 1.101
lib/libterminfo/terminfo.5.in: revision 1.16
usr.bin/tic/tic.c: revision 1.20
lib/libterminfo/terminfo.5.in: revision 1.17
Prefer __printflike.
Use queue(3)
Replace linear lookup with hash table, reducing runtime by 60%.
Use e* from util.h.
One more strdup -> estrdup.
Maintain nalias and nterm on the fly.
Add void for ttyslot prototype.
Use memcmp in place of strncmp, since length is known to no longer than
either of the arguments.
Fix a number of memory leaks. Keep final loop of the cleanup in tic(1)
under #ifdef __VALGRIND__ though.
Add __predict_true / __predict_false definitions.
Add a special seeder for cdbw_output that gives stable results.
Hook up cdbw(3) for the tool build.
Prototype for cdbw_stable_seeder.
Provide a usable thr_once for !_REENTRANT
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
Switch terminfo(3) to cdb(5).
Fix typos.
Make Alan Barrett happy and add ().
Add cdbr(3) support to tools/compat.
Bump date for previous.
Relax consistency to make it possible to match valid entries.
Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.
 1.21.6.1 30-Oct-2012  yamt sync with head
 1.22.32.1 10-Jun-2019  christos Sync with HEAD
 1.5 09-Mar-1995  jtc date and time functions have been moved
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.43 17-Feb-2021  dholland Document that rewinddir(3) might either reopen or just lseek the dir.

(Currently it depends on the underlying directory, but documenting the
exact details seems inadvisable.)

Also, Someone(TM) should check if POSIX permits this or if we ought to
improve the implementation.
 1.42 17-Feb-2021  dholland Fix some typos/malapropisms in directory(3).
 1.41 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.40 22-Jan-2016  pgoyette Improved wording.
 1.39 22-Jan-2016  plunky clarify closing of descriptor returned by dirfd(3)
 1.38 08-Oct-2012  njoly Kill some extra spaces in function arguments.
 1.37 15-Oct-2011  rmind branches: 1.37.2; 1.37.8;
Mention POSIX conformance of some functions, when they appeared, sprinkle .Xr.
 1.36 17-Dec-2010  njoly Fix cross-reference, dir(5) -> dirent(3).
 1.35 04-Jun-2010  jruoho Fix .Xr; dirent(5) -> dirent(3).
 1.34 17-May-2010  jruoho Actually the previous is wrong; all of these can set the errno either via
each other or via something like malloc(3) or lseek(2).
 1.33 17-May-2010  jruoho Fix the note about errno in ERRORS; telldir(3), seekdir(3), and rewinddir(3)
do not set the errno.
 1.32 16-May-2010  wiz Sort sections. Fix typo. Fix xref. Improve wording in one case.
 1.31 16-May-2010  jruoho At least one markup-typo slipped through the cracks.
 1.30 16-May-2010  jruoho Rewrite much of the page.

Provide much more detailed and structured discussion. Notably, try to gather
some of the conditions around the famous undefined behavior; these functions
(or the implementations) are quite prone to such behavior.

Add compatibility notes. (The big change here is that in SUSv4 it is no
longer mandated that the directory streams are implemented by using file
descriptors.)

XXX: Please proofread this. Consider also adding some additional notes. For
instance, I left the semantics about "." and ".." out. The returned
errno's should be enumerated as well.
 1.29 11-Jan-2009  christos merge christos-time_t
 1.28 05-Dec-2008  wiz New sentence, new line. Bump date for fdopendir.
 1.27 05-Dec-2008  ad Add fdopendir(), from Solaris/Linux.
 1.26 18-May-2006  christos branches: 1.26.28;
Explicitly mention that telldir values are only valid for the lifetime of
the DIR pointer. Pointed out by Klaus Klein.
 1.25 17-May-2006  christos PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 04-Jul-2003  wiz Drop whitespace.
 1.22 28-May-2003  kleink Add restrict qualifiers to previous.
 1.21 28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.20 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.19 02-Mar-2003  enami Cosmetic changes in sample code.
 1.18 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.17 10-Aug-2002  wiz Update Dd for recent changes.
 1.16 10-Aug-2002  yamt - move a example into EXAMPLES section.
- check a return value of opendir.
from openbsd.
 1.15 29-Apr-2002  simonb Remove <sys/types.h> from synopsis, as per latest SUS/Posix specs.
 1.14 07-Feb-2002  ross generate & symbolically
 1.13 07-Feb-2002  ross Generate <>& symbolically.
 1.12 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.11 16-Sep-2001  wiz Boring whitespace fixes.
 1.10 22-Mar-1999  garbled branches: 1.10.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.7 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.6 27-Jul-1994  jtc branches: 1.6.2;
Sync with 4.4 lite
 1.5 10-Jan-1994  jtc Fix spelling errors.
 1.4 20-Aug-1993  jtc Fixed typo. Readdir returns a "struct dirent *", not "struct dirent".
 1.3 20-Aug-1993  mycroft Technically, readdir(3) returns a `struct dirent *', not a `struct direct *',
not that they aren't the same thing.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 27-Jul-1994  jtc Sync with 4.4 lite
 1.6.2.1 27-Jul-1994  jtc file directory.3 was added on branch netbsd-1-0 on 1994-07-27 05:37:09 +0000
 1.10.12.6 18-Oct-2002  nathanw Catch up to -current.
 1.10.12.5 13-Aug-2002  nathanw Catch up to -current.
 1.10.12.4 21-Jun-2002  nathanw Catch up to -current.
 1.10.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.10.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.10.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.26.28.1 04-Jan-2009  christos merge with head.
 1.37.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.37.2.1 30-Oct-2012  yamt sync with head
 1.5 29-Aug-1994  mycroft Clean up deleted files.
 1.4 28-Mar-1994  cgd don't ever extern lseek...
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 04-Jun-1993  proven Removed bugs and memory leaks from the directory function.
 1.4 26-Sep-2010  yamt fix rewinddir on nfs. fix PR/42879 (and probably PR/40229.)
 1.3 16-Sep-2010  yamt - remove a wrong _DIAGASSERT
- update comments
- whitespace
 1.2 04-May-2008  tonnerre branches: 1.2.8;
Fix a bug in the implementation of seekdir(). If the first entry in
a block has been unlinked, seekdir() may overshoot by one entry.
Thus, _readdir_unlinked() must not skip deleted entries when being
called from seekdir().
Christos agreed.
 1.1 17-May-2006  christos branches: 1.1.18;
PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.1.18.1 18-May-2008  yamt sync with head.
 1.2.8.2 04-May-2008  tonnerre Fix a bug in the implementation of seekdir(). If the first entry in
a block has been unlinked, seekdir() may overshoot by one entry.
Thus, _readdir_unlinked() must not skip deleted entries when being
called from seekdir().
Christos agreed.
 1.2.8.1 04-May-2008  tonnerre file dirent_private.h was added on branch christos-time_t on 2008-05-04 18:53:27 +0000
 1.14 10-May-2008  christos branches: 1.14.6;
undo the constification of the argument. Per opengroup.
 1.13 30-Apr-2008  martin branches: 1.13.2;
Convert TNF licenses to new 2 clause variant
 1.12 23-Apr-2008  plunky constify dirname(3) and basename(3)
 1.11 06-Sep-2003  kleink branches: 1.11.30;
Add Xref to dirname(1).
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 17-Oct-2002  wiz Use .Dq and .Sq.
 1.8 17-Oct-2002  thorpej Change basename(3) and dirname(3) to return a pointer to static
storage, rather than modifying their input arguments. While not
reentrant, this is explcitly allowed by IEEE Std 1003.1-2001 (which
allows either behavior, stating that it is implementation-dependent).

The new semantics are considered less hostile/more useful by most programs
which use basename(3) and/or dirname(3) (several programs in the NetBSD
tree reimplement basename()/dirname() themselves to avoid modification
of the input argument).

This new implementation truncates results to PATH_MAX. The Std does
not address this in the static storage case. However since PATH_MAX
is the maximum pathname length in the Std, this should not be a problem
in practice. Nontheless, it is noted in the BUGS section.

See the basename(3)/dirname(3) regression tests in src/regress/lib/libc.

Inspired by discussion with Niels Provos, related to PR 18647.
 1.7 07-Feb-2002  ross branches: 1.7.2;
Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 16-Sep-2001  wiz Boring whitespace fixes.
 1.4 12-Sep-1999  kleink branches: 1.4.10;
Use full month names with .Dd, as per mdoc.samples(7).
 1.3 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.2 05-Feb-1998  perry add LIBRARY section to man page
 1.1 02-Nov-1997  kleink Add basename() and dirname(), from XPG4.2.
 1.4.10.4 11-Nov-2002  nathanw Catch up to -current
 1.4.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.7.2.1 07-Dec-2002  he Pull up revision 1.8 (requested by thorpej in ticket #918):
Change basename(3) and dirname(3) to return a pointer to
static storage instead of modifying their arguments. Fixes
PR#18647.
 1.11.30.1 18-May-2008  yamt sync with head.
 1.13.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.6.2 10-May-2008  christos undo the constification of the argument. Per opengroup.
 1.14.6.1 10-May-2008  christos file dirname.3 was added on branch christos-time_t on 2008-05-10 22:39:41 +0000
 1.14 27-Sep-2018  kre HACK: if calling dirname() with the results of a previous dirname()
there is no need to copy the path into the output buffer, it is already
there....

All this has to change to become compat with a forthcoming POSIX update.
 1.13 16-Jul-2014  christos branches: 1.13.22; 1.13.24;
basename_r and dirname_r are non-standard and different from what we define
here on FreeBSD. Their libgen.h exposes them unconditionally, so hide ours
for now.
 1.12 14-Jul-2014  christos Factor out the basename and dirname code into basename_r and dirname_r
which are static for now. Inspired by similar changes to android(bionic).
 1.11 24-Nov-2009  tnozaki branches: 1.11.12; 1.11.22;
guard single-dot from modification by the application
(SUSv3 spec don't forbid this brutal operation).
this idea taken from OpenBSD's version of basename(3) and dirname(3).
 1.10 10-May-2008  christos branches: 1.10.6;
undo the constification of the argument. Per opengroup.
 1.9 28-Apr-2008  martin branches: 1.9.2;
Remove clause 3 and 4 from TNF licenses
 1.8 23-Apr-2008  plunky constify dirname(3) and basename(3)
 1.7 17-Oct-2002  tron branches: 1.7.30;
Fix lint error.
 1.6 17-Oct-2002  thorpej Change basename(3) and dirname(3) to return a pointer to static
storage, rather than modifying their input arguments. While not
reentrant, this is explcitly allowed by IEEE Std 1003.1-2001 (which
allows either behavior, stating that it is implementation-dependent).

The new semantics are considered less hostile/more useful by most programs
which use basename(3) and/or dirname(3) (several programs in the NetBSD
tree reimplement basename()/dirname() themselves to avoid modification
of the input argument).

This new implementation truncates results to PATH_MAX. The Std does
not address this in the static storage case. However since PATH_MAX
is the maximum pathname length in the Std, this should not be a problem
in practice. Nontheless, it is noted in the BUGS section.

See the basename(3)/dirname(3) regression tests in src/regress/lib/libc.

Inspired by discussion with Niels Provos, related to PR 18647.
 1.5 31-Jan-2002  tv branches: 1.5.2;
Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.4 21-Jan-2002  tv Add hooks for reachover builds from src/tools/compat.
 1.3 15-Sep-2001  simonb Unwrap a line that wasn't >80 characters long before it was wrapped.
 1.2 22-Jan-2000  mycroft branches: 1.2.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.1 02-Nov-1997  kleink Add basename() and dirname(), from XPG4.2.
 1.2.6.5 11-Nov-2002  nathanw Catch up to -current
 1.2.6.4 22-Mar-2002  nathanw Catch up to -current.
 1.2.6.3 08-Mar-2002  nathanw Catch up to -current.
 1.2.6.2 28-Jan-2002  nathanw Catch up to -current.
 1.2.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.5.2.2 08-Dec-2002  he Pull up revision 1.7 (requested by he in ticket #918):
Fix this so that it compiles again.
 1.5.2.1 07-Dec-2002  he Pull up revision 1.6 (requested by thorpej in ticket #918):
Change basename(3) and dirname(3) to return a pointer to
static storage instead of modifying their arguments. Fixes
PR#18647.
 1.7.30.1 18-May-2008  yamt sync with head.
 1.9.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.6.2 10-May-2008  christos undo the constification of the argument. Per opengroup.
 1.10.6.1 10-May-2008  christos file dirname.c was added on branch christos-time_t on 2008-05-10 22:39:41 +0000
 1.11.22.1 10-Aug-2014  tls Rebase.
 1.11.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.24.1 10-Jun-2019  christos Sync with HEAD
 1.13.22.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.37 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.36 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.35 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.34 19-Mar-2006  christos branches: 1.34.44;
Coverity CID 512: Fix memory leak.
 1.33 22-Jun-2005  he Fix the toolification of disklabel by using the nbinclude namespace
under HAVE_NBTOOL_CONFIG_H for disktab.h as well. This means
disktab.h has to be installed in the nbinclude include directory.

(Failure mode: with TOOLDIR as a subdirectory of /usr, the host's disktab.h
got picked up, and not the in-tree copy.)

Reviewed by dyoung.
 1.32 12-Jun-2005  dyoung Make disklabel(8) and fdisk(8) into "host tools " last step: build
and install ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-disklabel,
${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk by "reaching over" to
the sources in ${NETBSDSRCDIR}/sbin/{disklabel fdisk}/.

To avoid clashes with a build-host's header files, especially on
*BSD, the host-tools versions of fdisk and disklabel search for
#includes such as disklabel.h, disklabel_acorn.h, disklabel_gpt.h,
and bootinfo.h in a new #includes namespace, nbinclude/. That is,
they #include <nbinclude/sys/disklabel.h>, <nbinclude/machine/disklabel.h>,
<nbinclude/sparc64/disklabel.h>, instead of <sys/disklabel.h> and
such. I have also updated the system headers to #include from
nbinclude/-space when HAVE_NBTOOL_CONFIG_H is #defined.
 1.31 23-Apr-2004  christos adjust to constification.
 1.30 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.29 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.28 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.27 07-Jul-2000  itohy branches: 1.27.2;
Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.26 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.25 20-Sep-1999  lukem branches: 1.25.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.24 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.23 19-Jan-1999  abs Add '-f disktab' option to disklabel, via lib/6623 from
Greg A. Woods <woods@most.weird.com>. (Very) slightly tweaked disklabel.8
 1.22 12-Nov-1998  christos delint
 1.21 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.20 26-Jul-1998  mycroft const poisoning.
 1.19 28-Feb-1998  enami Just nuke the cast rather than changing (char *) to (void *). Even lint
doesn't complain about it.
 1.18 26-Feb-1998  perry trivial changes to reduce lint complaints
 1.17 03-Feb-1998  perry remove obsolete register declarations
 1.16 02-Feb-1998  perry merge/update to lite-2
 1.15 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.14 13-Jul-1997  christos Fix RCSID's
#if 0 a local unused error function
 1.13 14-Feb-1997  scottr getdiskbyname() was broken by previous change, adversely affecting
newfs(8) and disklabel(8). Back this out, and note instead that all
instances of strcpy() here are safe.
 1.12 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.11 07-Jun-1995  cgd branches: 1.11.4;
eliminate the need for some (fatal) casts.
 1.10 13-May-1995  jtc #include appropriate header files to bring prototypes into scope
 1.9 27-Feb-1995  cgd make lint/SCCS Id if more standard.
 1.8 25-Feb-1995  cgd typo
 1.7 25-Feb-1995  cgd update to 4.4-Lite and/or clean up Id
 1.6 19-Oct-1994  cgd branches: 1.6.2;
pointer type.
 1.5 12-Jun-1994  cgd fix up includes for new FS code
 1.4 11-Nov-1993  jtc First pass at getting a clean compile with "gcc -Wall", mostly explictly
declaring function return values, etc.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.1 02-May-1995  jtc #include "namespace.h"
 1.11.4.2 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.11.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.25.4.1 27-Dec-1999  wrstuden DEV_BSIZE -> DEF_BSIZE.
 1.27.2.1 11-Nov-2002  nathanw Catch up to -current
 1.34.44.2 30-Oct-2012  yamt sync with head
 1.34.44.1 17-Apr-2012  yamt sync with head
 1.2 26-Feb-2021  wiz Fix xref, add missing word.
 1.1 26-Feb-2021  christos PR/56012: Kouichi Hashikawa: getutent(3) man page is missing
 1.7 05-Jul-2020  christos revert previous; utmpxname is already documented in getlastlogx.3. Should
probably be moved.
 1.6 05-Jul-2020  christos document utmpxname(3)
 1.5 30-Apr-2008  martin branches: 1.5.8;
Convert TNF licenses to new 2 clause variant
 1.4 04-May-2004  atatat branches: 1.4.24;
That's "endutxent", not "entutxent". Hi, wiz!
 1.3 27-Jun-2003  wiz branches: 1.3.2;
Remove superfluous "".
 1.2 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.1 27-Sep-2002  wiz branches: 1.1.2;
Add documentation for utmpx and some related functions.
Thanks for some explanations to christos, and for some STANDARDS hints
to Klaus Klein.
 1.1.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.1 27-Sep-2002  nathanw file endutxent.3 was added on branch nathanw_sa on 2002-10-18 02:15:46 +0000
 1.3.2.1 06-May-2004  jmc Pullup rev 1.4 (requested by atatat in ticket #260)

Thats "endutxent", not "entutxent".
 1.4.24.1 18-May-2008  yamt sync with head.
 1.5.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.5.8.1 30-Apr-2008  martin file endutxent.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.24 02-Feb-2024  jkoshy Make the err(3) manual clearer to read.

- Mention that the 'fmt' argument to these functions holds
a printf(3)-like format specification.
- Clarify that the err()/warn()/errc()/warnc() family of functions
will append an additional error message to the output.
- Add whitespace to separate paragraphs describing distinct
concepts.
- Move the sentence mentioning the final output newline to
a less ambiguous location within the text.
- Add a cross-reference to printf(3).
 1.23 05-Jan-2023  kre Add errc() and verrc() to the list of functions which do not return,
but exit() instead.

This was omitted when the *c() set of functions were added in 2014.
 1.22 03-Jul-2017  wiz branches: 1.22.8; 1.22.16;
Remove workaround for ancient HTML generation code.
 1.21 16-Jan-2014  christos branches: 1.21.18;
Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.20 22-Mar-2010  joerg branches: 1.20.6; 1.20.12;
Use .In for header files instead of .Ar Pa and variations.
 1.19 10-Aug-2003  wiz Be more explicit about the difference between the err and errx (and
similar) functions. Based on wording from Jeremy C. Reed.
Closes PR 22424.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.16 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.15 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.14 07-Feb-2002  ross Generate <>& symbolically.
 1.13 16-Sep-2001  wiz Boring whitespace fixes.
 1.12 22-Mar-2001  cgd clean up a bit, xref exit(3), and suggest use of EXIT_FAILURE.
 1.11 19-Feb-2001  cgd branches: 1.11.2;
add cross-reff to getprogname(3)
 1.10 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 29-Sep-1997  enami Use warn() instead of err() as an example of ``Warn of an error''.
 1.7 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.6 21-Feb-1997  mikel clarify what is printed; from Arne Henrik Juul in PR 3242, with some
minor editing by myself.
 1.5 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.4 25-Nov-1993  jtc Misc manpage fixes.
 1.3 06-Nov-1993  cgd update to latest version; no *significant* changes.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 30-Apr-1993  glass branches: 1.1.1;
new err stuff
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.11.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.11.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.11.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.20.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.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.21.18.1 06-Jan-2023  martin Pull up following revision(s) (requested by kre in ticket #1782):

lib/libc/gen/err.3: revision 1.23

Add errc() and verrc() to the list of functions which do not return,
but exit() instead.

This was omitted when the *c() set of functions were added in 2014.
 1.22.16.2 20-Jul-2024  martin Pull up following revision(s) (requested by rin in ticket #750):

lib/libc/gen/err.3: revision 1.24

Make the err(3) manual clearer to read.
- Mention that the 'fmt' argument to these functions holds
a printf(3)-like format specification.
- Clarify that the err()/warn()/errc()/warnc() family of functions
will append an additional error message to the output.
- Add whitespace to separate paragraphs describing distinct
concepts.
- Move the sentence mentioning the final output newline to
a less ambiguous location within the text.
- Add a cross-reference to printf(3).
 1.22.16.1 06-Jan-2023  martin Pull up following revision(s) (requested by kre in ticket #37):

lib/libc/gen/err.3: revision 1.23

Add errc() and verrc() to the list of functions which do not return,
but exit() instead.

This was omitted when the *c() set of functions were added in 2014.
 1.22.8.1 06-Jan-2023  martin Pull up following revision(s) (requested by kre in ticket #1563):

lib/libc/gen/err.3: revision 1.23

Add errc() and verrc() to the list of functions which do not return,
but exit() instead.

This was omitted when the *c() set of functions were added in 2014.
 1.26 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.25 13-Sep-2005  christos don't use the weak names directly, so that the compat code works.
 1.24 13-Sep-2005  christos compat core reorg.
 1.23 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.22 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.21 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.20 22-Apr-2002  bjh21 When testing __STDC__, consistently use #ifdef rather than #if. The Sun
Workshop 5.0 C compiler defines __STDC__ to 0 unless it's in full-ANSI mode,
and in full ANSI mode it won't give us 64-bit integers (at least on a 32-bit
CPU).
 1.19 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.18 28-Jan-2002  tv Fix previous to actually include config.h.
 1.17 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.16 17-Aug-1999  mycroft branches: 1.16.10;
Make some needed weak aliases.
 1.15 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.14 13-Jul-1997  christos Fix RCSID's
Use namespace.h
 1.13 15-Apr-1996  jtc branches: 1.13.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.12 25-Feb-1995  cgd re-order things the way they'd like to be ordered
 1.11 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.10 17-Dec-1994  pk branches: 1.10.2;
Correct number of underscores on internal function calls.
 1.9 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.8 11-Dec-1994  christos - Changed all internal libc references of {v,}err{x,} and {v,}warn{x,} to
__{v,}err{x,} and __{v,}warn{x,}
- moved err.c to __err.c and added err.c which contains weak references for
the above functions.
- Reordered the functions in __err.c to avoid redeclarations and changed
the varargs declarations to conform with the K&R style.
 1.7 06-Nov-1993  cgd update to latest version; va_list specification changes.
 1.6 06-Nov-1993  jtc Remove extra "eval" variables in warn() & warnx() function definitions;
these variables were probably introduced by copying the definitions of
err() & errx() when the functions were first implemented.
 1.5 13-Oct-1993  jtc Use __dead instead of volatile.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 30-Jul-1993  mycroft Add even more RCS frobs.
 1.2 01-May-1993  mycroft Cleanup for GCC 2...
s/__dead/volatile/ (Does the format really exist in GCC 1?)
s/va_list/_VA_LIST_/ (to match prototypes)
 1.1 30-Apr-1993  glass branches: 1.1.1;
new err stuff
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.10.2.2 02-May-1995  jtc #include "namespace.h"
 1.10.2.1 17-Feb-1995  jtc Use "namespace.h"; back out old mechanism for namespace purity.
 1.13.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.16.10.4 21-Jun-2002  nathanw Catch up to -current.
 1.16.10.3 25-Apr-2002  nathanw Catch up to -current.
 1.16.10.2 22-Mar-2002  nathanw Catch up to -current.
 1.16.10.1 08-Mar-2002  nathanw Catch up to -current.
 1.3 06-Jun-2014  joerg branches: 1.3.4;
Fix conditionals.
 1.2 06-Jun-2014  christos be friendlier to nbcompat
 1.1 16-Jan-2014  christos branches: 1.1.2; 1.1.4;
Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.1.4.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.4.1 16-Jan-2014  yamt file errc.c was added on branch yamt-pagecache on 2014-05-22 11:36:52 +0000
 1.1.2.1 10-Aug-2014  tls Rebase.
 1.3.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.4.1 06-Jun-2014  tls file errc.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.4 16-Dec-2010  joerg Replace use of errlist with a single concatenated version and an offset
array. This requires less storage and avoids one runtime relocation per
errno value.
 1.3 12-Dec-2010  joerg Don't bother with SCCS or the other RCSID conditionals.
 1.2 12-Dec-2010  christos remove comment
 1.1 12-Dec-2010  christos Automatically generate the error list.
 1.19 12-Dec-2010  christos errlist.c is automatically generated now.
 1.18 09-Dec-2010  joerg Wrap sys_errlist constants in a macro to make it easier to extract
the strings reliably with sed/awk.
 1.17 31-Oct-2006  cbiere Changed error message of ENOPROTOOPT to "Protocol option not available".
 1.16 20-Feb-2006  christos Add 3 new error strings.
 1.15 13-Sep-2005  christos compat core reorg.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 09-Apr-2003  kleink Change the strerror() string for ERANGE consistently to "Result too
large or too small" and reword its intro(2) description to reflect
the present use for non-numerical out-of-range errors; resolves
Andrew Brown's PR standards/21004, the discussion of which was
dramatically sped up by repeated whipping from Perry Metzger. :-)
 1.12 17-Aug-1999  mycroft Make some needed weak aliases.
 1.11 06-Dec-1998  jonathan Move warnings about sys_errlist[], sys_nerr, __sys_errlist, _sys_nerr
to _sys_siglist.c, so the warning is shown once at link time, not three times
(once for errlist.c itself, once each for the two includes in _sys_siglist.c).
 1.10 01-Dec-1998  thorpej Warn about references to the compatibility sys_errlist[] or sys_nerr, and
direct the user to include <errno.h> to generate the correct reference.

Warn about references to the deprecated __sys_signame[] or __sys_nerr, and
direct the user to include <errno.h> and use sys_errlist or sys_nerr instead.
 1.9 03-Mar-1998  mycroft Back out the changes that broke old executables referring to sys_errlist[].
 1.8 08-Feb-1998  kleink Add ENOMSG.
 1.7 06-Feb-1998  mikel add EAUTH, ENEEDAUTH, EIDRM
 1.6 09-Oct-1997  mycroft Make _sys_nerr const.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.3 12-Dec-1994  jtc branches: 1.3.2;
Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.2 25-Oct-1994  cgd typo
 1.1 10-Oct-1994  jtc branches: 1.1.1;
Renamed sys_errlist[] and sys_nerr to __sys_errlist[] and __sys_nerr.
The traditional API of sys_errlist[] and sys_nerr is provided by weak
references if they are supported. Otherwise, we're forced to have to
have two copies of the error message string table in the library.
Fortunately, unless a program uses both sys_errlist[] and strerror(),
only one of the copies will be linked into the executable.

This is all to provide an clean namespace as required by ANSI. I've
done the same for sys_siglist[], even though it is not required, to
be consistant.
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.3.2.2 02-May-1995  jtc #include "namespace.h"
 1.3.2.1 17-Feb-1995  jtc Use "namespace.h", back out old mechanism for namespace purity.
 1.4.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.6 10-Oct-1994  mycroft Clean up deleted files.
 1.5 02-Dec-1993  mycroft Add `const's to sys_errlist decl to match 4.4.
 1.4 13-Oct-1993  jtc Remove "errno" definition.
Errno should be defined in the c start up code, crt0.c (It is in most
ports) otherwise the sys_errlst table will be linked into binaries
where it is not used.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.5 12-Jun-2005  lukem Add missing __RCSID()
 1.4 17-Feb-2000  kleink Back out previous: when statically linking executables a warning will be
displayed for the reference through __errno(), which is really wrong.
 1.3 13-Feb-2000  kleink Arrange for a linker warning to be displayed when the errno datum is accessed
directly; inspired by a conversation with Havard Eidnes.
 1.2 27-Feb-1995  cgd branches: 1.2.12;
merge with Lite, keeping local changes. Also use new Id format.
 1.1 23-Dec-1993  cgd add file eaten by crash
 1.2.12.2 18-Feb-2000  he Undo pull-up of revision 1.3 (requested by abs and kleink):
There's still ``legal'' references to errno, so don't complain.
 1.2.12.1 15-Feb-2000  he Pull up revision 1.3 (requested by kleink):
Arrange for a linker warning to be displayed when the errno datum
is accessed directly (not using <errno.h>).
 1.1 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.14 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.13 13-Sep-2005  christos don't use the weak names directly, so that the compat code works.
 1.12 13-Sep-2005  christos compat core reorg.
 1.11 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.8 22-Apr-2002  bjh21 When testing __STDC__, consistently use #ifdef rather than #if. The Sun
Workshop 5.0 C compiler defines __STDC__ to 0 unless it's in full-ANSI mode,
and in full ANSI mode it won't give us 64-bit integers (at least on a 32-bit
CPU).
 1.7 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.6 28-Jan-2002  tv Fix previous to actually include config.h.
 1.5 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.4 17-Aug-1999  mycroft branches: 1.4.10;
Make some needed weak aliases.
 1.3 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.2 13-Jul-1997  christos Use "namespace.h"
Fix RCSID's
 1.1 15-Apr-1996  jtc branches: 1.1.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.1.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.4.10.4 21-Jun-2002  nathanw Catch up to -current.
 1.4.10.3 25-Apr-2002  nathanw Catch up to -current.
 1.4.10.2 22-Mar-2002  nathanw Catch up to -current.
 1.4.10.1 08-Mar-2002  nathanw Catch up to -current.
 1.32 04-Jan-2022  uwe exec(3): execlpe() first argument should be named "file"

"path" arguments are names used as-is, "file" arguments to "p"
functions are used to construct the pathname using $PATH if necessary.
 1.31 01-Sep-2019  wiz Remove superfluous Pp.
 1.30 01-Sep-2019  sevan Document history of exec()
Move statement on execlpe() & execvpe() to HISTORY section.
 1.29 18-Sep-2017  wiz branches: 1.29.4; 1.29.6;
Remove superfluous Tn.
 1.28 17-Sep-2017  abhinav Add execlpe and execvpe to the NAME section
 1.27 10-Dec-2016  rin Fix typo; ".Lx" should be ".Nx"
 1.26 27-Sep-2014  wiz branches: 1.26.2;
Add execvpe in one more place to explain its last argument.
Call character '0' 'NUL' instead of 'null'.
 1.25 27-Sep-2014  wiz Consistency in commas. Wording.
 1.24 26-Sep-2014  christos missed one reference.
 1.23 26-Sep-2014  christos add execvpe, execlpe (reviewed by phone)
 1.22 22-Nov-2012  abs - Correct macro usage;
- sort section order.

From Bug Hunting.
 1.21 22-Mar-2010  joerg branches: 1.21.6; 1.21.12;
Use .In for header files instead of .Ar Pa and variations.
 1.20 25-May-2005  wiz <> -> Aq.
 1.19 07-May-2005  perry cross reference script.7
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.16 10-Aug-2002  wiz Fix formatting glitch, end sentence with a dot, and use Nm instead of
a self-Xr. Update Dd for recent changes.
 1.15 10-Aug-2002  yamt default path doesn't contain current directory anymore.
from openbsd.
 1.14 10-Aug-2002  yamt reflect change of default path.
from openbsd.
 1.13 07-Feb-2002  ross Generate <>& symbolically.
 1.12 15-Jan-2002  wiz Formatting improvements.
 1.11 22-Aug-2001  groo begin executed --> being executed
 1.10 28-Apr-1998  fair branches: 1.10.12;
Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 23-Nov-1997  enami Un-capitalize function names at the beginning of line.
 1.7 23-Nov-1997  enami In the SEE ALSO list,

- remove duplicated `environ(7)'.
- remove unexistent system call `trace(2)'.
- delete a period at the end.
 1.6 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.5 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.4 10-Jan-1994  jtc Fix spelling errors.
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.12.5 13-Aug-2002  nathanw Catch up to -current.
 1.10.12.4 22-Mar-2002  nathanw Catch up to -current.
 1.10.12.3 08-Mar-2002  nathanw Catch up to -current.
 1.10.12.2 28-Jan-2002  nathanw Catch up to -current.
 1.10.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.21.12.1 25-Feb-2013  tls resync with head
 1.21.6.1 16-Jan-2013  yamt sync with (a bit old) head
 1.26.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.29.6.1 05-Sep-2019  martin Pull up following revision(s) (requested by sevan in ticket #174):
lib/libc/sys/chmod.2: revision 1.48
lib/libc/sys/stat.2: revision 1.59
lib/libc/sys/unlink.2: revision 1.30
lib/libc/sys/lseek.2: revision 1.25
lib/libc/sys/getuid.2: revision 1.18
lib/libc/sys/chown.2: revision 1.37
lib/libm/man/exp.3: revision 1.32
lib/libm/man/log.3: revision 1.7
lib/libc/sys/open.2: revision 1.60
lib/libc/stdio/fopen.3: revision 1.36
lib/libc/stdio/putc.3: revision 1.14
lib/libc/sys/mount.2: revision 1.51
share/man/man9/copy.9: revision 1.22
share/man/man9/uiomove.9: revision 1.20
lib/libc/sys/setuid.2: revision 1.23
lib/libc/sys/close.2: revision 1.18
sbin/init/init.8: revision 1.61
lib/libc/sys/write.2: revision 1.36
lib/libc/sys/read.2: revision 1.39
sbin/init/init.8: revision 1.62
lib/libc/sys/wait.2: revision 1.40
usr.bin/tty/tty.1: revision 1.10
lib/libc/sys/link.2: revision 1.33
usr.bin/du/du.1: revision 1.24
lib/libc/stdlib/exit.3: revision 1.17
usr.bin/su/su.1: revision 1.53
usr.bin/mail/mail.1: revision 1.66
lib/libc/sys/fork.2: revision 1.25
usr.bin/su/su.1: revision 1.54
usr.bin/mail/mail.1: revision 1.67
lib/libm/man/sin.3: revision 1.15
share/man/man9/intro.9: revision 1.26
share/man/man5/utmp.5: revision 1.17
lib/libc/compat-43/creat.3: revision 1.17
lib/libc/time/ctime.3: revision 1.61
lib/libcompat/4.1/stty.3: revision 1.10
usr.bin/dc/dc.1: revision 1.3
lib/libm/man/cos.3: revision 1.17
lib/libc/sys/chdir.2: revision 1.23
lib/libc/gen/exec.3: revision 1.30
lib/libc/gen/exec.3: revision 1.31
games/bcd/bcd.6: revision 1.18
games/bcd/bcd.6: revision 1.19
usr.bin/write/write.1: revision 1.7
usr.bin/wc/wc.1: revision 1.18
usr.bin/pr/pr.1: revision 1.24
usr.bin/who/who.1: revision 1.25
lib/libc/sys/mkdir.2: revision 1.30
lib/libc/stdio/getc.3: revision 1.13
usr.bin/sort/sort.1: revision 1.40
usr.bin/mesg/mesg.1: revision 1.11
share/man/man5/passwd.5: revision 1.34
sort was there since v1
https://www.bell-labs.com/usr/dmr/www/man61.pdf

dc was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

du was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

mail was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

mesg was in v1
https://www.bell-labs.com/usr/dmr/www/man12.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man13.pdf

su was in v1
https://www.bell-labs.com/usr/dmr/www/man13.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man13.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man14.pdf
Update URL

write was in v1
https://www.bell-labs.com/usr/dmr/www/man14.pdf
grammar

passwd(5) was in v1
https://www.bell-labs.com/usr/dmr/www/man51.pdf

utmp(5) was present in v1
https://www.bell-labs.com/usr/dmr/www/man51.pdf

Earliest version of wtmp I could find was in v3
https://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man5/wtmp.5

Document history of chdir(2)
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history of chmod(2)
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history of chown(2)
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

create was present in v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history of exec()
Move statement on execlpe() & execvpe() to HISTORY section.

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

fork was present in v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf
stat() was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

document history of fstat()
https://www.bell-labs.com/usr/dmr/www/man21.pdf

getuid was present in v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf

stty & gtty were around since v1
https://www.bell-labs.com/usr/dmr/www/man21.pdf
https://www.bell-labs.com/usr/dmr/www/man22.pdf

mount & umount were present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

Open was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

read was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

seek was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

setuid was in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

unlink was presen in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

wait was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

write was present in v1
https://www.bell-labs.com/usr/dmr/www/man22.pdf

start documenting history
exp was present in v1
https://www.bell-labs.com/usr/dmr/www/man31.pdf

Start documenting history
https://www.bell-labs.com/usr/dmr/www/man31.pdf

Start documenting history
https://www.bell-labs.com/usr/dmr/www/man31.pdf

log appeared in v1
https://www.bell-labs.com/usr/dmr/www/man31.pdf

putc & putw were in v1
https://www.bell-labs.com/usr/dmr/www/man31.pdf

putchar was in v4
https://minie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man3/putchr.3

Start documenting history
https://www.bell-labs.com/usr/dmr/www/man31.pdf

Document history.
https://www.bell-labs.com/usr/dmr/www/man11.pdf
Between v1 & v6 UNIX, bcd was rewritten in C, but I don't know if which
version,
hence I've skipped mentioning it.
End sentence with a dot.
Remove superfluous Pp.
Remove superfluous Pp.
Remove superfluous Ns.
Remove superfluous Pp.
fetch(9) -> ufetch(9)
fetch(9) -> ufetch(9). Remove superfluous Pp.
fetch(9) -> ufetch(9). Remove reference to unimplemented ppi(9).
 1.29.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9 03-Jul-1996  jtc Split all exec*() functions out of exec.c into their own files.
 1.8 03-Jul-1996  jtc Added a new VA_START macro to hide the differences between varargs.h
and stdargs.h. This cleans up a lot of conditionals throughout this
file.
 1.7 14-Dec-1995  jtc Changed to use alloca() instead of malloc() to allocate argument vectors.
Programs that don't use malloc()/free() (ie. provide their own allocation
scheme atop sbrk()) should still be able to use exec*.
 1.6 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.5 24-Nov-1993  jtc branches: 1.5.4;
Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.4 22-Oct-1993  pk In execvp(): `eacces' did not get initialized when path name contains a '/'.
This causes the wrong error to be reported when execve() fails.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.3 02-May-1995  jtc #include "namespace.h"
 1.5.4.2 26-Apr-1995  jtc Namespace protect exec*() functions.
 1.5.4.1 26-Apr-1995  jtc #include "namespace.h"
 1.18 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.17 30-Jun-2011  joerg Drop special cases for i386 and m68k. It is not a validate assumption
that the address of an argument is at the same stack slot the caller
placed in it. It is perfectely valid to copy it into the local frame
first.
 1.16 09-Jan-2008  simonb Remove support for NetBSD/pc532.
 1.15 20-Mar-2006  he branches: 1.15.10;
Now that we use an errno constant, we need <errno.h>.
 1.14 20-Mar-2006  rtr check the return of alloca() if it fails set errno = ENOMEM and fail execl().
approved by christos@
resolves pr29671
 1.13 29-Nov-2005  christos cleanup casts and KNF.
 1.12 29-Nov-2005  christos WARNS=4
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 04-Mar-2003  nathanw Don't acquire __environ_lock around exec*() calls; nothing requires
that these calls be thread-safe with respect to the environment, and it
causes serious problems for threaded applications which call vfork() and
exec*() (including indirectly, via popen() or system()).

Acquire and release __environ_lock in the parent in popen() and system() to
play safe and provide the child with a stable environment.

__environ_lock should also have an atfork() handler; still under development.
 1.9 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.7 22-Jan-2000  mycroft branches: 1.7.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 11-Sep-1998  kleink Add a multiple-reader/single-writer lock to protect environ.
 1.5 20-Nov-1997  mjacob argv alloca'd is too short. Alloc an extra member.
 1.4 21-Jul-1997  jtc branches: 1.4.2;
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.3 13-Jul-1997  christos Fix RCSID's
 1.2 04-Jul-1996  jtc branches: 1.2.2;
Thanks to the calling conventions used by some cpus, the argument lists
passed to the execl(), execle(), and execlp() functions are in the form
of the argument vector to be passed to execve(). On these architectures,
it is unnecessary to count the number of arguments, allocate space on
the stack, copy the arguments, etc. The vector already on the stack
can be used instead.

When some arguments are passed in registers (like most RISC CPU's), it
should be possible to allocate stack space adjacent such that the
registers can be copied to that memory. After that, the same
approach described above can be used.

This change takes advantage of this on the i386, m68k, and ns32k. It
is probably true on the vax, but I am unable to check. RISC CPU's
probably need assembly language implementations to ensure everything
is placed exactly as needed when registers are copied to the stack...
 1.1 03-Jul-1996  jtc Split all exec*() functions out of exec.c into their own files.
 1.2.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.4.2.1 20-Nov-1997  mellon Pull rev 1.5 up from trunk (mjacob)
 1.7.6.2 21-Jun-2002  nathanw Catch up to -current.
 1.7.6.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.15.10.1 23-Mar-2008  matt sync with HEAD
 1.12 30-Jun-2011  joerg Drop special cases for i386 and m68k. It is not a validate assumption
that the address of an argument is at the same stack slot the caller
placed in it. It is perfectely valid to copy it into the local frame
first.
 1.11 09-Jan-2008  simonb Remove support for NetBSD/pc532.
 1.10 29-Nov-2005  christos branches: 1.10.10;
cleanup casts and KNF.
 1.9 29-Nov-2005  christos WARNS=4
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.6 22-Jan-2000  mycroft branches: 1.6.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.5 23-Nov-1997  enami Allocate one more element for arg vector, like execl.c rev 1.5.
 1.4 21-Jul-1997  jtc branches: 1.4.2;
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.3 13-Jul-1997  christos Fix RCSID's
 1.2 04-Jul-1996  jtc branches: 1.2.2;
Thanks to the calling conventions used by some cpus, the argument lists
passed to the execl(), execle(), and execlp() functions are in the form
of the argument vector to be passed to execve(). On these architectures,
it is unnecessary to count the number of arguments, allocate space on
the stack, copy the arguments, etc. The vector already on the stack
can be used instead.

When some arguments are passed in registers (like most RISC CPU's), it
should be possible to allocate stack space adjacent such that the
registers can be copied to that memory. After that, the same
approach described above can be used.

This change takes advantage of this on the i386, m68k, and ns32k. It
is probably true on the vax, but I am unable to check. RISC CPU's
probably need assembly language implementations to ensure everything
is placed exactly as needed when registers are copied to the stack...
 1.1 03-Jul-1996  jtc Split all exec*() functions out of exec.c into their own files.
 1.2.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.4.2.1 23-Nov-1997  mellon Pull rev 1.5 up from trunk (enami)
 1.6.6.1 21-Jun-2002  nathanw Catch up to -current.
 1.10.10.1 23-Mar-2008  matt sync with HEAD
 1.13 26-Sep-2014  christos add execvpe, execlpe (reviewed by phone)
 1.12 30-Jun-2011  joerg Drop special cases for i386 and m68k. It is not a validate assumption
that the address of an argument is at the same stack slot the caller
placed in it. It is perfectely valid to copy it into the local frame
first.
 1.11 09-Jan-2008  simonb Remove support for NetBSD/pc532.
 1.10 29-Nov-2005  christos branches: 1.10.10;
cleanup casts and KNF.
 1.9 29-Nov-2005  christos WARNS=4
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.6 22-Jan-2000  mycroft branches: 1.6.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.5 23-Nov-1997  enami Allocate one more element for arg vector, like execl.c rev 1.5.
 1.4 21-Jul-1997  jtc branches: 1.4.2;
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.3 13-Jul-1997  christos Fix RCSID's
 1.2 04-Jul-1996  jtc branches: 1.2.2;
Thanks to the calling conventions used by some cpus, the argument lists
passed to the execl(), execle(), and execlp() functions are in the form
of the argument vector to be passed to execve(). On these architectures,
it is unnecessary to count the number of arguments, allocate space on
the stack, copy the arguments, etc. The vector already on the stack
can be used instead.

When some arguments are passed in registers (like most RISC CPU's), it
should be possible to allocate stack space adjacent such that the
registers can be copied to that memory. After that, the same
approach described above can be used.

This change takes advantage of this on the i386, m68k, and ns32k. It
is probably true on the vax, but I am unable to check. RISC CPU's
probably need assembly language implementations to ensure everything
is placed exactly as needed when registers are copied to the stack...
 1.1 03-Jul-1996  jtc Split all exec*() functions out of exec.c into their own files.
 1.2.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.4.2.1 23-Nov-1997  mellon Pull rev 1.5 up from trunk (enami)
 1.6.6.1 21-Jun-2002  nathanw Catch up to -current.
 1.10.10.1 23-Mar-2008  matt sync with HEAD
 1.3 17-Jan-2018  kamil Revert to commits as they broke few rump tests

"Include namespace.h in a few of libc source files
[...]
This change finishes elimination of usage of the global name of the
following symbols:
- close -> _close
- execve -> _execve
- fcntl -> _fcntl
- setcontext -> _setcontext
- wait6 -> _wait6
- write -> _write
- writev -> _writev"

"Register more syscalls in namespace.h (of libc)

Add weak symbols for:
- fcntl
- close
- execve
- setcontext
- wait6
- write
- writev"

These changes broke:

fs/nfs/t_rquotad:get_nfs_be_1_both
fs/nfs/t_rquotad:get_nfs_be_1_group
fs/nfs/t_rquotad:get_nfs_be_1_user
fs/nfs/t_rquotad:get_nfs_le_1_both
fs/nfs/t_rquotad:get_nfs_le_1_group
fs/nfs/t_rquotad:get_nfs_le_1_user
lib/librumphijack/t_config:fdoff
lib/librumphijack/t_tcpip:http
lib/librumphijack/t_tcpip:nfs
lib/librumphijack/t_vfs:cpcopy
lib/librumphijack/t_vfs:mv_x
lib/librumphijack/t_vfs:paxcopy
net/net/t_forwarding:ipforwarding_fastforward_v4
net/net/t_forwarding:ipforwarding_fastforward_v6
net/net/t_forwarding:ipforwarding_fragment_v4
net/net/t_forwarding:ipforwarding_misc
net/net/t_mtudisc6:mtudisc6_basic

This revert fixes the failures, except lib/librumphijack/t_vfs.

The original changes were added in order to facilitate a usage of
sanitizers against programs linked with NetBSD's libc. It is no longer
needed, so abandon these changes.

Sponsored by <The NetBSD Foundation>
 1.2 05-Jan-2018  kamil Include namespace.h in a few of libc source files

The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

This change finishes elimination of usage of the global name of the
following symbols:
- close -> _close
- execve -> _execve
- fcntl -> _fcntl
- setcontext -> _setcontext
- wait6 -> _wait6
- write -> _write
- writev -> _writev

Sponsored by <The NetBSD Foundation>
 1.1 07-Feb-2017  kamil branches: 1.1.2; 1.1.4;
Mark exect(3) obsolete and bind it to plain execve(2) on all platforms

The original exect(2) from BSD4.2 was enabling bit for tracing
(single-step mode) and calling execve(2). The purpose of it was to generate
a signal for a tracer once the application will change its image to a new
program.

This approach no longer works as:
- exect(2) traces (single-steps) libc and it requires hundreds or
thousands steps before entering a new image
- it's vax and x86 specific code
- this functionality has been moved to the kernel - once a process is
traced it will generate SIGTRAP with si_code TRAP_EXEC and route it to
its debugger
- the side effects and unportability make this interface unusable
- there are no known users of this interface
- it apparently never worked better since day0 of NetBSD ("day0 bug")

Users are requested to move to other execve(2) variants. Calling current
execve(2) as it is the most similar behavior to this one from BSD4.2.

Discussed several times on mailing lists and in PR/51700.

Add warning to exect(3) telling about marking this function obsolete.

This function is prepared to be removed in next libc major bump.

Sponsored by <The NetBSD Foundation>
 1.1.4.2 21-Apr-2017  bouyer Sync with HEAD
 1.1.4.1 07-Feb-2017  bouyer file exect.c was added on branch bouyer-socketcan on 2017-04-21 16:53:09 +0000
 1.1.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.1 07-Feb-2017  pgoyette file exect.c was added on branch pgoyette-localcount on 2017-03-20 06:56:57 +0000
 1.11 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.10 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.9 29-Nov-2005  christos branches: 1.9.44;
cleanup casts and KNF.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 04-Mar-2003  nathanw Don't acquire __environ_lock around exec*() calls; nothing requires
that these calls be thread-safe with respect to the environment, and it
causes serious problems for threaded applications which call vfork() and
exec*() (including indirectly, via popen() or system()).

Acquire and release __environ_lock in the parent in popen() and system() to
play safe and provide the child with a stable environment.

__environ_lock should also have an atfork() handler; still under development.
 1.6 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.5 22-Jan-2000  mycroft branches: 1.5.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.4 11-Sep-1998  kleink Add a multiple-reader/single-writer lock to protect environ.
 1.3 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.2 13-Jul-1997  christos Fix RCSID's
 1.1 03-Jul-1996  jtc branches: 1.1.2;
Split all exec*() functions out of exec.c into their own files.
 1.1.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.5.6.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.9.44.1 30-Oct-2012  yamt sync with head
 1.32 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.31 26-Sep-2014  christos add execvpe, execlpe (reviewed by phone)
 1.30 20-Jul-2007  yamt branches: 1.30.16;
add a comment.
 1.29 09-Nov-2006  christos undo the previous; we need alloca here, otherwise the parent will leak on
vfork.
 1.28 09-Nov-2006  christos use mmap instead of malloc because we may have vforked. pointed out by yamt.
 1.27 08-Nov-2006  christos if we are using ssp, use malloc instead of alloca.
 1.26 29-Nov-2005  christos WARNS=4
 1.25 01-Jun-2005  lukem appease gcc -Wuninitialized
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 15-Mar-2003  christos PR/13242: John Heasley: ENOTDIR is not fatal
 1.22 04-Mar-2003  nathanw Don't acquire __environ_lock around exec*() calls; nothing requires
that these calls be thread-safe with respect to the environment, and it
causes serious problems for threaded applications which call vfork() and
exec*() (including indirectly, via popen() or system()).

Acquire and release __environ_lock in the parent in popen() and system() to
play safe and provide the child with a stable environment.

__environ_lock should also have an atfork() handler; still under development.
 1.21 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.20 08-Dec-2001  enami Use memcpy instead of memmove since no overlaps here (copy from somewhere
outside of the funciton to our stack).
 1.19 19-Sep-2001  enami Cosmetic changes (including ANSI'fy).
 1.18 19-Sep-2001  enami Remove unnecessary alloca, strcpy and strlen call.
 1.17 18-Sep-2001  simonb Use alloca() instead of malloc() and strdup(). Proper fix for the find
problem posted to current-users@netbsd.org. Solution suggested by a
couple of folks on that mailing list, and Art Grabowski who pointed me
at a similar change in OpenBSD.
 1.16 22-Jan-2000  mycroft branches: 1.16.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.15 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.14 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.13 16-Sep-1999  lukem revert previous (as per klaus). will diagassert() name == NULL check instead...
 1.12 16-Sep-1999  lukem check name != NULL before checking name[0] != '\0'
 1.11 04-Feb-1999  kleink Make argv construction code reentrant.
 1.10 12-Nov-1998  christos fix lint const lossage.
 1.9 11-Sep-1998  kleink Add a multiple-reader/single-writer lock to protect environ.
 1.8 26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.7 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.6 26-Feb-1998  perry trivial changes to reduce lint complaints
 1.5 03-Feb-1998  perry remove obsolete register declarations
 1.4 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.3 13-Jul-1997  christos Fix RCSID's
Initialize `path' in case of error.
Fix gcc warnings.
 1.2 24-Apr-1997  kleink POSIX.1/stopgap measure: if "" is to be executed, fail with ENOENT
immediately as there is no way for namei() to deal with this when
traversing $PATH.
 1.1 03-Jul-1996  jtc branches: 1.1.2;
Split all exec*() functions out of exec.c into their own files.
 1.1.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.16.6.3 28-Jan-2002  nathanw Catch up to -current.
 1.16.6.2 08-Oct-2001  nathanw Catch up to -current.
 1.16.6.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.30.16.2 20-Jul-2007  yamt add a comment.
 1.30.16.1 20-Jul-2007  yamt file execvp.c was added on branch matt-mips64 on 2007-07-20 12:41:08 +0000
 1.6 16-Dec-2011  wiz Split extattr(3) into two man pages to get rid of ugly duplicate Nd.
Work done by Abhinav Upadhyay with minimal cleanup.
 1.5 06-Aug-2011  wiz branches: 1.5.2;
Drop trailing whitespace.
 1.4 03-Aug-2011  manu Make cp -p and mv preverve extended attributes, and complain if they cannot.

Also introduce library functions for copying extended attributes from one
file to another:
- extattr_copy_file, extattr_copy_fd, extattr_copy_link, with FreeBSD style,
where a namespace is to be supplied
- cpxattr, fcpxattr, lcpxattr, with Linux style, where all namespaces
accessible to the caller are copied, and the others are silently ignored.
 1.3 02-Jan-2005  wiz Sort SEE ALSO.
 1.2 02-Jan-2005  wiz Fix date string.
 1.1 02-Jan-2005  thorpej System calls and support routines for file system extended attributes. Libc
version is bumped to 12.125.

From FreeBSD.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.5 09-Mar-2017  maya Remove redundant null check before free. it is safe to free(NULL)
While here, clear up odd whitespace issue. NFC
 1.4 13-Mar-2012  christos branches: 1.4.14; 1.4.18;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.3 03-Aug-2011  manu branches: 1.3.2;
Make cp -p and mv preverve extended attributes, and complain if they cannot.

Also introduce library functions for copying extended attributes from one
file to another:
- extattr_copy_file, extattr_copy_fd, extattr_copy_link, with FreeBSD style,
where a namespace is to be supplied
- cpxattr, fcpxattr, lcpxattr, with Linux style, where all namespaces
accessible to the caller are copied, and the others are silently ignored.
 1.2 09-Feb-2005  kleink A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.1 02-Jan-2005  thorpej System calls and support routines for file system extended attributes. Libc
version is bumped to 12.125.

From FreeBSD.
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.18.1 21-Apr-2017  bouyer Sync with HEAD
 1.4.14.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4 10-Dec-2021  andvar s/unaccessible/inaccessible/
 1.3 11-Mar-2021  msaitoh s/skiping/skipping/
 1.2 16-Dec-2011  manu branches: 1.2.4;
Do not tell about specific errno, as all xattr copying function
retuenrs error from extattr_list_file and extattr_get_file.
 1.1 16-Dec-2011  wiz Split extattr(3) into two man pages to get rid of ugly duplicate Nd.
Work done by Abhinav Upadhyay with minimal cleanup.
 1.2.4.2 17-Apr-2012  yamt sync with head
 1.2.4.1 16-Dec-2011  yamt file extattr_copy_file.3 was added on branch yamt-pagecache on 2012-04-17 00:05:18 +0000
 1.2 09-Mar-2025  christos move the man page in the same place as FreeBSD for consistency.
 1.1 16-Dec-2011  wiz branches: 1.1.4; 1.1.54;
Split extattr(3) into two man pages to get rid of ugly duplicate Nd.
Work done by Abhinav Upadhyay with minimal cleanup.
 1.1.54.1 02-Aug-2025  perseant Sync with HEAD
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 16-Dec-2011  yamt file extattr_namespace_to_string.3 was added on branch yamt-pagecache on 2012-04-17 00:05:18 +0000
 1.3 29-Nov-2013  joerg Add fabsl alias if necessary.
 1.2 10-Sep-2010  matt branches: 1.2.6; 1.2.12;
Resurrect this for MIPS softfloat.
 1.1 27-Jan-2010  matt branches: 1.1.2;
file fabs_ieee754.c was initially added on branch matt-nb5-mips64.
 1.1.2.1 27-Jan-2010  matt Don't use cfc1/ctc1 in softfloat. Use the "common" fabs/modf/ldexp when
using softfloat.
 1.2.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.3 30-Apr-2013  matt Include softfloat-for-gcc.h for __ARM_EABI__ to get aeabi aliases.
 1.2 05-Aug-2012  matt branches: 1.2.2;
If compiling for SOFTFLOAT, include "softfloat/softfloat-for-gcc.h" so we
can pick any redefinitions of the function (for ARM EABI).
 1.1 09-Jul-2011  matt branches: 1.1.2;
Add ieee754 versions of the compiler runtime functions
__fixuns{sf,df,tf}{si,di}.
Add an ieee754 version of the compiler runtime function __floatuntfdi
 1.1.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.1.2.1 30-Oct-2012  yamt sync with head
 1.2.2.1 23-Jun-2013  tls resync from head
 1.1 09-Jul-2011  matt Add ieee754 versions of the compiler runtime functions
__fixuns{sf,df,tf}{si,di}.
Add an ieee754 version of the compiler runtime function __floatuntfdi
 1.4 16-Apr-2022  andvar fix various typos in comments and log messages.
 1.3 25-Mar-2012  christos cast RHS of >>= operation to unsigned int
 1.2 31-Aug-2011  matt branches: 1.2.2;
Refactor to fix some signedness problems.
 1.1 09-Jul-2011  matt Add ieee754 versions of the compiler runtime functions
__fixuns{sf,df,tf}{si,di}.
Add an ieee754 version of the compiler runtime function __floatuntfdi
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.3 30-Apr-2013  matt Include softfloat-for-gcc.h for __ARM_EABI__ to get aeabi aliases.
 1.2 05-Aug-2012  matt branches: 1.2.2;
If compiling for SOFTFLOAT, include "softfloat/softfloat-for-gcc.h" so we
can pick any redefinitions of the function (for ARM EABI).
 1.1 09-Jul-2011  matt branches: 1.1.2;
Add ieee754 versions of the compiler runtime functions
__fixuns{sf,df,tf}{si,di}.
Add an ieee754 version of the compiler runtime function __floatuntfdi
 1.1.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.1.2.1 30-Oct-2012  yamt sync with head
 1.2.2.1 23-Jun-2013  tls resync from head
 1.2 05-Jan-2024  rin fixunstf[sd]i_ieee754: Explicitly include stddef.h for size_t

Fix build for mips{,n}64. Note that stddef.h has been implicitly
included via eabi.h for aarch64, on the other hand.
 1.1 09-Jul-2011  matt branches: 1.1.52;
Add ieee754 versions of the compiler runtime functions
__fixuns{sf,df,tf}{si,di}.
Add an ieee754 version of the compiler runtime function __floatuntfdi
 1.1.52.1 15-Oct-2024  martin Additionally pull up following revision(s) (requested by rin in ticket #952):

lib/libc/gen/fixunstfdi_ieee754.c: revision 1.2
lib/libc/gen/fixunstfsi_ieee754.c: revision 1.3

fixunstf[sd]i_ieee754: Explicitly include stddef.h for size_t

Fix build for mips{,n}64. Note that stddef.h has been implicitly
included via eabi.h for aarch64, on the other hand.
 1.3 05-Jan-2024  rin fixunstf[sd]i_ieee754: Explicitly include stddef.h for size_t

Fix build for mips{,n}64. Note that stddef.h has been implicitly
included via eabi.h for aarch64, on the other hand.
 1.2 05-Aug-2012  matt branches: 1.2.42;
If compiling for SOFTFLOAT, include "softfloat/softfloat-for-gcc.h" so we
can pick any redefinitions of the function (for ARM EABI).
 1.1 09-Jul-2011  matt branches: 1.1.2;
Add ieee754 versions of the compiler runtime functions
__fixuns{sf,df,tf}{si,di}.
Add an ieee754 version of the compiler runtime function __floatuntfdi
 1.1.2.1 30-Oct-2012  yamt sync with head
 1.2.42.1 15-Oct-2024  martin Additionally pull up following revision(s) (requested by rin in ticket #952):

lib/libc/gen/fixunstfdi_ieee754.c: revision 1.2
lib/libc/gen/fixunstfsi_ieee754.c: revision 1.3

fixunstf[sd]i_ieee754: Explicitly include stddef.h for size_t

Fix build for mips{,n}64. Note that stddef.h has been implicitly
included via eabi.h for aarch64, on the other hand.
 1.1 30-Jan-2014  joerg branches: 1.1.4; 1.1.8;
Provide a simple floatunditf implementation, at least mips64 needs one.
 1.1.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 30-Jan-2014  tls file floatunditf_ieee754.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.1.4.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.4.1 30-Jan-2014  yamt file floatunditf_ieee754.c was added on branch yamt-pagecache on 2014-05-22 11:36:52 +0000
 1.1 23-Aug-2013  matt branches: 1.1.4; 1.1.8;
Add __floatunsi{sd}f for IEEE754.
Unlike the quad versions, these don't use floating point.
 1.1.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 23-Aug-2013  tls file floatunsidf_ieee754.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.1.4.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.4.1 23-Aug-2013  yamt file floatunsidf_ieee754.c was added on branch yamt-pagecache on 2014-05-22 11:36:52 +0000
 1.1 23-Aug-2013  matt branches: 1.1.4; 1.1.8;
Add __floatunsi{sd}f for IEEE754.
Unlike the quad versions, these don't use floating point.
 1.1.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 23-Aug-2013  tls file floatunsisf_ieee754.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.1.4.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.4.1 23-Aug-2013  yamt file floatunsisf_ieee754.c was added on branch yamt-pagecache on 2014-05-22 11:36:52 +0000
 1.8 14-Jun-2014  apb Teach fmtcheck(3) that a pointer and a long are not the same.
 1.7 09-Mar-2009  joerg branches: 1.7.12; 1.7.22;
Fix preamble to match order set out by mdoc(7). Discussed with wiz.
 1.6 30-Apr-2008  martin branches: 1.6.8; 1.6.10;
Convert TNF licenses to new 2 clause variant
 1.5 16-Apr-2003  wiz branches: 1.5.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 01-Oct-2002  wiz Remove mdoc macro from weird place.
 1.3 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.2 07-Feb-2002  ross Generate <>& symbolically.
 1.1 20-Oct-2000  briggs branches: 1.1.2;
Add {__,}fmtcheck(), a function specified by Bill Sommerfeld to check
a user-supplied format string against a fallback format string to ensure
that they will consume arguments of the same type.

libc minor bump for new API entry point.
 1.1.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.2 22-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 08-Mar-2002  nathanw Catch up to -current.
 1.5.30.1 18-May-2008  yamt sync with head.
 1.6.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.6.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.6.8.1 30-Apr-2008  martin file fmtcheck.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.7.22.1 10-Aug-2014  tls Rebase.
 1.7.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16 13-Dec-2017  rin Revert change made by rev 1.11; now, fmtcheck(3) does not complain about
unused trailing arguments as before.

See also discussion on tech-userland:
http://mail-index.netbsd.org/tech-userlevel/2017/12/07/msg011019.html
 1.15 06-Dec-2017  rin Fix possible use of uninitialized variable in case of WIN32 && !_WIN64.
 1.14 06-Dec-2017  rin Teach fmtcheck(3) about wint_t, intmax_t, char *, intmax_t *, and wide string
arguments. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev181154
 1.13 06-Dec-2017  rin Teach fmtcheck(3) about the ' (thousands separator) flag. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev143905
 1.12 06-Dec-2017  rin Teach fmtcheck(3) about the flags a, A, F, G, t, and z. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev117014
 1.11 06-Dec-2017  rin Correct oversight of wrong format string with fewer number of arguments than
default format string has.
 1.10 20-Jan-2016  christos Add support for Windows I{32,64} formats from Jason Hood via file(1).
 1.9 14-Jun-2014  apb Teach fmtcheck(3) that a pointer and a long are not the same.
 1.8 28-Apr-2008  martin branches: 1.8.8; 1.8.28; 1.8.40;
Remove clause 3 and 4 from TNF licenses
 1.7 24-Dec-2005  perry branches: 1.7.18;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 28-Oct-2004  dsl Use (unsigned char) cast to sanitise arguments to ctype functions.
 1.5 27-Oct-2004  dsl Fix a load of international alphabet problems with isxxx() and toupper()
Change isspace(*char_ptr) to isspace(*char_ptr & 0xff) so that the correct
piece of memory is looked at for the bit mask.
gcc optimises out the '& 0xff' (on i386 at least).
Fixes problems found by gcc when the splurious (int) cast is removed
from the #defines in ctype.h
 1.4 10-Feb-2001  briggs Remove extra #include.
 1.3 16-Nov-2000  matt The prototype for fmtcheck is in <stdio.h> so we'd better include it.
 1.2 01-Nov-2000  briggs fmtcheck() should be declared as fmtcheck(), not __fmtcheck().
The weak_alias is __fmtcheck(). matt@3am-software.com pointed this out
as a problem when trying to build on a vax.
 1.1 20-Oct-2000  briggs Add {__,}fmtcheck(), a function specified by Bill Sommerfeld to check
a user-supplied format string against a fallback format string to ensure
that they will consume arguments of the same type.

libc minor bump for new API entry point.
 1.7.18.1 18-May-2008  yamt sync with head.
 1.8.40.1 10-Aug-2014  tls Rebase.
 1.8.28.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8.8.1 28-Apr-2008  martin file fmtcheck.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.8 22-Jan-2023  rillig fmtmsg.3: fix typo
 1.7 11-Apr-2011  jruoho Markup improvements.
 1.6 30-Apr-2008  martin branches: 1.6.8;
Convert TNF licenses to new 2 clause variant
 1.5 16-Apr-2003  wiz branches: 1.5.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.3 07-Feb-2002  ross Generate <>& symbolically.
 1.2 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.1 12-Sep-1999  kleink branches: 1.1.10;
Add an XSH5 fmtmsg() implementation.
 1.1.10.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.1.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.5.30.1 18-May-2008  yamt sync with head.
 1.6.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.6.8.1 30-Apr-2008  martin file fmtmsg.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.6 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.5 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.4 28-Apr-2008  martin branches: 1.4.4; 1.4.8;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Nov-2002  thorpej branches: 1.3.30;
Fix signed/unsigned comparison warnings.
 1.2 13-Sep-1999  kleink branches: 1.2.10;
Add the inevitable __RCSID().
 1.1 12-Sep-1999  kleink Add an XSH5 fmtmsg() implementation.
 1.2.10.1 11-Nov-2002  nathanw Catch up to -current
 1.3.30.1 18-May-2008  yamt sync with head.
 1.4.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4.8.1 28-Apr-2008  martin file fmtmsg.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.4.4.1 17-Apr-2012  yamt sync with head
 1.22 30-Nov-2010  jruoho Xref glob(7).
 1.21 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.20 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.19 07-Oct-2002  wiz Mdoc nits, and bump date for FNM_LEADING_DIR addition.
 1.18 06-Oct-2002  provos implement FNM_LEADING_DIR; matches Linux and other *BSDs; approved thorpej
 1.17 07-Feb-2002  ross Generate <>& symbolically.
 1.16 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.15 16-Sep-2001  wiz Boring whitespace fixes.
 1.14 28-Jun-2000  thorpej branches: 1.14.2;
Implement FNM_CASEFOLD, for matching the pattern in a case-insensitive
way. Flag name taken from glibc.
 1.13 05-Feb-1998  perry branches: 1.13.10;
add LIBRARY section to man page
 1.12 02-Feb-1998  perry merge/update to lite-2
 1.11 23-Apr-1997  cjs Add `glob' to the brief description to make this easier to find when
searching the permuted index.
 1.10 27-Feb-1995  cgd delete wordexp reference
 1.9 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.8 25-Nov-1993  jtc Misc manpage fixes.
 1.7 11-Nov-1993  jtc Implement the FNM_PERIOD flag.
 1.6 09-Nov-1993  jtc Fixed the most major defect in fnmatch(): backslash-escape processing in
bracket expressions. Still need to implement FNM_PERIOD...
 1.5 06-Nov-1993  cgd update to latest version; no *significant* changes.
 1.4 30-Jul-1993  mycroft Add RCS identifiers.
 1.3 30-Jul-1993  mycroft Add RCS frob.
 1.2 16-Jun-1993  jtc Update fnmatch() to be more posix complient (from bostic).
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.10.1 03-Jul-2000  thorpej Pull up rev. 1.14:
Implement FNM_CASEFOLD, for matching the pattern in a case-insensitive
way. Flag name taken from glibc.
 1.14.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.14.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.14.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.14.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.26 12-Oct-2014  christos Fix fnmatch issues according to POSIX.
http://pubs.opengroup.org/onlinepubs/009695399/utilities/\
xcu_chap02.html#tag_02_13_01
1. A [...] pattern containing a slash is not a pattern; the [ ]'s become regular
characters
2. A [] or a [!] is not an empty pattern, why would it? The first would never
match and the second would always match which makes it equivalent to ?
In those cases the ] is taken as a literal character and does not have
special meaning.
 1.25 25-Mar-2012  christos PR/41558: Stathis Kamperis: Treat a backslash followed by NUL as NUL, instead
of a backslash if FNM_NOESCAPE is not set. According to TOG: a backslash in
a pattern followed by any other character, will match that second character
in the string.
 1.24 31-Jan-2011  christos branches: 1.24.4;
add braces, per joerg.
 1.23 31-Jan-2011  christos bump down the recursion limit to 64.
 1.22 31-Jan-2011  christos Limit recursions to avoid DoS attacks from Maksymilian Arciemowicz
 1.21 24-Dec-2005  perry branches: 1.21.40;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.19 06-Oct-2002  provos implement FNM_LEADING_DIR; matches Linux and other *BSDs; approved thorpej
 1.18 28-Jun-2000  thorpej branches: 1.18.2;
Implement FNM_CASEFOLD, for matching the pattern in a case-insensitive
way. Flag name taken from glibc.
 1.17 22-Jan-2000  mycroft branches: 1.17.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.15 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.14 16-Mar-1999  christos Fix gcc-2.8.1 warnings.
 1.13 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.12 13-Jul-1997  christos Fix gcc warnings.
Fix RCSID's
 1.11 27-Feb-1995  cgd branches: 1.11.4;
merge with Lite, keeping local changes. Also use new Id format.
 1.10 24-Nov-1993  jtc Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.9 11-Nov-1993  jtc First pass at getting a clean compile with "gcc -Wall", mostly explictly
declaring function return values, etc.
 1.8 11-Nov-1993  jtc Implement the FNM_PERIOD flag.
 1.7 09-Nov-1993  jtc Fixed the most major defect in fnmatch(): backslash-escape processing in
bracket expressions. Still need to implement FNM_PERIOD...
 1.6 06-Nov-1993  cgd just berkeley copyright/version # changes.
 1.5 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.4 30-Jul-1993  mycroft Add RCS frob.
 1.3 16-Jun-1993  jtc Update fnmatch() to be more posix complient (from bostic).
 1.2 10-Apr-1993  mycroft Make return status match POSIX and man page.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.17.4.1 03-Jul-2000  thorpej Pull up rev. 1.18:
Implement FNM_CASEFOLD, for matching the pattern in a case-insensitive
way. Flag name taken from glibc.
 1.18.2.1 18-Oct-2002  nathanw Catch up to -current.
 1.21.40.1 08-Feb-2011  bouyer Sync with HEAD
 1.24.4.1 17-Apr-2012  yamt sync with head
 1.3 30-Apr-2008  martin branches: 1.3.8;
Convert TNF licenses to new 2 clause variant
 1.2 15-Jan-2004  kleink branches: 1.2.30;
Add C99 fpclassify(), isfinite(), isnormal(), and signbit() macros.
 1.1 29-Oct-2003  kleink Add manual pages for fpclassify and isfinite.
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.3.8.1 30-Apr-2008  martin file fpclassify.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 28-Oct-2003  kleink Upon rereading the implementation suggestions in the standard, rename the
double-precision version to __fpclassifyd(). No need to diverge, here.
 1.1 28-Oct-2003  kleink C99 7.12.3.1: add IEEE library portions of fpclassify. Don't build these
yet as the VAX implementation is still subject to discussion.
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 28-Oct-2003  kleink branches: 1.1.30;
Upon rereading the implementation suggestions in the standard, rename the
double-precision version to __fpclassifyd(). No need to diverge, here.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file fpclassifyd_ieee754.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.3 28-Apr-2008  martin branches: 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 29-Oct-2003  kleink branches: 1.2.30;
Fix the exponent value we're comparing with.
 1.1 28-Oct-2003  kleink C99 7.12.3.1: add IEEE library portions of fpclassify. Don't build these
yet as the VAX implementation is still subject to discussion.
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3.8.1 28-Apr-2008  martin file fpclassifyf_ieee754.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.3 23-Nov-2013  martin Fix very stupid typo
 1.2 21-Nov-2013  martin Make ext_fraclm and ext_frachm parts of the long double mantissa optional
in generic code
 1.1 17-Jan-2011  matt branches: 1.1.4; 1.1.8; 1.1.14;
Make the MIPS N32/N64 ABIs properly support 128-bit long doubles. With this
change, we should be fully conformant with the N32 and N64 ABIs.
Add {fpclassify,infinity,isnan,ininf,signbit}l_ieee754.c back to lib/libc/gen.
Note that infinityl_ieee754.c will work with either 64-bit, 80-bit, or
128-bit long doubles.
 1.1.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.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.1.4.2 29-Apr-2011  matt Pull in true (128-bit) long double support for MIPS from -current.
 1.1.4.1 17-Jan-2011  matt file fpclassifyl_ieee754.c was added on branch matt-nb5-mips64 on 2011-04-29 07:48:34 +0000
 1.12 27-Mar-2011  wiz Whitespace and punctuation.
 1.11 26-Mar-2011  christos add fpgetprec/fpsetprec
 1.10 30-Apr-2008  martin branches: 1.10.8;
Convert TNF licenses to new 2 clause variant
 1.9 04-Apr-2004  wiz branches: 1.9.24;
Add comma after "i.e.".
 1.8 04-Apr-2004  perry make this man page explain what the calls do somewhat better.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.5 05-Mar-2002  wiz Drop duplicate .Pp.
 1.4 07-Feb-2002  ross Generate <>& symbolically.
 1.3 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.2 16-Sep-2001  wiz Boring whitespace fixes.
 1.1 30-Apr-1999  ross branches: 1.1.2; 1.1.12;
* New MI man page for fp{set,get}{round,sticky,mask}(3).
* Implement fpgetsticky() for alpha.
* Direct fpsetsticky() and fp{get,set}mask() into alpha kernel via sysarch(2).
* Define new sysarch(2) stub for above and install and distribute sysarch.h
for alpha. (The fpcr IS user mode r/w, but for reasons beyond the scope
of a commit message kernel calls are needed.) And much kernel Magick is
required before these do anything, but this way programs compiled under
1.4 will DTRT on future snapshots and releases.
 1.1.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.1.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.1.2.2 30-Apr-1999  ross * New MI man page for fp{set,get}{round,sticky,mask}(3).
* Implement fpgetsticky() for alpha.
* Direct fpsetsticky() and fp{get,set}mask() into alpha kernel via sysarch(2).
* Define new sysarch(2) stub for above and install and distribute sysarch.h
for alpha. (The fpcr IS user mode r/w, but for reasons beyond the scope
of a commit message kernel calls are needed.) And much kernel Magick is
required before these do anything, but this way programs compiled under
1.4 will DTRT on future snapshots and releases.
 1.1.2.1 30-Apr-1999  ross file fpgetmask.3 was added on branch netbsd-1-4 on 1999-04-30 00:58:32 +0000
 1.9.24.1 18-May-2008  yamt sync with head.
 1.10.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.10.8.1 30-Apr-2008  martin file fpgetmask.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.13 03-Jul-2006  drochner move manpages for frexp/ldexp/modf to libm -- the (most) implementation is
already there
 1.12 23-Mar-2006  wiz Bump date for previous.
 1.11 21-Mar-2006  drochner mention single precision versions and advise to link against libm
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 16-Sep-2001  wiz Boring whitespace fixes.
 1.5 23-May-2001  kleink Fix return value interval; from Tadayuki OKADA in PR lib/12984.
 1.4 05-Feb-1998  perry branches: 1.4.10; 1.4.12;
add LIBRARY section to man page
 1.3 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.4.10.1 26-May-2001  he Pull up revision 1.5 (requested by kleink):
Correct return value interval. Fixes PR#12984.
 1.6 03-Jul-2006  drochner replaced by code in libc/compat/gen
 1.5 21-Feb-2006  drochner scale denormal numbers, to get a meaningful exponent (and a mantissa
which just consists of the implicit bit),
fixes PR lib/32861 by FX Coudert
(the bug was seen in gfortran stress tests)
(we should use the code in fdlibm as we do for frexpf())
 1.4 27-Oct-2003  kleink branches: 1.4.6;
Retire local union { floating-type; struct ieee_prec; } in favor of those
available from <machine/ieee.h>
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.2 12-May-2003  nathanw Fix a comment delimeter
 1.1 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.4.6.1 24-Mar-2006  riz Pull up following revision(s) (requested by drochner in ticket #1216):
lib/libc/gen/frexp_ieee754.c: revision 1.5
scale denormal numbers, to get a meaningful exponent (and a mantissa
which just consists of the implicit bit),
fixes PR lib/32861 by FX Coudert
(the bug was seen in gfortran stress tests)
(we should use the code in fdlibm as we do for frexpf())
 1.31 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.30 12-Feb-2012  wiz Remove duplicate function declaration. From Henning Petersen in PR 45998.
 1.29 15-Oct-2011  christos branches: 1.29.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.28 12-Aug-2006  christos - Add strndup and stresep
- Use stresep so in fstab so that we can mount paths with white space in them.
 1.27 24-Dec-2005  perry branches: 1.27.2;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.26 29-Nov-2005  christos WARNS=4
 1.25 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.24 16-Apr-2002  groo botched strncpy -> strlcpy
from xs@kittenz.org
 1.23 31-Aug-2001  lukem fstabscan() fixes:
- if _fs_fstab.fs_type is NULL, the line is incorrect, so warn about it
rather than trying to deference a NULL pointer.
fixes [bin/13787] by Dave Burgess.
- clear _fs_fstab before each use (just to be sure)
 1.22 22-Jan-2000  mycroft branches: 1.22.4; 1.22.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.21 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.20 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.19 23-Feb-1999  mrg add a new fstab type "dp" for the user-specified dump device.
change swapctl -A to see this and add it via swapctl(2). also
add a new swapctl -D <device> to change the dump device on the
fly.
 1.18 26-Jan-1999  thorpej Fix printf format errors.
 1.17 24-Jan-1999  christos - Use strsep() instead of strtok_r()
- Use warn{x,}() instead of home brewed error()
- Simplify some code.
 1.16 16-Oct-1998  kleink Use strtok_r() instead of strtok(), lest the application be surprised by
strtok()'s internal marker having changed.
 1.15 11-Oct-1998  kleink Need "namespace.h".
 1.14 26-Jul-1998  mycroft Use warn(3).
 1.13 26-Jul-1998  mycroft const poisoning.
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.10 13-Jul-1997  christos Fix RCSID's
Fix bogus NULL casts
GC constant strings.
Fix gcc warnings.
 1.9 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.8 03-Apr-1996  jtc branches: 1.8.2;
Add explict function return types
 1.7 27-Feb-1995  cgd oops; since i kept the writev() trick, still need uio.h
 1.6 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.5 13-Aug-1994  mycroft branches: 1.5.2;
Use writev(2) when reporting errors.
 1.4 13-Aug-1994  pk Allow a `#' to appear on line by itself (without spitting out errors).
 1.3 26-Aug-1993  jtc branches: 1.3.2;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.2.1 13-Aug-1994  mycroft update from trunk
 1.5.2.1 02-May-1995  jtc #include "namespace.h"
 1.8.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.22.6.2 25-Apr-2002  nathanw Catch up to -current.
 1.22.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.22.4.2 17-Apr-2002  he Pull up revision 1.24 (requested by groo):
Replace an instance of erroneous usage of strncpy() with strlcpy().
 1.22.4.1 27-Oct-2001  he Pull up revision 1.23 (requested by lukem):
Two fixes to fstabscan():
o if fs_type is NULL, warn in stead of crashing
o clear _fs_fstab before each use
Fixes PR#13787 and PR#14117.
 1.27.2.1 27-Aug-2006  riz Pull up following revision(s) (requested by tron in ticket #63):
regress/lib/libc/string/Makefile: revision 1.9
lib/libc/string/strsep.3: revision 1.17
lib/libc/string/strsep.3: revision 1.18
regress/lib/libc/string/stresep/Makefile: revision 1.1
distrib/sets/lists/base/shl.mi: revision 1.364
regress/lib/libc/string/stresep/stresep_test.c: revision 1.1
lib/libc/gen/fstab.c: revision 1.28
lib/libc/shlib_version: revision 1.181
lib/libc/string/strndup.c: revision 1.1
lib/libc/string/strdup.3: revision 1.13
lib/libc/string/strdup.3: revision 1.14
lib/libc/string/Makefile.inc: revision 1.61
include/string.h: revision 1.31
distrib/sets/lists/comp/mi: revision 1.909
lib/libc/string/stresep.c: revision 1.1
lib/libc/include/namespace.h: revision 1.118
- Add strndup and stresep
- Use stresep so in fstab so that we can mount paths with white space in th=
em.
Add stresep and strndup.
add regression test for stresep.
libc 146
man pages for stresep and strndup.
Mark up NULL.
stresep, not strnsep. Remove duplicate "the". Bump date for previous.
 1.29.2.1 17-Apr-2012  yamt sync with head
 1.18 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.17 20-Jul-2013  wiz Use Mt for email addresses.
 1.16 27-Apr-2010  jruoho branches: 1.16.6; 1.16.12; 1.16.16;
Note POSIX compliance.
 1.15 10-Mar-2009  joerg Use .An for the author instead of more physical .Bl.
 1.14 09-Mar-2009  joerg Fix preamble to match order set out by mdoc(7). Discussed with wiz.
 1.13 15-Sep-2004  hubertf branches: 1.13.36;
Change copyright to 2-clause BSD-copyright.
Changed with explicit permission of Thorsten Lockert (tholo sigmasoft com)
 1.12 27-Jun-2003  wiz branches: 1.12.2;
Remove superfluous semicolon.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 02-Mar-2003  enami s/indentifier/identifier/
 1.9 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 05-Jun-2001  wiz Uppercase Dt argument, fix AUTHORS section name.
 1.6 12-Dec-2000  briggs branches: 1.6.2;
Fix an old typo: s/ket_t/key_t/
 1.5 19-Nov-1999  kristerw Typos (from OpenBSD)
 1.4 12-Nov-1998  christos branches: 1.4.6;
Change the signature of ftok from (const char *, char) to (const char *, int)
Document that only the 8 least significant bits are used in the key generation
and that the return value is (key_t)-1
[this is to fix K&R vs. ansi compilation and lint warnings]
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.1 26-Jun-1994  jtc Ftok() routine, needed by most programs that use SysV IPC.
 1.4.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.6.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.12.2.1 16-Sep-2004  jmc Pullup rev 1.13 (requested by hubertf in ticket #850)

Change copyright to 2-clause BSD-copyright.
 1.13.36.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.16.16.1 23-Jul-2013  riastradh sync with HEAD
 1.16.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.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.12 26-Jul-2018  kamil Avoid undefined behavior in ftok(3)

Do not change the signedness bit with a left shift operation.
Cast to unsigned integer to prevent this.

ftok.c:56:10, left shift of 123456789 by 24 places cannot be represented in type 'int'
ftok.c:56:10, left shift of 4160 by 24 places cannot be represented in type 'int'

Detected with micro-UBSan in the user mode.
 1.11 20-Mar-2012  matt branches: 1.11.30; 1.11.32;
Use C89 definitions.
Remove use of __P
 1.10 15-Sep-2004  hubertf branches: 1.10.50;
Change copyright to 2-clause BSD-copyright.
Changed with explicit permission of Thorsten Lockert (tholo sigmasoft com)
 1.9 22-Jan-2000  mycroft branches: 1.9.10;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 12-Nov-1998  christos Change the signature of ftok from (const char *, char) to (const char *, int)
Document that only the 8 least significant bits are used in the key generation
and that the return value is (key_t)-1
[this is to fix K&R vs. ansi compilation and lint warnings]
 1.5 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.4 13-Jul-1997  christos Fix RCSID's
 1.3 27-Feb-1995  cgd branches: 1.3.4;
merge with Lite, keeping local changes. Also use new Id format.
 1.2 26-Jun-1994  jtc branches: 1.2.4;
Moved RCS ID into static variable rcsid
 1.1 26-Jun-1994  jtc Ftok() routine, needed by most programs that use SysV IPC.
 1.2.4.1 02-May-1995  jtc #include "namespace.h"
 1.3.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.10.1 16-Sep-2004  jmc Pullup rev 1.10 (requested by hubertf in ticket #850)

Change copyright to 2-clause BSD-copyright.
 1.10.50.1 17-Apr-2012  yamt sync with head
 1.11.32.1 10-Jun-2019  christos Sync with HEAD
 1.11.30.1 28-Jul-2018  pgoyette Sync with HEAD
 1.38 29-Oct-2024  uwe fts(3): Don't use top-level .Sh sections for functions

The list of possible .Sh sections in a man page is kinda limited
(think DTD, or schema). As a minimal fix use .Ss sub-sections for
now. It might be better to use tagged list with .Fn items that repeat
the arglist so that when you read the descriptions of the arguments
you actually see them, but that requires more intrusive editing.
 1.37 28-Oct-2024  uwe fts(3): don't use (incorrect) custom -width with .Bl -tag

Default widths are good enough.
 1.36 28-Oct-2024  uwe fts(3): indent and untabify FTSENT definition
 1.35 28-Oct-2024  uwe fts(3): use Pq for longer phrases

In PostScript output the extra breathing space that .Pq adds imrpoves
readability of parenthetical clauses.
 1.34 28-Oct-2024  uwe fts(3): NUL (character) is not a Dv
 1.33 28-Oct-2024  uwe fts(3): structures are Vt not Fa
 1.32 28-Oct-2024  jschauma Explicitly note that on error, fts_open() returns NULL and sets errno.

This uses the same language as used by OpenBSD's fts_open(3).
 1.31 30-Jun-2013  wiz branches: 1.31.40;
Strings are NUL-terminated, not NULL-terminated.
 1.30 30-Mar-2011  jruoho branches: 1.30.4; 1.30.10;
Improve -width.
 1.29 29-Apr-2010  jruoho It was nice to expect fts(3) to appear in the '88 revision. But perhaps
people had too high hopes.
 1.28 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.27 31-Mar-2004  snj Simplify a clunky multi-line Fn, correct Nm usage, use Dq for quotes, add
some commas.
 1.26 31-Mar-2004  snj Bump date for last.
 1.25 31-Mar-2004  heas Add bits about FTS_WHITEOUT & FTS_W.
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.22 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.21 07-Feb-2002  ross Generate <>& symbolically.
 1.20 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.19 16-Sep-2001  wiz Boring whitespace fixes.
 1.18 26-Sep-1999  jdolecek branches: 1.18.8;
xref symlink(7)
 1.17 28-Apr-1998  fair branches: 1.17.4;
Change occurrences of "UNIX" to .Ux or .At as appropriate.
 1.16 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.15 05-Feb-1998  perry add LIBRARY section to man page
 1.14 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.13 21-Mar-1997  mikel branches: 1.13.2;
fix type of fts_open() argument; from Enami Tsugutomo in PR lib/3368.
 1.12 20-Mar-1997  perry fix 3364 from enami tsugutomo -- FTS ftsp -> FTS *ftsp
 1.11 27-Feb-1995  cgd merge with Lite, keeping local changes. Also use new Id format.
 1.10 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.9 12-Apr-1994  cgd minor fixes
 1.8 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.7 09-Nov-1993  jtc I've been informed that the fts family of functions is being considered
for a _future_ edition of 1003.1.
I recovered the STANDARDS section, and reworded it slightly so it is
clear that we are talking about a future edition instead of 1003.1-88.
 1.6 06-Nov-1993  cgd nuke comments re: posix, per jtc. this isn't spec'd by posix.
 1.5 06-Nov-1993  cgd update to latest version; no *significant* changes.
 1.4 01-Oct-1993  jtc Fts may be great, by we can't claim it's a superset of POSIX.1 since
fts isn't part of POSIX.1 (or POSIX.2 either).
 1.3 30-Jul-1993  mycroft Add RCS identifiers.
 1.2 30-Jul-1993  mycroft Latest versions from uunet.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.2.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.17.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.18.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.18.8.3 22-Mar-2002  nathanw Catch up to -current.
 1.18.8.2 08-Mar-2002  nathanw Catch up to -current.
 1.18.8.1 08-Oct-2001  nathanw Catch up to -current.
 1.30.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.4.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.31.40.1 02-Aug-2025  perseant Sync with HEAD
 1.52 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.51 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.50 02-Nov-2021  nia fts(3): Use reallocarr instead of realloc(x * y), eliminate a temporary
variable.
 1.49 31-May-2016  pgoyette Use calloc(1, ...) instead of malloc(...) followed immediately by memset()

Addresses PR lib/46818
 1.48 29-Jan-2015  manu Fix double free in fts_read()/fts_close()

When fts_read() gets an error on fchdir(), it exited with sp->fts_cur
set to a freed structure. fts_close() would later attempt to free it
again, crashing the program.
 1.47 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.46 26-Sep-2012  msaitoh Fix in comment.
 1.45 15-Sep-2012  spz remove dubious cast
 1.44 14-Mar-2012  christos branches: 1.44.2;
rename the macros ftsent_ since they apply to the ftsent struct not the
fts one.
 1.43 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.42 16-Oct-2011  mrg branches: 1.42.2;
default O_CLOEXEC to 0 for systems that don't define it, like, say, netbsd-5.
 1.41 15-Oct-2011  christos close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.40 02-Nov-2009  stacktic Make sure fts_statp is NULL when FTS_NOSTAT is set
 1.39 16-Aug-2009  christos Version fts one more time! This is the most versioned API ever... Bump
fts_level from short to int to avoid a potential DoS.
From Maksymilian Arciemowicz
 1.38 28-Feb-2009  pgoyette Avoid possible integer overflow and subsequent collateral damage.
Received from OpenBSD via US-CERT as VU #590371.

Original OpenBSD commit log:

> revision 1.42
> date: 2009/02/11 13:24:05; author: otto; state: Exp; lines: +9 -1
> Avoid level going negative on deep (i mean really deep) dirs. Reported
> by Maksymilian Arciemowicz. ok kettenis@ millert@
 1.37 03-Feb-2009  lukem branches: 1.37.2;
fix sign-compare issue
 1.36 11-Jan-2009  christos merge christos-time_t
 1.35 03-Jan-2009  lukem Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319
 1.34 27-Sep-2008  lukem branches: 1.34.4; 1.34.6;
fix unused variable if !defined(FTS_ALLOC_ALIGNED)
 1.33 20-Sep-2008  lukem Add fts_free() to complement fts_alloc(), and use instead of free().
Should avoid a memory leak on systems without ALIGNBYTES.
 1.32 10-Mar-2008  lukem Style tweaks:
* test defined(HAVE_foo) not just HAVE_foo
* replace u_foo with unsigned foo
* the whitespace change whose name we dare not mention
 1.31 30-Mar-2006  christos branches: 1.31.4; 1.31.10; 1.31.14; 1.31.16;
PR/33163: Auster Vl.: fts: cant allocate memory | filename too long
Change the ftp_pathlen and fts_namelen to u_int from u_short so that
pathnames > 32K work.
 1.30 19-Mar-2006  christos Coverity CID 17: Free parent if it was not used.
 1.29 11-Dec-2005  christos Restore the compatibility versions of fts not to do path mangling (i.e.
remove double slashes). Also make sure we free sp in all cases. From yamt,
many thanks!
 1.28 18-Nov-2005  christos ANSI prototypes and function declarations. No functional change.
 1.27 17-Nov-2005  christos 1. minimize code diffs with FreeBSD
2. return ENAMETOOLONG instead of ENOMEM if name is too long to fit.
3. only decrement cp if we are pointing to the end of the string.
[this fixes the cp truncation of the last char problem reported]
 1.26 22-Oct-2005  christos Instead of special-casing root, special case paths that end with a /, so
that find foo/ does not print foo//bar. From FreeBSD.
 1.25 13-Sep-2005  christos compat core reorg.
 1.24 19-Aug-2005  christos 64 bit inode changes
 1.23 04-Dec-2003  keihan netbsd.org -> NetBSD.org
NetBSD.ORG -> NetBSD.org

Now src/lib is done.
 1.22 22-Oct-1997  thorpej Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.21 22-Oct-1997  fvdl New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.
 1.20 21-Oct-1997  fvdl branches: 1.20.2;
Hacks to enable libc to work without bumping the major.
 1.19 09-Oct-1997  christos Revert all slash removing changes; it is not worth it...
The latest one broke "ls foo.c/". Sync with Lite-2.
 1.18 08-Oct-1997  pk Restore the NAPPEND macro, as it existed until revision 1.13, that deals
with roots consisting of a single slash. This special case of special
cases cannot be dealt with in fts_open() by simply chopping of a
trailing slash.

All this to avoid the occasional doubling of slashes. Oh well..
 1.17 07-Oct-1997  pk In fts_alloc() copy the trailing 0 character explicitly, instead of
relying on the passed input string having a 0 character at the right spot.
Takes care of PR#4234.
 1.16 27-Sep-1997  pk The change in revision 1.13 to avoid doubling slashes in path names
messes up the internal administrations of the fts engine.

Do this differently by simply stripping one trailing slash (if any)
from root paths passed to fts_open().
 1.15 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.14 13-Jul-1997  christos Fix RCSID's
Add missing prototypes.
Fix rest of gcc warnings.
 1.13 10-Jul-1997  phil Fix it so fts_* never adds a / to a path name when there is
already a trailing /. Fixes PR 1495.
 1.12 27-Feb-1995  cgd branches: 1.12.4;
merge with Lite, keeping local changes. Also use new Id format.
 1.11 28-Dec-1994  mycroft branches: 1.11.2;
Mostly sync with CSRG.
 1.10 26-Oct-1994  mycroft Avoid extra stat()s if a link count of 1 is returned for directories but the
d_type field is filled in.
 1.9 17-Apr-1994  cgd POSIXification and bostic's official fix for the missing relative path problem
 1.8 12-Apr-1994  cgd re-POSIXIFICATION. should have been punted back to bostic...
 1.7 12-Apr-1994  cgd oops, restore bug fix that wasn't fed back to bostic...
 1.6 12-Apr-1994  cgd minor fixes
 1.5 14-Jan-1994  jtc Fix obscure bug where the working directory would not be restored to its
proper place (occurs if one of fts_open()'s arguments is a relative path
to a empty directory).
 1.4 24-Nov-1993  jtc Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Latest versions from uunet.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.2.1 02-May-1995  jtc #include "namespace.h"
 1.12.4.2 16-Sep-1996  jtc snapshot namespace cleanup: rpc & xdr
 1.12.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.20.2.2 22-Oct-1997  thorpej Pull up from trunk:

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.20.2.1 21-Oct-1997  thorpej file fts.c was added on branch netbsd-1-3 on 1997-10-22 06:41:30 +0000
 1.31.16.1 24-Mar-2008  keiichi sync with head.
 1.31.14.1 15-Jan-2009  bouyer Pull up following revision(s) (requested by lukem in ticket #1256):
lib/libc/gen/fts.c: revision 1.35
Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319
 1.31.10.1 23-Mar-2008  matt sync with HEAD
 1.31.4.1 15-Jan-2009  bouyer Pull up following revision(s) (requested by lukem in ticket #1256):
lib/libc/gen/fts.c: revision 1.35
Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319
 1.34.6.2 04-Jan-2009  christos merge with head.
 1.34.6.1 27-Sep-2008  christos file fts.c was added on branch christos-time_t on 2009-01-04 17:02:19 +0000
 1.34.4.2 16-Aug-2009  bouyer Pull up following revision(s) (requested by christos in ticket #915):
lib/libc/gen/fts.c: revision 1.38
Avoid possible integer overflow and subsequent collateral damage.
Received from OpenBSD via US-CERT as VU #590371.
Original OpenBSD commit log:
revision 1.42
date: 2009/02/11 13:24:05; author: otto; state: Exp; lines: +9 -1
Avoid level going negative on deep (i mean really deep) dirs. Reported
by Maksymilian Arciemowicz. ok kettenis@ millert@
 1.34.4.1 08-Jan-2009  snj branches: 1.34.4.1.2; 1.34.4.1.4;
Pull up following revision(s) (requested by lukem in ticket #226):
lib/libc/gen/fts.c: revision 1.35
Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319
 1.34.4.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.34.4.1.2.1 16-Aug-2009  bouyer Pull up following revision(s) (requested by christos in ticket #915):
lib/libc/gen/fts.c: revision 1.38
Avoid possible integer overflow and subsequent collateral damage.
Received from OpenBSD via US-CERT as VU #590371.
Original OpenBSD commit log:
revision 1.42
date: 2009/02/11 13:24:05; author: otto; state: Exp; lines: +9 -1
Avoid level going negative on deep (i mean really deep) dirs. Reported
by Maksymilian Arciemowicz. ok kettenis@ millert@
 1.37.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.42.2.2 30-Oct-2012  yamt sync with head
 1.42.2.1 17-Apr-2012  yamt sync with head
 1.44.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5 30-Apr-2010  jruoho More obsolete things. These are all already deprecated in NetBSD, but it is
worth noting that also the standard has marked these as legacy.
 1.4 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.3 07-Feb-2006  wiz Fix .St argument.
 1.2 12-Jan-2006  wiz Use In, improve macro usage, serial comma.
 1.1 30-Dec-2005  agc Add Todd Miller's ftw(3) and nftw(3) file-tree walking functionality,
from OpenBSD.

Bump libc minor to 136.
 1.1 30-Dec-2005  agc Add Todd Miller's ftw(3) and nftw(3) file-tree walking functionality,
from OpenBSD.

Bump libc minor to 136.
 1.10 06-Dec-2022  uwe getbsize(3): Use .Ev for BLOCKSIZE
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 30-May-2003  simonb Use the date I committed this, not the date I originally came up with
the changes.
 1.7 30-May-2003  simonb Allow either parameter to the getbsize(3) function to be a NULL, in
which case it is ignored.
 1.6 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.5 07-Feb-2002  ross Generate <>& symbolically.
 1.4 22-Mar-1999  garbled branches: 1.4.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.1 27-Jan-1994  cgd branches: 1.1.1;
add two man pages
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.4.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.17 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.16 29-Nov-2005  christos branches: 1.16.44;
WARNS=4
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 30-May-2003  simonb Allow either parameter to the getbsize(3) function to be a NULL, in
which case it is ignored.
 1.13 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.12 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.11 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.10 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.9 13-Jul-1997  christos Fix namespace problems
Fix RCSID's
Fix gcc warnings.
 1.8 22-Jan-1996  mycroft branches: 1.8.2;
Add missing argument to warnx().
 1.7 16-Jun-1995  jtc Use standard conditional for rcsid definition.
 1.6 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.5 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.4 11-Dec-1994  christos - Changed all internal libc references of {v,}err{x,} and {v,}warn{x,} to
__{v,}err{x,} and __{v,}warn{x,}
- moved err.c to __err.c and added err.c which contains weak references for
the above functions.
- Reordered the functions in __err.c to avoid redeclarations and changed
the varargs declarations to conform with the K&R style.
 1.3 25-Jan-1994  cgd kill force.
 1.2 25-Jan-1994  cgd kill the 'prog' arg to getbsize(); it's unneeded. minor rev bump.
 1.1 06-Aug-1993  mycroft branches: 1.1.1;
Add getbsize() from Berkeley, somewhat modified.
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.8.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.16.44.1 30-Oct-2012  yamt sync with head
 1.22 12-Apr-2005  drochner Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.21 12-Apr-2005  drochner this should refer to "cgetset", not "cgetseq"
 1.20 23-Apr-2004  wiz branches: 1.20.2; 1.20.4; 1.20.6;
Bump date for previous.
 1.19 23-Apr-2004  christos Adjust to constification of db_name vector.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 30-Jun-2003  wiz Fixes to make these man page look nice with groff-1.19.
 1.16 03-May-2003  wiz Misc. fixes from jmc@openbsd.
 1.15 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.14 07-Feb-2002  ross generate & symbolically
 1.13 07-Feb-2002  ross Generate <>& symbolically.
 1.12 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.11 08-Mar-1999  kleink branches: 1.11.12;
Const poisoning, integer argument promotion.
 1.10 29-Apr-1998  fair Fix a few bad .Xr's. Nuke rampant abuse of .Nm.
Clarify examples through the judicious use of .Qq and .Em.
 1.9 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 05-Feb-1998  perry remove illegal quotes from .Dd directives
 1.6 02-Feb-1998  perry merge/update to lite-2
 1.5 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.4 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.3 10-Jan-1994  jtc Fix spelling errors.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 18-May-1993  cgd branches: 1.1.1;
bring in getcap routines, supplied by CSRG, from 4.4...
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.11.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.20.6.1 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.20.4.1 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.20.2.1 26-Aug-2007  bouyer Pull up following revision(s) (requested by bad in ticket #1821):
lib/libc/gen/cgetcap.3: revisions 1.1 - 1.3
lib/libc/gen/Makefile.inc: revision 1.143
lib/libc/gen/getcap.3: file removal
Both libcurses and libc installed a getcap(3) manpage, and both used it
as target for a bunch of MLINKS. This had the effect that whatever came
last in install overwrote everything from the other camp.
Solve this by renaming the libc page -- this makes sense because no
function is really named "getcap" here.
 1.58 21-Sep-2023  shm Fix memory leak in getent()

Memory was not freed if record was not found
 1.57 18-Jun-2017  manu branches: 1.57.8; 1.57.16;
Make shared -DSMALL libc buildable without breaking libhack

We used -DSMALL to exclude code from libc in order to build
libhack. Introduce -DLIBHACK to do this without so that
-DSMALL does not remove code necessary for building a shared libc
 1.56 24-Sep-2014  christos branches: 1.56.8;
undo, the right place for this is compat_defs.h
 1.55 24-Sep-2014  he Provide a backward-compatible conditional define of O_CLOEXEC
for those systems which lack it, since these files are used in
tools builds.
 1.54 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.53 26-Jun-2014  christos branches: 1.53.2;
don't depend on expandtc to open the database or not.
 1.52 04-Jun-2012  joerg branches: 1.52.2; 1.52.8;
ANSIfy
 1.51 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.50 15-Oct-2011  christos branches: 1.50.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.49 07-Feb-2011  joerg Don't define weak aliases in the SMALL case. They conflict with the real
function name since SMALL doesn't use the normal rename logic.
 1.48 02-Feb-2008  christos branches: 1.48.24;
Add csetexpandtc()
 1.47 04-Jul-2006  jnemeth branches: 1.47.10;
KNF
 1.46 29-May-2006  jnemeth missed check for malloc() returning NULL
 1.45 02-Apr-2006  christos Add coverity annotations.
 1.44 19-Mar-2006  christos Coveriry CID 509: Avoid NULL pointer deref.
 1.43 19-Mar-2006  christos Coverity CID 510: Avoid uninitialized variable.
 1.42 29-Nov-2005  christos WARNS=4
 1.41 25-Apr-2004  christos Add -DSMALL so that this can be used in libhack.
 1.40 23-Apr-2004  christos Ansify and add change db_name vector from char ** to const char * const *
 1.39 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.38 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.37 31-Jan-2003  uwe Avoid cgetcap &co prototypes conflicting with those provided by the host.
With this change we can cross-compile on FreeBSD 4.x.
 1.36 04-Aug-2002  tron Include "sys/param.h" and use "MATHPATHLEN" instead of "_POSIX_PATH_MAX"
to fix build problem.
 1.35 16-Apr-2002  groo branches: 1.35.2;
Detect if line length exceeds buffer capacities.
from xs@kittenz.org
 1.34 25-Jun-2001  mrg avoid an underrun in "buf". noted by dean@huxley.org in PR#13292
 1.33 02-Jun-2000  itojun branches: 1.33.2; 1.33.4;
correct memory leak due to t_getstr() and realloc(). the commit will
prevent "top -s 0" from chewing up memory.

TODO: realloc() audit, revisit recent termcap/curses changes
 1.32 22-Jan-2000  mycroft branches: 1.32.2;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.31 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.30 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.29 29-Mar-1999  abs Cast argument to isspace to (unsigned char) to pass zoularis.
 1.28 23-Mar-1999  abs Fix 'suggest parentheses' warning noted by Erik E. Fair <fair@clock.org>
 1.27 22-Mar-1999  abs If we push a cap entry (usually from the environment), strip : deliminated
entries that only contain whitespace, in a similar fashion to reading from
a file.
 1.26 16-Mar-1999  christos Fix gcc-2.8.1 warnings.
 1.25 13-Nov-1998  christos avoid assignment of a read only location that lint does not pick, but gcc does.
 1.24 12-Nov-1998  christos delint
 1.23 26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.22 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.21 27-Jul-1998  mycroft const poisoning.
 1.20 21-Jul-1998  mycroft Suppress blank fields due to continuation lines.
 1.19 18-Mar-1998  tv PR 5170: don't fclose twice, or call ferror after fclose.
required removing fcloses and/or moving them, nulling the pointers
like they should have been, and adding a terminating null byte and break
in one case (perhaps we never ran into those problems before).
cgetclose() already does a fclose and null of the pointer, so don't
duplicate it when we don't need to.
 1.18 02-Mar-1998  thorpej Fix type size lossage on the Alpha.
 1.17 26-Feb-1998  perry trivial changes to reduce lint complaints
 1.16 03-Feb-1998  perry remove obsolete register declarations
 1.15 25-Aug-1997  kleink Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.
 1.14 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.13 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.12 17-May-1997  pk NULL => 0 (Arne Juul; PR#3629)
 1.11 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.10 24-Aug-1995  mycroft branches: 1.10.4;
Do not terminate the search on errors other than ENOENT.
 1.9 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.8 26-Mar-1994  cgd slight mod
 1.7 06-Mar-1994  cgd fix for lib/156: cgetent does access free'd memory,
from Thomas Eberhardt
 1.6 04-Jan-1994  cgd rename fgetline()
 1.5 22-Dec-1993  cgd don't squish newline at end of fgetline()... from bostic
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 30-Jul-1993  mycroft Add even more RCS frobs.
 1.2 08-Jun-1993  mycroft fgetline() does not return the newline.
 1.1 18-May-1993  cgd branches: 1.1.1;
bring in getcap routines, supplied by CSRG, from 4.4...
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.10.4.2 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.32.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.33.4.3 13-Aug-2002  nathanw Catch up to -current.
 1.33.4.2 25-Apr-2002  nathanw Catch up to -current.
 1.33.4.1 08-Oct-2001  nathanw Catch up to -current.
 1.33.2.2 17-Apr-2002  he Pull up revision 1.35 (requested by groo):
Detect if line length exceeds buffer size.
 1.33.2.1 26-Oct-2001  jhawk Pull up revision 1.34 (requested by mrg):
Avoid an underrun in "buf". Fixes PR#13292.
 1.35.2.1 18-Jun-2004  jmc forgot one fix for PR#24481
 1.47.10.1 23-Mar-2008  matt sync with HEAD
 1.48.24.1 08-Feb-2011  bouyer Sync with HEAD
 1.50.2.2 30-Oct-2012  yamt sync with head
 1.50.2.1 17-Apr-2012  yamt sync with head
 1.52.8.1 10-Aug-2014  tls Rebase.
 1.52.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.53.2.1 23-Jul-2017  snj Pull up following revision(s) (requested by manu in ticket #1440):
distrib/utils/libhack/Makefile: revision 1.25
distrib/utils/libhack/Makefile.inc: revision 1.27
lib/libc/gen/getcap.c: revision 1.57
Make shared -DSMALL libc buildable without breaking libhack
We used -DSMALL to exclude code from libc in order to build
libhack. Introduce -DLIBHACK to do this without so that
-DSMALL does not remove code necessary for building a shared libc
 1.56.8.2 11-Mar-2024  martin Pull up following revision(s) (requested by ozaki-r in ticket #1947):

lib/libc/gen/getcap.c: revision 1.58

Fix memory leak in getent()

Memory was not freed if record was not found
 1.56.8.1 04-Jul-2017  martin Pull up following revision(s) (requested by manu in ticket #79):
distrib/utils/libhack/Makefile.inc: revision 1.27
lib/libc/gen/getcap.c: revision 1.57
distrib/utils/libhack/Makefile: revision 1.25
Make shared -DSMALL libc buildable without breaking libhack
We used -DSMALL to exclude code from libc in order to build
libhack. Introduce -DLIBHACK to do this without so that
-DSMALL does not remove code necessary for building a shared libc
 1.57.16.1 11-Mar-2024  martin Pull up following revision(s) (requested by ozaki-r in ticket #630):

lib/libc/gen/getcap.c: revision 1.58

Fix memory leak in getent()

Memory was not freed if record was not found
 1.57.8.1 11-Mar-2024  martin Pull up following revision(s) (requested by ozaki-r in ticket #1816):

lib/libc/gen/getcap.c: revision 1.58

Fix memory leak in getent()

Memory was not freed if record was not found
 1.18 29-Apr-2010  jruoho Add some STANDARDS lingo, mainly to note the functions that have been
removed from POSIX (2008).
 1.17 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.14 07-Feb-2002  ross Generate <>& symbolically.
 1.13 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.12 16-Sep-2001  wiz Boring whitespace fixes.
 1.11 22-Mar-1999  garbled branches: 1.11.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.10 08-Jun-1998  lukem Implement a new manual page category ``SECURITY CONSIDERATIONS''
(suggested by mycroft)
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 27-Nov-1997  mikel s/EACCESS/EACCES/, from Brian Evans via OpenBSD
 1.7 08-Oct-1997  kleink branches: 1.7.2;
getcwd(3) is not defined by ANSI C but by 1003.1; pointed out by Alan Curry
in PR lib/4238.
 1.6 30-Jul-1995  jtc stdio.h -> unistd.h
 1.5 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.4 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.3 04-Oct-1993  jtc Update to reflect the fact that this manpage is used for both getcwd & getwd:
Change main title from GETWD to GETCWD as getcwd is the prefered interface.
Add getwd to NAME section so it shows up in whatis database.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 28-Nov-1997  mellon Pull rev 1.8 up from trunk (mikel)
 1.11.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.53 21-Jun-2012  enami All error path must go through the free function call after an
allocation of resolved path might succeeded.
 1.52 21-Jun-2012  christos PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.51 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.50 21-Feb-2011  joerg branches: 1.50.4; 1.50.6; 1.50.10;
Redo the SSP wrappers to be transparent on the resulting object files.
This works by having the inline wrapper calling a second function which
uses renaming to output the correct function name.
 1.49 16-Feb-2011  tron Fix build with SSP enabled.
 1.48 15-Feb-2011  christos Fix non-fortify build.
 1.47 20-Jan-2011  christos provide a _sys_getcwd() entry like all the rest of the system calls to be
used by SSP.
 1.46 01-Jan-2010  dholland branches: 1.46.2;
POSIX says realpath(NULL, foo) is supposed to yield EINVAL rather than
being allowed to crash. Go figure. Closes PR lib/42559 from Stathis Kamperis.
 1.45 26-Oct-2007  christos make _FORTIFY_SOURCE play nicely with lint
 1.44 03-Jun-2007  christos branches: 1.44.4;
Make these work with _FORTIFY_SOURCE, by overriding the fortified definitions
 1.43 17-Mar-2006  christos Appease Coverity CID 2527; not a bug.
 1.42 31-Dec-2005  elad Revert back to revision 1.40, as requested by cube@.
Unbreaks KDE.
 1.41 22-Dec-2005  elad Allow last component to be non-existing again. I broke this behavior for
no apparent good reason in revision 1.39.

This is what broke systrace's filename normalization.

Go back to original behavior as in revision 1.35: return resolved name,
but also set errno to ENOENT.
 1.40 13-Aug-2005  elad Make this compile again (remove unused serrno).
Noted by uwe@.
 1.39 13-Aug-2005  elad Don't allow last path element to be nonexistant.
 1.38 05-Jul-2005  enami Fixes to previous:
- Don't handle single and multiple slashes differently.
- A symlink to a directory can be appear in the middle of path. Don't
reject it.
 1.37 04-Jul-2005  elad Make realpath(3) work correctly.

The current code resolves paths like `/foo/bar/', `/foo/bar/./', and
`/foo/bar/../', even if `bar' is a regular file and not a directory.

Reviewed by cube@.
 1.36 30-Jan-2005  enami branches: 1.36.2;
- Modify realpath() not to alter process wide state current working
directory. Strategy from FreeBSD. Addess PR#28986.
- Make realpath() to return an error when null string is passed or
the last component is symlink to null string. The kernel lookup
routine returns an error if such path are passed.
 1.35 23-Jan-2005  enami - Remove macros used only by old getcwd() implementation.
- Fix memory leak on error. (I guess the loop isn't necessary but
it is different matter).
- Remove knowledge about old malloc implementation.
 1.34 06-Jan-2005  simonb Remove the old userland version of getcwd(): it's been #ifdef'd out
since 1999 when we switched to a (faster) system call based getcwd(),
and as shown recently has had some buffer size problems anyway (although
they have since been fixed).
 1.33 06-Jan-2005  christos Fix handling of memory allocation. From OpenBSD.
 1.32 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.31 03-Aug-2003  itojun be more pedantic to strlcpy/strcat errors
 1.30 03-Aug-2003  itojun use strlcat for safety
 1.29 03-Aug-2003  itojun fix off-by-one error in realpath()
 1.28 17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.27 17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.26 19-Oct-2002  provos readlink(2) does not NUL-terminate, use with sizeof (buf-1).
from deraadt@openbsd.org; approved thorpej.
 1.25 16-Apr-2002  groo branches: 1.25.2;
botched strncpy -> strlcpy
from xs@kittenz.org
 1.24 22-Jan-2000  mycroft branches: 1.24.4; 1.24.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.23 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.22 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.21 10-Aug-1999  fvdl Keep track of the number of encountered symlinks and fail with ELOOP
if they exceed MAXSYMLINKS.
 1.20 11-Jul-1999  sommerfeld Avoid infinite loop if pathname is longer than the maximum the kernel
is willing to return from getcwd().
(this can only happen in -current).
 1.19 11-Jun-1999  christos make this compile under linux
 1.18 03-May-1999  christos int -> size_t problems, change do { } while (0) to for (;;)
 1.17 26-Mar-1999  sommerfe move __getcwd prototypes to libc-private header file.

XXX duplicate the prototype in getcwd regression test (which needs to
call the syscall directly for reasonably complete testing).
 1.16 26-Mar-1999  sommerfe Use __getcwd() system call in getcwd() unless OLD_GETCWD is defined
 1.15 06-Nov-1998  christos port to svr4.
 1.14 26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.13 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.12 14-Mar-1998  lukem backout parts of the lite2 merge; it causes undesirable lossage:
* $PWD was used if it appeared ``correct''. this `enhancment' was
not documented in getcwd(3), and caused problems for pwd(1) (which
uses getcwd(3)), and in turn <bsd.obj.mk> (which uses pwd) when $PWD
is set to the logical path instead of the real path (e.g, symlink
/usr/src -> /z/NetBSD-current/src).
[$PWD is set to the logical path by tcsh(1) with set symlinks=expand]
* as getcwd() without the $PWD code is just a wrapper to getcwd_physical(),
rename the latter to the latter. hack realpath() to use the getcwd().

yet another case of `it was a good idea, but...'
 1.11 26-Feb-1998  perry trivial changes to reduce lint complaints
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 02-Feb-1998  perry add some fixes to realpath() that were in the old realpath.c
 1.8 02-Feb-1998  perry merge/update to lite-2
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.5 16-Jun-1995  jtc branches: 1.5.4;
Don't cast void functions to void.
 1.4 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.5.4.2 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.5.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.24.6.3 10-Dec-2002  thorpej Sync with HEAD.
 1.24.6.2 11-Nov-2002  nathanw Catch up to -current
 1.24.6.1 25-Apr-2002  nathanw Catch up to -current.
 1.24.4.3 12-May-2004  jmc Pullup rev 1.26 (requested by kleink in ticket #146)

readlink(2) does not NUL-terminate, use with sizeof (buf-1).
 1.24.4.2 05-Aug-2003  msaitoh Pull up revision 1.29 (requested by itojun in ticket #61):
Fix NetBSD SA 2003-11.
Fix off-by-one error in realpath().
 1.24.4.1 17-Apr-2002  he Pull up revision 1.25 (requested by groo):
Replace an instance of erroneous usage of strncpy() with strlcpy().
 1.25.2.2 11-May-2004  tron Pull up revision 1.26 (requested by kleink in ticket #1687):
readlink(2) does not NUL-terminate, use with sizeof (buf-1).
from deraadt@openbsd.org; approved thorpej.
 1.25.2.1 04-Aug-2003  grant Pull up revision 1.29 (requested by itojun in ticket #1394):

fix off-by-one error in realpath()
 1.36.2.3 01-Jan-2006  riz Pull up following revision(s) (requested by elad in ticket #1077):
lib/libc/gen/getcwd.c: revision 1.42
Revert back to revision 1.40, as requested by cube@.
Unbreaks KDE.
 1.36.2.2 29-Dec-2005  riz Pull up following revision(s) (requested by elad in ticket #1068):
lib/libc/gen/getcwd.c: revision 1.41
Allow last component to be non-existing again. I broke this behavior for
no apparent good reason in revision 1.39.
This is what broke systrace's filename normalization.
Go back to original behavior as in revision 1.35: return resolved name,
but also set errno to ENOENT.
 1.36.2.1 14-Aug-2005  riz branches: 1.36.2.1.2;
Pull up revisions 1.37-1.40 (requested by elad in ticket #648):
1.37:
Make realpath(3) work correctly.
The current code resolves paths like `/foo/bar/', `/foo/bar/./', and
`/foo/bar/../', even if `bar' is a regular file and not a directory.
Reviewed by cube@.

1.38:
Fixes to previous:
- Don't handle single and multiple slashes differently.
- A symlink to a directory can be appear in the middle of path. Don't
reject it.

1.39:
Don't allow last path element to be nonexistant.

1.40:
Make this compile again (remove unused serrno).
Noted by uwe@.
 1.36.2.1.2.2 01-Jan-2006  riz Pull up following revision(s) (requested by elad in ticket #1077):
lib/libc/gen/getcwd.c: revision 1.42
Revert back to revision 1.40, as requested by cube@.
Unbreaks KDE.
 1.36.2.1.2.1 29-Dec-2005  riz Pull up following revision(s) (requested by elad in ticket #1068):
lib/libc/gen/getcwd.c: revision 1.41
Allow last component to be non-existing again. I broke this behavior for
no apparent good reason in revision 1.39.
This is what broke systrace's filename normalization.
Go back to original behavior as in revision 1.35: return resolved name,
but also set errno to ENOENT.
 1.44.4.1 06-Nov-2007  matt sync with HEAD
 1.46.2.3 05-Mar-2011  bouyer Sync with HEAD
 1.46.2.2 17-Feb-2011  bouyer Sync with HEAD
 1.46.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.50.10.1 20-Apr-2013  bouyer Pull up following revision(s) (requested by christos in ticket #874):
lib/libc/gen/realpath.3: revision 1.13
lib/libc/gen/getcwd.c: revision 1.52
PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.50.6.1 20-Apr-2013  bouyer Pull up following revision(s) (requested by christos in ticket #874):
lib/libc/gen/realpath.3: revision 1.13
lib/libc/gen/getcwd.c: revision 1.52
PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.50.4.2 30-Oct-2012  yamt sync with head
 1.50.4.1 17-Apr-2012  yamt sync with head
 1.6 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.5 24-Mar-2009  drochner minor fix in description of an error condition
 1.4 20-Jan-2009  drochner branches: 1.4.2;
cleanup after devmajor_t:
-since getdevmajor(3) is now binary compatible again with <=5.0
there is no need to rename, I've just left a __getdevmajor50 symbol
temporarily for those who track -current
-update manpage
 1.3 16-Dec-2004  wiz Use more markup. Sort sections.
 1.2 16-Dec-2004  christos document properly the return value and the errno settings.
 1.1 16-Dec-2004  atatat Add a function called getdevmajor().

It tells you the major device number for whatever character or block
device you ask it. This is sort of the inverse of devname(3) but not
quite, since it's backed by the kernel (sysctl's kern.drivers
information) and not a database cobbled together from the contents of
the filesystem.
 1.4.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.7 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.6 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.5 20-Jan-2009  drochner branches: 1.5.8;
cleanup after devmajor_t:
-since getdevmajor(3) is now binary compatible again with <=5.0
there is no need to rename, I've just left a __getdevmajor50 symbol
temporarily for those who track -current
-update manpage
 1.4 20-Jan-2009  drochner Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.
 1.3 16-Dec-2004  atatat Fix a whitespace nit and make this compile again. So there.
 1.2 16-Dec-2004  christos knf fixes.
 1.1 16-Dec-2004  atatat Add a function called getdevmajor().

It tells you the major device number for whatever character or block
device you ask it. This is sort of the inverse of devname(3) but not
quite, since it's backed by the kernel (sysctl's kern.drivers
information) and not a database cobbled together from the contents of
the filesystem.
 1.5.8.1 17-Apr-2012  yamt sync with head
 1.1 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.13 19-Aug-2009  joerg Fix markup.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.9 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 22-Mar-1999  garbled branches: 1.6.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 19-Jan-1999  abs Add '-f disktab' option to disklabel, via lib/6623 from
Greg A. Woods <woods@most.weird.com>. (Very) slightly tweaked disklabel.8
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.6.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.16 06-Feb-2015  ginsbach PR/49642: change processor to host

Use the wording used by FreeBSD, IRIX, and MacOSX (as a sample) rather
suggested wording in PR from Henning Petersen.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.12 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.6 08-May-1998  kleink Substitute `domain name' for `host name' at a couple of places; this was
obviously copied from gethostname.3.
 1.5 06-May-1998  kleink For consistency with the {get,set}hostname() change, change the type of
the `namelen' argument to {get,set}domainname() from int to size_t.
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 03-Jan-1997  mikel there is no sysctl(2); reference sysctl(3) instead.
 1.2 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.1 07-May-1994  cgd domainname stuff
 1.8.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 07-Aug-2003  agc branches: 1.12.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 18-Nov-1999  is In case of an error returned by sysctl, and errno=ENOMEM, restore the
old errno and return 0. This makes us complant with SUSV2 and our own
manual page. See PR pr7836 by Simon Burge.
 1.9 20-Sep-1999  lukem branches: 1.9.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 13-Oct-1998  kleink Need an internal name for getdomainname().
 1.6 06-May-1998  kleink For consistency with the {get,set}hostname() change, change the type of
the `namelen' argument to {get,set}domainname() from int to size_t.
 1.5 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.4 13-Jul-1997  christos Fix RCSID's
 1.3 16-Jun-1995  jtc branches: 1.3.4;
Change return type of {get,set}{domain,host}name() from long to int.
 1.2 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.1 07-May-1994  cgd domainname stuff
 1.3.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.56.1 30-Oct-2012  yamt sync with head
 1.8 28-Aug-2024  riastradh getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
 1.7 15-Aug-2024  riastradh getentropy(3): Make this visible to POSIX.1-2024 applications.

Likewise GETENTROPY_MAX.

It is now part of POSIX:

https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/getentropy.html

Cite standard in man page too. While here, use `.Nm' rather than
`.Fn getentropy' for self-reference in the man page, for consistency
with other usage.

PR standards/58603: getentropy(3): update visibility and documentation
for POSIX.1-2024
 1.6 30-Jun-2023  uwe branches: 1.6.2;
getentropy(3): use .Sx to xref CAVEATS
 1.5 30-Jun-2023  riastradh getrandom(2), getentropy(3): Rework man pages.

Make supportable promises. Omit needless verbiage. Give caveats
with cross-references to entropy(7). Emphasize that security is
necessarily relative to system configuration.

XXX pullup-10
 1.4 31-May-2022  riastradh branches: 1.4.2;
libc: Reintroduce getentropy.

This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing. Now getentropy is more widely adopted and soon to be in
POSIX. So reintroduce the symbol into libc since we'll be keeping it
anyway. Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch. The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

SYNOPSIS
#include <unistd.h>

int getentropy(void *buffer, size_t length);

DESCRIPTION
The getentropy() function shall write length bytes of data
starting at the location pointed to by buffer. The output
shall be unpredictable high quality random data, generated by
a cryptographically secure pseudo-random number
generator. The maximum permitted value for the length
argument is given by the {GETENTROPY_MAX} symbolic constant
defined in <limits.h>.

RETURN VALUES
Upon successful completion, getentropy() shall return 0;
otherwise, -1 shall be retunred and errno set to indicate the
error.

ERRORS
The getentropy() function shall fail if:

[EINVAL] The value of length is greater than
{GETENTROPY_MAX}.

The getentropy() function may fail if:

[ENOSYS] The system does not provide the necessary
source of entropy.

RATIONALE
The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE. When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.
 1.3 22-Sep-2020  nia remove getentropy bits
 1.2 07-May-2020  wiz Fix macro usage. Fix typo. New sentence, new line.
 1.1 06-May-2020  nia Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.

Posted to tech-userlevel@ a week ago and reviewed by riastradh@.

GETENTROPY(3) Library Functions Manual GETENTROPY(3)

NAME
getentropy - fill a buffer with high quality random data

LIBRARY
Standard C Library (libc, -lc)

SYNOPSIS
#include <unistd.h>

int
getentropy(void *buf, size_t buflen);

DESCRIPTION
The getentropy() function fills a buffer with high quality random data,
suitable for seeding cryptographically secure psuedorandom number
generators.

getentropy() is only intended for seeding random number generators and is
not intended for use by regular code which simply needs secure random
data. For this purpose, please use arc4random(3).

The maximum value for buflen is 256 bytes.

IMPLEMENTATION NOTES
getentropy() reads from the sysctl(7) variable kern.arandom.

RETURN VALUES
The getentropy() function returns 0 on success, and -1 if an error
occurred.

ERRORS
getentropy() will succeed unless:

[EFAULT] The buf argument points to an invalid memory address.

[EIO] Too many bytes were requested.

SEE ALSO
arc4random(3), rnd(4)

STANDARDS
The getentropy() function is non-standard.

HISTORY
The getentropy() function first appeared in OpenBSD 5.6, then in
FreeBSD 12.0, and NetBSD 10.
 1.4.2.3 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #939):

distrib/sets/lists/debug/module.md.amd64: revision 1.18
sys/modules/Makefile: revision 1.292
lib/libc/gen/arc4random.c: revision 1.34
lib/libc/gen/arc4random.c: revision 1.35
lib/libc/gen/arc4random.c: revision 1.36
lib/libc/gen/arc4random.c: revision 1.37
sys/kern/kern_entropy.c: revision 1.70
lib/libc/gen/arc4random.c: revision 1.38
sys/kern/kern_entropy.c: revision 1.71
lib/libc/gen/getentropy.3: revision 1.8
distrib/sets/lists/modules/md.amd64: revision 1.103
share/man/man4/rnd.4: revision 1.42
share/man/man4/rnd.4: revision 1.44
lib/libc/include/arc4random.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1786
sys/arch/i386/conf/GENERIC: revision 1.1258
sys/modules/acpivmgenid/acpivmgenid.ioconf: revision 1.1
sys/arch/amd64/conf/ALL: revision 1.190
distrib/sets/lists/debug/mi: revision 1.446
sys/arch/i386/conf/ALL: revision 1.521
lib/libc/gen/Makefile.inc: revision 1.219
distrib/sets/lists/debug/module.md.i386: revision 1.12
sys/dev/acpi/acpi_vmgenid.c: revision 1.1
sys/dev/acpi/acpi_vmgenid.c: revision 1.2
lib/libc/include/reentrant.h: revision 1.22
sys/arch/evbarm/conf/GENERIC64: revision 1.219
share/man/man4/Makefile: revision 1.735
distrib/sets/lists/modules/md.i386: revision 1.100
distrib/sets/lists/tests/mi: revision 1.1334
lib/libc/gen/arc4random.3: revision 1.22
sys/dev/acpi/files.acpi: revision 1.133
lib/libc/gen/arc4random.3: revision 1.23
tests/lib/libc/gen/t_arc4random.c: revision 1.1
sys/sys/entropy.h: revision 1.6
sys/arch/amd64/conf/GENERIC: revision 1.614
sys/modules/acpivmgenid/Makefile: revision 1.1
share/man/man4/acpivmgenid.4: revision 1.1
lib/libc/gen/Makefile.inc: revision 1.220
tests/lib/libc/gen/Makefile: revision 1.56
share/man/man4/acpivmgenid.4: revision 1.2
share/man/man4/acpivmgenid.4: revision 1.3

(all via patch)

Catch up with all the lint warnings since exit on warning was disabled.

Disable 'missing header declaration' and 'nested extern' warnings for now.
acpivmgenid(4): New driver for virtual machine generation ID.

Added to amd64/ALL and i386/ALL kernel configurations, and made
available as a loadable module acpivmgenid.kmod on x86, for now.
TBD: Add to all ACPI-supporting GENERIC kernels.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Factor out subroutines to reset and gather entropy.
`Reset' means we keep the data in the pool, but assume it had zero
entropy. `Gather' means we request samples from all on-demand
sources and wait for the synchronous ones to complete.

No functional change intended, other than to expose new symbols --
just preparation to expose these to acpivmgenid(4), so it can use
these when the VM host notifies us that we, the guest, have been
cloned.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Reset and gather entropy on VM clone notification.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Reseed if system entropy epoch changes.
This can happen, for example, if the system is a VM instance, and the
VM is cloned.

This incurs the cost of a system call on every arc4random call, which
is unfortunate, but
1. we don't currently have a (machine-independent) mechanism for
exposing a read-only page to userland shared by the kernel to
enable a cheaper access path to the entropy epoch; and
2. the algorithm here -- a simple application of ChaCha -- is likely
also a bottleneck and could be much cheaper by
(a) using sys/crypto/chacha for machine-dependent vectorized
ChaCha code, and
(b) filling a buffer (somewhere between a cipher block and a page)
in a batch at a time, instead of running ChaCha to generate
only 32 bytes at a time.
So although this might be a performance hit, the security benefit is
worthwhile and we have a clear path to do better than reversing the
performance hit later.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

acpivmgenid(4): Nix BUGS that have been squashed.
Reference kern.entropy.epoch for the remaining bug (which is a
performance issue, not a security issue).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed. (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random.c: Fix test program.

This isn't wired up anywhere, but let's reduce the bitrot. It was
helpful in reminding me that kern.entropy.epoch was, for reasons I
can't remember, restricted to privileged access.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

amd64, evbarm, i386: Add acpivmgenid(4) to GENERIC.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

rnd(4): Document kern.entropy.epoch is unprivileged and elaborate.
Cross-reference acpivmgenid(4).
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Note that arc4random respects kern.entropy.epoch.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork
Add debug info for new acpivmgenid module

arc4random(3): Add automatic tests.

This verifies that:
- arc4random zeroes its state and reseeds itself on fork
- arc4random reseeds itself on entropy consolidation (e.g., VM clone)
- arc4random falls back to global state if it can't allocate local
state because address space limits cause mmap to fail

NOTE: This adds a new libc symbol __arc4random_global, but it's in
the reserved namespace and only used by t_arc4random, so no libc
minor bump.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

getentropy(3): Note intent to reseed on VM clone, and caveats.

Tidy markup and pacify some mandoc -Tlint complaints while here.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

Bump dates on man pages recently updated to mention VM clones.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random(3): Pacify some of lint's complaints.
PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork

arc4random: suppress another lint warning
 1.4.2.2 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #938):

lib/libc/gen/getentropy.3: revision 1.7
include/limits.h: revision 1.44
include/unistd.h: revision 1.167

getentropy(3): Make this visible to POSIX.1-2024 applications.

Likewise GETENTROPY_MAX.

It is now part of POSIX:
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/getentropy.html

Cite standard in man page too. While here, use `.Nm' rather than
`.Fn getentropy' for self-reference in the man page, for consistency
with other usage.

PR standards/58603: getentropy(3): update visibility and documentation
for POSIX.1-2024
 1.4.2.1 11-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #319):

sys/dev/pci/ubsec.c: revision 1.64
sys/dev/pci/hifn7751.c: revision 1.82
lib/libc/gen/getentropy.3: revision 1.5
lib/libc/gen/getentropy.3: revision 1.6
share/man/man4/rnd.4: revision 1.41
lib/libc/sys/getrandom.2: revision 1.2
lib/libc/sys/getrandom.2: revision 1.3
share/man/man5/rc.conf.5: revision 1.193
share/man/man7/entropy.7: revision 1.5
share/man/man7/entropy.7: revision 1.6
share/man/man7/entropy.7: revision 1.7
share/man/man7/entropy.7: revision 1.8
etc/security: revision 1.130
share/man/man7/entropy.7: revision 1.9
etc/security: revision 1.131
sys/crypto/cprng_fast/cprng_fast.c: revision 1.19
sys/sys/rndio.h: revision 1.3
tests/lib/libc/sys/t_getrandom.c: revision 1.5
etc/defaults/rc.conf: revision 1.164
etc/defaults/rc.conf: revision 1.165
sys/sys/rndsource.h: revision 1.10
sys/kern/kern_entropy.c: revision 1.62
sys/kern/kern_entropy.c: revision 1.63
sys/kern/kern_entropy.c: revision 1.64
sys/kern/subr_cprng.c: revision 1.44
sys/kern/kern_entropy.c: revision 1.65
sys/kern/kern_clock.c: revision 1.149
sys/dev/pci/viornd.c: revision 1.22
share/man/man9/rnd.9: revision 1.32
sys/kern/subr_prf.c: revision 1.202
sys/sys/rndsource.h: revision 1.8
sys/sys/rndsource.h: revision 1.9
share/man/man7/entropy.7: revision 1.10

1. Reinstate netbsd<=9 entropy estimator to unblock /dev/random, in
parallel with assessment of only confident entropy sources (seed,
HWRNG) for security warnings like sshd keys in motd and daily
insecurity report.

2. Make multiuser boot wait for first /dev/random output soon after
loading a seed and configuring rndctl, so that getentropy(3) meets
its contract starting early at boot without introducing blocking
paths that could cause hangs in init(8) or single-user mode.
Operators can choose to disable this wait in rc.conf.

3. Fix some bugs left over from reducing the global entropy lock from
a spin lock at IPL_VM to an adaptive lock at IPL_SOFTSERIAL.

4. Update man pages.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 31-May-2022  riastradh libc: Reintroduce getentropy.

This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing. Now getentropy is more widely adopted and soon to be in
POSIX. So reintroduce the symbol into libc since we'll be keeping it
anyway. Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch. The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

SYNOPSIS
#include <unistd.h>

int getentropy(void *buffer, size_t length);

DESCRIPTION
The getentropy() function shall write length bytes of data
starting at the location pointed to by buffer. The output
shall be unpredictable high quality random data, generated by
a cryptographically secure pseudo-random number
generator. The maximum permitted value for the length
argument is given by the {GETENTROPY_MAX} symbolic constant
defined in <limits.h>.

RETURN VALUES
Upon successful completion, getentropy() shall return 0;
otherwise, -1 shall be retunred and errno set to indicate the
error.

ERRORS
The getentropy() function shall fail if:

[EINVAL] The value of length is greater than
{GETENTROPY_MAX}.

The getentropy() function may fail if:

[ENOSYS] The system does not provide the necessary
source of entropy.

RATIONALE
The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE. When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.
 1.2 22-Sep-2020  nia remove getentropy bits
 1.1 06-May-2020  nia Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.

Posted to tech-userlevel@ a week ago and reviewed by riastradh@.

GETENTROPY(3) Library Functions Manual GETENTROPY(3)

NAME
getentropy - fill a buffer with high quality random data

LIBRARY
Standard C Library (libc, -lc)

SYNOPSIS
#include <unistd.h>

int
getentropy(void *buf, size_t buflen);

DESCRIPTION
The getentropy() function fills a buffer with high quality random data,
suitable for seeding cryptographically secure psuedorandom number
generators.

getentropy() is only intended for seeding random number generators and is
not intended for use by regular code which simply needs secure random
data. For this purpose, please use arc4random(3).

The maximum value for buflen is 256 bytes.

IMPLEMENTATION NOTES
getentropy() reads from the sysctl(7) variable kern.arandom.

RETURN VALUES
The getentropy() function returns 0 on success, and -1 if an error
occurred.

ERRORS
getentropy() will succeed unless:

[EFAULT] The buf argument points to an invalid memory address.

[EIO] Too many bytes were requested.

SEE ALSO
arc4random(3), rnd(4)

STANDARDS
The getentropy() function is non-standard.

HISTORY
The getentropy() function first appeared in OpenBSD 5.6, then in
FreeBSD 12.0, and NetBSD 10.
 1.12 07-Apr-2012  christos cross reference getfsspecname
 1.11 22-Mar-2010  joerg branches: 1.11.6;
Use .In for header files instead of .Ar Pa and variations.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 22-Mar-1999  garbled branches: 1.6.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.3 25-Nov-1993  jtc Misc manpage fixes.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.11.6.1 17-Apr-2012  yamt sync with head
 1.32 07-Feb-2018  pgoyette Fix typos, as reported by Eitan Adler. Update dates.
 1.31 28-Apr-2011  wiz Sort sections and errors.
 1.30 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.29 30-Apr-2008  christos branches: 1.29.8;
Mention errno settings on failure.
 1.28 25-May-2005  wiz branches: 1.28.18;
Bump date for standards.
 1.27 24-May-2005  kleink Truth, meet standards section. Standards section, meet truth.
 1.26 19-Apr-2005  wiz Add a comma for readability.
 1.25 19-Apr-2005  lukem Clarify getgr*_r() return value when entry isn't found.
Improve markup of various constants.
 1.24 04-Apr-2005  wiz Remove superfluous comma.
 1.23 04-Apr-2005  christos Describe get{pw,gr}ent_r. XXX: Are they in any standards?
 1.22 05-Oct-2004  lukem branches: 1.22.2;
Correct order of description of getgr{nam,gid}{,_r}() functions.
 1.21 04-Oct-2004  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.
This makes it much easier to write dynamic nsswitch backends for getgrent(3).
Per my proposal on tech-userlevel.

Implement getgrgid_r() and getgrnam_r() APIs per the POSIX 1003.1, 2004 Ed.
These aren't fully reentrant or threadsafe yet, because the compat stuff
currently uses non-reentrant data sources (getnetgrent(3), getgrent(3)),
and there is probably some locking to be improved in the backends.
This will be fixed in the near future.
We also need to add _SC_GETGR_R_SIZE_MAX to sysconf(3).
 1.20 02-Sep-2004  jmmv s/password databases/group databases/
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.17 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.16 29-Apr-2002  simonb Remove <sys/types.h> from synopsis, as per latest SUS/Posix specs.
 1.15 07-Feb-2002  ross Generate <>& symbolically.
 1.14 16-Sep-2001  wiz Boring whitespace fixes.
 1.13 25-Apr-1999  lukem branches: 1.13.10;
* highlight that getgrent() doesn't suppress duplicate info from multiple
nsswitch.conf sources
* consistently refer to `functions', rather than occasionally referring
to them as `routines'.
 1.12 16-Jan-1999  lukem branches: 1.12.2;
reference nsswitch.conf(5)
 1.11 05-Feb-1998  perry add LIBRARY section to man page
 1.10 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.9 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.8 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.7 10-Jan-1994  jtc Fix spelling errors.
 1.6 25-Oct-1993  jtc Update source and manual pages to match X/Open 1170 specification.
Updated setpassent() to understand YP (a bug), and changed setpwent()
to simply be a call to setpassent(0) (to remove duplicated code).
 1.5 15-Oct-1993  jtc Use .Xr for SEE ALSO cross references.
 1.4 04-Oct-1993  jtc Changed SYNOPSIS, included <sys/types.h> before <grp.h> as it is needed
to define gid_t for getgrgid().
 1.3 30-Jul-1993  mycroft Add RCS identifiers.
 1.2 14-Apr-1993  sef Bloody stupid misspelled name caused me grief, so I'm changing it
wherever I can. (Function is getgrnam, documentation says getgrnam*e*!)
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.2.1 27-Apr-1999  perry pullup 1.12->1.13 (lukem)
 1.13.10.5 18-Oct-2002  nathanw Catch up to -current.
 1.13.10.4 21-Jun-2002  nathanw Catch up to -current.
 1.13.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.13.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.13.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.22.2.6 11-Jul-2005  tron Pull up revision 1.28 (requested by lukem in ticket #540):
Bump date for standards.
 1.22.2.5 11-Jul-2005  tron Pull up revision 1.26 (requested by lukem in ticket #540):
Add a comma for readability.
 1.22.2.4 11-Jul-2005  tron Pull up revision 1.25 (requested by lukem in ticket #540):
Clarify getgr*_r() return value when entry isn't found.
Improve markup of various constants.
 1.22.2.3 11-Jul-2005  tron Pull up revision 1.24 (requested by lukem in ticket #540):
Remove superfluous comma.
 1.22.2.2 11-Jul-2005  tron Pull up revision 1.23 (requested by lukem in ticket #540):
Describe get{pw,gr}ent_r. XXX: Are they in any standards?
 1.22.2.1 28-May-2005  tron Pull up revision 1.27 (requested by kleink in ticket #345):
Truth, meet standards section. Standards section, meet truth.
 1.28.18.1 18-May-2008  yamt sync with head.
 1.29.8.2 30-Apr-2008  christos Mention errno settings on failure.
 1.29.8.1 30-Apr-2008  christos file getgrent.3 was added on branch christos-time_t on 2008-04-30 14:51:11 +0000
 1.67 29-Aug-2012  dholland Check for NULL *before* using ALIGN().

I don't remember what prompted this, but it's obviously a desirable fix
and I've been carrying it on a heavily-used machine for more than a year.
 1.66 29-Mar-2012  christos PR?40728: W. Stukenbrock: Fix various issues with NIS-netgroups in users
and groups.
 1.65 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.64 15-Oct-2011  christos branches: 1.64.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.63 09-Jun-2011  sjg _gr_copy() can get called with fromgrp->gr_mem == NULL.
 1.62 28-Apr-2008  martin branches: 1.62.6; 1.62.8; 1.62.22;
Remove clause 3 and 4 from TNF licenses
 1.61 03-Feb-2007  christos branches: 1.61.10;
make this compile with DIAGNOSTIC
 1.60 15-Oct-2006  christos fix incomplete initializers
 1.59 19-Mar-2006  christos iCoverity CID 706: Remove dead code.
 1.58 19-Apr-2005  lukem When sequentially parsing a source looking for entries don't fail with
NS_UNAVAIL on an unparseable or too long line; instead try the next entry.
This is more consistent with the behaviour prior to the rework in rev 1.49.
 1.57 19-Apr-2005  lukem getgrent():
Return the correct result. (broken in rev 1.56 -- Hi Christos!)

getgr{ent,nam,uid}_r():
Return 0 "entry not found" and errno for other failures.
("entry not found" still sets *result to NULL).

Various backends:
don't set the retval to errno (or modify errno) for NS_NOTFOUND.

Per discussion with Klaus Klein.
 1.56 02-Apr-2005  christos PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.55 31-Mar-2005  lukem tweak comment reminding us about lack of reentrancy
 1.54 06-Jan-2005  lukem branches: 1.54.2;
Rename various "internal" variables and functions and make non-static so other
internal libc source files can use these (including getgroupmembership(3)).

Be more consistent in the API that the __grscan_<source>() methods use.

In __grscan_compat() support an optional custom 'search' function used when a
"+" lookup is required. Normally this will be getgrent() from group_compat,
but getgroupmembership(3) will use a tailored compat search routine for
efficiency.
 1.53 10-Nov-2004  lukem Use the common __nsdefaultFOO rather than private defaultFOO duplicates.
 1.52 10-Nov-2004  lukem Use _GETGR_R_SIZE_MAX from <limits.h> rather than defining a private version.
 1.51 29-Oct-2004  lukem #include "reentrant.h" instead of <threadlib.h>
 1.50 24-Oct-2004  lukem Protect access to all public functions via a mutex as some of the backends are
not reentrant (such as compat getgr*_r, because it uses the non reentrant
_{dns,nis}_getgrent() backends to implement `+group').
 1.49 04-Oct-2004  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.
This makes it much easier to write dynamic nsswitch backends for getgrent(3).
Per my proposal on tech-userlevel.

Implement getgrgid_r() and getgrnam_r() APIs per the POSIX 1003.1, 2004 Ed.
These aren't fully reentrant or threadsafe yet, because the compat stuff
currently uses non-reentrant data sources (getnetgrent(3), getgrent(3)),
and there is probably some locking to be improved in the backends.
This will be fixed in the near future.
We also need to add _SC_GETGR_R_SIZE_MAX to sysconf(3).
 1.48 13-Oct-2003  agc Move Jason Downs's code from a 4-clause to a 3-clause licence by
removing the advertising clause. Diffs provided in PR 22410 by Joel
Baker, confirmed to the board by Jason Downs.

With additional thanks to Jason Thorpe.
 1.47 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.46 17-Feb-2003  simonb Fix a tyop in a comment.
 1.45 16-Feb-2003  elric Reorganise the getting of grouplists for a user so that Hesiod (and
potentially other name services) can directly query for a user's
grouplist rather than needing to iterate over the group map. This
is required for correct operation of Hesiod.

Reviewed by: lukem, christos
Addresses PR lib/20183
 1.44 03-Feb-2003  elric When looking up gids with hesiod, use the gid map and fall back to the
group map.

Addresses PR lib/20145
 1.43 17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.42 02-Feb-2002  lukem be consistent with internal names: s/start_gr/grstart/ ; s/matchline/gr&/
 1.41 12-Jan-2002  lukem ansi knf
 1.40 17-Dec-2000  lukem branches: 1.40.2;
fix typo in _nis_grscan(). "if (data); free(data);" -> "if (data) free(data);"
noted by Jacques Vidrine <nectar@FreeBSD.org>
 1.39 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.38 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.37 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.36 25-Apr-1999  lukem change getgrent() backends so that a flag (per source) is set once the
source has been exhausted. this allows getgrent() across multiple
sources (e.g, ``group: files nis'') to work correctly. the flags are
reset in setgrent()/endgrent().

(as per similar change in getpwent.c rev 1.42)

XXX: this change means that code that uses getgrent() to obtain a list
of groups will have to do duplicate suppression... getgrouplist()
springs to mind; i'm about to modify that
 1.35 18-Apr-1999  lukem specifically include stdarg/varargs.h
 1.34 26-Jan-1999  lukem branches: 1.34.2;
always compile in support for `compat' backends (even if !YP & !HESIOD),
and make it the responsibility of the backends to fallback to `files'
if !YP & !HESIOD. fixes chsh problem noted by billc@netbsd.org.
 1.33 25-Jan-1999  lukem convert from hes_*() -> hesiod_*()
 1.32 20-Jan-1999  lukem nsdispatch defaults now: "group: compat", "group_compat: nis"
 1.31 19-Jan-1999  lukem * `passwd' defaults to `compat', and `passwd_compat' defaults to `nis'
* constify ns_dtab defs
 1.30 19-Jan-1999  lukem convert to new nsdispatch(3)
 1.29 18-Jan-1999  christos delint
 1.28 16-Jan-1999  lukem fix some gid casts
 1.27 16-Jan-1999  lukem pull nsswitch up to main branch
 1.26 26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.25 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.24 27-Jul-1998  mycroft Make these compile without __AUDIT__.
 1.23 26-Jul-1998  mycroft const poisoning.
 1.22 26-Feb-1998  perry trivial changes to reduce lint complaints
 1.21 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.20 13-Jul-1997  christos Add missing prototypes
Fix RCSID's
Fix gcc warnings
 1.19 22-May-1997  lukem branches: 1.19.2;
a valid uid/gid *ends* in \0 (i.e, barf if (*ep != '\0'), not if (*ep == '\0'))
 1.18 22-May-1997  lukem * parse gid with strtoul() instead of atoi(), and sanity check a) the parsed
value was just a number, b) it doesn't exceed GID_MAX
* convert gid to a string with %u not %d
* use [gu]id_t instead of int
 1.17 21-May-1997  lukem fix potential memory leaks: before calling yp_next(), reset key to NULL. if
an error occurred, and key != NULL, free(key).
 1.16 20-May-1997  lukem * ensure that "outdata" values to various yp_xxx() functions are set
to the null pointer before invocation, so that the test in the
error case of "if (outdata != NULL) free(outdata)" won't potentially
try and free memory that wasn't malloc()ed.
* factor some duplicated code out of both parts of an "if {} else {}"
construct.
* remove use of `register' & KNFify.
 1.15 22-Jan-1997  thorpej Don't transfer the entire YP database using yp_{first,next}(); instead
use yp_match(), which is much more efficient.

From Michael.Eriksson@era-t.ericsson.se, PR #3114.
 1.14 20-Dec-1996  cgd grscan()'s last arg has to be a const char *, not just a char *
 1.13 28-Jul-1995  phil branches: 1.13.4; 1.13.8;
Improvements to YP support from Jason Downs.
 1.12 16-Mar-1995  pk Speed up getgrnam() and getgrpid() by using yp_match().
 1.11 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.10 02-Aug-1994  deraadt be lenient; let a few other forms of + activate YP
 1.9 29-Jul-1994  deraadt avoid core dump
 1.8 07-Mar-1994  deraadt branches: 1.8.2;
better, more forgiving solution to previous problem.
 1.7 06-Mar-1994  deraadt fix small obscure YP buglet, and properly terminate gr_mem
 1.6 24-Nov-1993  jtc Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.5 25-Oct-1993  jtc Update source and manual pages to match X/Open 1170 specification.
Updated setpassent() to understand YP (a bug), and changed setpwent()
to simply be a call to setpassent(0) (to remove duplicated code).
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 30-Jul-1993  mycroft Add even more RCS frobs.
 1.2 04-May-1993  deraadt I was horrified to find these had not been commited with the YP changes.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.2.2 03-Aug-1994  cgd from trunk.
 1.8.2.1 01-Aug-1994  cgd from trunk
 1.13.8.1 06-Nov-1996  lukem initial nsswitch implementation
 1.13.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.19.2.5 14-Jan-1999  lukem use new ns_dtab structure
 1.19.2.4 02-Nov-1998  lukem sync with current
 1.19.2.3 02-Jun-1997  lukem * during getgrent(), set _gr_none = 1 and return NS_SUCCESS upon EOF.
this prevents the sources being "merged" by default, which caused
problems with getgrouplist() and NIS
* use gid_t instead of int in the appropriate locations
* minor formatting fixes
 1.19.2.2 26-May-1997  lukem only initialise ns_dtab if it hasn't been done yet
 1.19.2.1 24-May-1997  lukem convert to use nsdispatch()
 1.34.2.1 27-Apr-1999  perry pullup 1.35->1.36 (lukem)
 1.40.2.4 10-Dec-2002  thorpej Sync with HEAD.
 1.40.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.40.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.40.2.1 28-Jan-2002  nathanw Catch up to -current.
 1.54.2.4 11-Jul-2005  tron Pull up revision 1.58 (requested by lukem in ticket #540):
When sequentially parsing a source looking for entries don't fail with
NS_UNAVAIL on an unparseable or too long line; instead try the next entry.
This is more consistent with the behaviour prior to the rework in rev 1.49.
 1.54.2.3 11-Jul-2005  tron Pull up revision 1.57 (requested by lukem in ticket #540):
getgrent():
Return the correct result. (broken in rev 1.56 -- Hi Christos!)
getgr{ent,nam,uid}_r():
Return 0 "entry not found" and errno for other failures.
("entry not found" still sets *result to NULL).
Various backends:
don't set the retval to errno (or modify errno) for NS_NOTFOUND.
Per discussion with Klaus Klein.
 1.54.2.2 11-Jul-2005  tron Pull up revision 1.56 (requested by lukem in ticket #540):
PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.54.2.1 11-Jul-2005  tron Pull up revision 1.55 (requested by lukem in ticket #540):
tweak comment reminding us about lack of reentrancy
 1.61.10.1 18-May-2008  yamt sync with head.
 1.62.22.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.62.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.62.8.1 28-Apr-2008  martin file getgrent.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.62.6.1 18-Jun-2011  bouyer Pull up following revision(s) (requested by sjg in ticket #1636):
lib/libc/gen/getgrent.c: revision 1.63
_gr_copy() can get called with fromgrp->gr_mem == NULL.
 1.64.2.2 30-Oct-2012  yamt sync with head
 1.64.2.1 17-Apr-2012  yamt sync with head
 1.15 24-Oct-2017  abhinav Remove trailing comma after last Nm entry in the NAME section
 1.14 02-May-2008  martin branches: 1.14.8;
Move TNF licenses to 2 clause form
 1.13 06-Jan-2005  lukem branches: 1.13.24;
document getgroupmembership(3)
 1.12 28-Sep-2004  wiz Drop space at EOL and dot at end of SEE ALSO.
 1.11 28-Sep-2004  lukem Expand description of return value.
Remove bug about incorrect sizing calculation; it seems to DTRT for me.
Also reference group(5).
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 25-Apr-1999  lukem branches: 1.6.10;
document duplicate suppression
 1.5 05-Feb-1998  perry branches: 1.5.2;
add LIBRARY section to man page
 1.4 03-Feb-1998  perry .Bx'ize
 1.3 12-Oct-1995  jtc Manpage fixes from Jochen Pohl. Aligns the prototypes in the SYNOPSIS
section with the actual function declarations. Also fixes decription
of _SC_CLK_TCK in sysconf(3). See PR #1587 and PR #1589 for details.
 1.2 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.1 05-May-1994  cgd branches: 1.1.1;
add getgrouplist
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.5.2.1 27-Apr-1999  perry pullup 1.5->1.6 (lukem)
 1.6.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.24.1 18-May-2008  yamt sync with head.
 1.14.8.2 02-May-2008  martin Move TNF licenses to 2 clause form
 1.14.8.1 02-May-2008  martin file getgrouplist.3 was added on branch christos-time_t on 2008-05-02 18:11:05 +0000
 1.22 28-Apr-2008  martin branches: 1.22.8;
Remove clause 3 and 4 from TNF licenses
 1.21 06-Jan-2005  lukem branches: 1.21.24;
Implement getgroupmembership(3). This is similar to getgrouplist(3), except
that the "int maxgroups" and "int *ngroups" parameters are separated into
two separate parameters which makes it possible to call multiple nsswitch
back-ends and have the results correctly merged.
getgrouplist(3) is now implemented using getgroupmembership(3).

Proposed on tech-userlevel on December 1, 2004.
 1.20 28-Sep-2004  lukem 'gid_t *groups' may be NULL if we're just sizing the list by calling
getgrouplist(3) with *grpcnt==0, so don't _DIAGASSERT(groups != NULL).

Tweak API used between getgrouplist(3) and the back-end nsswitch methods;
move the public return value to the start of the va_list and reserve the
'void *retval' for "internal use" (e.g, errno passing or some other need).
 1.19 25-Sep-2004  lukem Try nsdispatch "getgrouplist" before iterating the getgrent() list.
Implement a dns (hesiod) backend which tries a grplist hesiod lookup.
Convert back to using getgrent() similar to rev 1.15, instead of
using the private _getgrent_user() from getgrent.c.
 1.18 25-Sep-2004  lukem ANSI KNF
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 16-Feb-2003  elric Reorganise the getting of grouplists for a user so that Hesiod (and
potentially other name services) can directly query for a user's
grouplist rather than needing to iterate over the group map. This
is required for correct operation of Hesiod.

Reviewed by: lukem, christos
Addresses PR lib/20183
 1.15 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.14 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 25-Apr-1999  lukem suppress duplicate gids (e.g, when multiple sources are given in
nsswitch.conf and they contain similar information).

XXX: in the case where the given array is too small and -1 is returned,
the returned ngroups will be too large by a factor of the difference
between the given size and the number of matches. this is not considered
to be a major problem, since it's still going to be a smaller figure than
what the previous (non suppressive) behaviour returned.
 1.11 08-Apr-1999  drochner remove unused label
 1.10 05-Apr-1999  mycroft Return the full group count when it exceeds the maximum. Also DTRT if the
maximum is 0 (possibly used to size the list for memory allocation, rather
than core dumping).
 1.9 03-Feb-1998  perry branches: 1.9.2;
remove obsolete register declarations
 1.8 02-Feb-1998  perry merge/update to lite-2
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
Fix inconsistent function definition with unistd.h
Fix gcc warnings
 1.5 01-Jun-1995  jtc branches: 1.5.4;
Don't duplicate the primary group. The first member of the groups list
no longer serves as effective group id.
 1.4 25-Feb-1995  cgd update to 4.4-Lite where appropriate, clean up Id format, etc.
 1.3 13-Oct-1994  cgd oops; fix that.
 1.2 13-Oct-1994  cgd check bounds properly.
 1.1 05-May-1994  cgd branches: 1.1.1; 1.1.2;
add getgrouplist
 1.1.2.1 15-Oct-1994  cgd From trunk.
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.2.1 27-Apr-1999  perry pullup 1.9->1.12 (lukem)
 1.21.24.1 18-May-2008  yamt sync with head.
 1.22.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.22.8.1 28-Apr-2008  martin file getgrouplist.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.4 28-Apr-2008  martin branches: 1.4.8;
Remove clause 3 and 4 from TNF licenses
 1.3 03-Feb-2007  christos branches: 1.3.10;
Compile with DIAGNOSTIC
 1.2 15-Oct-2006  christos fix incomplete initializers
 1.1 06-Jan-2005  lukem Implement getgroupmembership(3). This is similar to getgrouplist(3), except
that the "int maxgroups" and "int *ngroups" parameters are separated into
two separate parameters which makes it possible to call multiple nsswitch
back-ends and have the results correctly merged.
getgrouplist(3) is now implemented using getgroupmembership(3).

Proposed on tech-userlevel on December 1, 2004.
 1.3.10.1 18-May-2008  yamt sync with head.
 1.4.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4.8.1 28-Apr-2008  martin file getgroupmembership.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.18 03-Sep-2015  jnemeth PR/49641 - Henning Petersen -- wordo
 1.17 07-Feb-2006  wiz .Fn needs an argument.
 1.16 14-Oct-2005  christos Don't hide the error from sysctl. From Liam Foy.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.12 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.6 06-May-1998  kleink Per X/Open XNS5 (a/k/a C523), change the type of the `namelen' argument to
gethostname() from int to size_t. Change sethostname() in the same way
for consistency.
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 08-Apr-1996  jtc Add proper punctuation; Reported by Mike Long <mike.long@analog.com> in PR #2302.
 1.3 11-Feb-1996  neil Fixed SEE ALSO section. Closes PR # 2049
 1.2 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.8.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 14-Oct-2005  christos branches: 1.12.44;
Don't hide the error from sysctl. From Liam Foy.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 18-Nov-1999  is In case of an error returned by sysctl, and errno=ENOMEM, restore the
old errno and return 0. This makes us complant with SUSV2 and our own
manual page. See PR pr7836 by Simon Burge.
 1.8 20-Sep-1999  lukem branches: 1.8.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 06-May-1998  kleink Per X/Open XNS5 (a/k/a C523), change the type of the `namelen' argument to
gethostname() from int to size_t. Change sethostname() in the same way
for consistency.
 1.5 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.4 13-Jul-1997  christos Add missing unistd.h include
Fix RCSID's
 1.3 16-Jun-1995  jtc branches: 1.3.4;
Change return type of {get,set}{domain,host}name() from long to int.
 1.2 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.3.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.8.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.44.1 30-Oct-2012  yamt sync with head
 1.2 30-Apr-2008  martin branches: 1.2.8;
Convert TNF licenses to new 2 clause variant
 1.1 26-Aug-2003  wiz branches: 1.1.30;
Add man page for getlastlogx and friends.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.2.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.2.8.1 30-Apr-2008  martin file getlastlogx.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.15 12-Apr-2011  jruoho Use RETURN VALUES rather than DIAGNOSTIC for... return values.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 12-May-2002  wiz Add return type. From KAWAKUBO Hiroshi in lib/16776.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.9 15-Jun-1999  simonb branches: 1.9.10;
The prototype for this is in <stdlib.h>...
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 03-Jan-1997  mikel there is no sysctl(2); reference sysctl(3) instead.
 1.6 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.5 07-May-1994  cgd clean up conflicts
 1.4 28-Jan-1994  cgd better way to get the load average
 1.3 28-Jan-1994  cgd note requirement of linking with -lkvm if you use this routine.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 07-May-1994  cgd various sysctl-related libc functions
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.10.4 21-Jun-2002  nathanw Catch up to -current.
 1.9.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.9.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.9.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.14 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.13 07-Aug-2003  agc branches: 1.13.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.11 26-Jun-2000  mrg branches: 1.11.2;
we now need <uvm/uvm_param.h>
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 25-Feb-1995  cgd branches: 1.5.4;
clean up Id's on files previously imported...
 1.4 07-May-1994  cgd clean up conflicts
 1.3 28-Jan-1994  cgd better way to get the load average
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 07-May-1994  cgd various sysctl-related libc functions
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.11.2.1 11-Nov-2002  nathanw Catch up to -current
 1.13.56.1 17-Apr-2012  yamt sync with head
 1.17 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.16 05-Oct-2019  uwe getlogin_r: use strcpy(). We check namelen before copying the result.
gcc 8 -Wstringop-overflow is uhappy when the specified bounds depend
on the length of the source and is not smart enough to see the check
we do. Besides we don't want the padding effect of strncpy() here.
 1.15 11-Jan-2009  christos branches: 1.15.48;
merge christos-time_t
 1.14 06-Jan-2009  lukem Change the second argument of getlogin_r() from int to size_t, per POSIX.
 1.13 25-Jun-2008  ad branches: 1.13.4; 1.13.6;
Add getlogin_r. Manual page changes mostly lifted from FreeBSD.
 1.12 07-Aug-2003  agc branches: 1.12.32;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.10 22-Jan-2000  mycroft branches: 1.10.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.8 13-Jul-1997  christos Add extern.h to get missing __getlogin prototype
Fix RCSID's
 1.7 23-Sep-1996  thorpej Update for the new internal name for __getlogin().
 1.6 27-Feb-1995  cgd branches: 1.6.4;
update from Lite, with local changes. fix Ids, etc.
 1.5 18-Dec-1993  jtc Fix bug #24 by renaming _logname_valid to __logname_valid.
 1.4 11-Oct-1993  jtc Moved cuserid() from getlogin.c to its own file, cuserid.c.
getlogin() and cuserid() do very different things, getlogin() is POSIX,
while cuserid() is not (it was removed in the 1990 revision).
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.6.1 25-Feb-2002  nathanw Move setlogin() stub to C code, and namespace-protect it.
 1.12.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.6.2 10-Jan-2009  christos sync with head.
 1.13.6.1 25-Jun-2008  christos file getlogin.c was added on branch christos-time_t on 2009-01-10 22:59:51 +0000
 1.13.4.1 16-Jan-2009  snj Pull up following revision(s) (requested by lukem in ticket #247):
include/unistd.h: revision 1.119
lib/libc/gen/getlogin.c: revision 1.14
lib/libc/sys/getlogin.2: revision 1.21
Change the second argument of getlogin_r() from int to size_t, per POSIX.
 1.15.48.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.16 12-Jun-2016  abhinav Don't refer getfsstat() using .Xr as we don't have man page for it anymore.
Ok from wiz@
 1.15 05-May-2004  jdolecek fix reference Nx 2.1 to Nx 3.0
 1.14 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.9 29-Apr-1998  fair branches: 1.9.12;
fix bad .Xr
 1.8 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 03-Feb-1998  perry .Bx'ize
 1.5 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.4 29-Aug-1994  mycroft branches: 1.4.2;
Correct first arg in synopsis.
 1.3 30-Nov-1993  jtc Use ".Va" macro when formatting "errno".
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.2 29-Aug-1994  mycroft Correct first arg in synopsis.
 1.4.2.1 29-Aug-1994  mycroft file getmntinfo.3 was added on branch netbsd-1-0 on 1994-08-29 03:27:37 +0000
 1.9.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.9.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.17 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.16 13-Sep-2005  christos branches: 1.16.44;
compat core reorg.
 1.15 12-Apr-2005  drochner getmntinfo() if a compatibility function, so there is no point in hiding
references to the compatibility getfsstat()
The real problem behind PR lib/29919 was a stale weak_alias, so back out
the workaround.
 1.14 07-Apr-2005  christos PR/29919: Evaldo Gardenali: getmntinfo() calling deprecated function getfsstat()
Fixed by defining an _getfsstat() internal function and calling that instead.
 1.13 21-Apr-2004  christos branches: 1.13.2;
Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 26-Feb-1998  perry trivial changes to reduce lint complaints
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 27-Feb-1995  cgd branches: 1.5.4;
update from Lite, with local changes. fix Ids, etc.
 1.4 12-Jun-1994  cgd fix up includes for new FS code
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.13.2.2 01-Mar-2006  riz Pull up following revision(s) (requested by drochner in ticket #1187):
lib/libc/sys/statfs.c: revision 1.4
lib/libc/gen/getmntinfo.c: revision 1.15
getmntinfo() if a compatibility function, so there is no point in hiding
references to the compatibility getfsstat()
The real problem behind PR lib/29919 was a stale weak_alias, so back out
the workaround.
 1.13.2.1 08-Apr-2005  tron Pull up revision 1.14 (requested by bouyer in ticket #125):
PR/29919: Evaldo Gardenali: getmntinfo() calling deprecated function getfsstat()
Fixed by defining an _getfsstat() internal function and calling that instead.
 1.16.44.1 17-Apr-2012  yamt sync with head
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 02-Mar-1999  christos branches: 1.9.12;
const poisoning.
 1.8 16-Jan-1999  lukem reference nsswitch.conf(5)
 1.7 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 26-May-1997  lukem cleanup some problems with the use of mandoc macros
 1.4 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.3 11-Dec-1994  christos NIS -> YP changes and other typos fixed (From Jason Thorpe)
 1.2 04-Dec-1994  christos New netgroup implementation; replaces Rick's old one that did not
expand recursively or handle YP.
 1.1 17-May-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 17-May-1994  mycroft From 4.4-Lite.
 1.9.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.43 31-May-2016  dholland PR 51002 David Binderman: fix wrong printing code not enabled by default.
 1.42 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.41 21-Oct-2009  snj branches: 1.41.6;
Remove 3rd and 4th clauses in christos' license. OK christos.
 1.40 05-Apr-2008  rtr branches: 1.40.10;
whitespace fix
 1.39 07-Feb-2007  oster Add "local" versions of getnetgrent() et al. and now call those for the NIS
versions. Fix conditional compilation issues with YP and NSS_FILES.
 1.38 06-Feb-2007  oster nsdispatch()-ify getnetgrent() and friends.

Approved by: christos
 1.37 15-Oct-2006  christos fix incomplete initializers
 1.36 03-Aug-2006  tron Remove leftover debugging message. Problem pointed out by Kurt Schreiner
on "current-users" mailing list.
 1.35 27-Jul-2006  dogcow back out last change as it is actually a visible function.
 1.34 27-Jul-2006  dogcow define _ng_cycle to be static, so gcc won't whing about its implicit decl.
 1.33 27-Jul-2006  christos move include of StringList.h before netgroup.h
 1.32 27-Jul-2006  christos add an _ng_cycle function to print the list of netgroups that are are dups.
 1.31 19-Mar-2006  christos Coverity 2278: Avoid leak on allocation failure.
 1.30 25-Jul-2005  christos PR/30832: Tomas Sk�re: Freed memory used in lib/libc/getnetgrent.c
While there, KNF and ansify.
 1.29 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.28 22-Jan-2000  mycroft branches: 1.28.6;
Delint.
 1.27 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.26 28-Nov-1999  lukem * check the result of sl_init() and sl_add()
* return an error state back up the call chain and take appropriate
action, rather than calling err() to terminate the process
 1.25 20-Sep-1999  lukem branches: 1.25.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.24 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.23 18-Apr-1999  lukem specifically include stdarg/varargs.h
 1.22 22-Jan-1999  lukem pre nsswitch default was more like "files [notfound=return] nis"
 1.21 21-Jan-1999  thorpej Fix two problems with the recent nsswitch changes to netgroups:
- The historic mode for netgroups was "files nis". Change the default to
this for when /etc/nsswitch.conf does not exist.
- The nis lookup dispatch was mistakenly conditional on -DHESIOD, not -DYP.
 1.20 19-Jan-1999  lukem * `passwd' defaults to `compat', and `passwd_compat' defaults to `nis'
* constify ns_dtab defs
 1.19 19-Jan-1999  lukem convert to new nsdispatch(3)
 1.18 18-Jan-1999  christos delint
 1.17 16-Jan-1999  lukem pull nsswitch up to main branch
 1.16 27-Jul-1998  mycroft Make these compile without __AUDIT__.
 1.15 26-Jul-1998  mycroft const poisoning.
 1.14 26-Feb-1998  perry trivial changes to reduce lint complaints
 1.13 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.12 13-Jul-1997  christos Fix RCSID's
Use namespace.h
 1.11 17-Jan-1997  lukem branches: 1.11.2;
Add stringlist implementation
Convert getnetgrent from private stringlist to public version
 1.10 20-Dec-1996  cgd ifdef YP, needs rpcsvc/ypclnt.h for protos
 1.9 27-Apr-1996  christos branches: 1.9.2; 1.9.6;
- grab prototypes from netgroup.h
- added _ng_print, netgroup pretty printing function
 1.8 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.7 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.6 12-Dec-1994  christos Return null for empty strings in triplets, not the empty string.
Fix memory corruption with double-freeing ng_copy. (From Jason Downs)
 1.5 11-Dec-1994  christos - Changed all internal libc references of {v,}err{x,} and {v,}warn{x,} to
__{v,}err{x,} and __{v,}warn{x,}
- moved err.c to __err.c and added err.c which contains weak references for
the above functions.
- Reordered the functions in __err.c to avoid redeclarations and changed
the varargs declarations to conform with the K&R style.
 1.4 04-Dec-1994  christos New netgroup implementation; replaces Rick's old one that did not
expand recursively or handle YP.
 1.3 19-Oct-1994  cgd needs stdlib.h
 1.2 19-Sep-1994  mycroft Fix null pointer dereference, per Rolf Grossman.
 1.1 17-May-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 17-May-1994  mycroft branches: 1.1.1.1.2;
From 4.4-Lite.
 1.1.1.1.2.1 06-Oct-1994  mycroft Update from trunk.
 1.9.6.1 06-Nov-1996  lukem initial nsswitch implementation
 1.9.2.2 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.11.2.4 14-Jan-1999  lukem use new ns_dtab structure
 1.11.2.3 02-Nov-1998  lukem sync with current
 1.11.2.2 26-May-1997  lukem only initialise ns_dtab if it hasn't been done yet
 1.11.2.1 24-May-1997  lukem convert to nsdispatch()
 1.25.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.28.6.1 21-Jun-2002  nathanw Catch up to -current.
 1.40.10.2 05-Apr-2008  rtr whitespace fix
 1.40.10.1 05-Apr-2008  rtr file getnetgrent.c was added on branch christos-time_t on 2008-04-05 08:01:55 +0000
 1.41.6.1 17-Apr-2012  yamt sync with head
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.8 16-Sep-2001  wiz Boring whitespace fixes.
 1.7 22-Mar-1999  garbled branches: 1.7.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.6 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.5 24-May-1998  kleink Declare this interface obsoleted by sysconf(_SC_PAGESIZE), which is the
portable equivalent to getpagesize().
 1.4 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.7.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.11 24-Jun-2012  christos fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.10 14-Dec-2009  matt branches: 1.10.6;
Make sure the kernel doesn't pass back 0 for pagesize.
 1.9 07-Aug-2003  agc branches: 1.9.46;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Add missing unistd.h include
Fix RCSID's
 1.5 25-Feb-1995  cgd branches: 1.5.4;
clean up Id's on files previously imported...
 1.4 19-Sep-1994  mycroft Fix oversight in last change.
 1.3 18-Sep-1994  mycroft Stylistic changes.
 1.2 15-Sep-1994  pk Cache pagesize.
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.46.1 05-Sep-2009  matt Add a DIAGASSERT for the returned pagesize being non-zero.
 1.10.6.1 30-Oct-2012  yamt sync with head
 1.23 24-Oct-2017  abhinav Add getpass_r and getpassfd to the NAME section as well.
 1.22 14-Apr-2012  wiz Wording. Remove trailing whitespace.
 1.21 14-Apr-2012  christos a clarification, an a formatting nit.
 1.20 14-Apr-2012  christos - If fd == NULL, do the dance with opening /dev/tty
- Add a flag to enter a newline when we are done.
 1.19 13-Apr-2012  christos add timeout.
 1.18 13-Apr-2012  wiz Remove trailing whitespace.
 1.17 12-Apr-2012  christos add GETPASS_ECHO_STAR
 1.16 12-Apr-2012  christos add getpassfd() that gives us even more fine grain control on how to get
the password.
 1.15 12-Apr-2012  wiz Remove trailing whitespace.
 1.14 12-Apr-2012  christos Add a new getpass implementation that does not mess with signals, and
include getpass_r
 1.13 06-May-2010  jruoho branches: 1.13.6;
.Nm -> .Fn.
 1.12 30-Apr-2010  jruoho Marked as legacy already in SUSv2; removed in POSIX 2001.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.7 07-Nov-2000  lukem branches: 1.7.2;
fix up various .Nm abuses:
- keep the case consistent between the actual name and what's referenced.
e.g, if it's `foo', don't use '.Nm Foo' at the start of a sentence.
- remove unnecessary `.Nm foo' after the first occurrence (except for
using `.Nm ""' if there's stuff following, or for the 2nd and so on
occurrences in a SYNOPSIS
- use Sx, Ic, Li, Em, Sq, and Xr as appropriate
 1.6 08-Jun-1998  lukem Implement a new manual page category ``SECURITY CONSIDERATIONS''
(suggested by mycroft)
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.6.1 17-Apr-2012  yamt sync with head
 1.30 31-Jan-2016  christos PR/50695: coypu: ctrl-c in su password input breaks shell (bash, csh)
Always restore the tty settings.
 1.29 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.28 16-Jun-2014  christos branches: 1.28.2;
Recognize CR as end of line too. the telnet client passes that to us instead
of linefeed.
 1.27 26-May-2012  christos branches: 1.27.2; 1.27.8;
make getpass and getpass_r print a newline like they did before.
 1.26 02-May-2012  christos test for both NUL and _POSIX_VDISABLE, because _POSIX_VDISABLE propagation
between different daemons and OS's does not seem reliable.
 1.25 14-Apr-2012  christos - If fd == NULL, do the dance with opening /dev/tty
- Add a flag to enter a newline when we are done.
 1.24 13-Apr-2012  christos prefer ETIMEDOUT.
 1.23 13-Apr-2012  christos add timeout.
 1.22 13-Apr-2012  christos - don't update the length of the buffer until the allocation succeeds
- print only printable characters otherwise print '?'
 1.21 13-Apr-2012  christos unconfuse lint; XXX: should really fix lint.
 1.20 12-Apr-2012  christos add GETPASS_ECHO_STAR
 1.19 12-Apr-2012  christos add getpassfd() that gives us even more fine grain control on how to get
the password.
 1.18 12-Apr-2012  christos raise signals for the tty characters that do.
 1.17 12-Apr-2012  christos Add a new getpass implementation that does not mess with signals, and
include getpass_r
 1.16 01-Jan-2008  christos branches: 1.16.28;
block signals before playing with files. From Anon Ymous
 1.15 07-Aug-2003  agc branches: 1.15.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.10 13-Jul-1997  christos Fix RCSID's
Fix gcc warning
 1.9 20-May-1996  jtc branches: 1.9.2;
Signal mask was not restored correctly.
Fix from James Chacon <jmc@pobox.com> in PR #2442.
 1.8 16-May-1996  christos Use the POSIX signal mask interface
 1.7 16-Jun-1995  jtc <sys/termios.h> -> <termios.h>
 1.6 28-Feb-1995  jtc Changed <sys/signal.h> to <signal.h>
 1.5 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.4 04-Jan-1994  jtc branches: 1.4.4;
Use _PATH_TTY constant instead of "/dev/tty".
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.2 02-May-1995  jtc #include "namespace.h"
 1.4.4.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.9.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.15.22.1 09-Jan-2008  matt sync with HEAD
 1.16.28.3 30-Oct-2012  yamt sync with head
 1.16.28.2 23-May-2012  yamt sync with head.
 1.16.28.1 17-Apr-2012  yamt sync with head
 1.27.8.1 10-Aug-2014  tls Rebase.
 1.27.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.2.1 26-Feb-2016  snj Pull up following revision(s) (requested by christos in ticket #1101):
lib/libc/gen/getpass.c: revision 1.30
PR/50695: coypu: ctrl-c in su password input breaks shell (bash, csh)
Always restore the tty settings.
 1.8 21-May-2011  dholland Clarify paragraph about calling setprogname, requested by Tobias Ulmer on
freenode. Bump date.
 1.7 29-Mar-2008  dholland branches: 1.7.10;
Add a note clarifying that getprogname() results are not trustable in a
setugid environment. Prompted by PR 38327 discussion.
 1.6 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.5 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.3 07-Feb-2002  ross Generate <>& symbolically.
 1.2 16-Sep-2001  wiz Boring whitespace fixes.
 1.1 19-Feb-2001  cgd branches: 1.1.2;
add getprogname() and setprogname(). These allow uses of __progname to
be wrapped in some sane fashion, for portability.
 1.1.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.1.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.7.10.2 29-Mar-2008  dholland Add a note clarifying that getprogname() results are not trustable in a
setugid environment. Prompted by PR 38327 discussion.
 1.7.10.1 29-Mar-2008  dholland file getprogname.3 was added on branch christos-time_t on 2008-03-29 16:51:41 +0000
 1.5 20-Apr-2021  christos Instead of compiling files with -fcommon, create an include file and declare
the 3 symbols that need to be common using an attribute. Put all the 3 symbol
definitions in libc in one place (initfini.c). Reviewed by joerg@
 1.4 06-Oct-2011  christos Provide symbol definitions for environ and __progname. These are duplicate
definitions to the ones provided by csu, but harmless since the linker resolves
them. There are 3 non weak data symbols provided in crt0.o:

D __progname [initialized data, assigned to ""]
B __ps_strings [BSS since assigned to 0]
C environ [common, uninitialized]

__ps_strings had already a second definition in libc (in BSS), now we added
__progname and __ps_strings (in BSS).

To get rid of the duplicate definition, we can remove them from csu, and
move the assignments to libc.

This is done so that libc has no undefined symbols so that linker maps
that want to do:
...
local:
*;
...
don't end up producing link failures for libc.
 1.3 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.2 09-Jul-2001  simonb Don't need to include <string.h>.
 1.1 19-Feb-2001  cgd branches: 1.1.2;
add getprogname() and setprogname(). These allow uses of __progname to
be wrapped in some sane fashion, for portability.
 1.1.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.40 07-Feb-2018  pgoyette Fix typos, as reported by Eitan Adler. Update dates.
 1.39 26-Dec-2016  abhinav Add missing full stop.
 1.38 28-Apr-2011  wiz branches: 1.38.26;
Sort sections and errors.
 1.37 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.36 30-Apr-2008  christos branches: 1.36.8;
Mention errno settings on failure.
 1.35 25-May-2005  wiz branches: 1.35.18;
Bump date for standards.
 1.34 24-May-2005  kleink Truth, meet standards section. Standards section, meet truth.
 1.33 19-Apr-2005  wiz Add a comma for readability.
 1.32 19-Apr-2005  lukem remove bogus punctuation
 1.31 19-Apr-2005  lukem Clarify getpw*_r() return value when entry isn't found.
Improve markup of various constants.
 1.30 04-Apr-2005  wiz Use Dq macro; end sentence with a dot; break line
differently so that abbreviation dot is not interpreted as line-ending dot.
 1.29 04-Apr-2005  wiz Remove superfluous comma.
 1.28 04-Apr-2005  christos Describe get{pw,gr}ent_r. XXX: Are they in any standards?
 1.27 31-Mar-2005  wiz Drop trailing whitespace.
 1.26 31-Mar-2005  christos Document the return values of the _r functions.
 1.25 05-Oct-2004  wiz branches: 1.25.2;
Add missing function types for getpwnam_r and getpwuid_r.
 1.24 05-Oct-2004  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.
This makes it much easier to write dynamic nsswitch backends for getpwent(3).
Per my proposal on tech-userlevel.

Implement getpwgid_r() and getpwnam_r() APIs per the POSIX 1003.1, 2004 Ed.
These aren't fully reentrant or threadsafe yet, because the compat stuff
currently uses non-reentrant data sources (getnetgrent(3), getpwent(3)),
and there is probably some locking to be improved in the backends.
This will be fixed in the near future.
We also need to add _SC_GETPW_R_SIZE_MAX to sysconf(3).

Fix the compat `+' prototype override so getpwnam(3) and getpwuid(3) DTRT.

Improve the description of pw_class and pw_gecos.
 1.23 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.22 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.21 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.20 29-Apr-2002  simonb Remove <sys/types.h> from synopsis, as per latest SUS/Posix specs.
 1.19 07-Feb-2002  ross Generate <>& symbolically.
 1.18 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.17 16-Sep-2001  wiz Boring whitespace fixes.
 1.16 11-Jul-2000  ad branches: 1.16.2;
Xr passwd.conf
 1.15 25-Apr-1999  lukem * highlight that getpwent() doesn't suppress duplicate info from multiple
nsswitch.conf sources
* consistently refer to `functions', rather than occasionally referring
to them as `routines'.
 1.14 16-Jan-1999  lukem branches: 1.14.2;
reference nsswitch.conf(5)
 1.13 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.12 05-Feb-1998  perry add LIBRARY section to man page
 1.11 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.10 14-Jul-1997  mikel xref getlogin(2) not getlogin(3)
 1.9 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.8 03-Mar-1997  cjs PR 3279, from <david@mono.org>.
Bugs section changed to clarify that static passwd structure
used for return value is shared among all functions.
 1.7 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.6 03-Jan-1995  jtc Password databases live in /etc, not /var/db. (PR #685)
 1.5 10-Jan-1994  jtc Fix spelling errors.
 1.4 25-Oct-1993  jtc Update source and manual pages to match X/Open 1170 specification.
Updated setpassent() to understand YP (a bug), and changed setpwent()
to simply be a call to setpassent(0) (to remove duplicated code).
 1.3 25-Oct-1993  jtc X/Open 1170 defines the return type of setpwent() to be void -- a trival
change since our setpwent() allways succeeded.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14.2.1 27-Apr-1999  perry pullup 1.14->1.15 (lukem)
 1.16.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.16.2.4 21-Jun-2002  nathanw Catch up to -current.
 1.16.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.16.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.16.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.25.2.10 11-Jul-2005  tron Pull up revision 1.35 (requested by lukem in ticket #540):
Bump date for standards.
 1.25.2.9 11-Jul-2005  tron Pull up revision 1.33 (requested by lukem in ticket #540):
Add a comma for readability.
 1.25.2.8 11-Jul-2005  tron Pull up revision 1.32 (requested by lukem in ticket #540):
remove bogus punctuation
 1.25.2.7 11-Jul-2005  tron Pull up revision 1.31 (requested by lukem in ticket #540):
Clarify getpw*_r() return value when entry isn't found.
Improve markup of various constants.
 1.25.2.6 11-Jul-2005  tron Pull up revision 1.30 (requested by lukem in ticket #540):
Use Dq macro; end sentence with a dot; break line
differently so that abbreviation dot is not interpreted as line-ending dot.
 1.25.2.5 11-Jul-2005  tron Pull up revision 1.29 (requested by lukem in ticket #540):
Remove superfluous comma.
 1.25.2.4 11-Jul-2005  tron Pull up revision 1.28 (requested by lukem in ticket #540):
Describe get{pw,gr}ent_r. XXX: Are they in any standards?
 1.25.2.3 11-Jul-2005  tron Pull up revision 1.27 (requested by lukem in ticket #540):
Drop trailing whitespace.
 1.25.2.2 28-May-2005  tron Pull up revision 1.34 (requested by kleink in ticket #345):
Truth, meet standards section. Standards section, meet truth.
 1.25.2.1 04-Apr-2005  tron Pull up revision 1.26 (requested by thorpej in ticket #100):
Document the return values of the _r functions.
 1.35.18.1 18-May-2008  yamt sync with head.
 1.36.8.2 30-Apr-2008  christos Mention errno settings on failure.
 1.36.8.1 30-Apr-2008  christos file getpwent.3 was added on branch christos-time_t on 2008-04-30 14:51:11 +0000
 1.38.26.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.84 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.83 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.82 14-Jan-2017  christos don't include machine/param.h <sys/param.h> already does WTF?
 1.81 08-Sep-2012  dholland branches: 1.81.14;
Revert previous temporary measure and fix the assertion properly instead.
 1.80 07-Sep-2012  dholland Disable bogus _DIAGASSERT.
 1.79 29-Mar-2012  christos PR/46279: Dr. W. Stukenbrock: Off-by-one in buffer length check and make sure
that the password fits in the supplied buffer.
 1.78 29-Mar-2012  christos PR?40728: W. Stukenbrock: Fix various issues with NIS-netgroups in users
and groups.
 1.77 23-Mar-2010  drochner branches: 1.77.6; 1.77.8;
remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable
 1.76 11-Jan-2009  christos merge christos-time_t
 1.75 28-Apr-2008  martin branches: 1.75.8;
Remove clause 3 and 4 from TNF licenses
 1.74 03-Feb-2007  christos branches: 1.74.10;
make this compile with DIAGNOSTIC
 1.73 15-Oct-2006  christos fix incomplete initializers
 1.72 29-Jun-2006  ginsbach Fix YP lookup latency reported by Stephen M. Jones on tech-net. This is a
performance regression between 2.0 and 3.0. The passwd compat method was
incorrectly querying the NIS server with yp_first()/yp_next() rather than
using yp_match() with the correct key.
 1.71 19-Mar-2006  christos Coverity CID 708: Remove dead code.
 1.70 05-Jun-2005  lukem Cosmetic tweak previous; IMHO we don't need the XXX comment in this
case, since I prefer to NULL initialize variables in this situation.
 1.69 04-Jun-2005  he Add an initialization to appease -Wuninitialized. Apparently the
sparc64 compiler gets this wrong.
 1.68 19-Apr-2005  lukem getpw{ent,nam,uid}_r():
Return 0 "entry not found" and errno for other failures.
("entry not found" still sets *result to NULL).

Various backends:
don't set the retval to errno (or modify errno) for NS_NOTFOUND.

Per discussion with Klaus Klein.
 1.67 02-Apr-2005  christos PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.66 28-Feb-2005  lukem branches: 1.66.2;
Restore getpwent() behaviour prior to rev 1.57; skip dodgy NIS & DNS entries
rather than failing with NS_UNAVAIL when encountering them.
Fixes PR 29272 by Antoine Reilles.
 1.65 10-Nov-2004  lukem Use the common __nsdefaultFOO rather than private defaultFOO duplicates.
 1.64 10-Nov-2004  lukem Use _GETPW_R_SIZE_MAX from <limits.h> rather than defining a private version.
 1.63 01-Nov-2004  lukem default to "compat" not "files"
 1.62 29-Oct-2004  lukem #include "reentrant.h" instead of <threadlib.h>
 1.61 24-Oct-2004  lukem Protect access to all public functions via a mutex as some of the backends are
not reentrant (such as compat, because it uses the non reentrant getnetgrent(3)
to implement `+@netgrp' & `-@netgrp').
 1.60 11-Oct-2004  lukem Fix MKYP=no MKHESIOD=no build.
Rename an internal function to a more appropriate name.
 1.59 07-Oct-2004  lukem Ensure that _nis_start(&state) has been called before using PASSWD_BYNAME()
or PASSWD_BYUID(), otherwise state.maptype won't be correct and the wrong
map may be selected (e.g., "passwd.by*" instead of "master.passwd.by*").

Set _PASSWORD_NOWARN in flags to __pw_scan(), so libc won't display parse
errors to stderr. (This was the behaviour before my recent rototill.)

Fixes PR 27168 from Markus W Kilbinger.
 1.58 05-Oct-2004  lukem Use PASSWD_BYxxx(state) macros instead of "passwd.byxxx" to refer to
the NIS "passwd.by*" maps.
Fixes problem with "passwd_compat: nis" noted by Matthias Scheler.
 1.57 05-Oct-2004  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.
This makes it much easier to write dynamic nsswitch backends for getpwent(3).
Per my proposal on tech-userlevel.

Implement getpwgid_r() and getpwnam_r() APIs per the POSIX 1003.1, 2004 Ed.
These aren't fully reentrant or threadsafe yet, because the compat stuff
currently uses non-reentrant data sources (getnetgrent(3), getpwent(3)),
and there is probably some locking to be improved in the backends.
This will be fixed in the near future.
We also need to add _SC_GETPW_R_SIZE_MAX to sysconf(3).

Fix the compat `+' prototype override so getpwnam(3) and getpwuid(3) DTRT.

Improve the description of pw_class and pw_gecos.
 1.56 26-Nov-2003  lukem Fix compile problem if -UYP -DHESIOD.
Noted on current-users by Srinivasa Kanduru.
 1.55 13-Oct-2003  agc Move Jason Downs's code from a 4-clause to a 3-clause licence by
removing the advertising clause. Diffs provided in PR 22410 by Joel
Baker, confirmed to the board by Jason Downs.

With additional thanks to Jason Thorpe.
 1.54 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.53 17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.52 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.51 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.50 16-Apr-2002  groo botched strncpy -> strlcpy
from xs@kittenz.org
 1.49 12-Feb-2002  mycroft Just return an error if we try to look up a user name that's too long, rather
than trying to truncate. The previous truncation code actually set key.size
too large and caused a (non-exploitable) core dump inside DB.
 1.48 03-Oct-2000  enami branches: 1.48.2;
Reset allocated buffer size to 0 on allocation failure.
 1.47 02-Oct-2000  simonb Fix potential buffer overflow processing long password database entries.
Inspired by similar OpenBSD change.
 1.46 22-Jan-2000  mycroft branches: 1.46.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.45 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.44 27-Apr-1999  ross Unconditionalize `rval' declaration referenced in usr.bin/chpass/ via .PATH
 1.43 26-Apr-1999  lukem change dns_getpw() to skip dodgy entries when doing getpwent(), rather
than returning NS_UNAVAIL. this means that a -ve uid entry in hesiod
doesn't stop getpwent() in its tracks. it also brings it in line with
how nis_getpw() works as well in this situation.
problem tracked down (with much pain & suffereing) by simonb.

XXX: we currently have no support for -ve uids, and this is painful in
XXX: hetrogenous environment... (this -ve check is enforced in __pwscan())
 1.42 25-Apr-1999  lukem change getpwent() backends so that a flag (per source) is set once the
source has been exhausted. this allows getpwent() across multiple
sources (e.g, ``passwd: files nis'') to work correctly. the flags are
reset in setpassent()/endpwent().

this fixes a bug noted in [lib/7449] by thorpej, and tracked down to
getpwent() as being the culprit by simonb.
 1.41 18-Apr-1999  lukem specifically include stdarg/varargs.h
 1.40 26-Jan-1999  lukem branches: 1.40.2;
always compile in support for `compat' backends (even if !YP & !HESIOD),
and make it the responsibility of the backends to fallback to `files'
if !YP & !HESIOD. fixes chsh problem noted by billc@netbsd.org.
 1.39 25-Jan-1999  lukem convert from hes_*() -> hesiod_*()
 1.38 21-Jan-1999  mycroft Use the right map for Hesiod lookups by uid.
 1.37 20-Jan-1999  christos - remove unneeded casts
- remove unreachable code
- delint
 1.36 19-Jan-1999  lukem * `passwd' defaults to `compat', and `passwd_compat' defaults to `nis'
* constify ns_dtab defs
 1.35 19-Jan-1999  lukem * maximum limit of names is MAXLOGNAME not UT_NAMESIZE. fixes [bin/6847] from
scott ellis.
* convert to new nsdispatch(3)
 1.34 18-Jan-1999  lukem * fix _compat_getpw so that it returns _local_getpw(...) if there
isn't a `+' token in the files database.
(this bug probably crept in when a merge to current occurred)
* ensure that the _bad_getpw callbacks in __getpwcompat have an
argument for error reporting.
 1.33 16-Jan-1999  lukem fix some uid casts
 1.32 16-Jan-1999  lukem pull nsswitch up to main branch
 1.31 13-Nov-1998  christos avoid assignment of a read only location that lint does not pick, but gcc does.
 1.30 12-Nov-1998  christos delint
 1.29 26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.28 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.27 27-Jun-1998  thorpej Fix a serious symbol collision problem introduced when pw_scan() was added
to libc. Note, pw_scan() is NO LONGER exported from libc (it never should
have been, and we're just going to pretend like it never was).
 1.26 08-Jun-1998  lukem * move pw_scan() from libutil to libc
* add support for YP "master.passwd.by*" (master.passwd in YP, including
pw_passwd) and "passwd.adjunct.by*" (SunOS `secure' maps (?)), based
on code in FreeBSD and partially from OpenBSD.
this is only used if euid == 0.
with this, the YP "passwd.by*" maps can have `*' in the pw_passwd field.
* use pw_scan() to parse YP "passwd.by*" and "master.passwd.by*" entries

XXX: i didn't test the "passwd.adjunct" support...
 1.25 10-Feb-1998  mrg allow root to use pwd.db.
 1.24 02-Feb-1998  perry merge/update to lite-2
 1.23 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.22 13-Jul-1997  christos Fix gcc warnings (unused variables, missing prototypes, etc.)
Fix RCSID's
 1.21 22-May-1997  lukem branches: 1.21.2;
a valid uid/gid *ends* in \0 (i.e, barf if (*ep != '\0'), not if (*ep == '\0'))
 1.20 22-May-1997  lukem * parse gid with strtoul() instead of atoi(), and sanity check a) the parsed
value was just a number, b) it doesn't exceed GID_MAX
* convert gid to a string with %u not %d
* use [gu]id_t instead of int
 1.19 22-May-1997  lukem * parse uid with strtoul() instead of atoi(), and sanity check a) the parsed
value was just a number, b) it doesn't exceed UID_MAX
* convert uid to a string with %u not %d
 1.18 21-May-1997  lukem fix potential memory leaks: before calling yp_next(), reset key to NULL. if
an error occurred, and key != NULL, free(key).
 1.17 20-May-1997  lukem * fix [lib/3580], by ensuring that the outdata arg to the yp_xxx()
calls is initialised to the null pointer so that the error condition
doesn't fail by trying to free() memory that wasn't malloc()ed
* cleanup a bit; remove use of register, KNFify
 1.16 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.15 20-Dec-1996  sommerfe Longer login name support: use MAXLOGNAME, not UT_NAMESIZE
 1.14 28-Jul-1995  phil branches: 1.14.4; 1.14.8;
Improvements to YP support from Jason Downs.
 1.13 17-May-1995  mycroft Modify getpwent() to use __ypparse().
 1.12 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.11 09-Mar-1994  deraadt branches: 1.11.4;
__initdb() should only warn about spwd.db errors once, fix from
Cornelis van der Laan <nils@merlin.ims.uni-stuttgart.de>
 1.10 10-Dec-1993  deraadt speed up getpwnam/getpwuid for standard cases
 1.9 25-Oct-1993  jtc Update source and manual pages to match X/Open 1170 specification.
Updated setpassent() to understand YP (a bug), and changed setpwent()
to simply be a call to setpassent(0) (to remove duplicated code).
 1.8 25-Oct-1993  jtc X/Open 1170 defines the return type of setpwent() to be void -- a trival
change since our setpwent() allways succeeded.
 1.7 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.6 30-Jul-1993  mycroft Add even more RCS frobs.
 1.5 24-Jul-1993  deraadt fixed a yp-related bug found by Paul Kranenburg <pk@cs.few.eur.nl>:
endpwent was free'ing passwd line.
 1.4 04-May-1993  deraadt I was horrified to find these had not been commited with the YP changes.
 1.3 21-Apr-1993  proven Opps, dbopen doesn't have an underscore. Fixed.
 1.2 21-Apr-1993  proven Fixed these twon files to use db_open instead of hash_open.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.4.1 02-May-1995  jtc #include "namespace.h"
 1.14.8.1 06-Nov-1996  lukem initial nsswitch implementation
 1.14.4.2 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.14.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.21.2.6 14-Jan-1999  lukem use new ns_dtab structure
 1.21.2.5 22-Nov-1998  lukem missed an #if
 1.21.2.4 02-Nov-1998  lukem sync with current
 1.21.2.3 02-Jun-1997  lukem * set _pw_none = 1 && return NS_SUCCESS in _*_getpwent() at EOF, so that
getpwent() won't merge sources.
 1.21.2.2 26-May-1997  lukem only initialise ns_dtab if it hasn't been done yet
 1.21.2.1 24-May-1997  lukem convert to using nsdispatch()
 1.40.2.2 27-Apr-1999  perry pullup 1.43->1.44 (ross)
 1.40.2.1 27-Apr-1999  perry pullup 1.41->1.43 (lukem)
 1.46.4.4 17-Apr-2002  he Pull up revision 1.50 (requested by groo):
Replace an instance of erroneous usage of strncpy() with strlcpy().
 1.46.4.3 17-Apr-2002  he Pull up revision 1.49 (requested by he):
Return an error if we try to look up a user name that is too long,
rather than trying to truncate. Fixes non-exploitable core dump
problem inside DB.
 1.46.4.2 11-Oct-2000  enami Pull up rev. 1.48 (approved by jhawk):
Reset allocated buffer size to 0 on allocation failure.
 1.46.4.1 02-Oct-2000  simonb Pull up rev 1.47 (approved by thorpej):
Fix potential buffer overflow processing long password database entries.
Inspired by similar OpenBSD change.
 1.48.2.6 10-Dec-2002  thorpej Sync with HEAD.
 1.48.2.5 11-Nov-2002  nathanw Catch up to -current
 1.48.2.4 21-Jun-2002  nathanw Catch up to -current.
 1.48.2.3 25-Apr-2002  nathanw Catch up to -current.
 1.48.2.2 22-Mar-2002  nathanw Catch up to -current.
 1.48.2.1 08-Mar-2002  nathanw Catch up to -current.
 1.66.2.3 13-Jul-2006  ghen Pull up following revision(s) (requested by ginsbach in ticket #1399):
lib/libc/gen/getpwent.c: revision 1.72
Fix YP lookup latency reported by Stephen M. Jones on tech-net. This is a
performance regression between 2.0 and 3.0. The passwd compat method was
incorrectly querying the NIS server with yp_first()/yp_next() rather than
using yp_match() with the correct key.
 1.66.2.2 11-Jul-2005  tron Pull up revision 1.68 (requested by lukem in ticket #540):
getpw{ent,nam,uid}_r():
Return 0 "entry not found" and errno for other failures.
("entry not found" still sets *result to NULL).
Various backends:
don't set the retval to errno (or modify errno) for NS_NOTFOUND.
Per discussion with Klaus Klein.
 1.66.2.1 11-Jul-2005  tron Pull up revision 1.67 (requested by lukem in ticket #540):
PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.74.10.1 18-May-2008  yamt sync with head.
 1.75.8.3 28-Dec-2008  christos don't hard-code 8.
 1.75.8.2 23-Nov-2008  christos - add a VERSION tag in the db files to handle new and old version passwd
entries.
XXX: Need to add the tag in mkpasswd.
 1.75.8.1 28-Apr-2008  christos file getpwent.c was added on branch christos-time_t on 2008-11-23 21:44:07 +0000
 1.77.8.1 07-Nov-2013  snj Pull up following revision(s) (requested by christos in ticket #979):
lib/libc/gen/getpwent.c: revision 1.79
PR/46279: Dr. W. Stukenbrock: Off-by-one in buffer length check and make sure
that the password fits in the supplied buffer.
 1.77.6.2 30-Oct-2012  yamt sync with head
 1.77.6.1 17-Apr-2012  yamt sync with head
 1.81.14.1 20-Mar-2017  pgoyette Sync with HEAD
 1.5 19-Mar-1998  fair remove getsubopt.3 - there is another man page for this in ../stdlib that came from the Lite2 merge. This closes PR4600
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13 09-May-2004  kleink There are two instances of getsubopt.c, one in gen, which came by the
ways of 386BSD, and one in stdlib, which is from Lite-2. The former was
picked up by the build process and has seen a little more maintenance
while the latter's location is "right", so bring the latter up to par
with the former and dispose of the (now) latter.

Reported by David A. Holland in PR lib/25160, which is worded in a
far less mind-boggling fashion than the above.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 16-Jun-1995  jtc branches: 1.5.4;
getsubopt() uses strcmp(), so include <string.h>
 1.4 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.21 07-Feb-2014  christos don't lie about function signatures.
 1.20 22-Apr-2012  wiz branches: 1.20.2;
Sort SEE ALSO.
 1.19 21-Apr-2012  roy Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.18 23-Apr-2006  wiz branches: 1.18.44;
No abbreviations in Dd arguments.
 1.17 18-Apr-2006  salo Add setttyentpath() information to RETURN VALUES and HISTORY, too.
 1.16 17-Apr-2006  salo Add setttyentpath(), functionally equivalent to setttyent() but takes an
additional argument to read the ttys information from an alternate path
istead of _PATH_TTYS.

Required for upcoming init(8) changes.

Mostly from <apb>.

Bump libc minor.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 22-Mar-1999  garbled branches: 1.11.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.10 15-Jan-1999  tsarna Add a "class" entry to ttyent. Closes PR#4638.
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 20-Oct-1997  scottr Add support for DTR/CTS flow control, from Bill Studenmund.
 1.7 17-Mar-1996  christos Add missing documentation for TTY_MDMBUF.
 1.6 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.5 30-Mar-1994  cgd typo
 1.4 18-Mar-1994  cgd update for new flag
 1.3 12-Mar-1994  cgd add some new flags for /etc/ttys' status field
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.12.3 18-Oct-2002  nathanw Catch up to -current.
 1.11.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.11.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.18.44.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.18.44.1 23-May-2012  yamt sync with head.
 1.20.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26 30-Jun-2013  martin Rearrange to make lint deal with it (to unbreak the build).
Someone please (1) fix lint and then (2) back this out ;-)
 1.25 30-Jun-2013  matt When opening a ttys files, try path.<machine> first. This helps
machine archs which have multiple ttys files (arm, mips, powerpc, m68k, sh3)
 1.24 15-Oct-2011  christos branches: 1.24.2; 1.24.8;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.23 17-Apr-2006  salo Add setttyentpath(), functionally equivalent to setttyent() but takes an
additional argument to read the ttys information from an alternate path
istead of _PATH_TTYS.

Required for upcoming init(8) changes.

Mostly from <apb>.

Bump libc minor.
 1.22 14-May-2005  christos make sure ty_class is cleared on each entry.
 1.21 10-Nov-2004  christos branches: 1.21.2;
PR/28183: Brian Marcotte: Getty eats the last character of the last field.
As Brian reports the bug is in skip(). The logic on end of line is broken.

- fix the bug which can cause buf[-1] to be written.
- don't leave the line buffer allocated on end of file.
- KNF
- use __func__ instead of hard-coding the function name.
- don't use needlessly global variables
 1.20 07-Aug-2003  agc branches: 1.20.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.19 20-Apr-2003  christos PR/5265: John Buller: ttyflags does not report syntax errors or unknown
tty options in /etc/ttys
Make this use fparseln and use warn and warnx to report problems.
 1.18 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.15 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.14 15-Jan-1999  tsarna Add a "class" entry to ttyent. Closes PR#4638.
 1.13 03-Feb-1998  perry remove obsolete register declarations
 1.12 20-Oct-1997  scottr Add support for DTR/CTS flow control, from Bill Studenmund.
 1.11 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.10 13-Jul-1997  christos Fix gcc warnings
Add missing prototypes
Fix RCSID's
 1.9 16-Jun-1995  jtc branches: 1.9.4;
Don't cast void functions to void.
 1.8 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.7 30-Mar-1994  cgd oops!
 1.6 18-Mar-1994  cgd update for new flag
 1.5 12-Mar-1994  cgd add some new flags for /etc/ttys' status field
 1.4 24-Nov-1993  jtc Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.20.4.1 13-May-2005  riz Pull up revision 1.21 (requested by is in ticket #1396):
PR/28183: Brian Marcotte: Getty eats the last character of the last field.
As Brian reports the bug is in skip(). The logic on end of line is broken.
- fix the bug which can cause buf[-1] to be written.
- don't leave the line buffer allocated on end of file.
- KNF
- use __func__ instead of hard-coding the function name.
- don't use needlessly global variables
 1.21.2.1 05-Jul-2005  tron Pull up revision 1.22 (requested by lukem in ticket #528):
make sure ty_class is cleared on each entry.
 1.24.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.2.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.11 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.10 23-Nov-2004  lukem document which #include file to use
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 22-Mar-1999  garbled branches: 1.6.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 16-Jan-1999  lukem reference nsswitch.conf(5)
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.12.2 18-Oct-2002  nathanw Catch up to -current.
 1.6.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.29 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.28 15-Oct-2011  christos branches: 1.28.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.27 28-Apr-2008  martin branches: 1.27.8;
Remove clause 3 and 4 from TNF licenses
 1.26 15-Oct-2006  christos branches: 1.26.16;
fix incomplete initializers
 1.25 29-Nov-2005  christos WARNS=4
 1.24 28-Feb-2005  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.

This makes it much easier to write dynamic nsswitch backends for the
getusershell(3) (et al) functions.

Per my proposal on tech-userlevel in September 2004.
 1.23 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.22 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.21 07-Jul-2000  itohy branches: 1.21.2;
Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.20 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.19 28-Nov-1999  lukem * check the error return of sl_init() and sl_add()
* minor KNF
 1.18 18-Apr-1999  lukem branches: 1.18.4;
specifically include stdarg/varargs.h
 1.17 25-Jan-1999  lukem convert from hes_*() -> hesiod_*()
 1.16 20-Jan-1999  christos - avoid unitialized warning.
- remove unreachable code.
- add ARGSUSED
- linted for const castaway.
 1.15 19-Jan-1999  lukem * `passwd' defaults to `compat', and `passwd_compat' defaults to `nis'
* constify ns_dtab defs
 1.14 19-Jan-1999  lukem convert to new nsdispatch(3)
 1.13 16-Jan-1999  lukem pull nsswitch up to main branch
 1.12 13-Nov-1998  christos delint
 1.11 13-Nov-1998  christos delint
 1.10 27-Jul-1998  mycroft Make these compile without __AUDIT__.
 1.9 26-Jul-1998  mycroft const poisoning.
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 27-Feb-1995  cgd branches: 1.5.4; 1.5.8; 1.5.10;
update from Lite, with local changes. fix Ids, etc.
 1.4 26-Aug-1993  jtc branches: 1.4.4;
Declare rcsid strings so they are stored in text segment.
 1.3 25-Aug-1993  jtc Declare static function before it is used.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 02-May-1995  jtc #include "namespace.h"
 1.5.10.6 14-Jan-1999  lukem use new ns_dtab structure
 1.5.10.5 02-Nov-1998  lukem sync with current
 1.5.10.4 27-May-1997  lukem * don't bother fstat()ing the file once it's open; as the result isn't used.
* only invoke sl_free(sl, ...) if (sl != NULL)
* remove use of register
* other minor cleanups
 1.5.10.3 26-May-1997  lukem only initialise ns_dtab if it hasn't been done yet
 1.5.10.2 24-May-1997  lukem refer to StringList type correctly
 1.5.10.1 23-May-1997  lukem convert getusershell() to nsswitch, adding yp and hesiod support
 1.5.8.1 06-Nov-1996  lukem initial nsswitch implementation
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.18.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.21.2.1 21-Jun-2002  nathanw Catch up to -current.
 1.26.16.1 18-May-2008  yamt sync with head.
 1.27.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.27.8.1 28-Apr-2008  martin file getusershell.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.28.2.1 17-Apr-2012  yamt sync with head
 1.3 02-Feb-1998  perry it turns out we don't want getvfsbyname after all.
 1.2 02-Feb-1998  perry merge/update to lite-2
 1.1 02-Feb-1998  perry branches: 1.1.1;
Initial revision
 1.1.1.1 02-Feb-1998  perry import lite-2
 1.3 02-Feb-1998  perry it turns out we don't want getvfsbyname after all.
 1.2 02-Feb-1998  perry merge/update to lite-2
 1.1 02-Feb-1998  perry branches: 1.1.1;
Initial revision
 1.1.1.1 02-Feb-1998  perry import lite-2
 1.45 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.44 29-May-2019  christos Add GLOB_TILDE_CHECK (from GNU)
 1.43 03-Jul-2017  wiz branches: 1.43.6;
Remove workaround for ancient HTML generation code.
 1.42 27-Dec-2012  christos Instead of changing the code to match the documentation, change the documentation
to match the code. NOCHECK is used only by csh(1) and csh(1) is too broken for
words (histchars quoting is "special").
 1.41 12-Aug-2012  christos branches: 1.41.2;
more markup, sort options
 1.40 25-Oct-2011  wiz branches: 1.40.2;
Fix function prototype. From Henning Petersen in PR 45516.
 1.39 30-Nov-2010  jruoho Xref glob(7).
 1.38 06-Sep-2010  christos Add GLOB_STAR support from Greg Dionne.
 1.37 06-Jul-2010  christos Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
 1.36 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.35 11-Apr-2009  joerg Fix markup.
 1.34 08-Apr-2009  wiz Add glob_pattern_p to NAME section.
 1.33 08-Apr-2009  christos add glob_pattern_p for glibc because cvs needs it and it is a huge mess
to compile in the gnu glob code.
 1.32 22-Feb-2008  christos branches: 1.32.8; 1.32.12; 1.32.14; 1.32.16;
GLOB_NO_DOTDIRS patch from mouse@
Fixes re-definition of GLOB_PERIOD.
 1.31 05-Dec-2007  christos branches: 1.31.4;
From Richard M Kreuter, add GLOB_PERIOD.
 1.30 26-Mar-2006  christos branches: 1.30.4; 1.30.10; 1.30.12;
PR/33123: Murray Armfield: standards compliance & glob.h
Certain fields in glob.h need to be size_t; fix this and version glob(3).
http://www.opengroup.org/onlinepubs/000095399/basedefs/glob.h.html
 1.29 08-Dec-2003  grant "int flags" is correct in the prototype, but not in the English
language. s/int/in/
 1.28 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.27 27-Jun-2003  wiz Quote question mark and brace.
 1.26 01-May-2003  wiz Grammar and mdoc fixes from jmc@openbsd.
 1.25 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.24 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.23 07-Feb-2002  ross generate & symbolically
 1.22 07-Feb-2002  ross Generate <>& symbolically.
 1.21 28-Oct-2001  kleink Partially back out previous: don't apply restrict qualifier to pointer
to function.
 1.20 27-Oct-2001  kleink Sprinkle some __restrict into <glob.h>.
 1.19 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.18 16-Sep-2001  wiz Boring whitespace fixes.
 1.17 16-Mar-2001  christos limit the amount of memory used, not the number of arguments used.
 1.16 16-Mar-2001  christos Implement GLOB_LIMIT that limits number of matches to ARG_MAX.
 1.15 19-Jun-1998  kleink branches: 1.15.12;
* Remove GLOB_QUOTE, add GLOB_NOESCAPE. Per POSIX, backslash quoting of
special characters is the default behaviour, which may be disabled by
setting GLOB_NOESCAPE.
* If no matching pathnames have been found and GLOB_NOCHECK was not set
(or special csh(1)-specific treatment of magic characters was requested),
return GLOB_NOMATCH instead of 0; the latter would indicate a successful
operation.
* Use strcoll() instead of strcmp() to sort globbed pathnames.
 1.14 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.13 31-Mar-1998  kleink Replace the old GLOB_ABEND constant with (the standardized) GLOB_ABORTED,
and explicitly state that the former is no longer supported.
 1.12 05-Feb-1998  perry add LIBRARY section to man page
 1.11 28-Dec-1997  lukem note that $HOME is used in ~/ globs
 1.10 19-Apr-1996  cgd fix a couple of typesetting and grammatical errors in GLOB_BRACE's description
 1.9 27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.8 06-Jan-1994  deraadt glob_t not GLOB_t. pointed out by <lm@rmit.edu.au>
 1.7 03-Dec-1993  cgd get rid of extra RCS Id in header
 1.6 30-Nov-1993  jtc Use ".Va" macro when formatting "errno".
 1.5 25-Nov-1993  jtc Misc manpage fixes.
 1.4 06-Nov-1993  cgd update to latest version.
 1.3 30-Jul-1993  mycroft Add RCS identifiers.
 1.2 30-Jul-1993  mycroft Latest versions from uunet.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.15.12.5 18-Oct-2002  nathanw Catch up to -current.
 1.15.12.4 22-Mar-2002  nathanw Catch up to -current.
 1.15.12.3 08-Mar-2002  nathanw Catch up to -current.
 1.15.12.2 14-Nov-2001  nathanw Catch up to -current.
 1.15.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.30.12.1 05-Aug-2010  riz Pull up following revision(s) (requested by christos in ticket #1399):
lib/libc/gen/glob.c: patch
lib/libc/gen/glob.3: revision 1.37 via patch
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
 1.30.10.2 23-Mar-2008  matt sync with HEAD
 1.30.10.1 09-Jan-2008  matt sync with HEAD
 1.30.4.1 05-Aug-2010  riz Pull up following revision(s) (requested by christos in ticket #1399):
lib/libc/gen/glob.c: patch
lib/libc/gen/glob.3: revision 1.37 via patch
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
 1.31.4.1 24-Mar-2008  keiichi sync with head.
 1.32.16.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.32.14.1 19-Jul-2010  riz Pull up following revision(s) (requested by christos in ticket #1430):
lib/libc/gen/glob.c: revision 1.25
lib/libc/gen/glob.c: revision 1.26
lib/libc/gen/glob.3: revision 1.37
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
Avoid DoS attacks for patterns that have braces. Noted by Maksymilian
Arciemowicz.
XXX: Pullup to 5.x
 1.32.12.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.32.8.1 19-Jul-2010  riz Pull up following revision(s) (requested by christos in ticket #1430):
lib/libc/gen/glob.c: revision 1.25
lib/libc/gen/glob.c: revision 1.26
lib/libc/gen/glob.3: revision 1.37
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
Avoid DoS attacks for patterns that have braces. Noted by Maksymilian
Arciemowicz.
XXX: Pullup to 5.x
 1.40.2.2 23-Jan-2013  yamt sync with head
 1.40.2.1 30-Oct-2012  yamt sync with head
 1.41.2.1 25-Feb-2013  tls resync with head
 1.43.6.1 10-Jun-2019  christos Sync with HEAD
 1.39 29-May-2019  christos Add GLOB_TILDE_CHECK (from GNU)
 1.38 08-May-2017  christos branches: 1.38.10;
use the symbolic M_ALL and trim with M_MASK
 1.37 26-Apr-2017  christos Switch from a recursive pattern matching algorithm to handle '*'
to a backtracking one. Avoids DoS attacks with patterns "a*a*a*a*a*...b"
matching against "aaaaaaaaaaaa..." https://research.swtch.com/glob
 1.36 04-Sep-2016  joerg branches: 1.36.4;
Bump the glob limits to 512KB for total string size and 64K path
entries. The old limits were too small for some important FTP use cases
like a pkgsrc repository.
 1.35 20-Mar-2013  lukem branches: 1.35.8; 1.35.10; 1.35.14;
Use "unsigned FOO" instead of less-portable "u_FOO".
 1.34 21-Feb-2013  christos remove code that did special handling for . and .. at the end of the path.
From mouse@
 1.33 27-Dec-2012  christos Instead of changing the code to match the documentation, change the documentation
to match the code. NOCHECK is used only by csh(1) and csh(1) is too broken for
words (histchars quoting is "special").
 1.32 18-Dec-2012  christos Do as the man page says, and for GLOB_NOCHECK return the original pattern,
not a modified version with the backslash characters removed.
 1.31 30-Oct-2011  christos branches: 1.31.2; 1.31.4; 1.31.8;
PR/45517: Henning Petersen: Add restrict keywords in the definition of glob
to match the declaration.
 1.30 14-May-2011  christos PR/44959: Henning Petersen: glob forgets to closedir on out of space condition.
 1.29 22-Jan-2011  christos remove stray printf.
 1.28 21-Jan-2011  christos prevent resource DoS from brace expansion (from Maksymilian Arciemowicz)
 1.27 06-Sep-2010  christos branches: 1.27.2;
Add GLOB_STAR support from Greg Dionne.
 1.26 06-Jul-2010  christos Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
 1.25 02-Jul-2010  christos Avoid DoS attacks for patterns that have braces. Noted by Maksymilian
Arciemowicz.
XXX: Pullup to 5.x
 1.24 08-Apr-2009  christos add glob_pattern_p for glibc because cvs needs it and it is a huge mess
to compile in the gnu glob code.
 1.23 26-May-2008  ad branches: 1.23.4; 1.23.6; 1.23.8; 1.23.10; 1.23.12;
Fedora Core 9 doesn't provide ARG_MAX, so use _POSIX_ARG_MAX if it's
not available.
 1.22 22-Feb-2008  christos branches: 1.22.2; 1.22.4;
GLOB_NO_DOTDIRS patch from mouse@
Fixes re-definition of GLOB_PERIOD.
 1.21 01-Feb-2008  christos branches: 1.21.2;
Try to fix previous commit of /.. and /. handling for GLOB_PERIOD. I will
write a regression test for this.
 1.20 18-Jan-2008  christos From Richard M Kreuter: GLOB_PERIOD fix for trailing ./ or ../
 1.19 05-Dec-2007  christos From Richard M Kreuter, add GLOB_PERIOD.
 1.18 01-Dec-2006  christos branches: 1.18.2; 1.18.8; 1.18.10;
ansi, minor knf, no functional change.
 1.17 24-Nov-2006  christos fix spelling of accommodate; from Zapher.
 1.16 26-Mar-2006  christos PR/33123: Murray Armfield: standards compliance & glob.h
Certain fields in glob.h need to be size_t; fix this and version glob(3).
http://www.opengroup.org/onlinepubs/000095399/basedefs/glob.h.html
 1.15 24-Jan-2006  christos Use a separate macro, not DEBUG to enforce 8 bit chars [glob uses internally
16 bit chars]. Fix lint complaint when compiling with 8 bit chars.
 1.14 29-Nov-2005  christos WARNS=4
 1.13 13-Sep-2005  elad Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
 1.12 13-Sep-2005  christos compat core reorg.
 1.11 04-Dec-2003  keihan netbsd.org -> NetBSD.org
NetBSD.ORG -> NetBSD.org

Now src/lib is done.
 1.10 22-Oct-1997  thorpej Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.9 22-Oct-1997  fvdl New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.
 1.8 21-Oct-1997  fvdl branches: 1.8.2;
Hacks to enable libc to work without bumping the major.
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix readdirfunc prototype
Fix RCSID's
 1.5 27-Feb-1995  cgd branches: 1.5.4;
update from Lite, with local changes. fix Ids, etc.
 1.4 06-Nov-1993  cgd branches: 1.4.4;
update to latest version.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Latest versions from uunet.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 02-May-1995  jtc #include "namespace.h"
 1.5.4.2 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.5.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.8.2.2 22-Oct-1997  thorpej Pull up from trunk:

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.8.2.1 21-Oct-1997  thorpej file glob.c was added on branch netbsd-1-3 on 1997-10-22 06:41:32 +0000
 1.18.10.1 05-Aug-2010  riz Pull up following revision(s) (requested by christos in ticket #1399):
lib/libc/gen/glob.c: patch
lib/libc/gen/glob.3: revision 1.37 via patch
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
 1.18.8.2 23-Mar-2008  matt sync with HEAD
 1.18.8.1 09-Jan-2008  matt sync with HEAD
 1.18.2.1 05-Aug-2010  riz Pull up following revision(s) (requested by christos in ticket #1399):
lib/libc/gen/glob.c: patch
lib/libc/gen/glob.3: revision 1.37 via patch
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
 1.21.2.1 24-Mar-2008  keiichi sync with head.
 1.22.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.22.2.1 04-Jun-2008  yamt sync with head
 1.23.12.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.23.10.2 24-Apr-2011  riz Pull up following revision(s) (requested by spz in ticket #1597):
lib/libc/gen/glob.c: revision 1.28
lib/libc/gen/glob.c: revision 1.29
prevent resource DoS from brace expansion (from Maksymilian Arciemowicz)
remove stray printf.
 1.23.10.1 19-Jul-2010  riz Pull up following revision(s) (requested by christos in ticket #1430):
lib/libc/gen/glob.c: revision 1.25
lib/libc/gen/glob.c: revision 1.26
lib/libc/gen/glob.3: revision 1.37
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
Avoid DoS attacks for patterns that have braces. Noted by Maksymilian
Arciemowicz.
XXX: Pullup to 5.x
 1.23.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.23.6.2 26-May-2008  ad Fedora Core 9 doesn't provide ARG_MAX, so use _POSIX_ARG_MAX if it's
not available.
 1.23.6.1 26-May-2008  ad file glob.c was added on branch christos-time_t on 2008-05-26 13:06:39 +0000
 1.23.4.2 24-Apr-2011  riz Pull up following revision(s) (requested by spz in ticket #1597):
lib/libc/gen/glob.c: revision 1.28
lib/libc/gen/glob.c: revision 1.29
prevent resource DoS from brace expansion (from Maksymilian Arciemowicz)
remove stray printf.
 1.23.4.1 19-Jul-2010  riz branches: 1.23.4.1.2;
Pull up following revision(s) (requested by christos in ticket #1430):
lib/libc/gen/glob.c: revision 1.25
lib/libc/gen/glob.c: revision 1.26
lib/libc/gen/glob.3: revision 1.37
crypto/dist/ssh/sftp.c: patch
crypto/dist/ssh/sftp-glob.c: patch
Add GLOB_LIMIT to the glob calls to prevent DoS attacks.
Apply more limits to GLOB_LIMIT, number of stat(2) calls from me and number
of readdir(3) calls from Maksymilian Arciemowicz. Also reduce the memory
used by matches strings from Maksymilian Arciemowicz.
Avoid DoS attacks for patterns that have braces. Noted by Maksymilian
Arciemowicz.
XXX: Pullup to 5.x
 1.23.4.1.2.1 24-Apr-2011  riz Pull up following revision(s) (requested by spz in ticket #1597):
lib/libc/gen/glob.c: revision 1.28
lib/libc/gen/glob.c: revision 1.29
prevent resource DoS from brace expansion (from Maksymilian Arciemowicz)
remove stray printf.
 1.27.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.31.8.2 23-Jun-2013  tls resync from head
 1.31.8.1 25-Feb-2013  tls resync with head
 1.31.4.1 24-Sep-2016  bouyer Pull up following revision(s) (requested by joerg in ticket #1404):
lib/libc/gen/glob.c: revision 1.36
Bump the glob limits to 512KB for total string size and 64K path
entries. The old limits were too small for some important FTP use cases
like a pkgsrc repository.
 1.31.2.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.14.1 18-Jan-2017  skrll Sync with netbsd-5
 1.35.10.1 13-Nov-2016  snj Pull up following revision(s) (requested by joerg in ticket #1247):
lib/libc/gen/glob.c: revision 1.36
Bump the glob limits to 512KB for total string size and 64K path
entries. The old limits were too small for some important FTP use cases
like a pkgsrc repository.
 1.35.8.1 18-Sep-2016  snj Pull up following revision(s) (requested by joerg in ticket #1247):
lib/libc/gen/glob.c: revision 1.36
Bump the glob limits to 512KB for total string size and 64K path
entries. The old limits were too small for some important FTP use cases
like a pkgsrc repository.
 1.36.4.2 11-May-2017  pgoyette Sync with HEAD
 1.36.4.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.38.10.1 10-Jun-2019  christos Sync with HEAD
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 06-Jan-2005  lukem branches: 1.1.24;
Rename various "internal" variables and functions and make non-static so other
internal libc source files can use these (including getgroupmembership(3)).

Be more consistent in the API that the __grscan_<source>() methods use.

In __grscan_compat() support an optional custom 'search' function used when a
"+" lookup is required. Normally this will be getgrent() from group_compat,
but getgroupmembership(3) will use a tailored compat search routine for
efficiency.
 1.1.24.1 18-May-2008  yamt sync with head.
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file gr_private.h was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.13 12-Mar-2019  wiz Fix typo.
 1.12 11-Mar-2019  kre PR lib/54053

When auto scaling, and the buffer is bigger than big enough
for the biggest possible number, don't try and calculate
the max value that will fit in the buffer - that calc
will overflow (guaranteed) and is useless, the value
we're formatting cannot possibly be bigger. So simply
use the unscaled value (the raw number).

While here, also avoid returning values that are larger
than the buffer len ... while it would be nice to be able
to find out how big the buffer should be so the data will
fit, the interface doesn't really allow that (the buffer
length passed in controls the scaling - at least when
auto scaling) and the code already does "return -1" when
it detects the buffer length is too small, even before
it works out how much would have been needed. So, rather
than returning a value > len (while truncating the result
to fit in len ... all courtesy of snprintf()) return -1
in this case as well.

Also, allow suffix==NULL (meaning "") - there's no reason
not to, and requiring users to pass in an explicit "" is
not useful.
 1.11 20-Aug-2011  wiz branches: 1.11.42;
Fix variable name in SYNOPSIS to match DESCRIPTION.
From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
 1.10 28-Apr-2011  wiz Spelling.
 1.9 14-Jan-2011  jruoho Xref strsuftoll(3) and orders(7).
 1.8 30-Apr-2008  martin branches: 1.8.8;
Convert TNF licenses to new 2 clause variant
 1.7 09-Feb-2008  jmmv branches: 1.7.4;
Document dehumanize_number(3).
 1.6 14-Dec-2007  xtraeme The humanize_number(3) proto will be available in stdlib.h, after
christos moves it to the correct place.
 1.5 11-Apr-2005  wiz branches: 1.5.10;
Remove duplicate word, from Wojciech A. Koszek in PR 29938.
 1.4 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.2 26-Sep-2002  wiz Kilo abbreviation is a small k (PR 18408).
 1.1 22-Aug-2002  abs branches: 1.1.2;
Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.1.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 22-Aug-2002  nathanw file humanize_number.3 was added on branch nathanw_sa on 2002-08-27 23:49:31 +0000
 1.5.10.2 23-Mar-2008  matt sync with HEAD
 1.5.10.1 09-Jan-2008  matt sync with HEAD
 1.7.4.1 18-May-2008  yamt sync with head.
 1.8.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.8.8.1 30-Apr-2008  martin file humanize_number.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.11.42.1 10-Jun-2019  christos Sync with HEAD
 1.19 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.18 11-Mar-2019  kre PR lib/54053

When auto scaling, and the buffer is bigger than big enough
for the biggest possible number, don't try and calculate
the max value that will fit in the buffer - that calc
will overflow (guaranteed) and is useless, the value
we're formatting cannot possibly be bigger. So simply
use the unscaled value (the raw number).

While here, also avoid returning values that are larger
than the buffer len ... while it would be nice to be able
to find out how big the buffer should be so the data will
fit, the interface doesn't really allow that (the buffer
length passed in controls the scaling - at least when
auto scaling) and the code already does "return -1" when
it detects the buffer length is too small, even before
it works out how much would have been needed. So, rather
than returning a value > len (while truncating the result
to fit in len ... all courtesy of snprintf()) return -1
in this case as well.

Also, allow suffix==NULL (meaning "") - there's no reason
not to, and requiring users to pass in an explicit "" is
not useful.
 1.17 13-Apr-2017  christos branches: 1.17.12;
Fix out of bounds read for very large numbers (pointed out by Brooks Davis)
https://svnweb.freebsd.org/changeset/base/316766
 1.16 17-Mar-2012  christos branches: 1.16.14; 1.16.18;
PR/44097: Yamamoto Takashi: Prevent overflow.
 1.15 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.14 28-Apr-2008  martin branches: 1.14.4; 1.14.8; 1.14.24;
Remove clause 3 and 4 from TNF licenses
 1.13 14-Dec-2007  christos branches: 1.13.4;
- add dehumanize_number
- decls for humanize_number and dehumanize_number are in stdlib.h
 1.12 13-Mar-2007  enami branches: 1.12.4;
Fix a bug that humanize_number() produces "1000" where it should be "1.0G"
or "1.0M". The bug reported by Greg Troxel.
 1.11 08-Jun-2006  simonb branches: 1.11.4; 1.11.6;
Use PRId64 instead of a cast to long long and %lld to print an int64_t.
 1.10 13-Sep-2005  christos compat core reorg.
 1.9 09-Feb-2005  kleink A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.8 27-Jul-2004  enami - Honor the HN_NOSPACE flag (i.e., don't put a space if specified,
and put space if not specified).
- There was a test which didn't count the suffixlen. Fix it.
- Make the code a bit easier to read.
 1.7 12-Jul-2004  enami Print 10450000 as 10M instead of 10.0M (more greater value such as
10500000 is printed as 10M).
 1.6 12-Jul-2004  enami No need to set divisor twice.
 1.5 26-Dec-2003  simonb Don't ever add a ".0" to a single digit number.

XXX: Should (for example) 1024 be 1.0K or 1K when the HN_DECIMAL flag
is passed? Should there be a separate option that says "use the
HN_DECIMAL behaviour unless we are exactly equal to the suffix"?
 1.4 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.3 27-Sep-2002  drochner SI prefixes apply to decimal multiplies only. For binary (2^n) multiplies
the most "officially looking" is IEC 60027-2, ie "Ki", "Mi", ...,
which is not too popular, and which would require more code changes.
So stick with the traditional capital "K" for (divisor==1024), and use
the SI "k" otherwise (ie (divisor==1000)).
 1.2 26-Sep-2002  wiz Kilo abbreviation is a small k (PR 18408).
 1.1 22-Aug-2002  abs branches: 1.1.2;
Move humanize_number(3) from libutil to libc as per discussion on tech-misc
Revert minor number bump on libutil (with note to skip it next update), and
bump libc.
 1.1.2.4 10-Dec-2002  thorpej Sync with HEAD.
 1.1.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 22-Aug-2002  nathanw file humanize_number.c was added on branch nathanw_sa on 2002-08-27 23:49:31 +0000
 1.11.6.1 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.11.4.1 25-Nov-2007  xtraeme Pull up following revision(s) (requested by simonb in ticket #992):
lib/libc/gen/humanize_number.c: revision 1.12
Fix a bug that humanize_number() produces "1000" where it should be "1.0G"
or "1.0M". The bug reported by Greg Troxel.
 1.12.4.1 09-Jan-2008  matt sync with HEAD
 1.13.4.1 18-May-2008  yamt sync with head.
 1.14.24.1 19-Mar-2012  riz Pull up following revision(s) (requested by dholland in ticket #129):
lib/libc/gen/humanize_number.c: revision 1.16
PR/44097: Yamamoto Takashi: Prevent overflow.
 1.14.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.14.8.1 28-Apr-2008  martin file humanize_number.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.14.4.1 17-Apr-2012  yamt sync with head
 1.16.18.1 21-Apr-2017  bouyer Sync with HEAD
 1.16.14.1 26-Apr-2017  pgoyette Sync with HEAD
 1.17.12.1 10-Jun-2019  christos Sync with HEAD
 1.3 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.2 19-Feb-2002  enami branches: 1.2.2;
Use tab to indent instead of spaces.
 1.1 19-Feb-2002  simonb Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.2.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.2.2.1 19-Feb-2002  nathanw file ieee754_frexp.c was added on branch nathanw_sa on 2002-03-08 21:35:08 +0000
 1.2 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.1 19-Feb-2002  simonb branches: 1.1.2;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.1.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 19-Feb-2002  nathanw file ieee754_infinity.c was added on branch nathanw_sa on 2002-03-08 21:35:09 +0000
 1.2 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.1 19-Feb-2002  simonb branches: 1.1.2;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.1.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 19-Feb-2002  nathanw file ieee754_isinf.c was added on branch nathanw_sa on 2002-03-08 21:35:09 +0000
 1.2 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.1 19-Feb-2002  simonb branches: 1.1.2;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.1.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 19-Feb-2002  nathanw file ieee754_isnan.c was added on branch nathanw_sa on 2002-03-08 21:35:09 +0000
 1.2 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.1 19-Feb-2002  simonb branches: 1.1.2;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.1.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 19-Feb-2002  nathanw file ieee754_ldexp.c was added on branch nathanw_sa on 2002-03-08 21:35:09 +0000
 1.2 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.1 19-Feb-2002  simonb branches: 1.1.2;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.1.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 19-Feb-2002  nathanw file ieee754_modf.c was added on branch nathanw_sa on 2002-03-08 21:35:10 +0000
 1.2 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.1 19-Feb-2002  simonb branches: 1.1.2;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.1.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.2.1 19-Feb-2002  nathanw file ieee754_nanf.c was added on branch nathanw_sa on 2002-03-08 21:35:10 +0000
 1.3 12-Jun-2005  lukem Add missing __RCSID()
 1.2 25-Oct-2003  kleink Whitespace cosmetics.
 1.1 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.2 12-Jun-2005  lukem Add missing __RCSID()
 1.1 25-Oct-2003  kleink Add __infinityf and __infinityl, float respectively long double analogs
of __infinity.
 1.1 25-Oct-2003  kleink Add __infinityf and __infinityl, float respectively long double analogs
of __infinity.
 1.1 17-Jan-2011  matt branches: 1.1.4;
Make the MIPS N32/N64 ABIs properly support 128-bit long doubles. With this
change, we should be fully conformant with the N32 and N64 ABIs.
Add {fpclassify,infinity,isnan,ininf,signbit}l_ieee754.c back to lib/libc/gen.
Note that infinityl_ieee754.c will work with either 64-bit, 80-bit, or
128-bit long doubles.
 1.1.4.2 29-Apr-2011  matt Pull in true (128-bit) long double support for MIPS from -current.
 1.1.4.1 17-Jan-2011  matt file infinityl_ieee754.c was added on branch matt-nb5-mips64 on 2011-04-29 07:48:34 +0000
 1.5 11-Jul-2021  kre Make sure dd_size is init'd, even when nothing has been read (so it
will be 0). Reported on tech-userlevel by Mouse 20210711T044753+0000
 1.4 16-Dec-2016  mrg scandir/alphasort take "const struct dirent **" not "const void *" in
modern unix. since we claim to be 'IEEE Std 1003.1-2008', make it so.
 1.3 13-Mar-2012  christos branches: 1.3.14;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.2 15-Oct-2011  christos branches: 1.2.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.1 26-Sep-2010  yamt fix rewinddir on nfs. fix PR/42879 (and probably PR/40229.)
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.3.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 01-May-2003  wiz Grammar and mdoc fixes from jmc@openbsd.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 10-Aug-2002  wiz Update Dd for recent changes.
 1.11 10-Aug-2002  yamt note about "too many groups" case.
from openbsd.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 12-Oct-1995  jtc Manpage fixes from Jochen Pohl. Aligns the prototypes in the SYNOPSIS
section with the actual function declarations. Also fixes decription
of _SC_CLK_TCK in sysconf(3). See PR #1587 and PR #1589 for details.
 1.5 03-Jun-1995  mycroft Don't set the rgid or egid. Document this behavior. This is compatible with
SunOS and SysV.
 1.4 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.3 19-Sep-1994  mycroft Update to 4.4-Lite version.
 1.2 30-Jul-1993  mycroft branches: 1.2.2;
Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 19-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.2.1 06-Oct-1994  mycroft Update from trunk.
 1.8.12.4 13-Aug-2002  nathanw Catch up to -current.
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.22 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.21 07-Aug-2003  agc branches: 1.21.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.20 19-Jan-2003  dsl Ignore groups beyond _SC_NGROUPS_MAX (as man page)
Ensure kernel doesn't pick up random numbers (would happen if _SC_NGROUPS_MAX
> NGROUPS)
(change agreed by christos)
 1.19 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.18 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.17 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.16 31-Mar-1999  lukem don't use warn() in initgroups(); it's not documented to do that, and
if stderr isn't valid the caller may dump core.
from Giles Lean <giles@nemeton.com.au> in [lib/7273]
 1.15 27-Feb-1998  perry trivial changes to quiet lint.
 1.14 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.13 13-Jul-1997  christos Use namespace.h
 1.12 04-Jul-1997  kleink Common sense dictates that the `basegid' paramater of initgroups(3) should
be of type gid_t, and not int.
 1.11 03-Jun-1995  mycroft branches: 1.11.4;
Don't set the rgid or egid. Document this behavior. This is compatible with
SunOS and SysV.
 1.10 02-Jun-1995  mycroft We must do setgid() explicitly now.
 1.9 13-May-1995  jtc #include appropriate header files to bring prototypes into scope
 1.8 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.7 12-Dec-1994  jtc Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.6 11-Dec-1994  christos - Changed all internal libc references of {v,}err{x,} and {v,}warn{x,} to
__{v,}err{x,} and __{v,}warn{x,}
- moved err.c to __err.c and added err.c which contains weak references for
the above functions.
- Reordered the functions in __err.c to avoid redeclarations and changed
the varargs declarations to conform with the K&R style.
 1.5 19-Sep-1994  mycroft Update to 4.4-Lite version.
 1.4 30-Mar-1994  cgd branches: 1.4.2;
gid_t is your friend!
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 19-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 06-Oct-1994  mycroft Update from trunk.
 1.11.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.21.56.1 30-Oct-2012  yamt sync with head
 1.3 12-Jan-1994  mycroft Clean up deleted files.
 1.2 13-Aug-1993  brezak Correct copyright statements
 1.1 13-Aug-1993  brezak Machine independent version of insque/remque
 1.5 12-Jan-1994  mycroft Clean up deleted files.
 1.4 21-Oct-1993  jtc #include <search.h> to ensure that the public function declarations match
the implementation.
Use old-style function definitions so functions can be compiled with non-ansi
compilers.
Functions are specified to take void * arguments, so they must be cast to
a struct qelem * before they are used.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 13-Aug-1993  brezak Correct copyright statements
 1.1 13-Aug-1993  brezak Machine independent version of insque/remque
 1.15 17-Apr-2008  apb branches: 1.15.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.14 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.13 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 10-Jul-2002  wiz Remove Xrefs to ourselves in SEE ALSO.
 1.9 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 16-Sep-2001  wiz Boring whitespace fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.15.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.15.10.1 17-Apr-2008  apb file isalnum.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.14 17-Apr-2008  apb branches: 1.14.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.13 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.12 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 16-Sep-2001  wiz Boring whitespace fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.14.10.1 17-Apr-2008  apb file isalpha.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.19 21-Feb-2021  rillig isascii.3: fix typo
 1.18 30-Apr-2010  jruoho Interestingly, the committees plan to remove also isascii(3) and toascii(3)
in the future.
 1.17 17-Apr-2008  apb branches: 1.17.10;
When given negative inputs, isascii returns false. Clarify that
it checks for the range 0 to 127, not "less than or equal to 0177".
 1.16 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 14-Apr-2003  wiz Bump date for last.
 1.12 14-Apr-2003  simonb Remove CAVEATS section and note that isascii() works on all integer
values.

From PR standards/21179 from Christian Biere. Verified against SUSv3 too.
 1.11 08-Nov-2002  enami s/than than/than/.
 1.10 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.7 05-Feb-1998  perry branches: 1.7.12;
add LIBRARY section to man page
 1.6 01-Nov-1997  kleink isascii() is not specified by ANSI C but X/Open; noticed by Peter Seebach
<seebs@puddle.plethora.net> in PR standards/4351.
 1.5 27-Feb-1995  cgd branches: 1.5.10;
merge with Lite, keeping local changes. Fix up Id format, etc.
 1.4 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.3 21-Sep-1993  cgd add Nd line, and correct the description of the function.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.10.1 02-Nov-1997  mellon Pull rev 1.6 up from trunk (kleink)
 1.7.12.5 11-Nov-2002  nathanw Catch up to -current
 1.7.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.7.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.17.10.2 17-Apr-2008  apb When given negative inputs, isascii returns false. Clarify that
it checks for the range 0 to 127, not "less than or equal to 0177".
 1.17.10.1 17-Apr-2008  apb file isascii.3 was added on branch christos-time_t on 2008-04-17 16:40:21 +0000
 1.4 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.3 01-Jun-2010  tnozaki branches: 1.3.6;
more split ctype.h -> sys/ctype_inline.h, sys/ctype_bits.h
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 12-Sep-1999  kleink Move the function implementations of (the non-ANSI) isascii() and toascii()
into separate modules to avoid namespace clashes.
 1.3.6.1 30-Oct-2012  yamt sync with head
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 07-Aug-2003  agc branches: 1.12.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 30-Sep-2001  lukem don't bother checking _DIAGASSERT(fd != -1), since the underlying
ioctl(2) will check it and return EBADF, and i got sick of the warnings
from programs like sshd which occassionally call isatty() with bad fds.
 1.10 22-Jan-2000  mycroft branches: 1.10.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 13-Oct-1998  kleink Need an internal name for isatty().
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 27-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 25-Apr-1995  jtc #include "namespace.h"
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.12.56.1 30-Oct-2012  yamt sync with head
 1.13 17-Apr-2008  apb branches: 1.13.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.12 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.11 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 16-Sep-2001  wiz Boring whitespace fixes.
 1.4 05-Feb-1998  perry branches: 1.4.12;
add LIBRARY section to man page
 1.3 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.2 04-Oct-1993  jtc Install isblank() manpage.
Fix title of isblank() manpage (was isspace(), the manpage I started with).
 1.1 14-Sep-1993  jtc Document isblank().
 1.4.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.4.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.13.10.1 17-Apr-2008  apb file isblank.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.13 17-Apr-2008  apb branches: 1.13.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.12 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.11 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.13.10.1 17-Apr-2008  apb file iscntrl.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.29 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.28 29-Mar-2025  riastradh branches: 1.28.2;
libc/isctype.c: Omit needless #include <assert.h>.

Crept in during an earlier revision when I wrote this with
_DIAGASSERT. (I opted to unconditionally abort so that you get the
feedback about undefined behaviour even if you don't run with
LIBC_DIAGASSERT set in the environment. Since it's undefined
behaviour we are allowed to do this unconditionally, of course!)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.27 29-Mar-2025  riastradh ctype(3): Summon a demon from caller's nose if abused out-of-line.

This way, applications which opt for the out-of-line functions will
crash with a potentially meaningful message to stderr if they pass
inputs on which the ctype(3) functions are undefined. (If fd 2 is
something else, tough -- this is nasal demon country, and they fly
where they please, application intent be damned.)

This probably won't catch many applications -- but it might catch C++
applications at runtime that can't be caught at build-time because
they eschew the macros.

The cost is a single predicted-not-taken branch -- it's checking c
for membership in the interval [-1,0xff] when we're already computing
c + 1, so it can be a single unsigned-compare. By deferring the
message and abort to an out-of-line function we avoid a stack frame
in the good case. And this is for the unlikely, out-of-line versions
of the ctype(3) functions -- most applications get the inline macros.
So I'm not concerned by the prospect of a performance impact.

Update the tests so they recognize SIGABRT as noisy failure too, not
just SIGSEGV.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.26 07-Jun-2024  riastradh branches: 1.26.2;
libc/locale: Nix needless size_t casts.

No functional change intended. No binary change to aarch64 libc.

Prompted by code inspection around PR lib/58319.
 1.25 19-Aug-2013  joerg Remove most LC_CTYPE specific parts of locale.cache.
 1.24 17-May-2013  joerg Provide explicit LC_C_LOCALE accessor and drop the various NULL checks.
Provide LC_GLOBAL_LOCALE in a way that works with all locale functions.
Merge constant data used by the initial global locale and the C locale.
Drop function call layer for _current_locale() and directly return the
locale reference, not a pointer to it. Use protected access for global
variables, so that libc references can avoid the GOT overhead.
 1.23 16-Apr-2013  joerg Add isalpha_l and friends.
 1.22 13-Apr-2013  joerg Extend ctype classification table to 16bit. Based on patch by
Takehiko Nozaki, with changes to compile fail when using the old names
and to exploit __BUILD_LEGACY
 1.21 14-Dec-2010  joerg branches: 1.21.6; 1.21.12;
Prefix ctype bitmask macros with _CTYPE
 1.20 01-Jun-2010  tnozaki more split ctype.h -> sys/ctype_inline.h, sys/ctype_bits.h
 1.19 22-May-2010  tnozaki make _locale_impl_t.cache as pointer to maintain easily binary compatibility in future.
no ABI change was made.
 1.18 11-Jan-2009  christos merge christos-time_t
 1.17 02-Jan-2009  tnozaki Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES} db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).

[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].

[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().

[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<

old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.16 07-Aug-2003  agc branches: 1.16.38; 1.16.40;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 12-Sep-1999  kleink Move the function implementations of (the non-ANSI) isascii() and toascii()
into separate modules to avoid namespace clashes.
 1.14 13-Jul-1997  christos Fix RCSID's
 1.13 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.12 17-May-1994  cgd copyright foo
 1.11 11-Nov-1993  jtc First pass at getting a clean compile with "gcc -Wall", mostly explictly
declaring function return values, etc.
 1.10 05-Oct-1993  jtc Due to an 8-bit attribute table and 9 bits of attributes, I've had to
remove the _B attribute from the "horizontal tab" position, and change
the isblank function to explicitly test against space and tab.

When I finish merging the 4.4 runes code, this table will have to grow
to 16 bit entries, as several more attributes have been introduced.
I'm making this change so existing libraries will continue working
for the next (little) while.
 1.9 14-Sep-1993  jtc Implement C version of isblank.
 1.8 05-Sep-1993  mycroft Separate the toupper() and tolower() functions so the tables *really* don't get
included unless you need them.
 1.7 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.6 23-Aug-1993  cgd use "_to*_tab_" rather than "_to*_table_" -- table is defined as the former
 1.5 06-Aug-1993  jtc Use C locale specific traslation tables for toupper and tolower.
Direct access to the tables is to be replaced by a pointer to tables for the
current locale.
 1.4 06-Aug-1993  jtc Provide function versions of isascii() and toascii().
 1.3 30-Jul-1993  mycroft Remove patchkit lossage, and RCS frob, and make tolower() and toupper() a
little faster.
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.16.40.1 04-Jan-2009  christos merge with head.
 1.16.38.1 15-Jan-2009  snj Pull up following revision(s) (requested by tnozaki in ticket #222):
distrib/sets/lists/base/mi: revision 1.788
distrib/utils/libhack/Makefile.inc: revision 1.23
distrib/utils/libhack/Makefile: revision 1.22
etc/mtree/NetBSD.dist: revision 1.387
include/locale.h: revision 1.15
lib/libc/citrus/Makefile.inc: revision 1.6
lib/libc/citrus/citrus_aliasname_local.h: revision 1.1
lib/libc/citrus/citrus_bcs.h: revision 1.5
lib/libc/citrus/citrus_bcs_strtol.c: revision 1.1
lib/libc/citrus/citrus_bcs_strtoul.c: revision 1.1
lib/libc/citrus/citrus_csmapper.c: revision 1.9
lib/libc/citrus/citrus_fix_grouping.h: revision 1.1
lib/libc/citrus/citrus_lc_ctype.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.h: revision 1.1
lib/libc/citrus/citrus_lc_monetary.c: revision 1.1
lib/libc/citrus/citrus_lc_monetary.h: revision 1.1
lib/libc/citrus/citrus_lc_numeric.c: revision 1.1
lib/libc/citrus/citrus_lc_numeric.h: revision 1.1
lib/libc/citrus/citrus_lc_template.h: revision 1.1
lib/libc/citrus/citrus_lc_template_decl.h: revision 1.1
lib/libc/citrus/citrus_lc_time.c: revision 1.1
lib/libc/citrus/citrus_lc_time.h: revision 1.1
lib/libc/citrus/citrus_module.c: revision 1.8
lib/libc/citrus/citrus_namespace.h: revision 1.7
lib/libc/citrus/modules/citrus_euc.c: revision 1.13
lib/libc/gen/Makefile.inc: revision 1.166
lib/libc/gen/isctype.c: revision 1.17 via patch
lib/libc/gen/tolower_.c: revision 1.10
lib/libc/gen/toupper_.c: revision 1.10
lib/libc/iconv/Makefile.inc: revision 1.3
lib/libc/iconv/iconv.c: revision 1.7
lib/libc/locale/Makefile.inc: revision 1.53
lib/libc/locale/___runetype_mb.c: file removal
lib/libc/locale/_wctrans.c: revision 1.7
lib/libc/locale/_wctrans_local.h: revision 1.3
lib/libc/locale/_wctype.c: revision 1.1
lib/libc/locale/_wctype_local.h: revision 1.1
lib/libc/locale/aliasname.c: revision 1.3
lib/libc/locale/aliasname_local.h: revision 1.2
lib/libc/locale/bsdctype.c: revision 1.1
lib/libc/locale/bsdctype.h: revision 1.1
lib/libc/locale/ctypeio.c: revision 1.8
lib/libc/locale/ctypeio.h: revision 1.2
lib/libc/locale/current_locale.c: revision 1.1
lib/libc/locale/dummy_lc_collate.c: revision 1.1
lib/libc/locale/dummy_lc_template.h: revision 1.1
lib/libc/locale/fix_grouping.c: revision 1.1
lib/libc/locale/fix_grouping.h: revision 1.1
lib/libc/locale/generic_lc_all.c: revision 1.1
lib/libc/locale/generic_lc_template.h: revision 1.1
lib/libc/locale/generic_lc_template_decl.h: revision 1.1
lib/libc/locale/global_locale.c: revision 1.1
lib/libc/locale/iswctype.c: file removal
lib/libc/locale/iswctype_mb.c: revision 1.1
lib/libc/locale/iswctype_sb.c: revision 1.6
lib/libc/locale/lcmessages.c: file removal
lib/libc/locale/lcmessages.h: file removal
lib/libc/locale/lcmonetary.c: file removal
lib/libc/locale/lcmonetary.h: file removal
lib/libc/locale/lcnumeric.c: file removal
lib/libc/locale/lcnumeric.h: file removal
lib/libc/locale/lctime.c: file removal
lib/libc/locale/lctime.h: file removal
lib/libc/locale/localeconv.c: revision 1.15
lib/libc/locale/localeio.c: revision 1.2
lib/libc/locale/localeio.h: revision 1.2
lib/libc/locale/localeio_lc_ctype.c: revision 1.1
lib/libc/locale/localeio_lc_messages.c: revision 1.1
lib/libc/locale/localeio_lc_monetary.c: revision 1.1
lib/libc/locale/localeio_lc_numeric.c: revision 1.1
lib/libc/locale/localeio_lc_time.c: revision 1.1
lib/libc/locale/multibyte.h: revision 1.4
lib/libc/locale/multibyte_amd1.c: revision 1.6
lib/libc/locale/multibyte_c90.c: revision 1.5
lib/libc/locale/nb_lc_messages_misc.h: revision 1.1
lib/libc/locale/nb_lc_monetary_misc.h: revision 1.1
lib/libc/locale/nb_lc_numeric_misc.h: revision 1.1
lib/libc/locale/nb_lc_template.h: revision 1.1
lib/libc/locale/nb_lc_template_decl.h: revision 1.1
lib/libc/locale/nb_lc_time_misc.h: revision 1.1
lib/libc/locale/nl_langinfo.c: revision 1.12
lib/libc/locale/rune.c: revision 1.31
lib/libc/locale/rune.h: revision 1.13
lib/libc/locale/rune_local.h: revision 1.11
lib/libc/locale/runeglue.c: revision 1.14
lib/libc/locale/runetable.c: revision 1.18
lib/libc/locale/setlocale.c: revision 1.55 via patch
lib/libc/locale/setlocale_local.h: revision 1.1
lib/libc/locale/setrunelocale.c: file removal
lib/libc/nls/Makefile.inc: revision 1.9
lib/libc/nls/catopen.c: revision 1.26
lib/libc/string/Makefile.inc: revision 1.68
lib/libc/string/wcscmp.c: revision 1.6
lib/libc/string/wcsncmp.c: revision 1.6
lib/libc/string/wcswidth.c: file removal
lib/libc/string/wmemcmp.c: revision 1.4
regress/lib/libc/locale/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/en_US.UTF-8.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.exp.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.in.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.exp.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.in.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.SJIS.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.eucJP.exp.uue: revision 1.2
regress/lib/libc/locale/ctype2/Makefile: revision 1.5
regress/lib/libc/locale/ctype2/ja_JP.ISO-2022-JP-2.in.uue: revision 1.1
regress/lib/libc/locale/ctype2/ja_JP.ISO2022-JP2.in.uue: file removal
regress/lib/libc/locale/ctype3/Makefile: revision 1.5
regress/lib/libc/locale/mbtowc/Makefile: revision 1.3
regress/lib/libc/locale/mbtowc/ja_JP.ISO-2022-JP: revision 1.1
regress/lib/libc/locale/mbtowc/ja_JP.ISO2022-JP: file removal
regress/lib/libc/locale/wcstod/wcstod_test.c: revision 1.2
share/locale/Makefile.locale: revision 1.1
share/locale/Makefile: revision 1.5
share/locale/ctype/Makefile: revision 1.28
share/locale/locale.alias: revision 1.11
share/locale/messages/Makefile: revision 1.5
share/locale/messages/en_US.ISO8859-1.src: file removal
share/locale/messages/en_US.US-ASCII.src: revision 1.1
share/locale/messages/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/messages/ja_JP.ct.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-2.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-5.src: revision 1.1
share/locale/messages/sr_YU.ISO8859-2.src: file removal
share/locale/messages/sr_YU.ISO8859-5.src: file removal
share/locale/messages/sr_YU.UTF-8.src: file removal
share/locale/messages/zh_CN.GB18030.src: file removal
share/locale/messages/zh_TW.eucTW.src: revision 1.1
share/locale/monetary/Makefile: revision 1.5
share/locale/monetary/af_ZA.ISO8859-1.src: revision 1.2
share/locale/monetary/am_ET.UTF-8.src: revision 1.2
share/locale/monetary/be_BY.CP1131.src: file removal
share/locale/monetary/be_BY.CP1251.src: revision 1.2
share/locale/monetary/be_BY.ISO8859-5.src: revision 1.2
share/locale/monetary/be_BY.UTF-8.src: revision 1.2
share/locale/monetary/bg_BG.CP1251.src: revision 1.2
share/locale/monetary/bg_BG.UTF-8.src: revision 1.2
share/locale/monetary/ca_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/cs_CZ.ISO8859-2.src: revision 1.2
share/locale/monetary/cs_CZ.UTF-8.src: revision 1.2
share/locale/monetary/da_DK.ISO8859-1.src: revision 1.2
share/locale/monetary/de_AT.ISO8859-1.src: revision 1.2
share/locale/monetary/de_CH.ISO8859-1.src: revision 1.2
share/locale/monetary/de_DE.ISO8859-1.src: revision 1.2
share/locale/monetary/el_GR.ISO8859-7.src: revision 1.2
share/locale/monetary/en_AU.ISO8859-1.src: revision 1.2
share/locale/monetary/en_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.UTF-8.src: revision 1.2
share/locale/monetary/en_IE.UTF-8.src: revision 1.2
share/locale/monetary/en_NZ.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.US-ASCII.src: revision 1.1
share/locale/monetary/es_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/et_EE.ISO8859-15.src: revision 1.2
share/locale/monetary/fi_FI.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_FR.ISO8859-1.src: revision 1.2
share/locale/monetary/he_IL.UTF-8.src: revision 1.2
share/locale/monetary/hi_IN.ISCII-DEV.src: revision 1.2
share/locale/monetary/hr_HR.ISO8859-2.src: revision 1.2
share/locale/monetary/hu_HU.ISO8859-2.src: revision 1.2
share/locale/monetary/hy_AM.ARMSCII-8.src: revision 1.2
share/locale/monetary/hy_AM.UTF-8.src: revision 1.2
share/locale/monetary/is_IS.ISO8859-1.src: revision 1.2
share/locale/monetary/it_IT.ISO8859-1.src: revision 1.2
share/locale/monetary/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/monetary/ja_JP.UTF-8.src: revision 1.2
share/locale/monetary/ja_JP.eucJP.src: revision 1.2
share/locale/monetary/kk_KZ.PT154.src: revision 1.2
share/locale/monetary/kk_KZ.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.eucKR.src: revision 1.2
share/locale/monetary/lt_LT.ISO8859-13.src: revision 1.2
share/locale/monetary/mn_MN.UTF-8.src: revision 1.2
share/locale/monetary/nl_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/nl_NL.ISO8859-1.src: revision 1.2
share/locale/monetary/no_NO.ISO8859-1.src: revision 1.2
share/locale/monetary/pl_PL.ISO8859-2.src: revision 1.2
share/locale/monetary/pl_PL.UTF-8.src: revision 1.2
share/locale/monetary/pt_BR.ISO8859-1.src: revision 1.2
share/locale/monetary/pt_PT.ISO8859-1.src: revision 1.2
share/locale/monetary/ro_RO.ISO8859-2.src: revision 1.2
share/locale/monetary/ru_RU.CP1251.src: revision 1.2
share/locale/monetary/ru_RU.CP866.src: revision 1.2
share/locale/monetary/ru_RU.ISO8859-5.src: revision 1.2
share/locale/monetary/ru_RU.KOI8-R.src: revision 1.2
share/locale/monetary/ru_RU.UTF-8.src: revision 1.2
share/locale/monetary/sk_SK.ISO8859-2.src: revision 1.2
share/locale/monetary/sl_SI.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_ME.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_RS.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_YU.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_YU.ISO8859-5.src: revision 1.2
share/locale/monetary/sr_YU.UTF-8.src: revision 1.2
share/locale/monetary/sv_SE.ISO8859-1.src: revision 1.2
share/locale/monetary/tr_TR.ISO8859-9.src: revision 1.2
share/locale/monetary/uk_UA.CP1251.src: revision 1.2
share/locale/monetary/uk_UA.ISO8859-5.src: revision 1.2
share/locale/monetary/uk_UA.KOI8-U.src: revision 1.2
share/locale/monetary/uk_UA.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.GB18030.src: revision 1.2
share/locale/monetary/zh_CN.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.eucCN.src: revision 1.2
share/locale/monetary/zh_HK.Big5hkscs.src: revision 1.1
share/locale/monetary/zh_HK.UTF-8.src: revision 1.2
share/locale/monetary/zh_TW.Big5.src: revision 1.2
share/locale/numeric/Makefile: revision 1.4
share/locale/numeric/am_ET.UTF-8.src: file removal
share/locale/numeric/en_US.ISO8859-1.src: file removal
share/locale/numeric/en_US.US-ASCII.src: revision 1.1
share/locale/numeric/ja_JP.eucJP.src: file removal
share/locale/numeric/ko_KR.eucKR.src: file removal
share/locale/numeric/mn_MN.UTF-8.src: file removal
share/locale/numeric/sr_ME.ISO8859-2.src: revision 1.1
share/locale/numeric/sr_YU.ISO8859-2.src: file removal
share/locale/numeric/sr_YU.ISO8859-5.src: file removal
share/locale/numeric/zh_CN.eucCN.src: file removal
share/locale/time/Makefile: revision 1.5
share/locale/time/en_US.ISO8859-1.src: file removal
share/locale/time/en_US.US-ASCII.src: revision 1.1
share/locale/time/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/time/ja_JP.ct.src: revision 1.1
share/locale/time/sr_ME.ISO8859-2.src: revision 1.1
share/locale/time/sr_ME.ISO8859-5.src: revision 1.1
share/locale/time/sr_ME.UTF-8.src: revision 1.1
share/locale/time/sr_YU.ISO8859-2.src: file removal
share/locale/time/sr_YU.ISO8859-5.src: file removal
share/locale/time/sr_YU.UTF-8.src: file removal
share/locale/time/zh_CN.GB18030.src: file removal
share/locale/time/zh_TW.eucTW.src: revision 1.1
usr.bin/locale/locale.c: revision 1.6
usr.bin/mklocale/Makefile: revision 1.12
usr.bin/mklocale/lex.l: revision 1.14
usr.bin/mklocale/mklocaledb.c: revision 1.1
usr.bin/mklocale/yacc.y: revision 1.25
usr.sbin/chrtbl/Makefile: revision 1.8
usr.sbin/chrtbl/ctypeio.c: revision 1.1
usr.sbin/chrtbl/ctypeio.h: revision 1.1
Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES}
db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).
[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].
[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().
[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<
old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.21.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.12.1 23-Jun-2013  tls resync from head
 1.21.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.26.2.1 02-Aug-2025  perseant Sync with HEAD
 1.28.2.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.14 17-Apr-2008  apb branches: 1.14.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.13 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.12 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 10-Jul-2002  wiz Remove Xrefs to ourselves in SEE ALSO.
 1.8 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.14.10.1 17-Apr-2008  apb file isdigit.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.4 06-Aug-2011  jruoho Xref the non-standard finite(3).
 1.3 30-Apr-2008  martin branches: 1.3.8;
Convert TNF licenses to new 2 clause variant
 1.2 15-Jan-2004  kleink branches: 1.2.30;
Add C99 fpclassify(), isfinite(), isnormal(), and signbit() macros.
 1.1 29-Oct-2003  kleink Add manual pages for fpclassify and isfinite.
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.3.8.1 30-Apr-2008  martin file isfinite.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 29-Oct-2003  kleink branches: 1.1.30;
C99 7.12.3.2: add library portions of isfinite, but don't build these just
yet.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file isfinited_ieee754.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 29-Oct-2003  kleink branches: 1.1.30;
C99 7.12.3.2: add library portions of isfinite, but don't build these just
yet.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file isfinitef_ieee754.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.1 17-Jan-2011  matt branches: 1.1.4;
Make the MIPS N32/N64 ABIs properly support 128-bit long doubles. With this
change, we should be fully conformant with the N32 and N64 ABIs.
Add {fpclassify,infinity,isnan,ininf,signbit}l_ieee754.c back to lib/libc/gen.
Note that infinityl_ieee754.c will work with either 64-bit, 80-bit, or
128-bit long doubles.
 1.1.4.2 29-Apr-2011  matt Pull in true (128-bit) long double support for MIPS from -current.
 1.1.4.1 17-Jan-2011  matt file isfinitel_ieee754.c was added on branch matt-nb5-mips64 on 2011-04-29 07:48:34 +0000
 1.14 17-Apr-2008  apb branches: 1.14.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.13 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.12 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.11 15-Oct-2004  enami Don't break line at the space since it is not a word separator but
an example of space character.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.14.10.1 17-Apr-2008  apb file isgraph.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.1 22-Feb-2007  drochner -get cabs() and cabsf() out of public view - these are historical and
conflict with C99 functions which are builtins in newer gcc
(actually, the old cabs() is ABI compatible with the new _complex one
on i386, but this is purely accidental)
remove public prototypes and manpages, move the code into a compat
subdirectory as libc does so that binary compatibility is kept
-add a manpage for the isgreater() etc macros, borrowed from FreeBSD
 1.13 27-Sep-2017  maya Move VAX notes to CAVEATS, clarify that it just returns zero

The VAX isinf implementation is in sys/arch/vax/include/math.h.
 1.12 04-Mar-2004  wiz Sort SEE ALSO.
 1.11 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 16-Aug-1999  kleink branches: 1.6.10;
Add header file inclusion, and Xref single-precision versions.
 1.5 02-Aug-1998  mycroft Fix obvious typo.
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.5 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.4 27-Oct-2003  skrll One ';' is enough.
 1.3 27-Oct-2003  kleink Retire local union { floating-type; struct ieee_prec; } in favor of those
available from <machine/ieee.h>
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.2 09-Aug-2021  andvar fix various typos in compatibility, mainly in comments.
 1.1 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.1 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.3 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.2 24-Oct-2003  kleink Add an error check to ensure these are used on platforms without a
distinct long doble type only.
 1.1 24-Oct-2003  kleink * Since there is no single portable IEEE 754 format for a long double,
keep a common implementation of isinfl() and isnanl() to be used by
platforms where `long double' == `double'; move others into
machine-dependent code.
* In due course, consider __VFP_FP__ on arm.
 1.5 21-Nov-2013  martin Make ext_fraclm and ext_frachm parts of the long double mantissa optional
in generic code
 1.4 17-Jan-2011  matt branches: 1.4.4; 1.4.8; 1.4.14;
Make the MIPS N32/N64 ABIs properly support 128-bit long doubles. With this
change, we should be fully conformant with the N32 and N64 ABIs.
Add {fpclassify,infinity,isnan,ininf,signbit}l_ieee754.c back to lib/libc/gen.
Note that infinityl_ieee754.c will work with either 64-bit, 80-bit, or
128-bit long doubles.
 1.3 24-Oct-2003  kleink * Since there is no single portable IEEE 754 format for a long double,
keep a common implementation of isinfl() and isnanl() to be used by
platforms where `long double' == `double'; move others into
machine-dependent code.
* In due course, consider __VFP_FP__ on arm.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 17-May-2003  thorpej Add _isinfl() and _isnanl() routines, currently for internal use only.
 1.4.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.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.4.4.2 29-Apr-2011  matt Pull in true (128-bit) long double support for MIPS from -current.
 1.4.4.1 17-Jan-2011  matt file isinfl_ieee754.c was added on branch matt-nb5-mips64 on 2011-04-29 07:48:35 +0000
 1.14 17-Apr-2008  apb branches: 1.14.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.13 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.12 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 16-Sep-2001  wiz Boring whitespace fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.14.10.1 17-Apr-2008  apb file islower.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.3 27-Sep-2017  maya move VAX notes to CAVEATS, clarify.
 1.2 04-Mar-2004  wiz Sort SEE ALSO, drop trailing space.
 1.1 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.4 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.3 27-Oct-2003  kleink Retire local union { floating-type; struct ieee_prec; } in favor of those
available from <machine/ieee.h>
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.2 09-Aug-2021  andvar fix various typos in compatibility, mainly in comments.
 1.1 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.1 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.3 04-Mar-2004  kleink * Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.2 24-Oct-2003  kleink Add an error check to ensure these are used on platforms without a
distinct long doble type only.
 1.1 24-Oct-2003  kleink * Since there is no single portable IEEE 754 format for a long double,
keep a common implementation of isinfl() and isnanl() to be used by
platforms where `long double' == `double'; move others into
machine-dependent code.
* In due course, consider __VFP_FP__ on arm.
 1.7 21-Nov-2013  martin Make ext_fraclm and ext_frachm parts of the long double mantissa optional
in generic code
 1.6 17-Jan-2011  matt branches: 1.6.4; 1.6.8; 1.6.14;
Make the MIPS N32/N64 ABIs properly support 128-bit long doubles. With this
change, we should be fully conformant with the N32 and N64 ABIs.
Add {fpclassify,infinity,isnan,ininf,signbit}l_ieee754.c back to lib/libc/gen.
Note that infinityl_ieee754.c will work with either 64-bit, 80-bit, or
128-bit long doubles.
 1.5 24-Oct-2003  kleink * Since there is no single portable IEEE 754 format for a long double,
keep a common implementation of isinfl() and isnanl() to be used by
platforms where `long double' == `double'; move others into
machine-dependent code.
* In due course, consider __VFP_FP__ on arm.
 1.4 23-Oct-2003  kleink Fix an RCS Id botch that occured when renaming.
 1.3 22-Oct-2003  kleink For a double-extended NaN, the exponent must be EXT_EXP_INFNAN, not
DBL_EXP_INFNAN.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 17-May-2003  thorpej Add _isinfl() and _isnanl() routines, currently for internal use only.
 1.6.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.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.6.4.2 29-Apr-2011  matt Pull in true (128-bit) long double support for MIPS from -current.
 1.6.4.1 17-Jan-2011  matt file isnanl_ieee754.c was added on branch matt-nb5-mips64 on 2011-04-29 07:48:35 +0000
 1.3 30-Apr-2008  martin branches: 1.3.8;
Convert TNF licenses to new 2 clause variant
 1.2 15-Jan-2004  wiz branches: 1.2.30;
I guess ture means true.
 1.1 15-Jan-2004  kleink Add C99 fpclassify(), isfinite(), isnormal(), and signbit() macros.
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.3.8.1 30-Apr-2008  martin file isnormal.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.13 17-Apr-2008  apb branches: 1.13.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.12 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.11 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.13.10.1 17-Apr-2008  apb file isprint.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.13 17-Apr-2008  apb branches: 1.13.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.12 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.11 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.13.10.1 17-Apr-2008  apb file ispunct.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.15 03-Oct-2012  wiz Improve wording.

From Bug Hunting.
 1.14 17-Apr-2008  apb branches: 1.14.6; 1.14.10; 1.14.30;
Refer to the CAVEATS section of ctype(3) for more information.
 1.13 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.12 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 16-Sep-2001  wiz Boring whitespace fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.30.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.14.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.14.10.1 17-Apr-2008  apb file isspace.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.14.6.1 30-Oct-2012  yamt sync with head
 1.14 17-Apr-2008  apb branches: 1.14.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.13 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.12 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 28-Apr-1998  fair branches: 1.7.12;
Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.4 25-Nov-1993  jtc Misc manpage fixes.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.3 01-Aug-2002  nathanw Catch up to -current.
 1.7.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.14.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.14.10.1 17-Apr-2008  apb file isupper.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.13 17-Apr-2008  apb branches: 1.13.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.12 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.11 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 15-Oct-1993  jtc Make sure all items in SEE ALSO list are comma separated.
Add cross references to isblank().
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.13.10.1 17-Apr-2008  apb file isxdigit.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.14 03-Jul-2006  drochner move manpages for frexp/ldexp/modf to libm -- the (most) implementation is
already there
 1.13 23-Mar-2006  wiz Bump date for previous.
 1.12 21-Mar-2006  drochner mention single precision versions and advise to link against libm
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.7 29-Aug-1999  mycroft branches: 1.7.10;
HUGE_VAL -> infinity
 1.6 29-Aug-1999  mycroft Mention more of the special cases.
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 18-Oct-1993  jtc Grammar and formatting fixes.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.6 07-Oct-2016  christos Sync with compat and remove dup implementations of ldexp and modf, switching
mips and m68k to the compat copies.
 1.5 28-Apr-2008  martin branches: 1.5.8; 1.5.46;
Remove clause 3 and 4 from TNF licenses
 1.4 30-Dec-2003  martin branches: 1.4.30;
In case of underflow, return -0.0 or +0.0, depending on the sign of
the argument.
This makes sparc64 pass regress/lib/libc/ldexp.
 1.3 27-Oct-2003  mrg fix a typo that caused the build to fail. mmm commit before compile
 1.2 27-Oct-2003  kleink Retire local union { floating-type; struct ieee_prec; } in favor of those
available from <machine/ieee.h>
 1.1 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.4.30.1 18-May-2008  yamt sync with head.
 1.5.46.1 04-Nov-2016  pgoyette Sync with HEAD
 1.5.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5.8.1 28-Apr-2008  martin file ldexp_ieee754.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.3 19-May-1994  mycroft Clean up deleted files.
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 22-Oct-1993  jtc Add my lsearch & lfind implementations.
 1.12 15-Oct-2011  rmind Mention POSIX conformance of some functions, when they appeared, sprinkle .Xr.
 1.11 30-Mar-2011  jruoho + .Pp.
 1.10 30-Apr-2008  martin branches: 1.10.8;
Convert TNF licenses to new 2 clause variant
 1.9 16-Apr-2003  wiz branches: 1.9.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.7 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 22-Mar-1999  garbled branches: 1.5.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.4 09-Mar-1999  erh Add missing .El lines.
 1.3 16-Feb-1999  kleink Dv vs. Va police.
 1.2 05-Feb-1998  perry add LIBRARY section to man page
 1.1 20-Dec-1997  kleink Add lockf(), an alternate interface to perform advisory record locking;
per XPG4.2.
 1.5.12.3 18-Oct-2002  nathanw Catch up to -current.
 1.5.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.9.30.1 18-May-2008  yamt sync with head.
 1.10.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.10.8.1 30-Apr-2008  martin file lockf.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.4 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.3 28-Apr-2008  martin branches: 1.3.4; 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 22-Jan-2000  mycroft branches: 1.2.38;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.1 20-Dec-1997  kleink Add lockf(), an alternate interface to perform advisory record locking;
per XPG4.2.
 1.2.38.1 18-May-2008  yamt sync with head.
 1.3.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3.8.1 28-Apr-2008  martin file lockf.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.3.4.1 30-Oct-2012  yamt sync with head
 1.3 19-May-1994  mycroft Clean up deleted files.
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 22-Oct-1993  jtc Add my lsearch & lfind implementations.
 1.3 19-May-1994  mycroft Clean up deleted files.
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 22-Oct-1993  jtc Add my lsearch & lfind implementations.
 1.10 04-May-2012  joerg Drop obsolete pthread restriction.
 1.9 29-Apr-2010  jruoho branches: 1.9.6; 1.9.8;
Properly mark the standard that "deprecated" all of these.
 1.8 28-Apr-2010  jruoho Note that the ucontext(2) et. al. were first moved from X/OPEN extensions to
the base POSIX-2001 and later marked as obsolete in POSIX-2008.
 1.7 20-Apr-2009  wiz Remove duplicate 'the' found by Jukka Salmi.
 1.6 16-Apr-2009  wiz Add CAVEATS section:
Due to limitations in the current pthread implementation, makecontext(3)
and sigaltstack(2) should not be used in programs which link against
libpthread (whether threads are used or not).

Wording from drochner@ and ad@

Bump date for man pages.

Add note in libpthread/README so it's not forgotten to update the man
pages when the problem is fixed.
 1.5 30-Apr-2008  martin branches: 1.5.6; 1.5.8; 1.5.10;
Convert TNF licenses to new 2 clause variant
 1.4 18-Nov-2003  uwe branches: 1.4.30;
s/modified/modifies/ in the description of makecontext().
 1.3 14-Oct-2003  wiz Move siginfo(5) and ucontext(5) to siginfo(2) and ucontext(2) resp.,
and fix references.
Per a discussion on source-changes around Sep 14 2003.
 1.2 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.1 21-Jan-2003  wiz Add makecontext(3) from Klaus Klein.
 1.4.30.1 18-May-2008  yamt sync with head.
 1.5.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.5.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.5.8.1 30-Apr-2008  martin file makecontext.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.5.6.1 25-Apr-2009  snj Pull up following revision(s) (requested by rmind in ticket #727):
lib/libc/gen/makecontext.3: revision 1.6
lib/libc/sys/sigaltstack.2: revision 1.22
lib/libpthread/pthread.3: revision 1.11
Add CAVEATS section:
Due to limitations in the current pthread implementation, makecontext(3)
and sigaltstack(2) should not be used in programs which link against
libpthread (whether threads are used or not).
Wording from drochner@ and ad@
Bump date for man pages.
 1.9.8.1 07-May-2012  riz Pull up following revision(s) (requested by joerg in ticket #223):
lib/libc/gen/makecontext.3: revision 1.10
Drop obsolete pthread restriction.
 1.9.6.1 23-May-2012  yamt sync with head.
 1.11 03-Jul-2006  drochner move manpages for frexp/ldexp/modf to libm -- the (most) implementation is
already there
 1.10 23-Mar-2006  wiz Bump date for previous.
 1.9 21-Mar-2006  drochner mention single precision versions and advise to link against libm
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 16-Sep-2001  wiz Boring whitespace fixes.
 1.4 05-Feb-1998  perry branches: 1.4.12;
add LIBRARY section to man page
 1.3 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.5 07-Oct-2016  christos Sync with compat and remove dup implementations of ldexp and modf, switching
mips and m68k to the compat copies.
 1.4 22-Mar-2012  he branches: 1.4.14;
Add a pair of casts to silence lint about conversion possibly losing bits.
 1.3 27-Jan-2010  drochner branches: 1.3.6;
fix behavior in case of +-Inf or NaN input: return the proper
values and set *iptr
(This code is only used under non-default build options, and on m68k.)
 1.2 27-Oct-2003  kleink Retire local union { floating-type; struct ieee_prec; } in favor of those
available from <machine/ieee.h>
 1.1 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.3.6.1 17-Apr-2012  yamt sync with head
 1.4.14.1 04-Nov-2016  pgoyette Sync with HEAD
 1.2 20-Oct-1994  mycroft Clean up deleted files.
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.2 20-Oct-1994  mycroft Clean up deleted files.
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.2 20-Oct-1994  mycroft Clean up deleted files.
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.2 20-Oct-1994  mycroft Clean up deleted files.
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.3 15-Apr-2005  kleink Push back the descriptions of NaN formats, and descriptions of the
distinction between signalling NaNs and quiet NaNs back into the
machine-dependent headers; treat the implementation of __nanf in the
same spirit.

IEEE 754 leaves the distinction between signalling NaNs and quiet NANs
to the implementation, and unlike our headers used to suggest they're
not identical in the interpretation of the fraction's MSb; in due
course, make those of hppa, mips, sh3, and sh5 reflect reality.
 1.2 22-Oct-2003  kleink branches: 1.2.6;
G/c __nanf2, which is neither being used nor the representation of a NaN.
 1.1 12-May-2003  kleink Rename ieee754_function.c to function_ieee754.c, following the convention
used in exec_format.c, loadfile_format.c, subsys_machdep.c etc.
Per discussion with Christos.
 1.2.6.1 19-Apr-2005  tron Pull up file removal (requested by kleink in ticket #163):
Push back the descriptions of NaN formats, and descriptions of the
distinction between signalling NaNs and quiet NaNs back into the
machine-dependent headers; treat the implementation of __nanf in the
same spirit.
IEEE 754 leaves the distinction between signalling NaNs and quiet NANs
to the implementation, and unlike our headers used to suggest they're
not identical in the interpretation of the fraction's MSb; in due
course, make those of hppa, mips, sh3, and sh5 reflect reality.
 1.2 26-Oct-2022  andvar fix RCSID.
 1.1 30-Dec-2005  agc Add Todd Miller's ftw(3) and nftw(3) file-tree walking functionality,
from OpenBSD.

Bump libc minor to 136.
 1.14 01-May-2011  christos Start eliminating "super-user" from the documentation.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.11 04-Sep-2002  wiz completion, not completition; use \- instead of -.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.8 16-Sep-2001  wiz Boring whitespace fixes.
 1.7 22-Mar-1999  garbled branches: 1.7.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.6 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.5 16-Feb-1998  kleink Sync SYNOPSIS with reality, and add RETURN VALUE and ERRORS sections.
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.4 17-Sep-2002  nathanw Catch up to -current.
 1.7.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13 01-May-2011  christos nice should always return EPERM, not EACCES
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 10-Jun-2002  kleink Take into consideration that setpriority() silently fits the given
priority into its interval, so we really need to use getpriority() to
retrieve the correct return value; noted by Matthias Drochner.
 1.10 04-Jun-2002  kleink As documented, return the new priority if successful; from Matthias
Drochner in PR lib/17156.
 1.9 22-Jan-2000  mycroft branches: 1.9.6; 1.9.8;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 09-Jun-1998  mikel include <errno.h> instead of declaring errno locally
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 27-Feb-1995  cgd branches: 1.5.4;
merge with Lite, keeping local changes. Fix up Id format, etc.
 1.4 27-Sep-1993  mycroft branches: 1.4.4;
#include <sys/types.h>, for magnum changes.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 02-May-1995  jtc #include "namespace.h"
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.8.2 11-Jun-2002  lukem Pull up revision 1.11 (requested by kleink in ticket #236):
Take into consideration that setpriority() silently fits the given
priority into its interval, so we really need to use getpriority() to
retrieve the correct return value; noted by Matthias Drochner.
 1.9.8.1 04-Jun-2002  lukem Pull up revision 1.10 (requested by kleink in ticket #150):
As documented, return the new priority if successful; from Matthias
Drochner in PR lib/17156.
 1.9.6.1 21-Jun-2002  nathanw Catch up to -current.
 1.14 30-Mar-2020  wiz Add comma in enumeration.
 1.13 30-Mar-2020  maya Mention elf rather than a.out some more.

(Also, inspired by freebsd, which removed the non-elf support)
 1.12 30-Mar-2020  maya xref elf(5).
 1.11 07-Aug-2003  agc branches: 1.11.98;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 22-Mar-1999  garbled branches: 1.7.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.4 09-May-1994  cgd new nlist routines
 1.3 10-Jan-1994  jtc Fix spelling errors.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.3 18-Oct-2002  nathanw Catch up to -current.
 1.7.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.11.98.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.26 21-Oct-2024  skrll Trailing whitespace
 1.25 18-Sep-2014  christos branches: 1.25.28;
make more descriptors that we open as close-on-exec
 1.24 21-Mar-2012  christos c89 definitions
 1.23 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.22 20-Aug-2009  he branches: 1.22.6;
Instead of including <a.out.h> to get at "struct nlist" (with a comment
to explain it), include <nlist.h> instead, so that our mips ports don't
error out in the absence of aout_machdep.h.
 1.21 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.20 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.19 14-Jun-2000  cgd branches: 1.19.4;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.18 23-Jan-2000  mycroft branches: 1.18.2;
Doh. Remove the __weak_alias() as well...
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 03-Jan-2000  msaitoh nlist for COFF
 1.15 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.14 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.13 26-Jul-1998  mycroft const poisoning.
 1.12 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.11 13-Jul-1997  christos Fix RCSID's
 1.10 01-Oct-1996  cgd fix a thinko in the check-removal changes
 1.9 30-Sep-1996  cgd kill recently added 'check' functions, since they only add code to be more
expensive, i.e. they save nothing and add code.
 1.8 27-Sep-1996  cgd Seriously revamp libc's nlist()/__fdnlist() support:
(1) split nlist() into multiple files, for clarity and to make
ELF 32/64 support easier,
(2) support multiple executable types at the same time, and
(3) add support for 32- and 64-bit ELF (32-bit ELF support
originally from OpenBSD, but with several bug fixes so
that it actually handles symbols types more correctly
(and therefore _works_ for some of the more tricky uses
of the nlist routines) and changes for 64-bit ELF support).
 1.7 16-May-1996  cgd branches: 1.7.2;
update for ecoff header changes. Most changes taken from PR 2413,
submitted by Jason Thorpe.
 1.6 29-Sep-1995  cgd add hack-ish support for ecoff nlists (used only on the Alpha).
It's hack-ish, but it appears to work well enough for all/most
programs that use libkvm, e.g. ps, w, netstat, dmesg, etc.
 1.5 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.4 09-May-1994  cgd new nlist routines
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.18.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.19.4.1 10-Dec-2002  thorpej Sync with HEAD.
 1.22.6.1 17-Apr-2012  yamt sync with head
 1.25.28.1 02-Aug-2025  perseant Sync with HEAD
 1.23 21-Mar-2012  christos c89 definitions
 1.22 20-Aug-2009  martin branches: 1.22.6;
forward declare struct nlist before including nlist_private.h to avoid a
compiler warning.
 1.21 20-Aug-2009  he Actually, when we really need the a.out defines from <nlist.h>, we
need to include <a.out.h> anyway. Move it inside #ifdef NLIST_AOUT.
 1.20 20-Aug-2009  he Instead of including <a.out.h> to get at "struct nlist" (with a comment
to explain it), include <nlist.h> instead, so that our mips ports don't
error out in the absence of aout_machdep.h.
 1.19 16-Aug-2009  matt Only include <sys/exec_aout.h> if NLIST_AOUT is defined.
Don't define NLIST_AOUT for mips anymore.
 1.18 16-Feb-2009  lukem A variation on the sign-compare fix for these.
 1.17 16-Feb-2009  tron Fix -Wsign-compare issue (on NetBSD/sparc64).
 1.16 08-Nov-2006  christos branches: 1.16.28;
if we are using ssp, use malloc instead of alloca.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 20-Apr-2003  christos PR/6156: Stefan Grefen: nlist returns bogus value if symbol is multiply
defined in object
 1.13 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.12 14-Jun-2000  cgd branches: 1.12.4;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.11 20-Sep-1999  lukem branches: 1.11.6;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.10 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.9 17-Jun-1999  thorpej MAP_COPY -> MAP_PRIVATE
 1.8 13-Nov-1998  christos delint
 1.7 14-Oct-1998  kleink Need "namespace.h".
 1.6 30-Jun-1998  thorpej Use pread(2) in one place.
 1.5 03-Feb-1998  perry remove obsolete register declarations
 1.4 15-Dec-1997  mrg use MAP_COPY|MAP_FILE.
 1.3 13-Jul-1997  christos Fix RCSID's
 1.2 30-Sep-1996  cgd kill recently added 'check' functions, since they only add code to be more
expensive, i.e. they save nothing and add code.
 1.1 27-Sep-1996  cgd Seriously revamp libc's nlist()/__fdnlist() support:
(1) split nlist() into multiple files, for clarity and to make
ELF 32/64 support easier,
(2) support multiple executable types at the same time, and
(3) add support for 32- and 64-bit ELF (32-bit ELF support
originally from OpenBSD, but with several bug fixes so
that it actually handles symbols types more correctly
(and therefore _works_ for some of the more tricky uses
of the nlist routines) and changes for 64-bit ELF support).
 1.11.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.12.4.1 10-Dec-2002  thorpej Sync with HEAD.
 1.16.28.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.22.6.1 17-Apr-2012  yamt sync with head
 1.11 22-Mar-2012  christos get rid of the cheesy BAD macros
 1.10 22-Mar-2012  he Make this lint-free (only built for real for the __sh__ ports):
* Mark some code after goto as /* NOTREACHED */
* Add a cast for file size (off_t) to size_t to avoid warning about
possibly losing bits.
* Avoid a "pointer casts may be troublesome" warning from lint
by doing a cast via "void *" instead of directly to "struct
coff_filehdr *".
 1.9 21-Mar-2012  christos c89 definitions
 1.8 21-Aug-2009  he branches: 1.8.6;
Introduce a new accessor macro N_NAME() to access the n_name field
in struct nlist, since it's accessed differently depending on
whether we do a.out or not. Use this macro as appropriate in the
nlist* functions.
Also replace some includes of <a.out.h> with <nlist.h>, to fix build
problem for mips.
 1.7 16-Feb-2009  lukem A variation on the sign-compare fix for these.
 1.6 25-Oct-2006  uwe branches: 1.6.28;
G/c check() macro, b/c it's used only twice and the off < 0 test is
useless in the first case (off is 0), and causes error with new gcc
(comparison of unsigned expression < 0 is always false) in the
second.

While here fix a typo in a comment and use less indent to make BAD and
BADUNMAP definitions fit 80 columns.

XXX: The second check should probably be more elaborate to protect
against bogus/malicious COFF files.
 1.5 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.4 14-Jun-2000  cgd sweep of my licenses (userland files w/o only my copyright) for
consistency. (no functional changes)
 1.3 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.2 09-Jun-2000  simonb Remove a bit of lint.
 1.1 03-Jan-2000  msaitoh branches: 1.1.2;
nlist for COFF
 1.1.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.6.28.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.8.6.1 17-Apr-2012  yamt sync with head
 1.23 20-Mar-2012  matt Simplify a bit and constify as well. Since the file is mapped read-only,
use const references to access its data.
 1.22 20-Mar-2012  christos cast to size_t
 1.21 20-Mar-2012  christos - sprinkle CONSTCOND
- back to char * to simplify code, requested by gimpy
 1.20 19-Mar-2012  christos don't do arithmetic on void pointer.
 1.19 18-Mar-2012  christos fix lint.
 1.18 21-Aug-2009  he branches: 1.18.6;
Introduce a new accessor macro N_NAME() to access the n_name field
in struct nlist, since it's accessed differently depending on
whether we do a.out or not. Use this macro as appropriate in the
nlist* functions.
Also replace some includes of <a.out.h> with <nlist.h>, to fix build
problem for mips.
 1.17 16-Feb-2009  lukem A variation on the sign-compare fix for these.
 1.16 16-Feb-2009  lukem fix -Wsign-compare issue (on alpha)
 1.15 23-Oct-2006  he branches: 1.15.28;
Avoid "unsigned < 0" comparison by open-coding the remaining part
of the check() macro.
 1.14 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.13 14-Jun-2000  cgd sweep of my licenses (userland files w/o only my copyright) for
consistency. (no functional changes)
 1.12 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.11 09-Jun-2000  simonb Remove a bit of lint.
 1.10 20-Sep-1999  lukem branches: 1.10.6;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 17-Jun-1999  thorpej MAP_COPY -> MAP_PRIVATE
 1.7 14-Oct-1998  kleink Need "namespace.h".
 1.6 03-Feb-1998  perry remove obsolete register declarations
 1.5 15-Dec-1997  mrg use MAP_COPY|MAP_FILE.
 1.4 13-Jul-1997  christos Fix RCSID's
 1.3 01-Oct-1996  cgd clone from nlist_elf32.c (with ECOFF mods). Adds comments,
optimization, cleanup.
 1.2 30-Sep-1996  cgd kill recently added 'check' functions, since they only add code to be more
expensive, i.e. they save nothing and add code.
 1.1 27-Sep-1996  cgd Seriously revamp libc's nlist()/__fdnlist() support:
(1) split nlist() into multiple files, for clarity and to make
ELF 32/64 support easier,
(2) support multiple executable types at the same time, and
(3) add support for 32- and 64-bit ELF (32-bit ELF support
originally from OpenBSD, but with several bug fixes so
that it actually handles symbols types more correctly
(and therefore _works_ for some of the more tricky uses
of the nlist routines) and changes for 64-bit ELF support).
 1.10.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.28.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.18.6.1 17-Apr-2012  yamt sync with head
 1.39 26-Feb-2016  christos lint comment
 1.38 20-May-2015  matt Rework ksym defines and includes.
 1.37 20-May-2015  matt Change the ksyms ioctls to more compat_netbsd32 friendly. Use _IOWR ioctls
to avoid extra copyouts. With these changes, netstat and vmstat work on
mips64eb with the normal N32 userland and a N64 kernel.
 1.36 19-May-2015  matt Support ELF64 on MIPS N32 even though it's ILP32.
XXX should we do this for other arches that support compat_netbsd32?
 1.35 21-Mar-2012  christos - don't compile unreachable code.
- convert uintmax_t to uintptr_t
 1.34 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.33 15-Oct-2011  christos branches: 1.33.2;
report STT_COMMON symbols as data.
 1.32 28-Aug-2010  joerg Replace the current usage of Elf64_Half with Elf64_Word and rename
NetBSD specific Elf64_Quarter to Elf64_Half. This restores compatibility
with the common ELF specifications.
 1.31 21-Aug-2009  he Introduce a new accessor macro N_NAME() to access the n_name field
in struct nlist, since it's accessed differently depending on
whether we do a.out or not. Use this macro as appropriate in the
nlist* functions.
Also replace some includes of <a.out.h> with <nlist.h>, to fix build
problem for mips.
 1.30 16-Feb-2009  lukem A variation on the sign-compare fix for these.
 1.29 06-Feb-2009  lukem branches: 1.29.2;
sign-compare fix
 1.28 12-Jun-2005  lukem Add missing __RCSID()
 1.27 01-Jun-2005  lukem Exit via the correct cleanup path; we can't munmap until the mmap has
been performed.
Detected with gcc -Wuninitialized.
(The bug was introduced in rev 1.22. Hi Ragge! :)
 1.26 28-Dec-2004  thorpej branches: 1.26.2;
More ELF_ST_BIND()/ELF_ST_TYPE() cleanup.
 1.25 27-Dec-2004  thorpej Use ELF_ST_BIND() and ELF_ST_TYPE().
 1.24 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.23 11-May-2003  christos make this compile again.
 1.22 11-May-2003  ragge Teach nlist to retrieve symbols from /dev/ksyms (using the quick-search
ioctl's).
 1.21 14-Jun-2000  cgd sweep of my licenses (userland files w/o only my copyright) for
consistency. (no functional changes)
 1.20 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.19 04-Nov-1999  erh branches: 1.19.2;
Remove ELFNAME defines since they are defined in sys/exec_elf.h
 1.18 25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.17 22-Oct-1999  hannken Undo last change. While these macros are defined in exec_elf.h, they are
enclosed by `#ifdef _KERNEL'.
 1.16 21-Oct-1999  erh Remove ELFNAME macros which are already defined in exec_elf.h.
 1.15 20-Sep-1999  lukem branches: 1.15.2;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.14 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.13 17-Jun-1999  thorpej MAP_COPY -> MAP_PRIVATE
 1.12 13-Nov-1998  christos delint
 1.11 14-Oct-1998  kleink Need "namespace.h".
 1.10 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.9 26-Jul-1998  mycroft const poisoning.
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 15-Dec-1997  mrg use MAP_COPY|MAP_FILE.
 1.6 17-Jul-1997  thorpej - Don't deref a bad pointer in the event the object has no symbol
section header. Instead, treat the object as stripped.
- Add a "default" case to the symbol type switch to calm GCC's jets.
 1.5 03-Oct-1996  cgd fix pasto: Elf_{Off,Word} rather than Elf32_{Off,Word}
 1.4 01-Oct-1996  cgd clean up comments a bit.
 1.3 01-Oct-1996  cgd "do over." Rewrite from scratch, or, more precisely, based on a high-speed
merge of libc's ECOFF nlist support (written by me, a while ago), and the
(relatively new, but again written by me) kvm_mkdb ELF support.
 1.2 30-Sep-1996  cgd kill recently added 'check' functions, since they only add code to be more
expensive, i.e. they save nothing and add code. also, beat it with the
style stick.
 1.1 27-Sep-1996  cgd Seriously revamp libc's nlist()/__fdnlist() support:
(1) split nlist() into multiple files, for clarity and to make
ELF 32/64 support easier,
(2) support multiple executable types at the same time, and
(3) add support for 32- and 64-bit ELF (32-bit ELF support
originally from OpenBSD, but with several bug fixes so
that it actually handles symbols types more correctly
(and therefore _works_ for some of the more tricky uses
of the nlist routines) and changes for 64-bit ELF support).
 1.15.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.26.2.1 11-Jun-2005  tron Pull up revision 1.27 (requested by lukem in ticket #393):
Exit via the correct cleanup path; we can't munmap until the mmap has
been performed.
Detected with gcc -Wuninitialized.
(The bug was introduced in rev 1.22. Hi Ragge! :)
 1.29.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.33.2.1 17-Apr-2012  yamt sync with head
 1.6 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.5 14-Jun-2000  cgd sweep of my licenses (userland files w/o only my copyright) for
consistency. (no functional changes)
 1.4 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.3 13-Jul-1997  christos branches: 1.3.10;
Fix RCSID's
 1.2 27-Sep-1996  cgd rename rcsid to e64rcsid, so it doesn't conflict with the one in nlist_elf32.c
 1.1 27-Sep-1996  cgd Seriously revamp libc's nlist()/__fdnlist() support:
(1) split nlist() into multiple files, for clarity and to make
ELF 32/64 support easier,
(2) support multiple executable types at the same time, and
(3) add support for 32- and 64-bit ELF (32-bit ELF support
originally from OpenBSD, but with several bug fixes so
that it actually handles symbols types more correctly
(and therefore _works_ for some of the more tricky uses
of the nlist routines) and changes for 64-bit ELF support).
 1.3.10.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.27 21-Oct-2024  skrll risc-v: Fix nlist on ELF64

The define __riscv64 is not provided (anymore?), so use _LP64 to determine
if nlist support for ELF64 should be added.

This fixes a problem pointed to me by he@

riscv64# pstat -sh -N /netbsd
pstat: kvm_nlist: bad namelist
riscv64#

in that it now doesn't fail with "bad namelist". Other problems with pstat
seem to exist, however.
 1.26 30-Mar-2020  maya branches: 1.26.8;
Be less of a minefield for new architectures. They're not going to be a.out.
Remove sh5, long gone.
(Hopefully nothing hits the #else case)
 1.25 29-Jan-2016  christos branches: 1.25.16;
add or1k
 1.24 29-Jan-2016  christos missing ia64.
 1.23 13-Jun-2015  dennis Add entries for riscv and aarch64. This lets the former build
complete and gets the latter close to the end.
 1.22 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.21 17-Jan-2011  matt branches: 1.21.6;
cleanup format of #ifdef
 1.20 24-Sep-2010  matt If not using O32 on mips, we need to read ELF64 symbols too.
 1.19 21-Aug-2009  he Introduce a new accessor macro N_NAME() to access the n_name field
in struct nlist, since it's accessed differently depending on
whether we do a.out or not. Use this macro as appropriate in the
nlist* functions.
Also replace some includes of <a.out.h> with <nlist.h>, to fix build
problem for mips.
 1.18 16-Aug-2009  matt Only include <sys/exec_aout.h> if NLIST_AOUT is defined.
Don't define NLIST_AOUT for mips anymore.
 1.17 26-Jul-2003  salo branches: 1.17.46;
netbsd.org->NetBSD.org
 1.16 23-Nov-2002  fvdl Enable ELF32 nlist (as well as ELF64) for x86-64.
 1.15 11-Jul-2002  scw Add SH5 support. (Missed these during the last sweep of my local tree)
 1.14 06-Jun-2002  fredette Added hppa support (some of it incomplete) to lib/csu, lib/libc,
and lib/libkvm.
 1.13 05-Jun-2002  fvdl Use NLIST_ELF64 for x86_64.
 1.12 03-May-2001  matt Enable ELF32 support for VAX.
 1.11 17-Feb-2001  bjh21 branches: 1.11.2;
Make both ARM ports support both NLIST_AOUT and NLIST_ELF32.
 1.10 14-Jun-2000  cgd sweep of my licenses (userland files w/o only my copyright) for
consistency. (no functional changes)
 1.9 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.8 09-May-2000  bjh21 branches: 1.8.2;
Initial commit of arm26 port
 1.7 03-Jan-2000  msaitoh nlist for COFF
 1.6 29-Jan-1999  thorpej Sync w/ kvm_mkdb.
 1.5 12-Jul-1998  thorpej Add Elf32 support for i386, m68k, and sparc.
 1.4 29-Mar-1997  thorpej MIPS: a.out, ecoff, and elf nlist support
PowerPC: a.out and elf nlist support
 1.3 30-Sep-1996  cgd kill recently added 'check' functions, since they only add code to be more
expensive, i.e. they save nothing and add code.
 1.2 27-Sep-1996  cgd slightly tune what gets compiled in: On the Alpha, we need ECOFF and
ELF64. On other architectures only include a.out support, since we don't
know whether or not they'll have the headers necessary for ECOFF and/or
ELF, and since they only want a.out for now (execpt the mips archs, but
they do Special things). There should be a better way to select which
bits of nlist code get compiled in, but currently there is not.
 1.1 27-Sep-1996  cgd Seriously revamp libc's nlist()/__fdnlist() support:
(1) split nlist() into multiple files, for clarity and to make
ELF 32/64 support easier,
(2) support multiple executable types at the same time, and
(3) add support for 32- and 64-bit ELF (32-bit ELF support
originally from OpenBSD, but with several bug fixes so
that it actually handles symbols types more correctly
(and therefore _works_ for some of the more tricky uses
of the nlist routines) and changes for 64-bit ELF support).
 1.8.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.11.2.4 10-Dec-2002  thorpej Sync with HEAD.
 1.11.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.11.2.2 21-Jun-2002  nathanw Catch up to -current.
 1.11.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.17.46.1 27-Jan-2010  matt Don't use cfc1/ctc1 in softfloat. Use the "common" fabs/modf/ldexp when
using softfloat.
 1.21.6.1 17-Apr-2012  yamt sync with head
 1.25.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.26.8.1 02-Aug-2025  perseant Sync with HEAD
 1.39 26-Nov-2014  christos - Use O_DIRECTORY to open the file, so that we don't need to stat() after
that.
- Move the stat() call to fdopendir() and change it's error handling so that
it does not hide errors.
- According to POSIX, fdopendir() transfers ownership of the fd only on
success, so don't close it on failure. XXX: We still make it non-blocking
on failure, but that's nitpicking.

XXX: pullup-7?
 1.38 15-Oct-2011  christos branches: 1.38.20;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.37 26-Sep-2010  yamt fix rewinddir on nfs. fix PR/42879 (and probably PR/40229.)
 1.36 16-Sep-2010  yamt - remove a wrong _DIAGASSERT
- update comments
- whitespace
 1.35 11-Jan-2009  christos merge christos-time_t
 1.34 05-Dec-2008  ad Add fdopendir(), from Solaris/Linux.
 1.33 10-Jan-2008  elad branches: 1.33.12;
PR/35562: khorben at defora dot org: Potential denial of service when
listing files on an NFS share

Limit the number of retries as suggested in the PR.

Reviewed by and okay fvdl@.
 1.32 17-Jul-2007  christos branches: 1.32.4;
kill MFSNAMELEN
 1.31 17-May-2006  christos PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.30 24-Jan-2006  christos rename __func to _func_unlocked, and add their prototypes in extern.h
instead of exposing them in dirent.h. More locking consistency fixes.
 1.29 24-Jan-2006  christos PR/32609: Tanaka Akira: seekdir blocks if pthread is linked
Do locking consistently to avoid recursive locks (like the bug reported in
this pr), and to avoid leaking locks on errors.
 1.28 13-Sep-2005  christos compat core reorg.
 1.27 19-Aug-2005  christos 64 bit inode changes
 1.26 19-Jan-2005  mycroft Also set FD_CLOEXEC in the union re-open case.
 1.25 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 29-May-2003  nathanw Allocate and initialize dirp->dd_lock before calling telldir(), which
will try to lock it.

Addresses PR lib/21712.
 1.22 28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.21 02-Mar-2003  enami Fix realloc usage.
 1.20 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.19 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.18 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.17 13-Nov-1998  christos delint
 1.16 27-Feb-1998  perry trivial changes to quiet lint.
 1.15 10-Oct-1997  fvdl Use getdents(). Read NFS directories in one go (just as union dirs, but
without removing double entries). This makes sure that we get a
consistent snapshot of the directory, and protects against any
'bad cookie' errors.
 1.14 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.13 13-Jul-1997  christos Fix RCSID's
 1.12 25-Feb-1997  fvdl Check for both the filesystem name and the filesystem flags to determine
whether a directory is a union mount, and thus needs to have double
entries filtered out.
 1.11 20-Dec-1996  cgd string.h for prototypes
 1.10 18-Jun-1995  cgd branches: 1.10.4;
don't assume f_fstypename is larger than MFSNAMELEN or is nul-terminated
 1.9 12-Jun-1995  jtc Open with O_NONBLOCK, in case someone tries to open a blocking device
or a non-open fifo instead of a directory.
 1.8 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.7 28-Dec-1994  mycroft branches: 1.7.2;
Format police, and a small patch for 64-bitness.
 1.6 28-Dec-1994  mycroft Repair a couple of things.
 1.5 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.4 15-Sep-1994  pk Use getpagesize() in stead of CLBYTES.
 1.3 27-Jul-1994  jtc branches: 1.3.2;
Add RCS Id's
 1.2 27-Jul-1994  jtc Return NULL and set errno to ENOTDIR if opening a non-directory (POSIX.1,
Section 5.1.2.4). Rename _seekdir to __seekdir, as former is in the
user's namespace.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.2.2 27-Jul-1994  jtc Add RCS Id's
 1.3.2.1 27-Jul-1994  jtc file opendir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:47 +0000
 1.7.2.2 02-May-1995  jtc #include "namespace.h"
 1.7.2.1 26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.10.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.32.4.1 23-Mar-2008  matt sync with HEAD
 1.33.12.1 04-Jan-2009  christos merge with head.
 1.38.20.1 14-Apr-2015  snj Pull up following revision(s) (requested by christos in ticket #691):
lib/libc/gen/opendir.c: revision 1.39
- Use O_DIRECTORY to open the file, so that we don't need to stat() after
that.
- Move the stat() call to fdopendir() and change it's error handling so that
it does not hide errors.
- According to POSIX, fdopendir() transfers ownership of the fd only on
success, so don't close it on failure. XXX: We still make it non-blocking
on failure, but that's nitpicking.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 07-Feb-2002  ross Generate <>& symbolically.
 1.12 16-Sep-2001  wiz Boring whitespace fixes.
 1.11 22-Mar-1999  garbled branches: 1.11.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.10 11-Dec-1998  is mention poll(2).
 1.9 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 16-May-1997  kleink Add/update 1003.1 conformance notice.
 1.6 17-Jan-1997  perry add setitimer (mentioned in text) to SEE ALSO
 1.5 17-Jan-1997  perry close 2885 -- sigpause->sigsuspend
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.11 24-Jun-2012  christos fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.10 07-Aug-2003  agc branches: 1.10.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 26-Sep-1998  christos Use posix system calls.
 1.7 27-Feb-1998  perry trivial changes to quiet lint.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 27-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.56.1 30-Oct-2012  yamt sync with head
 1.25 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.24 27-Mar-2022  gutteridge popen.3: revert s/null-/nul-/ change, this is subject to debate
 1.23 24-Mar-2022  gutteridge popen.3: minor spelling, grammar, style, and xref tweaks
 1.22 11-Sep-2021  rillig popen.3: move popenve from BUGS to HISTORY
 1.21 21-Feb-2017  abhinav Use Fn for function name.
 1.20 21-Jan-2015  wiz branches: 1.20.2; 1.20.4;
Whitespace fixes. Remove duplicate Pp.
 1.19 20-Jan-2015  christos Factor out popen() code into separate functions and create popenve()
using the new functions, a safer version of popen() that does not
involve a shell. Correct manual page inaccuracies.
 1.18 27-Jun-2011  wiz Various minor improvements.
 1.17 26-Jun-2011  christos * Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.
 1.16 02-Aug-2007  wiz branches: 1.16.14;
Add xref to shquote(3), suggested by joerg. Bump date.
 1.15 14-Jul-2004  wiz Bump date for previous.
 1.14 14-Jul-2004  kleink Add a STANDARDS section; noted by Peter Bex in PR standards/25957.
 1.13 07-Aug-2003  agc branches: 1.13.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.11 02-Mar-2003  jmmv Grammar fix in return values section.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.8 28-Apr-1998  fair branches: 1.8.12;
Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 02-Feb-1998  perry merge/update to lite-2
 1.5 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.4 07-May-1994  cgd clean up conflicts
 1.3 06-May-1994  jtc merge our changes into 4.4lite
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 06-May-1994  jtc 44lite code
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.13.2.1 15-Jul-2004  he Pull up revisions 1.14-1.15 (requested by kleink in ticket #658):
Add a STANDARDS section; fixes PR#25957.
 1.16.14.2 02-Aug-2007  wiz Add xref to shquote(3), suggested by joerg. Bump date.
 1.16.14.1 02-Aug-2007  wiz file popen.3 was added on branch matt-mips64 on 2007-08-02 23:45:11 +0000
 1.20.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.20.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.38 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.37 29-Oct-2021  kre Add "--" 'options end' parameter to the sh -c call that runs the
command, so that the command cannot appear to be more options
(which always then fails, as there would be no arg for "-c" to
treat as the command string in that case).

For the full (LONG) explanation, see:
http://mail-index.netbsd.org/current-users/2021/10/29/msg041629.html
 1.36 24-Jan-2019  christos PR/53904: Jintao Zhu: Use a mutex instead of an rwlock to assure thread safety
 1.35 02-Feb-2015  christos branches: 1.35.8; 1.35.14; 1.35.16;
CID/1267868: Resource leak "cur"
 1.34 20-Jan-2015  christos Fix non _REENTRANT build.
 1.33 20-Jan-2015  christos Factor out popen() code into separate functions and create popenve()
using the new functions, a safer version of popen() that does not
involve a shell. Correct manual page inaccuracies.
 1.32 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.31 26-Jun-2011  christos branches: 1.31.2;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.
 1.30 14-Nov-2010  tron Improve and simplify implementation of *env(3) functions:
- Use RB tree to keep track of memory allocated via setenv(3) as
suggested by Enami Tsugutomo in private e-mail.
This simplifies the code a lot as we no longer need to keep the size
of "environ" in sync with an array of allocated environment variables.
It also makes it possible to free environment variables in unsetenv(3)
if something has changed the order of the "environ" array.
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
results e.g. for " getenv("A=B") " if an environment variable "A"
with value "B=C" exists.
- Clean up the internal functions:
- Don't expose the read/write lock for the environment to other parts
of "libc". Provide locking functions instead.
- Use "bool" to report success or failure.
- Use "ssize_t" or "size_t" instead of "int" for indexes.
- Provide internal functions with simpler interfaces e.g. don't
combine return values and reference arguments.
- Don't copy "environ" into an allocated block unless we really need
to grow it.

Code reviewed by Joerg Sonnenberger and Christos Zoulas, tested by
Joerg Sonnenberger and me. These changes also fix problems in
zsh 4.3.* and pam_ssh according to Joerg.
 1.29 15-Oct-2006  christos instead of using the (void)&foo kludge to avoid longjmp clobbering of variables
make the variables volatile as needed.
 1.28 15-Sep-2003  cl make popen/pclose thread safe
 1.27 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.26 04-Mar-2003  nathanw Don't acquire __environ_lock around exec*() calls; nothing requires
that these calls be thread-safe with respect to the environment, and it
causes serious problems for threaded applications which call vfork() and
exec*() (including indirectly, via popen() or system()).

Acquire and release __environ_lock in the parent in popen() and system() to
play safe and provide the child with a stable environment.

__environ_lock should also have an atfork() handler; still under development.
 1.25 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.24 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.23 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.22 18-Jul-1998  lukem use AF_LOCAL instead of AF_UNIX
 1.21 19-Mar-1998  tv PR 3673: possible to close the wrong fds
 1.20 04-Feb-1998  tron Fix a severe bug in popen() which only showed up with NetBSD's true
vfork() implementation and close a possible file descriptor leak.
 1.19 03-Feb-1998  perry remove obsolete register declarations
 1.18 03-Feb-1998  perry force twoway and type out of registers in order to shut up a gcc
warning. What a crock!
 1.17 02-Feb-1998  perry fix typo from lite-2 commit
 1.16 02-Feb-1998  perry merge/update to lite-2
 1.15 16-Sep-1997  thorpej Make this safe in environments that have a Real vfork(2). Bug pointed
out by Chuck Cranor <chuck@netbsd.org>
 1.14 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.13 13-Jul-1997  christos Fix clobbered variable warning
Fix RCSID's
 1.12 29-Jun-1996  jtc branches: 1.12.2;
Changed to conform to POSIX.2 B.3.2.2 "popen() shall ensure that any streams
from previous popen() calls that remain open in the parent process are closed
in the new child process." Fixes PR #2575.
 1.11 16-Jun-1995  jtc Don't cast void functions to void.
 1.10 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.9 09-May-1994  jtc branches: 1.9.4;
merge in our POSIX.2 changes (again)
 1.8 07-May-1994  cgd clean up conflicts
 1.7 06-May-1994  jtc merge our changes into 4.4lite
 1.6 11-Nov-1993  jtc First pass at getting a clean compile with "gcc -Wall", mostly explictly
declaring function return values, etc.
 1.5 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.4 23-Aug-1993  jtc Don't block SIGINT, SIGQUIT, SIGHUP, etc. in pclose()...
"Some historical implementations either block or ignore the signals
SIGINT, SIGQUIT, and SIGHUP while waiting for the child process to
terminate. Since this behavior is not described in POSIX.2, such
implementations are not conforming."
 1.3 21-Aug-1993  jtc If mode is niether 'r' or 'w', set errno to EINVAL as per 1003.2-92.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 06-May-1994  jtc 44lite code
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.4.1 02-May-1995  jtc #include "namespace.h"
 1.12.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.31.2.1 30-Oct-2012  yamt sync with head
 1.35.16.1 10-Jun-2019  christos Sync with HEAD
 1.35.14.1 26-Jan-2019  pgoyette Sync with HEAD
 1.35.8.1 27-Jan-2019  martin Pull up following revision(s) (requested by christos in ticket #1170):

lib/libc/gen/popen.c: revision 1.36

PR/53904: Jintao Zhu: Use a mutex instead of an rwlock to assure thread safety
 1.13 15-Nov-2021  wiz Sort SEE ALSO.
 1.12 15-Nov-2021  christos Add man pages for posix_spawn_file_actions_add{f,}chdir from piyush
 1.11 12-Jun-2019  wiz Fix typo.
 1.10 12-Jun-2019  kamil Rephrase sentence about vfork+exec in posix_spawn(3)

Try to make it less confusing.

Requested by <joerg>
 1.9 12-Jun-2019  kamil Document that posix_spawn(3) uses a dedicated syscall

vfork+exec operations are done in one go. This is important information for
programs that wrap posix_spawn(3).
 1.8 11-Jun-2019  wiz Quote the name "Ed" to avoid confusion with the macro "Ed".
 1.7 11-Jun-2019  kamil Correct outdated note that posix_spawn(3) is implemented with vfork(2)

The original FreeBSD libc code uses vfork(2), it's not the case for NetBSD
as there is a dedicated kernel syscall.
 1.6 02-Feb-2014  wiz branches: 1.6.26;
Bump date for previous.
 1.5 02-Feb-2014  martin Limit the amount of kernel memory a posix_spawn syscall can use (for handling
the file action list) by limiting the maximum number of file actions to
twice the current file descriptor limit.
Fix a few bugs in the support functions and document the new limit.
From Maxime Villard.
 1.4 20-Jul-2013  wiz Use Mt for email addresses.
 1.3 23-Mar-2012  njoly branches: 1.3.2; 1.3.4; 1.3.6;
Use major.minor for NetBSD versions.
 1.2 13-Feb-2012  njoly branches: 1.2.2; 1.2.6; 1.2.8;
Fix sched_set{param,scheduler} sections.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.8.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.2.6.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.2.2.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.3.6.1 23-Jul-2013  riastradh sync with HEAD
 1.3.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.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.3.2.2 17-Apr-2012  yamt sync with head
 1.3.2.1 23-Mar-2012  yamt file posix_spawn.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.6.26.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3 15-Nov-2021  kre More cleanups and typo corrections.
 1.2 15-Nov-2021  wiz Clean up.
 1.1 15-Nov-2021  christos Add man pages for posix_spawn_file_actions_add{f,}chdir from piyush
 1.5 02-Feb-2014  wiz Sort errors. Bump date for previous.
 1.4 02-Feb-2014  martin Limit the amount of kernel memory a posix_spawn syscall can use (for handling
the file action list) by limiting the maximum number of file actions to
twice the current file descriptor limit.
Fix a few bugs in the support functions and document the new limit.
From Maxime Villard.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin branches: 1.1.2; 1.1.6; 1.1.8;
Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.1.8.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.1.6.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.1.2.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawn_file_actions_addopen.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.5 02-Feb-2014  wiz Sort errors. Bump date for previous.
 1.4 02-Feb-2014  martin Limit the amount of kernel memory a posix_spawn syscall can use (for handling
the file action list) by limiting the maximum number of file actions to
twice the current file descriptor limit.
Fix a few bugs in the support functions and document the new limit.
From Maxime Villard.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin branches: 1.1.2; 1.1.6; 1.1.8;
Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.1.8.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.1.6.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.1.2.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawn_file_actions_init.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.5 07-Nov-2021  christos Commit the userland portion of the posix_spawn_chdir project by Piyush Sachdeva
 1.4 02-Feb-2014  martin Remove paranthesis from return operands.
 1.3 02-Feb-2014  martin Limit the amount of kernel memory a posix_spawn syscall can use (for handling
the file action list) by limiting the maximum number of file actions to
twice the current file descriptor limit.
Fix a few bugs in the support functions and document the new limit.
From Maxime Villard.
 1.2 08-Apr-2012  martin branches: 1.2.2; 1.2.4;
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
 1.1 11-Feb-2012  martin branches: 1.1.2;
Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.1.2.2 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.1.2.1 12-Apr-2012  riz branches: 1.1.2.1.4; 1.1.2.1.6;
Pull up following revision(s) (requested by martin in ticket #175):
sys/kern/kern_exit.c: revision 1.238
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.4
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.5
sys/uvm/uvm_extern.h: revision 1.183
lib/libc/gen/posix_spawn_fileactions.c: revision 1.2
sys/kern/kern_exec.c: revision 1.348
sys/kern/kern_exec.c: revision 1.349
sys/compat/netbsd32/syscalls.master: revision 1.95
sys/uvm/uvm_glue.c: revision 1.159
sys/uvm/uvm_map.c: revision 1.317
sys/compat/netbsd32/netbsd32.h: revision 1.95
sys/kern/exec_elf.c: revision 1.38
sys/sys/spawn.h: revision 1.2
sys/sys/exec.h: revision 1.135
sys/compat/netbsd32/netbsd32_execve.c: revision 1.34
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
Fix asynchronous posix_spawn child exit status (and test for it).
 1.1.2.1.6.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.1.2.1.4.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 08-Apr-2012  yamt file posix_spawn_fileactions.c was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.2 02-Feb-2014  martin Remove paranthesis from return operands.
 1.1 11-Feb-2012  martin branches: 1.1.4; 1.1.8;
Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.1.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.4.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.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 11-Feb-2012  yamt file posix_spawn_sched.c was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawnattr_getflags.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawnattr_getpgroup.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawnattr_getschedparam.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawnattr_getschedpolicy.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawnattr_getsigdefault.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawnattr_getsigmask.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 20-Jul-2013  wiz Use Mt for email addresses.
 1.2 23-Mar-2012  njoly branches: 1.2.2; 1.2.4; 1.2.6;
Use major.minor for NetBSD versions.
 1.1 11-Feb-2012  martin Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.2.6.1 23-Jul-2013  riastradh sync with HEAD
 1.2.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.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.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 23-Mar-2012  yamt file posix_spawnattr_init.3 was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.5 11-Nov-2024  martin Error out early if posix_spawnp(3) is called with an empty file name
 1.4 11-May-2020  kre branches: 1.4.8;

Do as the manual says, and use _PATH_DEFPATH if PATH is not present in
the environment rather than simply turning into posix_spawn() in that case.

Also, we cannot use strtok() to parse PATH, the semantics don't fit the API.
Borrow the guts of execvp for the PATH search.

We still simply check for a file with 'x' permission, and assume that one
will do, whatever it is, which isn't really correct, but ...
 1.3 04-Jan-2018  kamil Add bunch of missing includes of namespace.h in libc

The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

This change eliminates usage of the global changes of the following symbols:
- strlcat -> _strlcat
- sysconf -> __sysconf
- closedir -> _closedir
- fparseln -> _fparseln
- kill -> _kill
- mkstemp -> _mkstemp
- reallocarr -> _reallocarr
- strcasecmp -> _strcasecmp
- strncasecmp -> _strncasecmp
- strptime -> _strptime
- strtok_r -> _strtok_r
- sysctl -> _sysctl
- dlopen -> __dlopen
- dlclose -> __dlclose
- dlsym -> __dlsym

Sponsored by <The NetBSD Foundation>
 1.2 22-Feb-2012  martin branches: 1.2.2;
Use C++ compatible declaration for posix_spawn (instead of the C99 specific
posix one).
 1.1 11-Feb-2012  martin branches: 1.1.2;
Add userland part of posix_spawn. Libc functions imported from FreeBSD.
Based on Charles Zhang's summer of code project.
 1.1.2.1 23-Feb-2012  riz Pull up following revision(s) (requested by martin in ticket #36):
include/spawn.h: revision 1.4
lib/libc/gen/posix_spawnp.c: revision 1.2
Use C++ compatible declaration for posix_spawn (instead of the C99 specific
posix one).
 1.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 22-Feb-2012  yamt file posix_spawnp.c was added on branch yamt-pagecache on 2012-04-17 00:05:19 +0000
 1.4.8.1 02-Aug-2025  perseant Sync with HEAD
 1.17 27-Aug-2010  christos add psiginfo.
 1.16 14-Apr-2010  njoly Add missing double quote.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Boring whitespace fixes.
 1.10 22-Mar-1999  garbled branches: 1.10.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.9 07-Jul-1998  kleink Fix sys_siglist and sys_signame declarations with reality; from John F. Woods
in PR lib/5720.
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 02-Feb-1998  perry merge/update to lite-2
 1.6 03-Jul-1995  jtc add setlocale(3) and strsignal(3) cross references
 1.5 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.4 08-Sep-1993  jtc Elements of sys_signame array should be in upper case.
Both kill and sliplogin, which were converted to use this array, are
either specified to use, or have traditionally used, upper case names.
This change shouldn't have bad side-effects, sys_signame is new to netbsd
and nothing in the source tree except kill and sliplogin use it.
 1.3 06-Aug-1993  mycroft Add sys_signame[].
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.10.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.10.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.10.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.23 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.22 27-Aug-2010  christos branches: 1.22.6;
add psiginfo.
 1.21 29-Nov-2005  christos WARNS=4
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.19 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.18 17-Nov-1998  christos revert previous change; same problem with perror().
 1.17 15-Nov-1998  christos delint
 1.16 13-Nov-1998  christos delint
 1.15 13-Nov-1998  christos delint
 1.14 28-Jul-1998  mycroft Use writev(2) (like perror(3)).
 1.13 27-Feb-1998  perry trivial changes to quiet lint.
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.10 13-Jul-1997  christos Fix RCSID's
Use extern.h don't make local prototypes
 1.9 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.8 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.7 06-Oct-1994  jtc branches: 1.7.2;
Change size of array passed to __strsignal() from 128 to NL_TEXTMAX.
 1.6 06-Oct-1994  jtc Call __strsignal() instead of accessing sys_siglist[] directly.
 1.5 26-Jun-1994  jtc Avoid core dump when using NULL message string.
 1.4 06-Dec-1993  mycroft Add a `const' to shut up gcc.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 02-May-1995  jtc #include "namespace.h"
 1.22.6.1 17-Apr-2012  yamt sync with head
 1.7 19-Jul-2014  wiz Use Nx.
 1.6 19-Jul-2014  roy Document that our use of pthread_mutex_unlock(3) is async-signal-safe
and as such can be used in a phtread_atfork(3) child handler.
 1.5 30-Apr-2008  martin branches: 1.5.8; 1.5.28; 1.5.40;
Convert TNF licenses to new 2 clause variant
 1.4 17-Jun-2005  peter branches: 1.4.18;
Fix some spelling errors.

From Igor Sobrado in PR/29997.
 1.3 16-Apr-2003  wiz branches: 1.3.4; 1.3.6;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 03-Mar-2003  wiz Drop trailing space, mark up NULL with .Dv, break
lines and add section to an xref.
 1.1 13-Feb-2003  nathanw Implement pthread_atfork() (in libc, because the required threadlib
stub behavior is exactly the same as the usual behavior).
 1.3.6.1 18-Jun-2005  tron Pull up revision 1.4 (requested by peter in ticket #473):
Fix some spelling errors.
From Igor Sobrado in PR/29997.
 1.3.4.1 21-Jun-2005  riz Pull up revision 1.4 (requested by peter in ticket #2002):
Fix some spelling errors.
From Igor Sobrado in PR/29997.
 1.4.18.1 18-May-2008  yamt sync with head.
 1.5.40.1 10-Aug-2014  tls Rebase.
 1.5.28.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.5.8.1 30-Apr-2008  martin file pthread_atfork.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.28 06-May-2025  riastradh libc: Sprinkle #ifdef _REENTRANT around thr_sigsetmask.

Workaround -- temporary, I hope -- for:

PR lib/59401: libc: thr_sigsetmask definition is incoherent
 1.27 09-Apr-2025  kre Redo pthread_atfork to avoid malloc()

Allow as many calls to pthread_atfork() as are needed, without
ever doing a single malloc() so it can be called as much as
needed in constructors, etc.

This is the implementation mooted some weeks ago - there
were some alternative suggestions for a different solution,
but none of them have eventuated, so until something else
happens, this will do.

I have been running with this for a while now, no issues
observed, though I am not much of a user of threaded
applications, or anything that really needs constructors.

Feel free to revert (or fix) this if something breaks.
 1.26 04-Mar-2025  christos Explain the situation better and allocate 16 instead of 3 for now to cover
the known cases (from kre@). Still needs to be fixed properly.
 1.25 04-Mar-2025  riastradh Revert __libc_atfork addition.

This reverts the following revisions:

lib/libc/gen/arc4random.c 1.40-41 (but not 1.42 which is independent)
lib/libc/gen/pthread_atfork.c 1.24
lib/libc/include/atfork.h 1.1

This additionally updates the comments in arc4random.c to reflect the
current state.

Requested by kre:
https://mail-index.netbsd.org/source-changes-d/2025/03/03/msg014388.html

Since the new symbol __libc_atfork has not been used outside libc,
this poses no ABI compatibility issues.
 1.24 02-Mar-2025  riastradh libc: New __libc_atfork.

This uses caller-provided storage for the callback queues.

Use it in arc4random(3) in order to avoid possible failure modes.

This is a private symbol, not designed for use outside NetBSD, and
the API is not intended to be stable (yet) -- I just took the
existing purely internal structure (struct atfork_callback) and
reused it for this API without changing any of the calling-side
logic. We could change it, e.g. to use a single structure per call,
to make the API a little less unwieldy, at the cost of
microscopically more storage and runtime for the users that don't use
all three callbacks; to be considered in a future change.

We might reasonably use __libc_atfork in libpthread for use in the
pthread_tsd_init constructor, in order to be confident it never
attempts malloc(3), but let's do that in a separate commit just in
case anything goes awry with that plan.

PR lib/59112: libpthread constructors use malloc
PR lib/59117: arc4random has some failure modes it shouldn't
 1.23 01-Mar-2025  christos simplify af_free() (from kre@)
 1.22 01-Mar-2025  christos keep a cache of 3 entries so that we don't have to call malloc(3) from
libpthread which can't call malloc from a constructor.
 1.21 01-Mar-2025  christos Revert for now. There has been a report that arc4random breaks with it,
and the tests for arc4random set RLIMIT_AS to 0 so that mmap fails.
 1.20 28-Feb-2025  kre Specify MAP_ANON, the default (MAP_FILE) with a fd == -1 makes no sense.
 1.19 28-Feb-2025  christos PR/59112: Martin Husemann: switch to using mmap instead of malloc
 1.18 20-Jan-2024  christos branches: 1.18.2;
Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.17 13-Sep-2022  riastradh pthread_atfork(3): Block signals during the call to pthread_atfork.

This doesn't affect the calls to the atfork handlers -- it only
protects access to the lists of handlers from interruption by a
signal, in case the signal handler calls fork(2).
 1.16 31-May-2022  andvar fix various typos in comments, documentation and messages.
 1.15 15-May-2020  joerg Hook up proper fork lock handling for malloc:
- lock all relevant mutexes just before fork
- unlock all mutexes just after fork in the parent
- full reinit non-spinlocks in the child
This is not using the normal pthread_atfork interface to ensure order of
operation, malloc is used as implementation detail too often.
 1.14 19-Apr-2020  joerg Rename __atomic_fork to __locked_fork and give it &errno as argument.
rtld and libc use different storage, so the initial version would
incorrectly report the failure reason for fork().

There is still a small race condition inside ld.elf_so as it doesn't use
thread-safe errno internally, but that's a more contained internal
issue.
 1.13 16-Apr-2020  joerg Introduce intermediate locking for fork, so that the dynamic linker is
in a consistent state. This most importantly avoids races between dlopen
and friends and fork, potentially resulting in dead locks in the child
when it itself tries to acquire locks.
 1.12 01-Feb-2020  kamil Revert previous

'git grep' breaks now.
 1.11 01-Feb-2020  kamil Switch atform allocations from malloc()+free() to mmap()+munmap()

This avoid bootstrapping malloc too early when libc+libpthread are not
ready. It is called through pthread__init() -> _pthread_atfork().

This also helps LLVM Leak Sanitizer to pacify false positive reports.
 1.10 20-Jan-2015  christos branches: 1.10.16; 1.10.18;
Fix non _REENTRANT build.
 1.9 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.8 28-Apr-2008  martin branches: 1.8.4; 1.8.8;
Remove clause 3 and 4 from TNF licenses
 1.7 07-Mar-2008  ad branches: 1.7.2;
Keep one builtin slot so that pthread initialization doesn't need to use
malloc().
 1.6 14-Dec-2007  yamt branches: 1.6.2;
fix indentation.
 1.5 13-Sep-2005  christos branches: 1.5.10;
compat core reorg.
 1.4 01-Jun-2005  lukem Ensure that we don't try to free random memory when another malloc fails,
by initializing newprepare, newparent, and newchild to NULL.
Detected by gcc -Wuninitialized.
 1.3 21-Oct-2004  lukem branches: 1.3.2;
minor KNF, making it easier to find where fork() is implemented
 1.2 07-Apr-2003  nathanw Oops, make the atfork queues static so they don't pollute the
namespace.
 1.1 13-Feb-2003  nathanw Implement pthread_atfork() (in libc, because the required threadlib
stub behavior is exactly the same as the usual behavior).
 1.3.2.1 11-Jun-2005  tron Pull up revision 1.4 (requested by lukem in ticket #394):
Ensure that we don't try to free random memory when another malloc fails,
by initializing newprepare, newparent, and newchild to NULL.
Detected by gcc -Wuninitialized.
 1.5.10.2 23-Mar-2008  matt sync with HEAD
 1.5.10.1 09-Jan-2008  matt sync with HEAD
 1.6.2.1 24-Mar-2008  keiichi sync with head.
 1.7.2.1 18-May-2008  yamt sync with head.
 1.8.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8.8.1 28-Apr-2008  martin file pthread_atfork.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.10.18.1 13-May-2020  martin Pull up following revision(s) (requested by chs in ticket #907):

libexec/ld.elf_so/rtld.c: revision 1.205
libexec/ld.elf_so/rtld.h: revision 1.140
libexec/ld.elf_so/symbols.map: revision 1.3
libexec/ld.elf_so/symbols.map: revision 1.4
lib/libc/gen/pthread_atfork.c: revision 1.13
lib/libc/gen/pthread_atfork.c: revision 1.14
libexec/ld.elf_so/rtld.h: revision 1.139
libexec/ld.elf_so/rtld.c: revision 1.204

Introduce intermediate locking for fork, so that the dynamic linker is
in a consistent state. This most importantly avoids races between dlopen
and friends and fork, potentially resulting in dead locks in the child
when it itself tries to acquire locks.

Rename __atomic_fork to __locked_fork and give it &errno as argument.
rtld and libc use different storage, so the initial version would
incorrectly report the failure reason for fork().

There is still a small race condition inside ld.elf_so as it doesn't use
thread-safe errno internally, but that's a more contained internal
issue.
 1.10.16.1 21-Apr-2020  martin Sync with HEAD
 1.18.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 18-Sep-2003  jdolecek remove pw_dup(3), for now at least
follows discussion on mailing lists, discussed in private e-mail with Itojun
 1.2 10-Sep-2003  wiz Use In instead of Fd for header files.
 1.1 09-Sep-2003  itojun have pw_dup(3). from openbsd
 1.3 18-Sep-2003  jdolecek remove pw_dup(3), for now at least
follows discussion on mailing lists, discussed in private e-mail with Itojun
 1.2 13-Sep-2003  itojun weak alias for pw_dup
 1.1 09-Sep-2003  itojun have pw_dup(3). from openbsd
 1.4 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.3 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.2 26-Jul-2003  salo branches: 1.2.56;
netbsd.org->NetBSD.org
 1.1 27-Jun-1998  thorpej Fix a serious symbol collision problem introduced when pw_scan() was added
to libc. Note, pw_scan() is NO LONGER exported from libc (it never should
have been, and we're just going to pretend like it never was).
 1.2.56.1 17-Apr-2012  yamt sync with head
 1.23 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.22 29-Jan-2009  enami branches: 1.22.8;
Put back rev. 1.20 so that nbpwd_mkdb built on 32bit time_t host generates
correct pwd.db.
 1.21 11-Jan-2009  christos merge christos-time_t
 1.20 01-Feb-2005  christos branches: 1.20.34;
Avoid passing in the actual pw field in gettime because it might not
be the type that we think it is. Fixes cross builds.
 1.19 20-Jan-2005  christos change long -> unsigned long
 1.18 20-Jan-2005  christos remove debugging printf.
 1.17 19-Jan-2005  christos Improve error messages.
 1.16 19-Jan-2005  christos - fix initialization of dowarn [use before set, thanks luke]
- always initialize flags so that we don't have to check for it.
- use the consistent variable names in functions.
 1.15 19-Jan-2005  christos - test for too long username (from Greg Woods)
- centralize id and time_t parsing, providing better error checking of
numeric values; previously the code would accept 12foo as an expiration
or change time.
- fix issue with dereferencing null flags in compat code.
- ansify, KNF
 1.14 11-Dec-2004  christos fix cast-qual issue.
 1.13 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 29-Jan-2002  tv Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
 1.10 20-Sep-1999  lukem branches: 1.10.10;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos delint
 1.7 14-Oct-1998  kleink Kill __LIBUTIL_BUILD in favor of the newly added _LIBC indicator completely;
suggested by Jason Thorpe.
 1.6 14-Oct-1998  kleink Do the internal symbol renaming dance only if inside the libc build environment
so libutil won't be affected; noticed by Alistair Crooks and Allen Briggs.
 1.5 13-Oct-1998  kleink Need an internal name for strsep().
 1.4 26-Jul-1998  mycroft const poisoning.
 1.3 26-Jul-1998  mycroft const poisoning.
 1.2 27-Jun-1998  thorpej Fix a serious symbol collision problem introduced when pw_scan() was added
to libc. Note, pw_scan() is NO LONGER exported from libc (it never should
have been, and we're just going to pretend like it never was).
 1.1 08-Jun-1998  lukem * move pw_scan() from libutil to libc
* add support for YP "master.passwd.by*" (master.passwd in YP, including
pw_passwd) and "passwd.adjunct.by*" (SunOS `secure' maps (?)), based
on code in FreeBSD and partially from OpenBSD.
this is only used if euid == 0.
with this, the YP "passwd.by*" maps can have `*' in the pw_passwd field.
* use pw_scan() to parse YP "passwd.by*" and "master.passwd.by*" entries

XXX: i didn't test the "passwd.adjunct" support...
 1.10.10.2 22-Mar-2002  nathanw Catch up to -current.
 1.10.10.1 08-Mar-2002  nathanw Catch up to -current.
 1.20.34.1 28-Dec-2008  christos Avoid unconst and use time_t conversions directly.
 1.22.8.1 17-Apr-2012  yamt sync with head
 1.18 24-Oct-2017  abhinav Add missing functions from the SYNOPSIS to the NAME section
 1.17 02-May-2008  martin branches: 1.17.8;
Move TNF licenses to 2 clause form
 1.16 07-Aug-2003  agc branches: 1.16.30;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.14 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.13 20-Feb-2002  wiz Whitespace nit.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 24-Jan-2002  lukem - Implement pwcache_userdb(3), which changes the routines that
user_from_uid(3) and uid_from_user(3) use to lookup user information.
- Implement pwcache_groupdb(3), which changes the routines that
group_from_gid(3) and gid_from_group(3) use to lookup group information.
- Ensure that private functions in pwcache.c are declared static
- Use strlcpy(3) instead of strncpy(3)
 1.10 16-Sep-2001  wiz Boring whitespace fixes.
 1.9 28-Jul-1998  mycroft branches: 1.9.12;
Document uid_from_user() and gid_from_group().
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 03-Feb-1998  perry .Bx'ize
 1.6 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.5 06-May-1996  christos branches: 1.5.8;
Close PR 2376
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 28-Jan-1994  cgd get rid of bogus comment
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.8.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.9.12.5 18-Oct-2002  nathanw Catch up to -current.
 1.9.12.4 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.3 08-Mar-2002  nathanw Catch up to -current.
 1.9.12.2 28-Jan-2002  nathanw Catch up to -current.
 1.9.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.16.30.1 18-May-2008  yamt sync with head.
 1.17.8.2 02-May-2008  martin Move TNF licenses to 2 clause form
 1.17.8.1 02-May-2008  martin file pwcache.3 was added on branch christos-time_t on 2008-05-02 18:11:05 +0000
 1.35 12-May-2024  rillig libc/pwcache.c: remove stray semicolon from do-while-0 macro
 1.34 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.33 05-Dec-2021  msaitoh s/numberic/numeric/ in comment.
 1.32 08-Nov-2018  msaitoh "s/ an an / an /" in comment. No functional change.
 1.31 23-Mar-2010  drochner branches: 1.31.44; 1.31.46;
remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable
 1.30 28-Apr-2008  martin branches: 1.30.8;
Remove clause 3 and 4 from TNF licenses
 1.29 20-Jun-2004  jmc branches: 1.29.24;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.28 18-Jun-2004  thorpej Slight hack to get this building on OS X again: Undo the renaming before
including the host's <pwd.h> to avoid renaming the host's versions of
these functions (which causes a prototype conflict). After <pwd.h> has
been included, then re-apply the renaming.
 1.27 18-May-2004  sjg Apply patch from OGAWA Takaya to fix FreeBSD hosted builds.
The trick is to force use of the NetBSD versions of user_from_{uid,gid}().

PR: 24843
 1.26 23-Apr-2004  simonb s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
 1.25 13-Oct-2003  agc branches: 1.25.2;
Move Keith Muller's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22397 by Joel Baker, confirmed
to the board by Keith Muller.
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 04-Dec-2002  grant fix typo in comment.
 1.22 03-Jul-2002  pooka add check for HAVE_USER_FROM_UID
 1.21 26-Feb-2002  tv branches: 1.21.2;
Add some more bits of host compatibility.
 1.20 29-Jan-2002  tv Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
 1.19 24-Jan-2002  lukem reorder the weak_alias stuff into the !HAVE_CONFIG_H section
 1.18 24-Jan-2002  lukem support reachover compile from tools/compat
 1.17 24-Jan-2002  lukem - Implement pwcache_userdb(3), which changes the routines that
user_from_uid(3) and uid_from_user(3) use to lookup user information.
- Implement pwcache_groupdb(3), which changes the routines that
group_from_gid(3) and gid_from_group(3) use to lookup group information.
- Ensure that private functions in pwcache.c are declared static
- Use strlcpy(3) instead of strncpy(3)
 1.16 04-Jan-2002  lukem ANSI KNF. remove NET2_STAT cruft
 1.15 13-Sep-2000  msaitoh branches: 1.15.2;
check LIBC_SCCS
 1.14 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 19-Jan-1999  mycroft Simplify this code slightly.
 1.11 28-Jul-1998  mycroft Fix a typo in a comment.
 1.10 28-Jul-1998  mycroft Import the version from pax(1), with a few changes:
* Functions renamed to match libc interface.
* Fixed to actually put entries into the hash tables!
* Different hash function, simpler but with the same distribution.
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 13-Jul-1997  christos Fix RCSID's
Parenthesize
 1.6 20-Dec-1996  sommerfe Longer login name support: use MAXLOGNAME, not UT_NAMESIZE
 1.5 13-May-1995  jtc branches: 1.5.4;
#include appropriate header files to bring prototypes into scope
 1.4 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.3 19-Jan-1994  jtc branches: 1.3.4;
Fix off by one bug in pwcashe routine group_from_gid().
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.15.2.5 10-Dec-2002  thorpej Sync with HEAD.
 1.15.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.15.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.15.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.15.2.1 28-Jan-2002  nathanw Catch up to -current.
 1.21.2.1 23-Jul-2004  tron Apply patch (request by dbj in ticket 1723):
Fix building the netbsd-1-6 branch under Darwin/MacOS.
 1.25.2.2 22-Jun-2004  tron Apply patch (requested by jmc in ticket #538):
Fix build problems caused by changes for ticket #527.
 1.25.2.1 22-Jun-2004  tron Pull up revision 1.29 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.29.24.1 18-May-2008  yamt sync with head.
 1.30.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.30.8.1 28-Apr-2008  martin file pwcache.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.31.46.1 10-Jun-2019  christos Sync with HEAD
 1.31.44.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.5 10-Nov-2003  wiz Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.4 13-Oct-2003  agc Move Keith Muller's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22397 by Joel Baker, confirmed
to the board by Keith Muller.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.2 03-Jun-2000  simonb Clarify the cache size description comments a little.
 1.1 28-Jul-1998  mycroft branches: 1.1.8;
Import the version from pax(1), with a few changes:
* Functions renamed to match libc interface.
* Fixed to actually put entries into the hash tables!
* Different hash function, simpler but with the same distribution.
 1.1.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.10 09-May-2011  jruoho Xref raise_default_signal(3).
 1.9 30-Jan-2009  wiz Remove empty trailing line.
 1.8 30-Jan-2009  ad Update for SUSv2 compliance.
 1.7 07-Aug-2003  agc branches: 1.7.38;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.5 07-Feb-2002  ross Generate <>& symbolically.
 1.4 05-Feb-1998  perry branches: 1.4.12;
add LIBRARY section to man page
 1.3 27-Feb-1995  cgd merge with Lite, keeping local changes. Fix up Id format, etc.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.7.38.1 02-Feb-2009  snj Pull up following revision(s) (requested by ad in ticket #400):
lib/libc/gen/raise.3: revision 1.8
Update for SUSv2 compliance.
 1.8 29-Jan-2009  rmind Change raise(3) to be thread-aware - send the signal to current LWP.
From <ad> via PR/40341.
 1.7 07-Aug-2003  agc branches: 1.7.38;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 13-Jul-1997  christos branches: 1.6.14;
Fix RCSID's
 1.5 27-Feb-1995  cgd branches: 1.5.4;
merge with Lite, keeping local changes. Fix up Id format, etc.
 1.4 11-Nov-1993  jtc branches: 1.4.4;
First pass at getting a clean compile with "gcc -Wall", mostly explictly
declaring function return values, etc.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 02-May-1995  jtc #include "namespace.h"
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.6.14.1 08-Jan-2003  thorpej Need an internal name for kill().
 1.7.38.1 02-Feb-2009  snj Pull up following revision(s) (requested by rmind in ticket #380):
lib/libc/gen/raise.c: revision 1.8
Change raise(3) to be thread-aware - send the signal to current LWP.
From <ad> via PR/40341.
 1.9 24-Oct-2017  abhinav Use commas at the right places in the NAME section
 1.8 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.7 05-Jan-2006  rpaulo #include <stdio.h> in the example.
 1.6 26-Dec-2005  perry u_intN_t -> uintN_t
 1.5 10-Dec-2003  itojun comment from niels provos;
- seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
- skipping number is not needed, so disable it for 16bit generator (makes
the repetition period to 30000)
 1.4 25-Nov-2003  wiz Bump date for previous.
 1.3 25-Nov-2003  itojun take "Skip a random number of ids" into consideration, correct the rotation
period number. simonb
 1.2 10-Sep-2003  wiz Fix Nd; use In instead of Fd; grammar fixes.
 1.1 09-Sep-2003  itojun add randomid(3).
 1.16 15-May-2022  andvar s/wich/which in comments.
 1.15 11-Sep-2021  andvar Add missing double p and d for stopped and overriden accordingly.
Fix few more typos along the way, mainly in copy-pasted comments.
 1.14 27-Dec-2019  msaitoh s/inital/initial/
 1.13 11-Jan-2009  christos branches: 1.13.48;
merge christos-time_t
 1.12 15-Oct-2006  christos branches: 1.12.26;
fix incomplete initializers
 1.11 26-Dec-2003  wiz Niels Provos kindly agreed to drop clauses 3 and 4 from the
license -- thanks.
Based on OpenBSD commit and hints by itojun.
 1.10 10-Dec-2003  itojun comment from niels provos;
- seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
- skipping number is not needed, so disable it for 16bit generator (makes
the repetition period to 30000)
 1.9 25-Nov-2003  itojun "seed2" was ruining the non-repeating property of this function; remove it.
discussed on tech-net for ip_id.c (thanks for all the analysis).
 1.8 16-Sep-2003  simonb Shut lint up.
 1.7 15-Sep-2003  itojun avoid overflow during multiply. David Laight
 1.6 13-Sep-2003  itojun correct setup of ru_b/a for 16/20 bit case
 1.5 13-Sep-2003  itojun use internal names for randomid()
 1.4 11-Sep-2003  itojun check malloc failure. yamt
 1.3 10-Sep-2003  tls Another gcc3 problem: "exp" shadows a builtin. Rename it to "expo".
 1.2 10-Sep-2003  tls This didn't build with gcc3 because it was missing <string.h> for memset.
 1.1 09-Sep-2003  itojun add randomid(3).
 1.12.26.1 08-Nov-2008  christos time_t changes
 1.13.48.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.27 10-Sep-2024  riastradh readdir(3): Preserve errno on end-of-directory.

PR pkg/57145: gmake: *** INTERNAL: readdir: Operation not supported.
Stop.
 1.26 25-Jun-2012  abs branches: 1.26.34; 1.26.42; 1.26.44;
Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.25 16-Sep-2010  yamt branches: 1.25.6;
- remove a wrong _DIAGASSERT
- update comments
- whitespace
 1.24 04-May-2008  tonnerre branches: 1.24.8;
Fix a bug in the implementation of seekdir(). If the first entry in
a block has been unlinked, seekdir() may overshoot by one entry.
Thus, _readdir_unlinked() must not skip deleted entries when being
called from seekdir().
Christos agreed.
 1.23 17-May-2006  christos branches: 1.23.18;
PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.22 24-Jan-2006  christos rename __func to _func_unlocked, and add their prototypes in extern.h
instead of exposing them in dirent.h. More locking consistency fixes.
 1.21 24-Jan-2006  christos PR/32609: Tanaka Akira: seekdir blocks if pthread is linked
Do locking consistently to avoid recursive locks (like the bug reported in
this pr), and to avoid leaking locks on errors.
 1.20 13-Sep-2005  christos compat core reorg.
 1.19 19-Aug-2005  christos 64 bit inode changes
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 28-May-2003  kleink Need <string.h> for memcpy().
 1.16 28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.15 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.14 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 13-Nov-1998  christos delint
 1.11 27-Feb-1998  perry trivial changes to quiet lint.
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 10-Oct-1997  fvdl Fix another getdents() botch. I must've had a Makefile without
warnings on.
 1.8 10-Oct-1997  fvdl Use getdents(). Read NFS directories in one go (just as union dirs, but
without removing double entries). This makes sure that we get a
consistent snapshot of the directory, and protects against any
'bad cookie' errors.
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 25-Feb-1995  cgd branches: 1.5.4;
clean up Id's on files previously imported...
 1.4 28-Dec-1994  mycroft branches: 1.4.2;
Mostly sync with CSRG.
 1.3 19-Oct-1994  cgd beware cast type.
 1.2 27-Jul-1994  jtc branches: 1.2.2;
Add RCS Id's
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.2.2 27-Jul-1994  jtc Add RCS Id's
 1.2.2.1 27-Jul-1994  jtc file readdir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:49 +0000
 1.4.2.2 02-May-1995  jtc #include "namespace.h"
 1.4.2.1 26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.5.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.23.18.1 18-May-2008  yamt sync with head.
 1.24.8.2 04-May-2008  tonnerre Fix a bug in the implementation of seekdir(). If the first entry in
a block has been unlinked, seekdir() may overshoot by one entry.
Thus, _readdir_unlinked() must not skip deleted entries when being
called from seekdir().
Christos agreed.
 1.24.8.1 04-May-2008  tonnerre file readdir.c was added on branch christos-time_t on 2008-05-04 18:53:27 +0000
 1.25.6.1 30-Oct-2012  yamt sync with head
 1.26.44.1 02-Aug-2025  perseant Sync with HEAD
 1.26.42.1 09-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #935):

lib/libc/gen/readdir.c: revision 1.27

readdir(3): Preserve errno on end-of-directory.

PR pkg/57145: gmake: *** INTERNAL: readdir: Operation not supported.
Stop.
 1.26.34.1 11-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1898):

lib/libc/gen/readdir.c: revision 1.27

readdir(3): Preserve errno on end-of-directory.

PR pkg/57145: gmake: *** INTERNAL: readdir: Operation not supported.
Stop.
 1.19 06-Mar-2017  pgoyette Improve grammar. Pointed out by Timo Buhrmester on netbsd-docs list.
 1.18 24-May-2013  wiz branches: 1.18.10; 1.18.14;
More markup. Merge two error entries for the same error.
 1.17 24-May-2013  enami Update ERRORS section:
- Remove some system calls from the list of functions which may set errno
during the execution of realpath(3) since they are no longer used
to implement it.
- Document some errno set by the realpath(3) itself.
 1.16 05-Mar-2013  enami - Refer the argument with correct name.
- Mark up the function as a function like rest of this paragraph does.
 1.15 05-Mar-2013  soda a sequel to getcwd.c revision 1.52 and realpath.3 revision 1.13 by christos:
explicitly mention that NULL is allowed as second argument
in the description part as well.

PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.14 21-Jun-2012  wiz branches: 1.14.2;
Drop trailing whitespace and avoid xr to itself.
 1.13 21-Jun-2012  christos PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.12 13-Aug-2005  elad branches: 1.12.44; 1.12.46; 1.12.50;
Don't allow last path element to be nonexistant.
 1.11 07-Aug-2003  agc branches: 1.11.6;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 06-Jul-2002  yamt s/resolved_name/resolvedname/g
s/resolved_path/resolvedname/g
 1.8 07-Feb-2002  ross branches: 1.8.2;
Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 16-Sep-2001  wiz Boring whitespace fixes.
 1.5 06-Apr-1999  cgd branches: 1.5.8; 1.5.10;
change:
.Sh "SEE ALSO"
to:
.Sh SEE ALSO
The doc macros check for the latter (actually just for 'SEE' as the first
argument to .Sh) to set the section header SEE ALSO flag, which modifies
some behaviour (e.g. references done with .Rs/.Re).
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.2 28-Dec-1995  thorpej New-style RCS ids.
 1.1 17-May-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 17-May-1994  mycroft New from 4.4-Lite. Needed for some 4.4 FS utilities.
 1.5.10.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.5.8.1 15-Mar-2003  he Pull up revision 1.9 (requested by yamt in ticket #10):
Typo corrections: resolved_name -> resolvedname; resolved_path
-> resolvedname.
 1.8.2.1 06-Jul-2002  lukem Pull up revision 1.9 (requested by yamt in ticket #437):
s/resolved_name/resolvedname/g
s/resolved_path/resolvedname/g
 1.11.6.1 14-Aug-2005  riz Pull up revision 1.12 (requested by elad in ticket #648):
Don't allow last path element to be nonexistant.
 1.12.50.1 20-Apr-2013  bouyer Pull up following revision(s) (requested by christos in ticket #874):
lib/libc/gen/realpath.3: revision 1.13
lib/libc/gen/getcwd.c: revision 1.52
PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.12.46.1 20-Apr-2013  bouyer Pull up following revision(s) (requested by christos in ticket #874):
lib/libc/gen/realpath.3: revision 1.13
lib/libc/gen/getcwd.c: revision 1.52
PR/46618: Onno van der Linden: realpath(3) isn't SUSv4 compliant (and causes
flactag 2.0.4 to dump core). Fix to accept a NULL argument for resolvedpath.
 1.12.44.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.12.44.1 30-Oct-2012  yamt sync with head
 1.14.2.1 23-Jun-2013  tls resync from head
 1.18.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.18.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.3 11-Nov-1993  mycroft Clean up deleted files.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5 12-Jan-1994  mycroft Clean up deleted files.
 1.4 21-Oct-1993  jtc #include <search.h> to ensure that the public function declarations match
the implementation.
Use old-style function definitions so functions can be compiled with non-ansi
compilers.
Functions are specified to take void * arguments, so they must be cast to
a struct qelem * before they are used.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 13-Aug-1993  brezak Correct copyright statements
 1.1 13-Aug-1993  brezak Machine independent version of insque/remque
 1.13 26-Sep-2010  yamt fix rewinddir on nfs. fix PR/42879 (and probably PR/40229.)
 1.12 17-May-2006  christos PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.11 24-Jan-2006  christos rename __func to _func_unlocked, and add their prototypes in extern.h
instead of exposing them in dirent.h. More locking consistency fixes.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up Id's on files previously imported...
 1.3 27-Jul-1994  jtc branches: 1.3.2; 1.3.4;
Add RCS Id's
 1.2 27-Jul-1994  jtc Return NULL and set errno to ENOTDIR if opening a non-directory (POSIX.1,
Section 5.1.2.4). Rename _seekdir to __seekdir, as former is in the
user's namespace.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.2 02-May-1995  jtc #include "namespace.h"
 1.3.4.1 26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.3.2.2 27-Jul-1994  jtc Add RCS Id's
 1.3.2.1 27-Jul-1994  jtc file rewinddir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:50 +0000
 1.4.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.17 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.16 17-Dec-2016  wiz Fix typo.
 1.15 16-Dec-2016  mrg scandir/alphasort take "const struct dirent **" not "const void *" in
modern unix. since we claim to be 'IEEE Std 1003.1-2008', make it so.
 1.14 17-Dec-2010  njoly branches: 1.14.28;
Fix cross-reference, dir(5) -> dirent(3).
 1.13 29-Apr-2010  jruoho Note POSIX compliance.
 1.12 05-Apr-2010  joerg Fix escape sequences
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Boring whitespace fixes.
 1.7 16-Apr-2000  mrg branches: 1.7.6;
make scandir(3)'s 3rd argument take a function that takes a *const*
struct dirent *, rather than non-const. this makes scandir(3) the
same as the scandir implementations in libiberty and glibc, and the
select function has no need to modify the dirent.
 1.6 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.3 27-Jul-1994  jtc branches: 1.3.2;
Sync with 4.4 lite
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.2.2 27-Jul-1994  jtc Sync with 4.4 lite
 1.3.2.1 27-Jul-1994  jtc file scandir.3 was added on branch netbsd-1-0 on 1994-07-27 05:37:12 +0000
 1.7.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.30 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.29 29-Oct-2021  nia scandir(3): Convert malloc(x * y) and realloc(x * y) to reallocarr
 1.28 16-Dec-2016  mrg scandir/alphasort take "const struct dirent **" not "const void *" in
modern unix. since we claim to be 'IEEE Std 1003.1-2008', make it so.
 1.27 13-Mar-2012  christos branches: 1.27.14;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.26 09-Jun-2007  christos branches: 1.26.36;
PR/36464: scandir(3) corrupts heap when run on ZFS directories because ZFS
returns the number of entries as the directory size.
Use a new, more conservative entries estimator.
 1.25 13-Sep-2005  christos branches: 1.25.4; 1.25.6;
compat core reorg.
 1.24 19-Aug-2005  christos 64 bit inode changes
 1.23 17-Mar-2005  kleink Rename select argument to selectfn to avoid a shadowing warning.
 1.22 07-Aug-2003  agc branches: 1.22.6;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.21 21-Nov-2001  enami Cosmetic changse.
 1.20 21-Nov-2001  enami Extend an array before allocating an element. This makes cleanup code a bit
simpler since we no longer need to worry about an element not in an array yet.
 1.19 25-Oct-2001  yamt avoid leaks in the case of error.
 1.18 16-Apr-2000  mrg branches: 1.18.6;
make scandir(3)'s 3rd argument take a function that takes a *const*
struct dirent *, rather than non-const. this makes scandir(3) the
same as the scandir implementations in libiberty and glibc, and the
select function has no need to modify the dirent.
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.15 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.14 13-Nov-1998  christos delint
 1.13 26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.12 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.11 27-Feb-1998  perry trivial changes to quiet lint.
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 03-Aug-1997  mikel don't forget d_type when copying dirent structure; from Giles Lean in
PR lib/3913. also, replace d_ino with d_fileno.
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 13-Jul-1997  christos Fix RCSID's
 1.6 25-Feb-1995  cgd branches: 1.6.4;
clean up Id's on files previously imported...
 1.5 27-Jul-1994  jtc branches: 1.5.2; 1.5.4;
Add RCS Id's
 1.4 27-Jul-1994  jtc Sync with 4.4 lite
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.5.2.2 27-Jul-1994  jtc Add RCS Id's
 1.5.2.1 27-Jul-1994  jtc file scandir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:51 +0000
 1.6.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.18.6.2 28-Jan-2002  nathanw Catch up to -current.
 1.18.6.1 14-Nov-2001  nathanw Catch up to -current.
 1.22.6.1 12-Jun-2007  liamjfoy Pull up following revision(s) (requested by christos in ticket #1803):

Be more conservative about computing the number of entries in
the directory. Avoids core-dump with ZFS filesystems (they return
the number of entries in stat(2) instead of the size in st_size)
 1.25.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.25.4.1 12-Jun-2007  liamjfoy Pull up following revision(s) (requested by christos in ticket #717):
lib/libc/gen/scandir.c: revision 1.26
PR/36464: scandir(3) corrupts heap when run on ZFS directories because ZFS
returns the number of entries as the directory size.
Use a new, more conservative entries estimator.
 1.26.36.1 17-Apr-2012  yamt sync with head
 1.27.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15 06-Mar-2013  yamt wrap a long line
 1.14 17-May-2006  christos branches: 1.14.44; 1.14.50;
PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.13 24-Jan-2006  christos rename __func to _func_unlocked, and add their prototypes in extern.h
instead of exposing them in dirent.h. More locking consistency fixes.
 1.12 24-Jan-2006  christos PR/32609: Tanaka Akira: seekdir blocks if pthread is linked
Do locking consistently to avoid recursive locks (like the bug reported in
this pr), and to avoid leaking locks on errors.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up Id's on files previously imported...
 1.3 27-Jul-1994  jtc branches: 1.3.2; 1.3.4;
Add RCS Id's
 1.2 27-Jul-1994  jtc Return NULL and set errno to ENOTDIR if opening a non-directory (POSIX.1,
Section 5.1.2.4). Rename _seekdir to __seekdir, as former is in the
user's namespace.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.2 02-May-1995  jtc #include "namespace.h"
 1.3.4.1 26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.3.2.2 27-Jul-1994  jtc Add RCS Id's
 1.3.2.1 27-Jul-1994  jtc file seekdir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:52 +0000
 1.4.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.14.50.1 23-Jun-2013  tls resync from head
 1.14.44.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.3 20-Oct-1994  mycroft Clean up deleted files.
 1.2 01-Dec-1993  cgd fix typo; from Louis A. Mamakos <louie@TransSys.COM>
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.2 20-Oct-1994  mycroft Clean up deleted files.
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1 14-Nov-1993  cgd Add the System V message queue and semaphore facilities. Implemented
by Daniel Boulet <danny@BouletFermat.ab.ca>
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 07-Aug-2003  agc branches: 1.12.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos delint
 1.7 06-May-1998  kleink For consistency with the {get,set}hostname() change, change the type of
the `namelen' argument to {get,set}domainname() from int to size_t.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Add missing unistd.h unclude
 1.4 16-Jun-1995  jtc branches: 1.4.4;
Change return type of {get,set}{domain,host}name() from long to int.
 1.3 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.2 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.1 07-May-1994  cgd domainname stuff
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.12.56.1 30-Oct-2012  yamt sync with head
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 07-Aug-2003  agc branches: 1.12.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos delint
 1.7 06-May-1998  kleink Per X/Open XNS5 (a/k/a C523), change the type of the `namelen' argument to
gethostname() from int to size_t. Change sethostname() in the same way
for consistency.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Add missing unistd.h include
 1.4 16-Jun-1995  jtc branches: 1.4.4;
Change return type of {get,set}{domain,host}name() from long to int.
 1.3 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.2 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.12.56.1 30-Oct-2012  yamt sync with head
 1.18 24-May-2021  riastradh Clarify what happens when you longjmp(..., 0).

Derived from C99 7.13.2.1 `The longjmp function'.
 1.17 31-May-2008  enami branches: 1.17.6; 1.17.64; 1.17.68;
Refer sigprocmask(2) instead of non existing sigmask(2). Also, xref
sigprocmask(2) and pthread_sigmask(3).
 1.16 30-Mar-2004  wiz branches: 1.16.24; 1.16.26;
Some wording improvements and other minor fixes from OpenBSD.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 01-May-2003  wiz Grammar and mdoc fixes from jmc@openbsd.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 10-Aug-2002  wiz Update Dd for recent changes.
 1.11 10-Aug-2002  yamt more about sigsetjmp/siglongjmp.
from openbsd.
 1.10 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 19-Oct-1993  jtc Use i386 sigsetjmp()/siglongjmp() implementation.
Install sigsetjmp()/siglongjmp() links to setjmp manpage.
Note that sigsetjmp() and siglongjmp() are 1003.1 compliant.
 1.3 18-Oct-1993  jtc Grammar and formatting fixes.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.12.4 13-Aug-2002  nathanw Catch up to -current.
 1.8.12.3 01-Aug-2002  nathanw Catch up to -current.
 1.8.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.16.26.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.16.24.1 04-Jun-2008  yamt sync with head
 1.17.68.1 31-May-2021  cjep sync with head
 1.17.64.1 21-Jun-2021  martin Pull up following revision(s) (requested by riastradh in ticket #1298):

lib/libc/gen/setjmp.3: revision 1.18

Clarify what happens when you longjmp(..., 0).

Derived from C99 7.13.2.1 `The longjmp function'.
 1.17.6.2 31-May-2008  enami Refer sigprocmask(2) instead of non existing sigmask(2). Also, xref
sigprocmask(2) and pthread_sigmask(3).
 1.17.6.1 31-May-2008  enami file setjmp.3 was added on branch christos-time_t on 2008-05-31 16:15:08 +0000
 1.8 24-Jun-2012  christos fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.7 07-Aug-2003  agc branches: 1.7.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.4 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.56.1 30-Oct-2012  yamt sync with head
 1.24 28-Apr-2024  rillig setmode.3: fix typos
 1.23 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.22 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.21 11-Jan-2009  christos merge christos-time_t
 1.20 04-Jan-2009  wiz Fix HTML output.
 1.19 04-Jan-2009  dholland Rework the text to make it clearer; it was really pretty confusing before.
Add an example; note some bugs/shortcomings. Bump date.
 1.18 01-Oct-2005  christos branches: 1.18.26; 1.18.28;
Make sure that setmode sets errno on failure (it used to return a random
errno) and document it.
 1.17 04-Jun-2005  wiz Bump date for previous.
 1.16 17-May-2005  peter - setmode() can fail on strtol(3); note this.
- Use .Va for errno.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 07-Feb-2002  ross Generate <>& symbolically.
 1.12 16-Sep-2001  wiz Boring whitespace fixes.
 1.11 26-May-1999  kleink branches: 1.11.10;
Need <unistd.h> for declarations.
 1.10 05-Feb-1998  perry add LIBRARY section to man page
 1.9 03-Feb-1998  perry .Bx'ize
 1.8 02-Feb-1998  perry merge/update to lite-2
 1.7 12-Oct-1995  jtc Manpage fixes from Jochen Pohl. Aligns the prototypes in the SYNOPSIS
section with the actual function declarations. Also fixes decription
of _SC_CLK_TCK in sysconf(3). See PR #1587 and PR #1589 for details.
 1.6 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.5 29-Mar-1994  cgd update based on some work i did for 4.4BSD
 1.4 30-Nov-1993  jtc Use ".Va" macro when formatting "errno".
 1.3 30-Jul-1993  mycroft Add RCS identifiers.
 1.2 20-Jul-1993  jtc Fix spelling error.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.18.28.1 04-Jan-2009  christos merge with head.
 1.18.26.1 16-Jan-2009  bouyer Pull up following revision(s) (requested by dholland in ticket #272):
lib/libc/gen/setmode.3: revision 1.19, 1.20
lib/libc/sys/chmod.2: revision 1.34
SEE ALSO getmode(3)/setmode(3).
Suggested in passing by Joerg a long time ago on tech-pkg, seems like
a good idea.
Bump date.
Rework the text to make it clearer; it was really pretty confusing before.
Add an example; note some bugs/shortcomings. Bump date.
Fix HTML output.
 1.38 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.37 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.36 12-Mar-2022  nia setmode(3): use reallocarr instead of realloc(x * y)
 1.35 12-Mar-2022  nia setmode(3): use reallocarr instead of malloc(x * y)
 1.34 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.33 21-Mar-2012  christos fix argument order.
 1.32 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.31 01-Oct-2005  christos branches: 1.31.44;
Make sure that setmode sets errno on failure (it used to return a random
errno) and document it.
 1.30 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.29 15-Jan-2003  kleink Rename auto variable shading global sigset().
 1.28 25-Jan-2000  enami branches: 1.28.6;
Use tab to indent.
 1.27 22-Jan-2000  mycroft Delint.
 1.26 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.25 20-Jan-2000  enami - To detect realloc failure, need to check the value just returned by it.
- Free storage on realloc failure.
- Some cosmetic changes.
 1.24 20-Jan-2000  mycroft Use strtol() to check validity of numeric values, rather than
hand-coding it.
 1.23 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.22 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.21 16-Mar-1999  christos Fix gcc-2.8.1 warnings.
 1.20 27-Feb-1998  perry trivial changes to quiet lint.
 1.19 03-Feb-1998  perry remove obsolete register declarations
 1.18 08-Oct-1997  mycroft Make sure the command list is properly terminated when parsing an
octal mode. From Alasdair Baird in PR 4232.
 1.17 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.16 13-Jul-1997  christos Fix RCSID's
pacify gcc
 1.15 07-Feb-1997  christos I ``who'' was not specified, set the appropriate bits as the manual page
states. chmod +s foo and chmod +t . now work.
 1.14 20-Dec-1996  cgd pull in unistd.h, const poisoning
 1.13 03-Apr-1996  jtc branches: 1.13.2;
Add explict function return types
 1.12 23-Mar-1995  jtc removed unnecessary #include <stddef.h>
 1.11 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.10 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.9 29-Mar-1994  cgd branches: 1.9.4;
update based on some work i did for 4.4BSD
 1.8 11-Feb-1994  cgd hopefully last one; more corner cases. Thanks to Mark Weaver for
inspiration, for demanding that i put one of these fixes in, and
for double-checking.
 1.7 10-Feb-1994  cgd fix -[ugo] and =[ugo]
 1.6 10-Feb-1994  cgd clean up, reorganize, etc.
 1.5 04-Jan-1994  cgd DTRT if op is =
 1.4 23-Dec-1993  jtc Explicitly declare function return types to silence "gcc -Wall".
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.4.1 02-May-1995  jtc #include "namespace.h"
 1.13.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.28.6.1 17-Jan-2003  thorpej Sync with HEAD.
 1.31.44.2 30-Oct-2012  yamt sync with head
 1.31.44.1 17-Apr-2012  yamt sync with head
 1.18 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.17 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.16 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.15 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.14 07-Feb-2002  ross Generate <>& symbolically.
 1.13 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.12 16-Sep-2001  wiz Boring whitespace fixes.
 1.11 19-Feb-2001  cgd branches: 1.11.2;
add cross-reff to getprogname(3)
 1.10 14-Jun-2000  cgd sweep of my licenses (userland files w/o only my copyright) for
consistency. (no functional changes)
 1.9 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.8 06-Apr-1999  pk branches: 1.8.6;
1, 2, 3 and.. 4!
 1.7 22-Mar-1999  garbled branches: 1.7.2;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 24-Nov-1997  lukem fix .Nx usage (use 1.0 instead of 0.9a, etc), and other minor cleanups
 1.4 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.3 09-Nov-1996  lukem fix example, from bgrayson@ece.utexas.edu (Brian C. Grayson) in [misc/2735]
 1.2 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.1 14-Apr-1994  cgd setproctitle(); no reason to have this code spread into N utils...
 1.7.2.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.8.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.11.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.11.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.11.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.23 20-Apr-2021  christos Instead of compiling files with -fcommon, create an include file and declare
the 3 symbols that need to be common using an attribute. Put all the 3 symbol
definitions in libc in one place (initfini.c). Reviewed by joerg@
 1.22 03-Jan-2008  christos Simplify and check for snprintf() error.
 1.21 26-Jul-2003  salo branches: 1.21.22;
netbsd.org->NetBSD.org
 1.20 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.19 19-Feb-2001  cgd branches: 1.19.2;
convert from __progname to getprogname()
 1.18 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.17 14-Jun-2000  cgd sweep of my licenses (userland files w/o only my copyright) for
consistency. (no functional changes)
 1.16 14-Jun-2000  cgd fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.15 22-Jan-2000  mycroft branches: 1.15.2;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.14 13-Nov-1998  christos delint
 1.13 13-Nov-1998  christos delint
 1.12 26-Jul-1998  mycroft const poisoning.
 1.11 05-Feb-1998  gwr Do not try to use PS_STRINGS unless USRSTACK is defined.
(On m68k it is defined only for kernel compilation.)
 1.10 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.9 16-Oct-1997  christos __ps_strings is now extern and not modified locally.
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 13-Jul-1997  christos Fix RCSID's
 1.6 17-May-1997  mycroft Do the previous change is a much less klugy fashion.
 1.5 13-May-1997  gwr Add a default definition of __ps_strings as suggested by PK.
(With lots of XXX marks advising its eventual removal! 8^)
 1.4 16-May-1995  mycroft branches: 1.4.4;
Use the new ps_strings format.
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 24-May-1994  deraadt need sys/param.h
 1.1 14-Apr-1994  cgd setproctitle(); no reason to have this code spread into N utils...
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.15.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.19.2.1 21-Jun-2002  nathanw Catch up to -current.
 1.21.22.1 09-Jan-2008  matt sync with HEAD
 1.3 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.2 09-Jul-2001  simonb Don't need to include <string.h> unless REALLY_SET_PROGNAME is true.
 1.1 19-Feb-2001  cgd branches: 1.1.2;
add getprogname() and setprogname(). These allow uses of __progname to
be wrapped in some sane fashion, for portability.
 1.1.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.4 06-Apr-1994  mycroft Clean up deleted files.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 06-Apr-1994  mycroft Clean up deleted files.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5 06-Apr-1994  mycroft Clean up deleted files.
 1.4 25-Feb-1994  cgd fix unclear man page; better is coming (later)
 1.3 15-Dec-1993  jtc More manpage tweaks.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7 01-Mar-1995  mycroft Clean up deleted files.
 1.6 29-May-1994  hpeyerl (blush). They didn't *ALL* have to be changed.
 1.5 28-May-1994  hpeyerl If we're going to re-activate these guys; we better make sure they
compile.
 1.4 19-Nov-1993  cgd finish cleanup
 1.3 19-Nov-1993  mycroft Clean up after Brezak.
 1.2 26-Aug-1993  brezak Add rcsid strings
 1.1 25-Aug-1993  brezak Add syscall stubs for SYSV Shared Memory.
 1.6 01-Mar-1995  mycroft Clean up deleted files.
 1.5 29-May-1994  hpeyerl (blush). They didn't *ALL* have to be changed.
 1.4 28-May-1994  hpeyerl If we're going to re-activate these guys; we better make sure they
compile.
 1.3 19-Nov-1993  mycroft Clean up after Brezak.
 1.2 26-Aug-1993  brezak Add rcsid strings
 1.1 25-Aug-1993  brezak Add syscall stubs for SYSV Shared Memory.
 1.6 01-Mar-1995  mycroft Clean up deleted files.
 1.5 29-May-1994  hpeyerl (blush). They didn't *ALL* have to be changed.
 1.4 28-May-1994  hpeyerl If we're going to re-activate these guys; we better make sure they
compile.
 1.3 19-Nov-1993  mycroft Clean up after Brezak.
 1.2 26-Aug-1993  brezak Add rcsid strings
 1.1 25-Aug-1993  brezak Add syscall stubs for SYSV Shared Memory.
 1.5 01-Mar-1995  mycroft Clean up deleted files.
 1.4 29-May-1994  hpeyerl (blush). They didn't *ALL* have to be changed.
 1.3 28-May-1994  hpeyerl If we're going to re-activate these guys; we better make sure they
compile.
 1.2 26-Aug-1993  brezak Add rcsid strings
 1.1 25-Aug-1993  brezak Add syscall stubs for SYSV Shared Memory.
 1.10 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.9 07-Sep-2008  apb branches: 1.9.6;
Fix some errors in examples, noticed by Robert Elz:
* use \e in the source to get a backslash in the output.
* test whether the result from shquote[v]() is -1 before, not after,
adding 1 to it.
 1.8 26-Jul-2003  salo branches: 1.8.32;
netbsd.org->NetBSD.org
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 03-Jan-2003  mjl Fix typos (from PR 19650)
 1.5 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.4 07-Feb-2002  ross generate & symbolically
 1.3 07-Feb-2002  ross Generate <>& symbolically.
 1.2 16-Sep-2001  wiz branches: 1.2.2;
Boring whitespace fixes.
 1.1 10-Mar-2001  cgd Add shquote() and shquotev(). From the manual page:
The shquote() and shquotev() functions copy strings and transform the
copies by adding shell escape and quoting characters. They are used to
encapsulate arguments to be included in command strings passed to the
system() and popen() functions, so that the arguments will have the cor-
rect values after being evaluated by the shell.
 1.2.2.6 08-Jan-2003  thorpej Sync with HEAD.
 1.2.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.4 22-Mar-2002  nathanw Catch up to -current.
 1.2.2.3 08-Mar-2002  nathanw Catch up to -current.
 1.2.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.2.1 16-Sep-2001  nathanw file shquote.3 was added on branch nathanw_sa on 2001-10-08 20:19:23 +0000
 1.8.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.6.2 07-Sep-2008  apb Fix some errors in examples, noticed by Robert Elz:
* use \e in the source to get a backslash in the output.
* test whether the result from shquote[v]() is -1 before, not after,
adding 1 to it.
 1.9.6.1 07-Sep-2008  apb file shquote.3 was added on branch christos-time_t on 2008-09-07 08:55:47 +0000
 1.8 19-Mar-2006  christos Coverity CID 561: Remove dead code.
 1.7 12-Jun-2005  lukem Add missing __RCSID()
 1.6 09-Feb-2005  kleink A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.5 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.4 12-Mar-2001  simonb branches: 1.4.2;
Include <string.h> for memcpy() prototype.
 1.3 10-Mar-2001  cgd actually, don't define SHQUOTE_USE_MULTIBYTE
 1.2 10-Mar-2001  christos make these lint properly.
1. don't use MB_CUR_MAX, but MB_LEN_MAX because MB_CUR_MAX is a variable.
2. return a size_t type.
3. added const cond on do while macros.
4. remove unused variables and code,
 1.1 10-Mar-2001  cgd Add shquote() and shquotev(). From the manual page:
The shquote() and shquotev() functions copy strings and transform the
copies by adding shell escape and quoting characters. They are used to
encapsulate arguments to be included in command strings passed to the
system() and popen() functions, so that the arguments will have the cor-
rect values after being evaluated by the shell.
 1.4.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.4.2.1 12-Mar-2001  nathanw file shquote.c was added on branch nathanw_sa on 2001-10-08 20:19:24 +0000
 1.5 12-Jun-2005  lukem Add missing __RCSID()
 1.4 09-Feb-2005  kleink A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.3 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.2 10-Mar-2001  christos branches: 1.2.2;
make these lint properly.
1. don't use MB_CUR_MAX, but MB_LEN_MAX because MB_CUR_MAX is a variable.
2. return a size_t type.
3. added const cond on do while macros.
4. remove unused variables and code,
 1.1 10-Mar-2001  cgd Add shquote() and shquotev(). From the manual page:
The shquote() and shquotev() functions copy strings and transform the
copies by adding shell escape and quoting characters. They are used to
encapsulate arguments to be included in command strings passed to the
system() and popen() functions, so that the arguments will have the cor-
rect values after being evaluated by the shell.
 1.2.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.2.1 10-Mar-2001  nathanw file shquotev.c was added on branch nathanw_sa on 2001-10-08 20:19:25 +0000
 1.5 30-Apr-2010  jruoho More obsolete things. These are all already deprecated in NetBSD, but it is
worth noting that also the standard has marked these as legacy.
 1.4 30-Apr-2008  martin branches: 1.4.8;
Convert TNF licenses to new 2 clause variant
 1.3 16-Apr-2003  wiz branches: 1.3.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 16-Jan-2003  kleink branches: 1.2.2;
Pasto; from Thomas Klausner.
 1.1 15-Jan-2003  kleink Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.2.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.2.2.1 16-Jan-2003  thorpej file sighold.3 was added on branch nathanw_sa on 2003-01-17 05:12:59 +0000
 1.3.30.1 18-May-2008  yamt sync with head.
 1.4.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.4.8.1 30-Apr-2008  martin file sighold.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 15-Jan-2003  kleink branches: 1.1.2; 1.1.32;
Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.1.32.1 18-May-2008  yamt sync with head.
 1.1.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 15-Jan-2003  thorpej file sighold.c was added on branch nathanw_sa on 2003-01-17 05:12:59 +0000
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file sighold.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.6 30-Apr-2010  wiz Merge two entries for the same error.
 1.5 30-Apr-2010  jruoho More obsolete things. These are all already deprecated in NetBSD, but it is
worth noting that also the standard has marked these as legacy.
 1.4 30-Apr-2008  martin branches: 1.4.8;
Convert TNF licenses to new 2 clause variant
 1.3 16-Apr-2003  wiz branches: 1.3.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 16-Jan-2003  wiz branches: 1.2.2;
typo fixes.
 1.1 15-Jan-2003  kleink Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.2.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.2.2.1 16-Jan-2003  thorpej file sigignore.3 was added on branch nathanw_sa on 2003-01-17 05:12:59 +0000
 1.3.30.1 18-May-2008  yamt sync with head.
 1.4.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.4.8.1 30-Apr-2008  martin file sigignore.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 15-Jan-2003  kleink branches: 1.1.2; 1.1.32;
Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.1.32.1 18-May-2008  yamt sync with head.
 1.1.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 15-Jan-2003  thorpej file sigignore.c was added on branch nathanw_sa on 2003-01-17 05:13:00 +0000
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file sigignore.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.12 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Boring whitespace fixes.
 1.7 05-Jul-2000  msaitoh branches: 1.7.2;
remove extra period in SEE ALL section
 1.6 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 17-Jan-1997  perry change sigpause(2) to sigsuspend(2) or sigpause(3), depending
Also try to fix other bad references to sig* man pages.
Fixes pr-2885 from Jonathan Stone
These SEE ALSO sections are still bloody messes (sigh)
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.14 03-Jan-2024  christos tidy up some extern declarations
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 07-Aug-2003  agc branches: 1.12.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 20-Dec-2000  christos fix nested extern
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.8 13-Jul-1997  christos Fix RCSID's
 1.7 03-Apr-1996  jtc branches: 1.7.2;
Add explict function return types
 1.6 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.5 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 30-Nov-1993  jtc branches: 1.4.4;
Renamed _sigintr to __sigintr. _sigintr is in the user's namespace.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 02-May-1995  jtc #include "namespace.h"
 1.7.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.12.56.1 30-Oct-2012  yamt sync with head
 1.18 09-Jul-2016  dholland Fix three of these strings (ones that are rarely seen)
 1.17 17-Jan-2007  hubertf Remove more duplicate #includes, and a few spurious whitespaces at EOL
From Slava Semushin <slava.semushin@gmail.com>
 1.16 13-Sep-2005  christos compat core reorg.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 17-Aug-1999  mycroft Make some needed weak aliases.
 1.13 06-Dec-1998  jonathan Move warnings about sys_siglist[] and __sys_siglist to _sys_siglist.c,
so that the warning is shown once at link time, not three times.
 1.12 01-Dec-1998  thorpej Warn about references to the compatibility sys_siglist[], and direct the
user to include <signal.h> or <unistd.h> to generate the correct reference.

Warn about references to the deprecated __sys_siglist[], and direct the
user to include <signal.h> or <unistd.h> and use sys_siglist instead.
 1.11 30-Nov-1998  thorpej Don't include <sys/cdefs.h> twice. Also, don't include <signal.h> or
<unistd.h>. These headers are not needed, and if included now, cause
a compile error since the exported and renamed type is different.
 1.10 26-Sep-1998  christos Adapt to new signal changes (from Jason)
 1.9 13-Jul-1997  christos Fix RCSID's
 1.8 04-Mar-1995  cgd branches: 1.8.4;
fix up some RCS Id's i botched.
 1.7 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.6 12-Dec-1994  jtc branches: 1.6.2;
Rework indirect reference support as outlined by my recent message to
the tech-userlevel mailing list.
 1.5 10-Oct-1994  jtc Renamed sys_errlist[] and sys_nerr to __sys_errlist[] and __sys_nerr.
The traditional API of sys_errlist[] and sys_nerr is provided by weak
references if they are supported. Otherwise, we're forced to have to
have two copies of the error message string table in the library.
Fortunately, unless a program uses both sys_errlist[] and strerror(),
only one of the copies will be linked into the executable.

This is all to provide an clean namespace as required by ANSI. I've
done the same for sys_siglist[], even though it is not required, to
be consistant.
 1.4 02-Dec-1993  mycroft Add `const's to sys_siglist and sys_signame decls.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 02-May-1995  jtc #include "namespace.h"
 1.6.2.1 17-Feb-1995  jtc Use "namespace.h", back out old mechanism for namespace purity.
 1.8.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.31 25-Jul-2025  uwe signal(3): drop emphatic warning about "new", reliable signals

4.2BSD was released in 1983 so the users had ample time to heed the
warning about the new signal(3) semantic. Tone it down and trim it,
moving the note about the old semantic to the history section.
 1.30 09-Feb-2024  uwe branches: 1.30.2;
signal(3): mention old signal(2) syscall in HISTORY
 1.29 07-Aug-2021  dholland typo
 1.28 06-Dec-2017  dholland The list of async-signal-safe functions got moved to sigaction(2).
 1.27 06-Jun-2016  wiz branches: 1.27.8;
Remove bsd_signal prototype from SYNOPSIS, we now have bsd_signal(3).
 1.26 06-Jun-2016  wiz Use Fn. Merge two EINVAL sections.
 1.25 05-Jun-2016  christos Document bsd_signal (From GSoC 2016 by Charles Cui)
 1.24 13-Jun-2004  lha Add list of async-signal-safe functions
Approved by wiz
 1.23 02-Jan-2004  jmmv Fix typo; from Aidan Kehoe in PR lib/23950.
 1.22 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.21 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.20 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.19 10-Jul-2002  wiz Sort SEE ALSO.
 1.18 28-Jun-2002  jdolecek Deal with .Fn macro problem with function returning pointer to function;
sidestep it using troff macro trick from FreeBSD version of this manpage.
xref psignal(3) and strsignal(3)

This fixes lib/12260 by Ada Lim and lib/17406 by Greg A. Woods.
 1.17 21-Feb-2002  wiz Improve RETURN VALUES section by mentioning SIG_ERR, per lib/15686, and fix
some spacing.
 1.16 07-Feb-2002  ross Generate <>& symbolically.
 1.15 23-Nov-2001  jdolecek s/Sig/Specified sig/ in ERRORS
 1.14 22-Nov-2001  tron Use ANSI signature for signal handler function.
 1.13 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.12 16-Sep-2001  wiz Boring whitespace fixes.
 1.11 06-Oct-1999  jdolecek branches: 1.11.8;
rip off the signal list and xref signal(7) instead
 1.10 22-Mar-1999  garbled branches: 1.10.4;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.9 09-Mar-1999  erh Add missing .El lines.
 1.8 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 26-Mar-1996  jtc Changed signal prototype to be more like ANSI C
 1.5 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 10-Jan-1994  jtc Fix spelling errors.
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.8.6 18-Oct-2002  nathanw Catch up to -current.
 1.11.8.5 01-Aug-2002  nathanw Catch up to -current.
 1.11.8.4 22-Mar-2002  nathanw Catch up to -current.
 1.11.8.3 08-Mar-2002  nathanw Catch up to -current.
 1.11.8.2 28-Jan-2002  nathanw Catch up to -current.
 1.11.8.1 08-Oct-2001  nathanw Catch up to -current.
 1.27.8.1 10-Dec-2017  snj Pull up following revision(s) (requested by dholland in ticket #433):
lib/libc/gen/signal.3: revision 1.28
The list of async-signal-safe functions got moved to sigaction(2).
 1.30.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 03-Jan-2024  christos tidy up some extern declarations
 1.15 02-Jan-2024  christos pass lint.
 1.14 03-Jun-2016  christos Add bsd_signal as required by POSIX (from GSoC 2016, Charles Cui)
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 07-Aug-2003  agc branches: 1.12.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 16-Oct-1998  kleink Need an internal name for signal().
 1.9 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.8 13-Jul-1997  christos Fix RCSID's
 1.7 04-Mar-1995  cgd branches: 1.7.4;
fix up some RCS Id's i botched.
 1.6 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.5 30-Nov-1993  jtc branches: 1.5.4;
Renamed _sigintr to __sigintr. _sigintr is in the user's namespace.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 30-Jul-1993  mycroft Add even more RCS frobs.
 1.2 16-Jun-1993  jtc According to Ansi C, signal is supposed to return SIG_ERR on error,
not BADSIG. I know they are the same thing, but this allows me to
remove the otherwised unused, bogus macro BADSIG from signal.h
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 02-May-1995  jtc #include "namespace.h"
 1.7.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.12.56.1 30-Oct-2012  yamt sync with head
 1.3 20-Aug-2020  kre When not compiling -DSMALL permit use of names RTMIN[+n] and RTMAX[-n]
(where n is a decimal integer in the range [0 .. SIGRTMAX-SIGRTMIN].
As usual a leading "sig" is ignored and the strings are case independent.

Some implementations do not name the real time signals, and using
labels like RTMIN+3 can be the only way they can be manipulated,
so allow that technique (we still return the RTnn names on the inverse
translation though).

Because this is used by both kill(1) and sh(1) the kill and trap
commands both gain access to the new notation (when !SMALL).
 1.2 14-May-2017  wiz Formatting and punctuation improvements.
 1.1 09-May-2017  kre branches: 1.1.2;


Add the new signalname/signalnext/signalnumber interface to libc.

This as discussed on current-users in the thread
entitled:
Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"
that can be found (starting at):
http://mail-index.netbsd.org/current-users/2017/04/28/msg031600.html

These functions provide the mechanism to enable applications
to divorce themselves from internal details of the signal
implementation.

Libc minor bumped, prototypes in <signal.h>, sets lists updated (and sorted).

One and all: feel free to improve the sources & man page (etc), but
please do not change the function signatures without discussion.
 1.1.2.3 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.1.2.2 11-May-2017  pgoyette Sync with HEAD
 1.1.2.1 09-May-2017  pgoyette file signalname.3 was added on branch prg-localcount2 on 2017-05-11 02:58:32 +0000
 1.1 09-May-2017  kre branches: 1.1.2;


Add the new signalname/signalnext/signalnumber interface to libc.

This as discussed on current-users in the thread
entitled:
Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"
that can be found (starting at):
http://mail-index.netbsd.org/current-users/2017/04/28/msg031600.html

These functions provide the mechanism to enable applications
to divorce themselves from internal details of the signal
implementation.

Libc minor bumped, prototypes in <signal.h>, sets lists updated (and sorted).

One and all: feel free to improve the sources & man page (etc), but
please do not change the function signatures without discussion.
 1.1.2.2 11-May-2017  pgoyette Sync with HEAD
 1.1.2.1 09-May-2017  pgoyette file signalname.c was added on branch prg-localcount2 on 2017-05-11 02:58:32 +0000
 1.1 09-May-2017  kre branches: 1.1.2;


Add the new signalname/signalnext/signalnumber interface to libc.

This as discussed on current-users in the thread
entitled:
Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"
that can be found (starting at):
http://mail-index.netbsd.org/current-users/2017/04/28/msg031600.html

These functions provide the mechanism to enable applications
to divorce themselves from internal details of the signal
implementation.

Libc minor bumped, prototypes in <signal.h>, sets lists updated (and sorted).

One and all: feel free to improve the sources & man page (etc), but
please do not change the function signatures without discussion.
 1.1.2.2 11-May-2017  pgoyette Sync with HEAD
 1.1.2.1 09-May-2017  pgoyette file signalnext.c was added on branch prg-localcount2 on 2017-05-11 02:58:32 +0000
 1.3 20-Aug-2020  kre When not compiling -DSMALL permit use of names RTMIN[+n] and RTMAX[-n]
(where n is a decimal integer in the range [0 .. SIGRTMAX-SIGRTMIN].
As usual a leading "sig" is ignored and the strings are case independent.

Some implementations do not name the real time signals, and using
labels like RTMIN+3 can be the only way they can be manipulated,
so allow that technique (we still return the RTnn names on the inverse
translation though).

Because this is used by both kill(1) and sh(1) the kill and trap
commands both gain access to the new notation (when !SMALL).
 1.2 04-Jan-2018  kamil Add bunch of missing includes of namespace.h in libc

The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

This change eliminates usage of the global changes of the following symbols:
- strlcat -> _strlcat
- sysconf -> __sysconf
- closedir -> _closedir
- fparseln -> _fparseln
- kill -> _kill
- mkstemp -> _mkstemp
- reallocarr -> _reallocarr
- strcasecmp -> _strcasecmp
- strncasecmp -> _strncasecmp
- strptime -> _strptime
- strtok_r -> _strtok_r
- sysctl -> _sysctl
- dlopen -> __dlopen
- dlclose -> __dlclose
- dlsym -> __dlsym

Sponsored by <The NetBSD Foundation>
 1.1 09-May-2017  kre branches: 1.1.2;


Add the new signalname/signalnext/signalnumber interface to libc.

This as discussed on current-users in the thread
entitled:
Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"
that can be found (starting at):
http://mail-index.netbsd.org/current-users/2017/04/28/msg031600.html

These functions provide the mechanism to enable applications
to divorce themselves from internal details of the signal
implementation.

Libc minor bumped, prototypes in <signal.h>, sets lists updated (and sorted).

One and all: feel free to improve the sources & man page (etc), but
please do not change the function signatures without discussion.
 1.1.2.2 11-May-2017  pgoyette Sync with HEAD
 1.1.2.1 09-May-2017  pgoyette file signalnumber.c was added on branch prg-localcount2 on 2017-05-11 02:58:32 +0000
 1.13 13-Sep-2005  christos compat core reorg.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 20-Mar-2002  christos add the rt signals so we don't core-dump.
 1.10 01-Dec-1998  thorpej branches: 1.10.12;
Warn about references to the compatibility sys_signame[], and direct
the user to include <signal.h> to generate the correct reference.

Suggestion from Christoph Badura.
 1.9 30-Nov-1998  thorpej Don't include <sys/cdefs.h> twice. Also, don't include <signal.h> or
<unistd.h>. These headers are not needed, and if included now, cause
a compile error since the exported and renamed type is different.
 1.8 26-Sep-1998  christos Fix array bounds (from Jason)
 1.7 13-Jul-1997  christos Fix RCSID's
 1.6 04-Mar-1995  cgd branches: 1.6.4;
fix up some RCS Id's i botched.
 1.5 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 02-Dec-1993  mycroft Add `const's to sys_siglist and sys_signame decls.
 1.3 08-Sep-1993  jtc Elements of sys_signame array should be in upper case.
Both kill and sliplogin, which were converted to use this array, are
either specified to use, or have traditionally used, upper case names.
This change shouldn't have bad side-effects, sys_signame is new to netbsd
and nothing in the source tree except kill and sliplogin use it.
 1.2 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.1 06-Aug-1993  mycroft Add sys_signame[].
 1.6.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.12.1 22-Mar-2002  nathanw Catch up to -current.
 1.3 30-Apr-2008  martin branches: 1.3.8;
Convert TNF licenses to new 2 clause variant
 1.2 15-Jan-2004  wiz branches: 1.2.30;
inifities are probably infinities.
 1.1 15-Jan-2004  kleink Add C99 fpclassify(), isfinite(), isnormal(), and signbit() macros.
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.3.8.1 30-Apr-2008  martin file signbit.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 15-Jan-2004  kleink branches: 1.1.30;
Add C99 fpclassify(), isfinite(), isnormal(), and signbit() macros.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file signbitd_ieee754.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 15-Jan-2004  kleink branches: 1.1.30;
Add C99 fpclassify(), isfinite(), isnormal(), and signbit() macros.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file signbitf_ieee754.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.3 17-May-2025  andvar Fix RCS ID in few more files.
 1.2 26-Apr-2019  maya branches: 1.2.12;
Unify signbitl implementations.
(Unclear why they were different, it was only the comments that
differed)

Add a comment describing why the generic version works for both 80-bit
and 128-bit double.
 1.1 17-Jan-2011  matt branches: 1.1.4; 1.1.48;
Make the MIPS N32/N64 ABIs properly support 128-bit long doubles. With this
change, we should be fully conformant with the N32 and N64 ABIs.
Add {fpclassify,infinity,isnan,ininf,signbit}l_ieee754.c back to lib/libc/gen.
Note that infinityl_ieee754.c will work with either 64-bit, 80-bit, or
128-bit long doubles.
 1.1.48.1 10-Jun-2019  christos Sync with HEAD
 1.1.4.2 29-Apr-2011  matt Pull in true (128-bit) long double support for MIPS from -current.
 1.1.4.1 17-Jan-2011  matt file signbitl_ieee754.c was added on branch matt-nb5-mips64 on 2011-04-29 07:48:35 +0000
 1.2.12.1 02-Aug-2025  perseant Sync with HEAD
 1.4 30-Apr-2010  jruoho More obsolete things. These are all already deprecated in NetBSD, but it is
worth noting that also the standard has marked these as legacy.
 1.3 30-Apr-2008  martin branches: 1.3.8;
Convert TNF licenses to new 2 clause variant
 1.2 16-Apr-2003  wiz branches: 1.2.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.1 15-Jan-2003  kleink branches: 1.1.2;
Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.1.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 15-Jan-2003  thorpej file sigrelse.3 was added on branch nathanw_sa on 2003-01-17 05:13:00 +0000
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.3.8.1 30-Apr-2008  martin file sigrelse.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 15-Jan-2003  kleink branches: 1.1.2; 1.1.32;
Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.1.32.1 18-May-2008  yamt sync with head.
 1.1.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 15-Jan-2003  thorpej file sigrelse.c was added on branch nathanw_sa on 2003-01-17 05:13:00 +0000
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file sigrelse.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.8 30-Apr-2010  wiz Merge two entries for the same error.
 1.7 30-Apr-2010  jruoho More obsolete things. These are all already deprecated in NetBSD, but it is
worth noting that also the standard has marked these as legacy.
 1.6 30-Apr-2008  martin branches: 1.6.8;
Convert TNF licenses to new 2 clause variant
 1.5 24-Jul-2005  rpaulo branches: 1.5.18;
Fix another sigignore -> sigset typo.

ok klenik@, hubertf@
 1.4 01-Feb-2005  drochner branches: 1.4.2;
fix pasto from sigignore.3
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 16-Jan-2003  wiz branches: 1.2.2;
typo fixes.
 1.1 15-Jan-2003  kleink Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.2.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.2.2.1 16-Jan-2003  thorpej file sigset.3 was added on branch nathanw_sa on 2003-01-17 05:13:00 +0000
 1.4.2.1 30-Jul-2005  tron Pull up revision 1.5 (requested by rpaulo in ticket #618):
Fix another sigignore -> sigset typo.
ok klenik@, hubertf@
 1.5.18.1 18-May-2008  yamt sync with head.
 1.6.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.6.8.1 30-Apr-2008  martin file sigset.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 15-Jan-2003  kleink branches: 1.1.2; 1.1.32;
Add sighold(3), sigignore(3), sigrelse(3) and sigset(3) to libc.
Fixes PR lib/19212, now redesignated standards/19212, from David Laight.
 1.1.32.1 18-May-2008  yamt sync with head.
 1.1.2.2 17-Jan-2003  thorpej Sync with HEAD.
 1.1.2.1 15-Jan-2003  thorpej file sigset.c was added on branch nathanw_sa on 2003-01-17 05:13:01 +0000
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file sigset.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.3 05-Feb-1995  mycroft Clean up deleted files.
 1.2 10-Dec-1994  jtc Changed to conform to NetBSD's new RCS Id convention.
 1.1 10-Dec-1994  jtc branches: 1.1.1;
Initial revision
 1.1.1.1 10-Dec-1994  jtc imported from 4.4lite
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 23-Nov-2001  jdolecek it's sufficient to say _once_ that the functions are macros; keep
the one which states sigemptyset() and sigfillset() are macros
Xref signal(7)
 1.10 16-Sep-2001  wiz Boring whitespace fixes.
 1.9 07-Jun-2000  nathanw branches: 1.9.4;
Fix incorrect uses of indicate/indicates/indicated for each other.
 1.8 05-Feb-1998  perry branches: 1.8.8;
add LIBRARY section to man page
 1.7 16-May-1997  kleink Add/update 1003.1 conformance notice.
 1.6 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.5 12-Aug-1994  jtc Updated to reflect the fact that these functions now detect errors
and that only sigemptyset() and sigfillset() have macro implementations.
 1.4 10-Jan-1994  jtc branches: 1.4.2;
Fix typos & formatting.
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 12-Aug-1994  mycroft update from trunk
 1.8.8.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.4.4 22-Mar-2002  nathanw Catch up to -current.
 1.9.4.3 08-Mar-2002  nathanw Catch up to -current.
 1.9.4.2 28-Jan-2002  nathanw Catch up to -current.
 1.9.4.1 08-Oct-2001  nathanw Catch up to -current.
 1.16 31-Jul-2010  joerg Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.
 1.15 13-Sep-2005  christos compat core reorg.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 01-Dec-1998  thorpej Warn about references to the compatibility sigaddset(), sigdelset(),
sigemptyset(), sigfillset(), and sigismember(), and direct the user
to include <signal.h> to generate the correct references.
 1.12 26-Sep-1998  christos Adapt to new signal changes (from Jason)
 1.11 13-Jul-1997  christos Fix RCSID's
 1.10 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.9 27-Feb-1995  cgd oops; we do need errno.h
 1.8 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.7 07-Feb-1994  proven branches: 1.7.4;
0 is not a valid signal, in the current scheme. The header signal.h does

#define sigmask(m) (1 << ((m)-1))

Also sigismember is supposed to return 1 if the signal is a member of the
mask, and 0 is it isn't.
 1.6 10-Jan-1994  jtc Set errno to EINVAL and return -1 if the argument to sigaddset(), sigdelset(),
or sigismember() is out of range. POSIX.1 allowed the old behavior, but
detecting the errors is a more reasonable course of action.
 1.5 11-Nov-1993  jtc First pass at getting a clean compile with "gcc -Wall", mostly explictly
declaring function return values, etc.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.4.2 02-May-1995  jtc #include "namespace.h"
 1.7.4.1 26-Apr-1995  jtc Add __weak_reference defns.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.10 16-Sep-2001  wiz Boring whitespace fixes.
 1.9 05-Feb-1998  perry branches: 1.9.12;
add LIBRARY section to man page
 1.8 19-Jul-1997  jtc Implement sleep() and usleep() in terms of nanosleep(). Uses only one
syscall instead of eight, and doesn't have any interactions with alarm
or interval timers.
 1.7 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.6 11-Dec-1994  mycroft Fix spelling error.
 1.5 28-May-1994  jtc Describe POSIX behavior of sleep.
More could be added, especially describing the effects of scheduling and/or
blocking SIGALRM outside of a sleep(). Also, using longjmp() in a signal
handler. But this will do until someone gets inspired to fill in the
grotty details.
 1.4 14-Oct-1993  jtc Change SYNOPSIS section to use "unsigned" instead of "u_int".
 1.3 30-Jul-1993  mycroft Add RCS identifiers.
 1.2 22-May-1993  deraadt sleep man page fix from <jan@encap.hanse.de>
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.9.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.9.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.23 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.22 28-Apr-2008  martin branches: 1.22.4; 1.22.8;
Remove clause 3 and 4 from TNF licenses
 1.21 22-Jan-2000  mycroft branches: 1.21.38;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.20 13-Nov-1998  christos delint
 1.19 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.18 19-Jul-1997  kleink __RCSID() police, typo in variable name; from jbernard@tater.mines.edu in
PR lib/3889.
 1.17 19-Jul-1997  jtc Implement sleep() and usleep() in terms of nanosleep(). Uses only one
syscall instead of eight, and doesn't have any interactions with alarm
or interval timers.
 1.16 13-Jul-1997  christos Prototype sleephandler
Fix RCSID's
 1.15 02-Aug-1996  phil branches: 1.15.2;
Make it correctly return unslept seconds if interrupted for any other
reason than SIGALRM. (Was ALWAYS returning 0.)
 1.14 11-May-1996  mycroft branches: 1.14.4;
Slight simplification.
 1.13 26-Oct-1995  pk Eliminate race by stopping timer before restarting it with remaining time
(one more system call).
 1.12 20-Oct-1995  pk Eliminate race in the "normal" case of not being interrupted by another signal.
 1.11 16-Oct-1995  pk 1) Turn off timer before resetting signal disposition.
2) Set signal mask before signal action, to avoid held SIGALRMs
bursting in after unsetting the handler.
 1.10 03-May-1995  mycroft branches: 1.10.2;
Explicitly unblock SIGALRM while waiting.
 1.9 21-Mar-1995  mycroft Minor changes.
 1.8 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.7 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.6 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.5 11-Dec-1994  mycroft branches: 1.5.2;
Clean this up a little. No functional changes.
 1.4 28-May-1994  jtc Changed to be POSIX.1 complian; now sleep can be interrupted, and it returns
the amount of time left "unslept" when it is.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 02-May-1995  jtc #include "namespace.h"
 1.10.2.2 26-Oct-1995  pk Eliminate race by stopping timer before restarting it with remaining time
(one more system call).
 1.10.2.1 20-Oct-1995  pk Update from trunk: race conditions.
 1.14.4.1 05-Aug-1996  jtc Pulled up from rev 1.15 by request from Phil Nelson
 1.15.2.2 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.15.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.21.38.1 18-May-2008  yamt sync with head.
 1.22.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.22.8.1 28-Apr-2008  martin file sleep.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.22.4.1 30-Oct-2012  yamt sync with head
 1.16 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.15 06-May-2010  jruoho Small improvements to markup and wording.
 1.14 09-Mar-2009  joerg Fix preamble to match order set out by mdoc(7). Discussed with wiz.
 1.13 30-Apr-2008  martin branches: 1.13.8; 1.13.10;
Convert TNF licenses to new 2 clause variant
 1.12 30-Jul-2006  wiz branches: 1.12.18;
Typo fix.
 1.11 27-Jul-2006  christos Add sl_delete, KNF, ansi
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 28-Nov-1999  lukem branches: 1.6.6;
* sl_init(); if malloc() fails return NULL instead of calling err(1,...)
* sl_add(); if realloc() fails return -1 instead of calling err(1,...).
otherwise, return 0.

NOTE: this change resulted in sl_add() changing from returning void to int.
this shouldn't be a problem because a) it returns 0 if ok (aka `void', b)
all invokers of sl_add() in the tree have been changed (mainly code i've
written).
 1.5 22-Mar-1999  garbled branches: 1.5.6;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 30-Jul-1997  jtc Fix files using old TNF copyright notice
 1.2 09-Apr-1997  kleink Fixed a typo and a .Os mistake.
 1.1 24-Feb-1997  lukem man page for stringlist functions
 1.5.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.6.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.12.18.1 18-May-2008  yamt sync with head.
 1.13.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.13.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.13.8.1 30-Apr-2008  martin file stringlist.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.15 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.14 21-May-2015  christos use reallocarr (Ingo Schwarze)
 1.13 28-Apr-2008  martin branches: 1.13.8;
Remove clause 3 and 4 from TNF licenses
 1.12 09-May-2007  christos branches: 1.12.10;
PR/36299: Greg Woods: Add namespace protection for sl_delete.
 1.11 27-Jul-2006  christos Add sl_delete, KNF, ansi
 1.10 25-Jan-2000  enami - Don't update the size of allocated storage until realloc successes.
- KNF left over.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 28-Nov-1999  lukem * sl_init(); if malloc() fails return NULL instead of calling err(1,...)
* sl_add(); if realloc() fails return -1 instead of calling err(1,...).
otherwise, return 0.

NOTE: this change resulted in sl_add() changing from returning void to int.
this shouldn't be a problem because a) it returns 0 if ok (aka `void', b)
all invokers of sl_add() in the tree have been changed (mainly code i've
written).
 1.7 27-Nov-1999  lukem convert to TNFi copyright (requested by christos)
 1.6 16-Sep-1999  lukem branches: 1.6.4;
* use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.5 29-Sep-1997  enami Delete `: %m' from a format string passed to err().
 1.4 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.3 13-Jul-1997  christos Fix RCSID's
Use namespace.h
 1.2 17-Jan-1997  lukem Add stringlist implementation
Convert getnetgrent from private stringlist to public version
 1.1 06-Nov-1996  lukem branches: 1.1.2;
file stringlist.c was initially added on branch nsswitch.
 1.1.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.6.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.10.1 18-May-2008  yamt sync with head.
 1.13.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.13.8.1 28-Apr-2008  martin file stringlist.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.57 21-Mar-2024  uwe sysconf(3): a few more markup fixes
 1.56 21-Mar-2024  uwe sysconf(3): the _SC constants are .Dv
 1.55 21-Mar-2024  uwe sysconf(3): NUL is not a defined variable
 1.54 21-Mar-2024  uwe sysconf(3): POSIX text doesn't capitalize "option".
 1.53 21-Mar-2024  wiz Fix NUL/NULL confusion.

One of these was reported by Mouse in PR 58058.
 1.52 25-Oct-2023  simonb Add _SC_AVPHYS_PAGES.
getconf(1) add this and SC_PHYS_PAGES.
libc: Use vm.uvmexp2 over vm.meter is it's twice as fast on my setup.
getconf.3: Tidy up wording for SC_PHYS_PAGES.
 1.51 03-Aug-2016  ryoon Fix _SC_TIMER_MAX listing, bump date
 1.50 05-Jul-2016  wiz branches: 1.50.2;
Bump date for _SC_THREAD_PRIO_PROTECT.
 1.49 03-Jul-2016  christos GSoC 2016 Charles Cui: Implement thread priority protection based on work
by Andy Doran. Also document the get/set pshared thread calls as not
implemented, and add a skeleton implementation that is disabled.
XXX: document _sched_protect(2).
 1.48 10-Jun-2016  christos GSoC 2016: Charles Cui: Add timer related macros
_POSIX_CPUTIME
_POSIX_THREAD_CPUTIME
_POSIX_DELAYTIMER_MAX
 1.47 10-Jun-2016  wiz Bump date for previous.
 1.46 10-Jun-2016  christos GSoC 2016: Charles Cui: add SEM_NSEMS_MAX
 1.45 26-Feb-2016  christos Add _SC_TIMER_MAX
 1.44 20-Aug-2015  wiz Bump date for previous.
 1.43 20-Aug-2015  pgoyette P1003_1B_SEMAPHORE is no longer optional
 1.42 03-Nov-2012  wiz Remove trailing whitespace.
 1.41 02-Nov-2012  christos Add _SC_PHYS_PAGES
 1.40 23-Aug-2011  jmcneill branches: 1.40.2; 1.40.4; 1.40.8;
maxmimum -> maximum
 1.39 09-Aug-2011  jruoho Xref limits(3).
 1.38 29-Apr-2011  wiz Mark up NULL.
 1.37 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.36 18-May-2009  wiz Bump date for last effective change (2008).
 1.35 15-Mar-2009  joerg Remove redundant markup as .Bl does vertical spacing already.
 1.34 06-Aug-2008  matt branches: 1.34.6; 1.34.8;
Add support for missing _SC_* constants for sysconf().
From andy dot shevchenko at gmail dot com
 1.33 15-Oct-2007  ad branches: 1.33.8;
Add _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF for sysconf(). These
are extensions but are provided by many Unix systems.
 1.32 14-Aug-2006  rpaulo branches: 1.32.8;
We support the POSIX Clock Selection Option.
 1.31 10-Nov-2004  lukem branches: 1.31.6;
Document _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX
 1.30 23-Apr-2004  simonb s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
 1.29 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.28 09-Jul-2003  kleink Fix pasto in 1.26; spotted by Thomas Klausner.
 1.27 09-Jul-2003  wiz Drop trailing spaces.
 1.26 09-Jul-2003  kleink Mention related kernel options where applicable.
 1.25 01-May-2003  wiz Grammar and mdoc fixes from jmc@openbsd.
 1.24 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.23 10-Feb-2003  wiz Drop trailing whitespace.
 1.22 02-Feb-2003  kleink Add sysconf(3) knobs for recent additions.
 1.21 19-Dec-2002  kleink Add a sysconf(3) knob for {ATEXIT_MAX}.
 1.20 08-Feb-2002  kleink Untangle the description of {MONOTONIC_CLOCK} somewhat.
 1.19 07-Feb-2002  ross Generate <>& symbolically.
 1.18 31-Jan-2002  kleink Add {POSIX_MONOTONIC_CLOCK} variables.
 1.17 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.16 16-Sep-2001  wiz Boring whitespace fixes.
 1.15 29-Aug-2000  kleink branches: 1.15.2;
{OPEN_MAX} does not apply to a user but a single process; noticed by Brook
Milligan on current-users.
 1.14 27-Sep-1999  kleink branches: 1.14.6;
Move {XOPEN_SHM} from Commands & Utilities to System Interfaces.
 1.13 27-Sep-1999  kleink 1003.1c: add {LOGIN_NAME_MAX}.
 1.12 24-Jun-1999  kleink branches: 1.12.2;
Add compile-time and run-time feature test knobs for the 1003.1 Mapped Files,
Process Memory Locking, Range Memory Locking and Memory Protection options.
 1.11 22-Mar-1999  garbled branches: 1.11.2;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.10 09-Mar-1999  erh Add missing .El lines.
 1.9 03-Aug-1998  kleink Add support for _SC_SYNCHRONIZED_IO and _SC_IOV_MAX. Rearrange documentation
a bit, and actually document _SC_XOPEN_SHM.
 1.8 24-May-1998  kleink Add support to query PAGESIZE, PAGE_SIZE, _POSIX_FSYNC and _XOPEN_SHM via
sysconf().
 1.7 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 03-Feb-1998  perry .Bx'ize
 1.4 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.3 12-Oct-1995  jtc Manpage fixes from Jochen Pohl. Aligns the prototypes in the SYNOPSIS
section with the actual function declarations. Also fixes decription
of _SC_CLK_TCK in sysconf(3). See PR #1587 and PR #1589 for details.
 1.2 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.11.2.1 09-Sep-2000  he Pull up revision 1.15 (requested by kleink):
Correct description of _SC_OPEN_MAX: it sets the limit per process,
not per user id.
 1.12.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.6.1 29-Aug-2000  kleink Pull up rev. 1.15 (approved by thorpej):
Scope fix in the description of _SC_OPEN_MAX.
 1.15.2.4 29-Dec-2002  thorpej Sync with HEAD.
 1.15.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.15.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.15.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.31.6.1 16-Aug-2006  tron Pull up following revision(s) (requested by rpaulo in ticket #25):
sys/sys/unistd.h: revision 1.34
lib/libc/gen/sysconf.3: revision 1.32
We support the POSIX Clock Selection Option.
 1.32.8.1 06-Nov-2007  matt sync with HEAD
 1.33.8.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.34.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.34.6.2 06-Aug-2008  matt Add support for missing _SC_* constants for sysconf().
From andy dot shevchenko at gmail dot com
 1.34.6.1 06-Aug-2008  matt file sysconf.3 was added on branch christos-time_t on 2008-08-06 17:17:05 +0000
 1.40.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.40.4.1 28-Nov-2012  riz Pull up following revision(s) (requested by christos in ticket #720):
sys/sys/unistd.h: revision 1.54
lib/libc/gen/sysconf.3: revision 1.41
lib/libc/gen/sysconf.c: revision 1.35
add _SC_PHYS_PAGES
Add _SC_PHYS_PAGES
Add _SC_PHYS_PAGES
 1.40.2.1 16-Jan-2013  yamt sync with (a bit old) head
 1.50.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.45 22-Dec-2024  riastradh sysconf(3): KNF

No functional change intended.

Prompted by exposing DELAYTIMER_MAX in preparation for:

PR kern/58926: itimer(9) integer overflow in overrun counting
 1.44 25-Oct-2023  simonb branches: 1.44.2;
Add _SC_AVPHYS_PAGES.
getconf(1) add this and SC_PHYS_PAGES.
libc: Use vm.uvmexp2 over vm.meter is it's twice as fast on my setup.
getconf.3: Tidy up wording for SC_PHYS_PAGES.
 1.43 15-Dec-2019  joerg PR 54619: Remove semaphore limit introduce as part of GSoC 2016 with
_SC_SEM_NSEMS_MAX. Report no limit for getconf(3). The ressource is
naturally limited by the backing file descriptor, so no separate limit
is necessary. Keep the accounting for debugging as it is part of the
sysctl ABI exposed by the kernel.
 1.42 16-Oct-2019  maya Provide sysconf(_SC_RTSIG_MAX) = SIGRTMAX - SIGRTMIN

Thanks nros@ for the correct definition
 1.41 04-Aug-2016  christos branches: 1.41.14; 1.41.16;
Realtime signal support from GSoC 2016, Charles Cui.
 1.40 03-Jul-2016  christos branches: 1.40.2;
GSoC 2016 Charles Cui: Implement thread priority protection based on work
by Andy Doran. Also document the get/set pshared thread calls as not
implemented, and add a skeleton implementation that is disabled.
XXX: document _sched_protect(2).
 1.39 10-Jun-2016  christos GSoC 2016: Charles Cui: Add timer related macros
_POSIX_CPUTIME
_POSIX_THREAD_CPUTIME
_POSIX_DELAYTIMER_MAX
 1.38 10-Jun-2016  christos GSoC 2016: Charles Cui: add SEM_NSEMS_MAX
 1.37 26-Feb-2016  christos Add _SC_TIMER_MAX
 1.36 19-Dec-2013  rmind Add shm_open(3) and shm_unlink(3) to support POSIX shared memory objects.
They are implemented using tmpfs (mounted at /var/shm).

Discussed on tech-{kern,userlevel} (quite a while ago).
 1.35 02-Nov-2012  christos Add _SC_PHYS_PAGES
 1.34 01-Aug-2012  martin branches: 1.34.2;
Define _POSIX_SPAWN in unistd.h and also provide its value via sysconf(),
as required by posix since we support posix_spawn().
 1.33 06-Aug-2008  matt branches: 1.33.2; 1.33.6; 1.33.22;
Add support for missing _SC_* constants for sysconf().
From andy dot shevchenko at gmail dot com
 1.32 25-Jun-2008  ad Add _SC_TTY_NAME_MAX.
 1.31 25-Jun-2008  ad Return -1 for the unsupported realtime extensions.
 1.30 24-Jun-2008  ad A few more POSIX defs for threads.
 1.29 09-Apr-2008  njoly branches: 1.29.4;
Fix _SC_MQ_OPEN_MAX/_SC_MQ_PRIO_MAX sysctlgetmibinfo calls.
The corresponding sysctl nodes are available under kern.mqueue tree.
 1.28 08-Mar-2008  yamt sysconf: cache the result of _SC_PAGESIZE.
 1.27 26-Jan-2008  rmind branches: 1.27.2;
sched_setparam: fix the case when incorrect (according to the class)
in-kernel priority is used. Reported by <drochner>.

Minor fixes for scheduling calls to conform the POSIX:
- If pid is equal to zero, use the calling process;
- In case of permission problem, return EPERM instead of EACESS;
- sched_setscheduler() should return previously used policy;
- pthread_* calls should return the error code or zero;

Should fix the namespace problems (and builds of some packages):
- Move cpuset_t defintion from pset.h to sched.h;
- Remove the #include of pset.h in pthread.h;
 1.26 15-Jan-2008  rmind Implementation of processor-sets, affinity and POSIX real-time extensions.
Add schedctl(8) - a program to control scheduling of processes and threads.

Notes:
- This is supported only by SCHED_M2;
- Migration of LWP mechanism will be revisited;

Proposed on: <tech-kern>. Reviewed by: <ad>.
 1.25 15-Oct-2007  ad Add _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF for sysconf(). These
are extensions but are provided by many Unix systems.
 1.24 07-Sep-2007  rmind Implementation of POSIX message queues.

Reviewed by: <ad>, <tech-kern>
 1.23 01-May-2007  rmind branches: 1.23.4;
- Create sysctl nodes for AIO.
- Add POSIX defined system variables and constants of AIO_LISTIO_MAX and
AIO_MAX values. Both with _POSIX_ASYNCHRONOUS_IO, provide them in
sysconf(3) and getconf(1) interfaces.
- Clean up sysconf(3) for handling sysctl nodes dynamically.
 1.22 25-Nov-2006  christos PR/34837: Mindaguas: Add SysV SHM dynamic reallocation and locking to the
physical memory
 1.21 10-Nov-2004  lukem need <limits.h> for _SC_GET{GR,PW}_SIZE_MAX
 1.20 10-Nov-2004  lukem Implement sysconf(3) _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX for
the 1003.1-2001 Thread Safe Functions (TSF) getgrnam_r(3) and getpwnam_r(3).

These are not implemented in sysctl(3) "user.*", since that adds a lot
of complexity in the implementation for no real benefit.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 02-Feb-2003  kleink Add sysconf(3) knobs for recent additions.
 1.17 19-Dec-2002  kleink Add a sysconf(3) knob for {ATEXIT_MAX}.
 1.16 30-Jun-2002  bjh21 Version times() so that programs compiled before the recent change to make
sysconf(_SC_CLK_TCK) return hz will work.

In detail:
__times13() returns values scaled by hz.
times() returns values scaled by 100.
<sys/times.h> renames times() to __times13().

_SC_CLK_TCK has changed from 3 to 39.
sysconf(3) returns 100.
sysconf(39) returns hz.
CLK_TCK is defined as sysconf(39).
 1.15 23-Jun-2002  perry make sysconf(_SC_CLK_TCK) return the kernel hz value, instead of a
fixed constant, as is done on Solaris, Linux, etc.

Technically, standards don't *require* this, but having it return a
constant is a violation of the spirit, and screws up programs that
(perhaps improperly) assume that it will return kernel hz.
 1.14 31-Jan-2002  kleink Add {POSIX_MONOTONIC_CLOCK} variables.
 1.13 07-May-2001  kleink Internally rename sysconf() to __sysconf() to make its latter name suitable
for use from public headers. Also, do so on all platforms.
 1.12 22-Jan-2000  mycroft branches: 1.12.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.11 27-Sep-1999  kleink 1003.1c: add {LOGIN_NAME_MAX}.
 1.10 24-Jun-1999  kleink branches: 1.10.2;
Add compile-time and run-time feature test knobs for the 1003.1 Mapped Files,
Process Memory Locking, Range Memory Locking and Memory Protection options.
 1.9 03-Aug-1998  kleink Add support for _SC_SYNCHRONIZED_IO and _SC_IOV_MAX. Rearrange documentation
a bit, and actually document _SC_XOPEN_SHM.
 1.8 24-May-1998  kleink Add support to query PAGESIZE, PAGE_SIZE, _POSIX_FSYNC and _XOPEN_SHM via
sysconf().
 1.7 30-Mar-1998  kleink Need <time.h> for CLK_TCK definition.
 1.6 27-Feb-1998  perry trivial changes to quiet lint.
 1.5 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.4 13-Jul-1997  christos Fix RCSID's
Remove unused variable
 1.3 04-Mar-1995  cgd branches: 1.3.4;
fix up some RCS Id's i botched.
 1.2 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd branches: 1.1.1.1.4;
various sysctl-related libc functions
 1.1.1.1.4.1 02-May-1995  jtc #include "namespace.h"
 1.3.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.6.5 29-Dec-2002  thorpej Sync with HEAD.
 1.12.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.12.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.12.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.12.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.23.4.2 23-Mar-2008  matt sync with HEAD
 1.23.4.1 06-Nov-2007  matt sync with HEAD
 1.27.2.1 24-Mar-2008  keiichi sync with head.
 1.29.4.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.33.22.2 28-Nov-2012  riz Pull up following revision(s) (requested by christos in ticket #720):
sys/sys/unistd.h: revision 1.54
lib/libc/gen/sysconf.3: revision 1.41
lib/libc/gen/sysconf.c: revision 1.35
add _SC_PHYS_PAGES
Add _SC_PHYS_PAGES
Add _SC_PHYS_PAGES
 1.33.22.1 09-Aug-2012  jdc Pull up revisions:
src/lib/libc/gen/sysconf.c revision 1.34
src/sys/sys/unistd.h revision 1.53
(requested by martin in ticket #460).

Define _POSIX_SPAWN in unistd.h and also provide its value via sysconf(),
as required by posix since we support posix_spawn().
 1.33.6.2 06-Aug-2008  matt Add support for missing _SC_* constants for sysconf().
From andy dot shevchenko at gmail dot com
 1.33.6.1 06-Aug-2008  matt file sysconf.c was added on branch christos-time_t on 2008-08-06 17:17:05 +0000
 1.33.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.33.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.33.2.1 30-Oct-2012  yamt sync with head
 1.34.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.40.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.41.16.1 18-Dec-2019  martin Pull up following revision(s) (requested by joerg in ticket #572):

sys/kern/uipc_sem.c: revision 1.56
lib/libc/gen/sysconf.c: revision 1.43

PR 54619: Remove semaphore limit introduce as part of GSoC 2016 with
_SC_SEM_NSEMS_MAX. Report no limit for getconf(3). The ressource is
naturally limited by the backing file descriptor, so no separate limit
is necessary. Keep the accounting for debugging as it is part of the
sysctl ABI exposed by the kernel.
 1.41.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.41.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.44.2.1 02-Aug-2025  perseant Sync with HEAD
 1.207 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.206 15-Sep-2019  wiz Fix markup, and remove two superfluous Pp.
 1.205 15-Sep-2019  christos fix wrong names and add markup
 1.204 06-Sep-2018  maxv fix references, the things were moved into netipsec/ a while ago
 1.203 03-Jul-2017  wiz branches: 1.203.4; 1.203.6;
Remove workaround for ancient HTML generation code.
 1.202 13-Jun-2014  wiz Remove trailing whitespace. Use more markup. Merge sections describing
the same error code.
 1.201 13-Jun-2014  joerg Add asysctl(3) and asysctlbyname(3) wrappers for the common idiom of
fetching dynamically sized data via sysctl.
 1.200 22-Mar-2010  joerg branches: 1.200.12; 1.200.22;
Use .In for header files instead of .Ar Pa and variations.
 1.199 26-Sep-2009  elad CTLFLAG_READONLY[12] are long gone.
 1.198 22-Jul-2009  alc Bump date.
 1.197 22-Jul-2009  alc Constify the fourth argument of sysctlbtname(3) (ie. `newp', the pointer to
the new value).

This change sync sysctl(3) and sysctlbtname(3) prototypes.

No objection on <tech-userlevel>
 1.196 11-Jan-2009  christos merge christos-time_t
 1.195 11-Nov-2008  reed Reference secmodel_securelevel(9) manual page.
 1.194 17-Sep-2008  christos branches: 1.194.4; 1.194.6;
From Ilya Dogolazky: Fix return value doc.
 1.193 18-Dec-2006  wiz branches: 1.193.12;
Sort error descriptions.
 1.192 04-Dec-2006  pavel Move the description of sysctl MIBs from sysctl.3 to a new manual page
sysctl.7. Remove the list of MIBs from sysctl.8 so we don't have to
maintain duplicate information, as proposed by YAMAMOTO Takashi on
tech-userlevel. Also remove references to header files from sysctl.8.

The numeric constants remain documented, they are still needed in some
cases. See the discussion on tech-userlevel. ("mib list in sysctl.8")

OK by YAMAMOTO Takashi.
 1.191 27-Nov-2006  elad branches: 1.191.2; 1.191.6;
Adapt to recent Veriexec sysctl(9) changes.
 1.190 25-Nov-2006  christos PR/34837: Mindaguas: Add SysV SHM dynamic reallocation and locking to the
physical memory
 1.189 23-Nov-2006  elad Add note about Segvguard interface/implementation being experimental and
with the potential to change in future releases.
 1.188 22-Nov-2006  elad Initial implementation of PaX Segvguard (this is still work-in-progress,
it's just to get it out of my local tree).
 1.187 19-Oct-2006  yamt document tcp.abc.
 1.186 13-Oct-2006  wiz Bump date for previous.
 1.185 09-Oct-2006  rpaulo Modular (I tried ;-) TCP congestion control API. Whenever certain conditions
happen in the TCP stack, this interface calls the specified callback to
handle the situation according to the currently selected congestion
control algorithm.
A new sysctl node was created: net.inet.tcp.congctl.{available,selected}
with obvious meanings.
The old net.inet.tcp.newreno MIB was removed.
The API is discussed in tcp_congctl(9).

In the near future, it will be possible to selected a congestion control
algorithm on a per-socket basis.

Discussed on tech-net and reviewed by <yamt>.
 1.184 08-Oct-2006  elad PR/27233: Arto Selonen: 'options BUFCACHE' vs. 'sysctl vm.bufcache'
documentation differs
 1.183 26-Sep-2006  elad Change the PaX mprotect(2) restrictions' "global_protection" knob to
just "global" -- it's shorter and more readable. Update documentation.
 1.182 06-Sep-2006  wiz Only mark up one word, not the whole sentence.
 1.181 06-Sep-2006  liamjfoy document net.inet.ip.maxflows. dump date.
 1.180 05-Sep-2006  rpaulo Import of TCP ECN algorithm for congestion control.
Both available for IPv4 and IPv6.
Basic implementation test results are available at
http://netbsd-soc.sourceforge.net/projects/ecn/testresults.html.

Work sponsored by the Google Summer of Code project 2006.
Special thanks to Kentaro Kurahone, Allen Briggs and Matt Thomas for their
help, comments and support during the project.
 1.179 04-Sep-2006  liamjfoy Update for carp(4). Bump date.

from openbsd
 1.178 11-Aug-2006  christos Pretending to be Elad's keyboard:

fileassoc.diff adds a fileassoc_table_run() routine that allows you to
pass a callback to be called with every entry on a given mount.

veriexec.diff adds some raw device access policies: if raw disk is
opened at strict level 1, all fingerprints on this disk will be
invalidated as a safety measure. level 2 will not allow opening disk
for raw writing if we monitor it, and prevent raw writes to memory.
level 3 will not allow opening any disk for raw writing.

both update all relevant documentation.

veriexec concept is okay blymn@.
 1.177 24-Jul-2006  wiz branches: 1.177.2;
Remove superfluous word, add comma to make it easier to parse.
 1.176 24-Jul-2006  elad blymn made ips mode prevent execution of non-monitored files; document
that.
 1.175 24-Jul-2006  elad ugh.. forgot to document no removal in ids mode.
 1.174 22-Jul-2006  elad "verified exec" -> "veriexec" + some minor tweaks.
 1.173 14-Jul-2006  wiz Punctuation nits.
 1.172 14-Jul-2006  elad move security.setid_core.* to kern.coredump.setid.*, as requested by yamt@.
 1.171 14-Jul-2006  elad okay, since there was no way to divide this to two commits, here it goes..

introduce fileassoc(9), a kernel interface for associating meta-data with
files using in-kernel memory. this is very similar to what we had in
veriexec till now, only abstracted so it can be used more easily by more
consumers.

this also prompted the redesign of the interface, making it work on vnodes
and mounts and not directly on devices and inodes. internally, we still
use file-id but that's gonna change soon... the interface will remain
consistent.

as a result, veriexec went under some heavy changes to conform to the new
interface. since we no longer use device numbers to identify file-systems,
the veriexec sysctl stuff changed too: kern.veriexec.count.dev_N is now
kern.veriexec.tableN.* where 'N' is NOT the device number but rather a
way to distinguish several mounts.

also worth noting is the plugging of unmount/delete operations
wrt/fileassoc and veriexec.

tons of input from yamt@, wrstuden@, martin@, and christos@.
 1.170 16-May-2006  elad Introduce PaX MPROTECT -- mprotect(2) restrictions used to strengthen
W^X mappings.

Disabled by default.

First proposed in:

http://mail-index.netbsd.org/tech-security/2005/12/18/0000.html

More information in:

http://pax.grsecurity.net/docs/mprotect.txt

Read relevant parts of options(4) and sysctl(3) before using!

Lots of thanks to the PaX author and Matt Thomas.
 1.169 26-Apr-2006  wiz Bump date for previous, uppercase I/O, serial comma, remove trailing space.
 1.168 25-Apr-2006  blymn Change DISKSTATS to IOSTATS, document new i/o stats sysctl.
 1.167 24-Feb-2006  wiz Bump date for previous.
 1.166 24-Feb-2006  drochner complete constification of the sysctl() user side
 1.165 02-Feb-2006  elad document knobs for security.setid_core.

while i'm here... catch up with reality: no more SECURITY_CURTAIN;
now we have security.curtain. (no constant)
 1.164 14-Jan-2006  wiz Replace statfs(2) with statvfs(2).
 1.163 14-Jan-2006  elad sync & sort kern.
 1.162 14-Jan-2006  elad sort vm.
 1.161 14-Jan-2006  elad sync & sort hw.
 1.160 13-Jan-2006  elad Sync net.{inet,inet6}.
 1.159 01-Dec-2005  wiz Bump date for previous. Remove trailing whitespace.
 1.158 01-Dec-2005  elad Change the entry from "foobar" to "not applicable" in the "Changeable"
field of kern.veriexec.count.. no idea how that went unnoticed. :)
 1.157 06-Oct-2005  simonb Add a full-stop to the end of a sentence.
 1.156 06-Oct-2005  wiz Fix typo. Add some commas. Improve markup.
 1.155 03-Oct-2005  elad Document security level for sysctl and security.curtain.

Hi Hubert! :)
 1.154 24-Sep-2005  rpaulo Document kern.hardclock_ticks. Pointed out by Hubert.
 1.153 17-Jul-2005  isaki Correct a typo.
 1.152 20-Jun-2005  elad - Use more calls to veriexec_report() where possible.

- Change #ifdef VERIFIED_EXEC_VERBOSE to another verbose level, 2. Add
sysctl(3) bits.

- Simplify access type conflict handling during load. This depends on
the values of access type defines to be ordered from least to most
'strict'.
 1.151 17-Jun-2005  wiz New sentence, new line.
 1.150 17-Jun-2005  elad More veriexec changes:

- Better organize strict level. Now we have 4 levels:
- Level 0, learning mode: Warnings only about anything that might've
resulted in 'access denied' or similar in a higher strict level.

- Level 1, IDS mode:
- Deny access on fingerprint mismatch.
- Deny modification of veriexec tables.

- Level 2, IPS mode:
- All implications of strict level 1.
- Deny write access to monitored files.
- Prevent removal of monitored files.
- Enforce access type - 'direct', 'indirect', or 'file'.

- Level 3, lockdown mode:
- All implications of strict level 2.
- Prevent creation of new files.
- Deny access to non-monitored files.

- Update sysctl(3) man-page with above. (date bumped too :)

- Remove FINGERPRINT_INDIRECT from possible fp_status values; it's no
longer needed.

- Simplify veriexec_removechk() in light of new strict level policies.

- Eliminate use of 'securelevel'; veriexec now behaves according to
its strict level only.
 1.149 24-May-2005  wiz New sentence, new line. <> -> Aq. Bump date for previous.
 1.148 24-May-2005  elad Add man-page bits about the 'count' node.
 1.147 19-May-2005  elad Some changes in veriexec.

New features:

- Add a veriexec_report() routine to make most reporting consistent and
remove some common code.
- Add 'strict' mode that controls how veriexec behaves.
- Add sysctl knobs:
o kern.veriexec.verbose controls verbosity levels. Value: 0, 1.
o kern.veriexec.strict controls strict level. Values: 0, 1, 2. See
documentation in sysctl(3) for details.
o kern.veriexec.algorithms returns a string with a space separated
list of supported hashing algorithms in veriexec.
- Updated documentation in man pages for sysctl(3) and sysctl(8).

Bug fixes:

- veriexec_removechk(): Code cleanup + handle FINGERPRINT_NOTEVAL
correctly.
- exec_script(): Don't pass 0 as flag when executing a script; use the
defined VERIEXEC_INDIRECT - which is 1. Makes indirect execution
enforcement work.
- Fix some printing formats and types..
 1.146 09-Apr-2005  atatat Mention that the number after CTL_NET is "usually the protocol", but
may not be (see net.bpf).
 1.145 30-Mar-2005  yamt s of sack is selective, not selection. pointed by Michael Eriksson.
 1.144 22-Mar-2005  wiz Wording improvements, from yamt@
 1.143 21-Mar-2005  yamt update tcp.sack. noted by Hubert Feyrer.
 1.142 27-Dec-2004  christos branches: 1.142.2;
RTC_OFFSET is writable; sync with sysctl.8
 1.141 15-Oct-2004  enami Fix some typos.
 1.140 15-Oct-2004  daniel Add vm.bufcache, vm.bufmem, vm.bufmem_lowater, m.bufmem_hiwater (PR misc/27247, misc/27233).
 1.139 27-Aug-2004  wiz Bump date for removal of net.key.random_int.
 1.138 27-Aug-2004  itojun remove net.key.random_int
 1.137 05-Jul-2004  cube KERN_CP_TIME returns an arry of uint64_ts, not longs, as noted by Adam
Sampson in PR 23190. Also, tell about ``kern.cp_time.#CPU''.
 1.136 02-Jul-2004  heas UDP checksums are always checked (RFC1122 S4.1.3.4), it is not controllable
by net.inet.udp.checksum.
 1.135 25-Mar-2004  wiz branches: 1.135.2;
Bump date for previous; new sentence, new line;
remove duplicate word and fix a punctuation typo.
 1.134 25-Mar-2004  atatat Move sysctlbyname(), sysctlnametomib(), and sysctlgetmibinfo() from
sysctl(8) into libc, making the minor number jump. Add prototypes to
sys/sysctl.h, fix sets, modify man pages, etc. That oughta cover it.
 1.133 24-Mar-2004  snj Bump date for last; avoid direct use of &, < and >; drop trailing space.
 1.132 24-Mar-2004  atatat Bring sysctl man pages up to date (wrt new query interface, the
versioning, and descriptions).
 1.131 08-Jan-2004  wiz There is no sysctl(9) (yet?), comment it out;
fix a typo.
 1.130 07-Jan-2004  atatat Add descriptions of flags.
 1.129 03-Jan-2004  wiz Uppercase CPU; mark up NULL; remove superfluous word; simplify macro usage.
 1.128 03-Jan-2004  atatat At long last, add descriptions of new "dynamic" operations.
 1.127 09-Dec-2003  wiz Bump date for previous (hi andrew!).
 1.126 09-Dec-2003  atatat Update man page to correct PROC_* names (addresses PR lib/23645) and
also describe the new PROC_PID_STOPEXIT variable.

Man page still not updated to include new features. I'm still working
on that.
 1.125 23-Nov-2003  wiz New sentence, new line. Remove trailing spaces.
 1.124 23-Nov-2003  jhawk Bump Dd.
better explain the interactions between ip.mtudisc and tcp.mssdflt,
with regards to the TCP segment size.
ip.mtudisc is not read-only, as was implied by "returns"
XXX: this ("returns") should be corrected for other parameters, too.
Xr tcp(4)
 1.123 15-Oct-2003  wiz Slight improvements.
 1.122 28-Sep-2003  dsl Simon has persuaded me to remove the 'sizeof (struct kinfo_drivers)' field.
 1.121 27-Sep-2003  dsl Add KERN_ROOT_PARTITION and KERN_DRIVERS
 1.120 07-Sep-2003  wiz Consistently use 'RFC 1234' instead of 'RFC1234' or 'RFC-1234'.
From jmc@openbsd.
 1.119 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.118 27-Jun-2003  wiz Pa Aq -> Aq Pa; Sy Pa -> Sy.
 1.117 03-May-2003  wiz Misc. fixes from jmc@openbsd.
 1.116 19-Apr-2003  christos add ident.
 1.115 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.114 12-Apr-2003  dogcow Document ip.checkinterface
 1.113 11-Apr-2003  salo Document HW_CNMAGIC, fix HW_PHYSMEM64 and HW_USERMEM64 format in the table,
describe HW_MACHINE_ARCH and HW_ALIGNBYTES in the same order as listed in the
table.
 1.112 17-Mar-2003  wiz Consistent tab usage.
 1.111 06-Mar-2003  thorpej HW_PHYSPAGES -> HW_PHYSMEM64, HW_USERPAGES -> HW_USERMEM64.
 1.110 01-Mar-2003  thorpej Document net.inet.tcp.init_win_local.
 1.109 27-Feb-2003  thorpej Document hw.physpages and hw.userpages.
 1.108 02-Feb-2003  kleink Add sysconf(3) knobs for recent additions.
 1.107 02-Jan-2003  jschauma Fix typos pointed out by Igor Sobrado in PR misc/19621.
 1.106 19-Dec-2002  kleink Add a sysconf(3) knob for {ATEXIT_MAX}.
 1.105 18-Dec-2002  wiz new sentence, new line.
 1.104 18-Dec-2002  wiz exec lives in section 3, not 2.
 1.103 11-Dec-2002  jdolecek Add kern.forkfsleep sysctl - set/get time (in miliseconds) for which
process would be forced to sleep in fork() if it hits either global
or user maxproc limit. Default is zero (no forced sleep).
Maximum is 20 seconds.
 1.102 11-Dec-2002  scw Add two sysctls: kern.labelsector and kern.labeloffset.
These are of use to userland code which previously depended on the
hard-coded values of LABELSECTOR and LABELOFFSET to figure out the
location of the disklabel for a particular platform.

With the introduction of umbrella ports such as evbarm, evbmips, etc,
the location of the disklabel may vary between kernels for the same
MACHINE. This sysctl will allow userland programs to remain independent
of the particular flavour of MACHINE in such cases.
 1.101 07-Nov-2002  wiz New sentence, new line (hi manu!). Drop trailing whitespace.
 1.100 07-Nov-2002  manu Added two sysctl-able flags: proc.curproc.stopfork and proc.curproc.stopexec
that can be used to block a process after fork(2) or exec(2) calls. The
new process is created in the SSTOP state and is never scheduled for running.

This feature is designed so that it is esay to attach the process using gdb
before it has done anything.

It works also with sproc, kthread_create, clone...
 1.99 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.98 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.97 20-Aug-2002  wiz Fix Ns abuse.
 1.96 10-Jul-2002  wiz Drop trailing space.
 1.95 13-Jun-2002  itojun net.inet.ip.redirtimeout default value changed
 1.94 28-May-2002  itojun document net.inet6.ip6.maxfrags
 1.93 19-May-2002  itojun branches: 1.93.2;
document net.key.* sysctl. provide sysctl MIB for controlling
proposal payload on ACQUIRE message. sync w/kame
 1.92 14-May-2002  itojun rename: net.inet6.ip6.bindv6only -> net.inet6.ip6.v6only
sync w/kame.
 1.91 14-May-2002  itojun s/IPV6_BINDV6ONLY/IPV6_V6ONLY/
 1.90 26-Feb-2002  martin Note ip.grettl
 1.89 10-Feb-2002  ross fix <> string names
 1.88 07-Feb-2002  ross generate & symbolically
 1.87 07-Feb-2002  ross Generate <>& symbolically.
 1.86 07-Feb-2002  ross Edit -mdoc usage.

* There is no -indent option to .Bd or .Bl, although you would
never know that from its frequent use in this tree. There is a
"-offset indent" combination that makes sense, and you can certainly
say "-width indent".

* Also, you can't markup the -width option argument, tho you CAN
use a callable macro. So "-width Ar filename" doesn't make sense,
but either "-width Ar" or "-width filename" does, as might something
like "-width xxfilename" for a little extra space.

* There are a lot of needlessly complex hanging tag macros in man4 used
to create simple item lists. Those should be simplified one of these
days before someone copies and edits yet another man4 page.
 1.85 31-Jan-2002  kleink Add {POSIX_MONOTONIC_CLOCK} variables.
 1.84 28-Jan-2002  simonb Document the new kern.tkstat.* sysctls.
 1.83 27-Jan-2002  simonb Implement the hw.disknames and hw.diskstats sysctl's that have been listed
in <sys/sysctl.h> since day one but never implemented.
 1.82 15-Jan-2002  wiz Whitespace nit.
 1.81 24-Dec-2001  chs update vm entries.
 1.80 30-Oct-2001  kml Added descriptions of the new sysctls for controlling the disposition
of IPv4 routes added via redirects, rediraccept and redirtimeout.
 1.79 18-Oct-2001  itojun bring in new net.inet6.icmp6.nodeinfo description.
 1.78 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.77 16-Sep-2001  wiz Boring whitespace fixes.
 1.76 12-Apr-2001  toshii KERN_RTC_OFFSET sysctl has been readonly.
 1.75 27-Mar-2001  itojun net.inet.ip.maxfragpackets defines the maximum size of ip reass queue
(prevents fragment flood from chewing up mbuf memory space).
derived from KAME net.inet6.ip6.maxfragpackets.
 1.74 08-Feb-2001  itojun branches: 1.74.2;
implement upper limit to icmp6 redirects (experimental, turned off)
negative value to {mtudisc,redirect}_{hi,lo}wat will turn off the limitation.
sync with kame.
 1.73 07-Feb-2001  itojun during ip6/icmp6 inbound packet processing, do not call log() nor printf() in
normal operation (/var can get filled up by flodding bogus packets).
sysctl net.inet6.icmp6.nd6_debug will turn on diagnostic messages.
(#define ND6_DEBUG will turn it on by default)

improve stats in ND6 code.

lots of synchronziation with kame (including comments and cometic ones).
 1.72 10-Jan-2001  hubertf * Document the vendor.* sysctl branch
* in sysctl.3, sort the list of CTL_ prefixes and sync with sysctl.h
 1.71 21-Dec-2000  itojun document net.inet6.icmp6.mtudisc_{lo,hi}wat.
 1.70 26-Oct-2000  jdolecek rewrite KERN_MAXPTYS description to match reality
 1.69 09-Sep-2000  jdolecek document kern.maxptys/KERN_MAXPTYS
note that kern.maxvnodes is raise only
 1.68 26-Aug-2000  itojun implement net.inet6.ip6.{anon,low}port{min,max} sysctl variable.
 1.67 26-Aug-2000  itojun document net.inet.ip.lowport{min,max}
 1.66 04-Aug-2000  kml Correct the documentation for SACK; although we have some preliminary
code in the tree, it doesn't do anything, and setting the sack sysctl
won't have any effect.
 1.65 02-Aug-2000  itojun pps rate limitation can be turned off by negative value.
 1.64 28-Jul-2000  itojun nuke net.inet*.ip*.*ratelimit.
 1.63 27-Jul-2000  itojun add net.inet.tcp.rstppslimit
 1.62 10-Jul-2000  itojun document sysctl variable "net.inet.icmp.errppslimit".
 1.61 09-Jul-2000  itojun add desription for net.inet6.icmp6.{errppslimit,nd6_maxnudhint}.
 1.60 03-Jul-2000  enami - One more s/vm/uvm/ substitution.
- Sort SEE ALSO list first by section.
 1.59 27-Jun-2000  mrg <vm/vm_param.h> is now <uvm/uvm_param.h>
 1.58 16-Jun-2000  simonb branches: 1.58.2;
Document KERN_MSGBUF sysctl.
 1.57 13-Jun-2000  simonb Bring a little closer to current reality - includes my recent sysctl
additions and well as a number of other small additions/changes/deletions.
 1.56 23-May-2000  itojun branches: 1.56.2;
correct FILES section. mention IPv6/IPsec headers.
 1.55 23-May-2000  itojun s/udp6.sendmax/udp6.sendspace/
 1.54 22-May-2000  itojun correct table formatting for net.inet.*.
we do not have net.inet6.tcp6.
 1.53 29-Mar-2000  jdolecek kill reference to getvfsbyname(3) - it's no longer present on NetBSD
 1.52 27-Feb-2000  itojun add hw.alignbytes sysctl mib. this gives you the value of ALIGNBYTES
at the kernel compilation time (ALIGNBYTES that the kernel uses).
 1.51 26-Feb-2000  itojun remove net.inet6.ip6.nd6_proxyall sysctl.
support "ndp -s <ip6> <mac> proxy" for proxy NDP.
 1.50 15-Feb-2000  thorpej Note net.inet.icmp.errratelimit and net.inet.tcp.rstratelimit.
 1.49 06-Feb-2000  fair Document KERN_LOGSIGEXIT.
sort sysctl variable list in sysctl.8
 1.48 23-Jan-2000  ad Change how the purpose of net.inet.tcp.log_refused is expressed so that it's
consistant with its neighbours.
 1.47 19-Jan-2000  itojun warning about net.inet6.ip6.forwarding.
 1.46 06-Jan-2000  itojun make IPV6_BINDV6ONLY setsockopt available. it controls behavior of
AF_INET6 wildcard listening socket. heavily documented in ip6(4).
net.inet6.ip6.bindv6only defines default value. default is 1.

"options INET6_BINDV6ONLY" removes any code fragment that supports
IPV6_BINDV6ONLY == 0 case (not defopt'ed as use of this is rare).
 1.45 06-Jan-2000  itojun wording fix in net.inet6.icmp6.errratelim.
 1.44 06-Jan-2000  itojun add missing variables under net.inet6.ip6.
 1.43 02-Jan-2000  itojun add net.inet6.icmp6.nodeinfo sysctl.
this allows you to disable/enable ICMPv6 node information query/reply
processing (which tells remote end the gethostname(3) setting, interface
addresses on the node, and some other things - documented in
draft-ietf-ipngwg-icmp-name-lookup* or something alike).

to test it, try ping6 -w ::1 with nodeinfo=0 and nodeinfo=1.
(sync with kame change)
 1.42 02-Jan-2000  itojun typo fix
 1.41 01-Jan-2000  itojun document PF_INET6 items (net.inet6.*).
 1.40 14-Oct-1999  jdolecek document ddb.fromconsole & DBCTL_FROMCONSOLE, description taken from options(4)
 1.39 10-Oct-1999  hwr Mention ipsec(4), as there are the ipsec mib variables documented.
 1.38 28-Sep-1999  bouyer Document CTL_PROC, the core filename format it core(5), and xref sysctl(8),
sysctl(3), core(5) in various place.
Document 'options DEFCORENAME' inj options(4) and $defcorename in rc.conf(5).
 1.37 27-Sep-1999  kleink 1003.1c: add {LOGIN_NAME_MAX}.
 1.36 24-Jun-1999  kleink branches: 1.36.2;
Add compile-time and run-time feature test knobs for the 1003.1 Mapped Files,
Process Memory Locking, Range Memory Locking and Memory Protection options.
 1.35 23-May-1999  ad Add new sysctl (net.inet.tcp.log_refused) that when set, causes refused TCP
connections to be logged.
 1.34 09-Mar-1999  erh branches: 1.34.2;
Add missing .El lines.
 1.33 06-Oct-1998  matt Add a sysctl for newreno (default to off).
 1.32 10-Sep-1998  mouse Create tcp.keepidle, tcp.keepintvl, tcp.keepcnt, tcp.slowhz sysctls.
 1.31 03-Aug-1998  kleink Add support to query the
* availability of POSIX Synchronized I/O (kern.synchronized_io),
* maximum number of iovec structures to be used in readv(2) etc. (kern.iov_max)
via sysctl().
 1.30 28-Jun-1998  nathanw Document shortcorename support and control.
 1.29 24-May-1998  kleink Permit checking the availability of the POSIX File Synchronization Option
(a/k/a fsync(2)), System V style message queues, semaphores and shared memory
at runtime by adding a sysctl variable for each.
 1.28 02-May-1998  thorpej Document tcp.cwm_burstsize and tcp.ack_on_push.
 1.27 30-Apr-1998  thorpej Document net.inet.ip.mtudisc and net.inet.ip.mtudisctimeout.
 1.26 30-Apr-1998  thorpej Rework some of the documentation pertaining to tcp.init_win and
tcp.mss_ifmtu, in an attempt to make it a little more clear. Also,
document tcp.mssdflt, tcp.sack, tcp.win_scale, tcp.timestamps,
tcp.compat_42, tcp.cwm, and tcp.cwm_burstsize.
 1.25 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.24 13-Apr-1998  kml Fix to ensure that the correct MSS is advertised for loopback
TCP connections by using the MTU of the interface. Also added
a knob, mss_ifmtu, to force all connections to use the MTU of
the interface to calculate the advertised MSS.
 1.23 05-Feb-1998  perry add LIBRARY section to man page
 1.22 05-Feb-1998  perry remove illegal quotes from .Dd directives
 1.21 03-Feb-1998  perry .Bx'ize
 1.20 02-Feb-1998  perry merge/update to lite-2
 1.19 05-Jan-1998  lukem document net.inet.ip.anonport{min,max}
 1.18 11-Dec-1997  thorpej Document net.inet.tcp.init_win.
 1.17 17-Oct-1997  thorpej Document net.inet.ip.allowsrcrt and net.inet.ip.subnetsarelocal.
 1.16 19-Sep-1997  leo Commit userland part of pr-1891.
 1.15 28-Jul-1997  thorpej Document new UDP and TCP tunables.
 1.14 06-Jun-1997  veego Update the manpage for HW_MACHINE_ARCH.
 1.13 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.12 09-Jan-1997  thorpej Document CTL_DDB MIB nodes.
 1.11 17-Jul-1996  explorer document AUTONICETIME and AUTONICEVAL sysctls
 1.10 13-Apr-1996  thorpej Document that "<sys/sysctl.h>" isn't enough ... suggest including
<sys/param.h>, too. Suggested my Kevin M. Lahey <kml@nas.nasa.gov>
in PR #1999.
 1.9 16-Jan-1996  thorpej Add a net.inet.ip.directed-broadcast sysctl as suggested by
Darren Reed <darrenr@vitruvius.arbld.unimelb.edu.au> in PR #1227.
This change is slightly different than the one submitted by Darren in
that the DIRECTED_BROADCAST compile-time option will behave like it used
to so that existing configurations utilizing it won't have to change.
 1.8 15-Jan-1996  thorpej Add net.inet.ip.forwsrcrt: if zero, the system will not forward
source-routed packets. Note this value is protected by kernel security
level; it can only be changed if securelevel < 1.
 1.7 30-Sep-1995  thorpej Document new RFC1323 sysctl variable.
 1.6 04-Aug-1995  thorpej Add and document a `kern.rawpartition' sysctl.
 1.5 25-Feb-1995  cgd clean up Id's on files previously imported...
 1.4 25-Jan-1995  cgd document sysctl variable kern.maxpartitions
 1.3 24-Jan-1995  cgd note KERN_DOMAINNAME, the addition of tickadj to KERN_CLOCKINFO.
 1.2 15-Dec-1994  jtc Fixed cross reference: sysctl(1) -> sysctl(8).
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 02-Feb-1998  perry import lite-2
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.34.2.1 30-May-2001  he Pull up revision 1.75 (via patch, requested by he):
Introduce net.inet.ip.maxfragpackets, which controls the maximum
number of IPv4 fragment reassembly queue entries. Defends against
certain DoS attacks. Fixes SA#2001-006.
 1.36.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.56.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.58.2.7 24-Apr-2001  he Pull up revision 1.75 (requested by itojun):
Introduce net.inet.ip.maxfragpackets, which controls the maximum
number of IPv4 fragment reassembly queue entries. Defends against
certain DoS attacks.
 1.58.2.6 26-Feb-2001  he Um, undo last commit; done in error.
 1.58.2.5 26-Feb-2001  he Pull up revision 1.72 (via patch, requested by hubertf):
Document the vendor.* sysctl branch, and note that we currently
have no registry for these sysctl values. Sort list of CTL_
prefixes, and sync with sysctl.h.
 1.58.2.4 27-Aug-2000  itojun pullup (approved by releng-1-5)

> implement net.inet6.ip6.{anon,low}port{min,max} sysctl variable.

> cvs rdiff -r1.67 -r1.68 basesrc/lib/libc/gen/sysctl.3
> cvs rdiff -r1.53 -r1.54 basesrc/sbin/sysctl/sysctl.8
> cvs rdiff -r1.18 -r1.19 syssrc/sys/netinet6/in6.h
> cvs rdiff -r1.29 -r1.30 syssrc/sys/netinet6/in6_pcb.c
> cvs rdiff -r1.3 -r1.4 syssrc/sys/netinet6/in6_src.c
> cvs rdiff -r1.25 -r1.26 syssrc/sys/netinet6/ip6_input.c
> cvs rdiff -r1.14 -r1.15 syssrc/sys/netinet6/ip6_var.h
 1.58.2.3 27-Aug-2000  itojun pullup (approved by releng-1-5)
> document net.inet.ip.lowport{min,max}
> cvs rdiff -r1.66 -r1.67 basesrc/lib/libc/gen/sysctl.3
> cvs rdiff -r1.52 -r1.53 basesrc/sbin/sysctl/sysctl.8
 1.58.2.2 16-Aug-2000  itojun pullup (approved by releng-1-5)

document *ppslimit.

sbin/sysctl/sysctl.8 1.48 -> 1.52
lib/libc/gen/sysctl.3 1.60 -> 1.63, 1.64 -> 1.65
 1.58.2.1 04-Aug-2000  kml Pullup of rev 1.66 approved by jhawk:
Correct the documentation for SACK; although we have some preliminary
code in the tree, it doesn't do anything, and setting the sack sysctl
won't have any effect.
 1.74.2.14 08-Jan-2003  thorpej Sync with HEAD.
 1.74.2.13 29-Dec-2002  thorpej Sync with HEAD.
 1.74.2.12 19-Dec-2002  thorpej Sync with HEAD.
 1.74.2.11 11-Dec-2002  thorpej Sync with HEAD.
 1.74.2.10 11-Nov-2002  nathanw Catch up to -current
 1.74.2.9 18-Oct-2002  nathanw Catch up to -current.
 1.74.2.8 27-Aug-2002  nathanw Catch up to -current.
 1.74.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.74.2.6 21-Jun-2002  nathanw Catch up to -current.
 1.74.2.5 22-Mar-2002  nathanw Catch up to -current.
 1.74.2.4 08-Mar-2002  nathanw Catch up to -current.
 1.74.2.3 28-Jan-2002  nathanw Catch up to -current.
 1.74.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.74.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.93.2.1 15-Jun-2002  lukem Pull up revision 1.95 (requested by itojun in ticket #266):
set IPv4 parameter to modern value.
- ICMPv4 redirect entry timeout = 600 sec (previous: never timeout)
 1.135.2.1 12-Nov-2004  jmc branches: 1.135.2.1.2;
Pullup rev 1.140 (requested by daniel in ticket #926)

Add vm.bufcache, vm.bufmem, vm.bufmem_lowater, m.bufmem_hiwater
 1.135.2.1.2.1 18-Jun-2005  riz Pull up revision 1.142 (requested by peter in ticket #1998):
RTC_OFFSET is writable; sync with sysctl.8
 1.142.2.7 06-Dec-2005  riz Pull up following revision(s) (requested by elad in ticket #1016):
lib/libc/gen/sysctl.3: revision 1.158
Change the entry from "foobar" to "not applicable" in the "Changeable"
field of kern.veriexec.count.. no idea how that went unnoticed. :)
 1.142.2.6 02-Jul-2005  tron Pull up revision 1.152 (requested by elad in ticket #487):
- Use more calls to veriexec_report() where possible.
- Change #ifdef VERIFIED_EXEC_VERBOSE to another verbose level, 2. Add
sysctl(3) bits.
- Simplify access type conflict handling during load. This depends on
the values of access type defines to be ordered from least to most
'strict'.
 1.142.2.5 02-Jul-2005  tron Pull up revision 1.151 (requested by elad in ticket #487):
New sentence, new line.
 1.142.2.4 02-Jul-2005  tron Pull up revision 1.150 (requested by elad in ticket #487):
More veriexec changes:
- Better organize strict level. Now we have 4 levels:
- Level 0, learning mode: Warnings only about anything that might've
resulted in 'access denied' or similar in a higher strict level.
- Level 1, IDS mode:
- Deny access on fingerprint mismatch.
- Deny modification of veriexec tables.
- Level 2, IPS mode:
- All implications of strict level 1.
- Deny write access to monitored files.
- Prevent removal of monitored files.
- Enforce access type - 'direct', 'indirect', or 'file'.
- Level 3, lockdown mode:
- All implications of strict level 2.
- Prevent creation of new files.
- Deny access to non-monitored files.
- Update sysctl(3) man-page with above. (date bumped too :)
- Remove FINGERPRINT_INDIRECT from possible fp_status values; it's no
longer needed.
- Simplify veriexec_removechk() in light of new strict level policies.
- Eliminate use of 'securelevel'; veriexec now behaves according to
its strict level only.
 1.142.2.3 10-Jun-2005  tron Pull up revision 1.149 (requested by elad in ticket #389):
New sentence, new line. <> -> Aq. Bump date for previous.
 1.142.2.2 10-Jun-2005  tron Pull up revision 1.148 (requested by elad in ticket #389):
Add man-page bits about the 'count' node.
 1.142.2.1 10-Jun-2005  tron Pull up revision 1.147 (requested by elad in ticket #389):
Some changes in veriexec.
New features:
- Add a veriexec_report() routine to make most reporting consistent and
remove some common code.
- Add 'strict' mode that controls how veriexec behaves.
- Add sysctl knobs:
o kern.veriexec.verbose controls verbosity levels. Value: 0, 1.
o kern.veriexec.strict controls strict level. Values: 0, 1, 2. See
documentation in sysctl(3) for details.
o kern.veriexec.algorithms returns a string with a space separated
list of supported hashing algorithms in veriexec.
- Updated documentation in man pages for sysctl(3) and sysctl(8).
Bug fixes:
- veriexec_removechk(): Code cleanup + handle FINGERPRINT_NOTEVAL
correctly.
- exec_script(): Don't pass 0 as flag when executing a script; use the
defined VERIEXEC_INDIRECT - which is 1. Makes indirect execution
enforcement work.
- Fix some printing formats and types..
 1.177.2.3 08-Sep-2006  rpaulo Pull up following revision(s) (requested by liamjfoy in ticket #127):
lib/libc/gen/sysctl.3: revision 1.181
sbin/sysctl/sysctl.8: revision 1.152
add net.inet.ip.maxflows. Bump date.
document net.inet.ip.maxflows. dump date.
 1.177.2.2 06-Sep-2006  rpaulo Pull up following revision(s) (requested by liamjfoy in ticket #119):
lib/libc/gen/sysctl.3: revision 1.179
Update for carp(4). Bump date.
from openbsd
 1.177.2.1 14-Aug-2006  tron Pull up following revision(s) (requested by elad in ticket #15):
sys/miscfs/specfs/spec_vnops.c: revision 1.88
share/man/man9/fileassoc.9: revision 1.7
sys/kern/kern_verifiedexec.c: revision 1.66
sys/sys/verified_exec.h: revision 1.39
sys/sys/fileassoc.h: revision 1.3
lib/libc/gen/sysctl.3: revision 1.178
share/man/man9/veriexec.9: revision 1.4
sys/kern/kern_fileassoc.c: revision 1.6
Pretending to be Elad's keyboard:
fileassoc.diff adds a fileassoc_table_run() routine that allows you to
pass a callback to be called with every entry on a given mount.
veriexec.diff adds some raw device access policies: if raw disk is
opened at strict level 1, all fingerprints on this disk will be
invalidated as a safety measure. level 2 will not allow opening disk
for raw writing if we monitor it, and prevent raw writes to memory.
level 3 will not allow opening any disk for raw writing.
both update all relevant documentation.
veriexec concept is okay blymn@.
 1.191.6.1 18-May-2009  bouyer Apply patch, requested by snj in ticket #1318:
lib/libc/gen/sysctl.3: patch
document PROC_PID_LIMIT_SBSIZE. Addresses PR 36463.
 1.191.2.1 18-May-2009  bouyer Apply patch, requested by snj in ticket #1318:
lib/libc/gen/sysctl.3: patch
document PROC_PID_LIMIT_SBSIZE. Addresses PR 36463.
 1.193.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.194.6.2 04-Jan-2009  christos merge with head.
 1.194.6.1 17-Sep-2008  christos file sysctl.3 was added on branch christos-time_t on 2009-01-04 17:02:19 +0000
 1.194.4.1 12-Nov-2008  snj Pull up following revision(s) (requested by reed in ticket #46):
sbin/sysctl/sysctl.8: revision 1.159
lib/libc/gen/sysctl.3: revision 1.195
Reference secmodel_securelevel(9) manual page.
 1.200.22.1 10-Aug-2014  tls Rebase.
 1.200.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.203.6.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.203.6.1 10-Jun-2019  christos Sync with HEAD
 1.203.4.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.39 27-Sep-2025  christos We don't need descriptions for install media.
 1.38 30-Mar-2021  rillig branches: 1.38.10;
libc/gen: fix hack for previously unsupported lint initializers

Supported since init.c 1.182 from 2021-03-30.
 1.37 16-May-2018  joerg Avoid complicated arithmetic involving NULL.
 1.36 10-Jan-2017  christos branches: 1.36.12;
simplify cast.
 1.35 05-Feb-2015  christos branches: 1.35.2;
add a couple of casts.
 1.34 16-May-2014  martin Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
 1.33 16-May-2014  martin When creating the descriptions for the "user" node, advance the output
pointer properly.
 1.32 20-Mar-2012  matt branches: 1.32.2; 1.32.8;
Use C89 definitions.
Remove use of __P
 1.31 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.30 27-Aug-2008  christos branches: 1.30.2; 1.30.6;
setup _POSIX2_C_BIND per SUSv3, from Andy Shevchenko
 1.29 24-Feb-2006  drochner branches: 1.29.20;
complete constification of the sysctl() user side
 1.28 29-Nov-2005  christos WARNS=4
 1.27 07-Sep-2004  jrf Replaced strncpy with strlcpy. Thanks to Peter Postma who
pointed them our in PR #25762. Approved by christos@NetBSD.org.
 1.26 25-Apr-2004  atatat Remove dynamic sysctl node version 0 from the tree. It seemed okay at
first, but quickly showed its shortcomings. The version 1 node we're
now using should be good for a while.
 1.25 11-Apr-2004  he Avoid using preprocessing conditionals in a macro argument list at least
as long as all ports have not yet been converted to using gcc 3.3.3.

Build bug discovered when building for vax.
 1.24 08-Apr-2004  atatat Descriptions for user.* sysctl nodes. Mostly copied from sysctl(3).
 1.23 26-Mar-2004  he branches: 1.23.2;
Introduce sysc_init_field() and use it to make the code a little less ugly.
Also, fix another gcc2-unfriendly initialization.
 1.22 26-Mar-2004  he Modify this so that it actually compiles with gcc2.
 1.21 25-Mar-2004  atatat Unwind the nested designators for fields within structs within structs
(or unions). This should really be put back once we're all using gcc3
for everything, since that makes it look a *lot* cleaner.
 1.20 24-Mar-2004  atatat Description framework for user-level sysctl nodes. Still haven't
written the descriptions.
 1.19 24-Mar-2004  atatat New node version and layout. This should take care of the netbsd32
emulation problem, formalizes the versioning (should it ever be needed
again), and provides a slot for descriptions.
 1.18 24-Mar-2004  atatat The new sysctl query interface returns the same information as the old
one, but you must pass in an empty node that indicates the version
you're using.
 1.17 24-Mar-2004  atatat Remove my private hack for watching how sysctl works. That's not
supposed to be there.
 1.16 24-Mar-2004  atatat Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.15 04-Dec-2003  atatat oops
 1.14 04-Dec-2003  atatat Adapt userland sysctl goop to new world order, permitting dynamic
discovery.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 19-Dec-2002  kleink Add a sysconf(3) knob for {ATEXIT_MAX}.
 1.11 22-Jan-2000  mycroft branches: 1.11.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 18-Nov-1998  kleink Now that it's delinted, make it compile on LP64 platforms again. (Using a
size_t for namelen isn't strictly appropriate/necessary anyhow.)
 1.7 13-Nov-1998  christos delint
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Include "extern.h" to pick up prototype for sysctl.
Fix RCSID's
 1.4 13-May-1995  jtc branches: 1.4.4;
#include appropriate header files to bring prototypes into scope
 1.3 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.2 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.11.6.1 29-Dec-2002  thorpej Sync with HEAD.
 1.23.2.3 28-Apr-2004  jmc Pullup rev 1.26 (requested by atatat in ticket #193)

Remove dynamic sysctl node version 0 from the tree.
 1.23.2.2 11-Apr-2004  tron Pull up revision 1.25 (requested by he in ticket #128):
Avoid using preprocessing conditionals in a macro argument list at least
as long as all ports have not yet been converted to using gcc 3.3.3.
Build bug discovered when building for vax.
 1.23.2.1 08-Apr-2004  jdc Pull up revision 1.24 (requested by atatat in ticket #89)

Descriptions for user.* sysctl nodes. Mostly copied from sysctl(3).
 1.29.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.6.2 27-Aug-2008  christos setup _POSIX2_C_BIND per SUSv3, from Andy Shevchenko
 1.30.6.1 27-Aug-2008  christos file sysctl.c was added on branch christos-time_t on 2008-08-27 08:56:50 +0000
 1.30.2.1 17-Apr-2012  yamt sync with head
 1.32.8.1 10-Aug-2014  tls Rebase.
 1.32.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.36.12.1 21-May-2018  pgoyette Sync with HEAD
 1.38.10.1 03-Oct-2025  martin Pull up following revision(s) (requested by christos in ticket #46):

lib/libc/gen/sysctl.c: revision 1.39
distrib/utils/libhack/Makefile.inc: revision 1.40

We don't need descriptions for install media.

Use a trimmed version of sysctl to reduce the size so that atari floppies
work again.
 1.7 13-Dec-2010  pooka Don't __weak_alias non-existent symbols. Apparently the alpha
compiler doesn't like it.
 1.6 13-Dec-2010  pooka Mirror sysctlgetmibinfo RUMP_ACTION change.
 1.5 22-Jul-2009  alc Constify the fourth argument of sysctlbtname(3) (ie. `newp', the pointer to
the new value).

This change sync sysctl(3) and sysctlbtname(3) prototypes.

No objection on <tech-userlevel>
 1.4 29-Apr-2008  martin branches: 1.4.8;
Convert to new 2 clause license
 1.3 12-Jun-2005  lukem branches: 1.3.18;
Add missing __RCSID()
 1.2 08-Apr-2004  atatat Weak aliases for sysctlfoobar() functions.
 1.1 25-Mar-2004  atatat branches: 1.1.2;
Move sysctlbyname(), sysctlnametomib(), and sysctlgetmibinfo() from
sysctl(8) into libc, making the minor number jump. Add prototypes to
sys/sysctl.h, fix sets, modify man pages, etc. That oughta cover it.
 1.1.2.1 08-Apr-2004  jdc Pull up revision 1.2 (requested by atatat in ticket #90)

Weak aliases for sysctlfoobar() functions.
 1.3.18.1 18-May-2008  yamt sync with head.
 1.4.8.2 29-Apr-2008  martin Convert to new 2 clause license
 1.4.8.1 29-Apr-2008  martin file sysctlbyname.c was added on branch christos-time_t on 2008-04-29 06:53:02 +0000
 1.16 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.15 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.14 27-Aug-2019  kamil Enhance the support of LLVM sanitizers

Define _REENTRANT for MKSANITIZER build. This is needed for at least stdio
code. This caused new build issued with duplicated symbols in few places
and rump kernel code picking different code paths borrowed from libc.
Handle all this in one go.

Add bsd.sanitizer.mk to share common code used by programs and libraries.

Switch from realall to beforeinstall target in .syms files. This is more
reliable in MKSANITIZER.
 1.13 30-Sep-2016  dholland branches: 1.13.14; 1.13.16;
Be more careful about preserving errno. Might conceivably be related
to PR 51432.
 1.12 30-Sep-2016  dholland Be consistent about returning -1 on error. Don't return random errnos
instead.
 1.11 16-May-2014  martin branches: 1.11.6;
Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
 1.10 13-Mar-2012  christos branches: 1.10.2; 1.10.8;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.9 13-Dec-2010  pooka branches: 1.9.6;
Don't __weak_alias non-existent symbols. Apparently the alpha
compiler doesn't like it.
 1.8 05-Nov-2010  pooka make sysctl(8) work as a rump client
 1.7 12-Feb-2009  lukem sign-compare fixes
 1.6 29-Apr-2008  martin branches: 1.6.8; 1.6.10;
Convert to new 2 clause license
 1.5 12-Jun-2005  lukem branches: 1.5.18;
Add missing __RCSID()
 1.4 09-Feb-2005  kleink Use strtoimax(), incidentally removing the only libc-internal use of
strtoq().
 1.3 08-Apr-2004  atatat Weak aliases for sysctlfoobar() functions.
 1.2 26-Mar-2004  he branches: 1.2.2;
Introduce sysc_init_field() and use it to make the code a little less ugly.
Also, fix another gcc2-unfriendly initialization.
 1.1 25-Mar-2004  atatat Move sysctlbyname(), sysctlnametomib(), and sysctlgetmibinfo() from
sysctl(8) into libc, making the minor number jump. Add prototypes to
sys/sysctl.h, fix sets, modify man pages, etc. That oughta cover it.
 1.2.2.1 08-Apr-2004  jdc Pull up revision 1.3 (requested by atatat in ticket #90)

Weak aliases for sysctlfoobar() functions.
 1.5.18.1 18-May-2008  yamt sync with head.
 1.6.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.6.8.2 29-Apr-2008  martin Convert to new 2 clause license
 1.6.8.1 29-Apr-2008  martin file sysctlgetmibinfo.c was added on branch christos-time_t on 2008-04-29 06:53:02 +0000
 1.9.6.1 17-Apr-2012  yamt sync with head
 1.10.8.1 10-Aug-2014  tls Rebase.
 1.10.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.6.1 04-Nov-2016  pgoyette Sync with HEAD
 1.13.16.1 01-Sep-2019  martin Pull up following revision(s) (requested by kamil in ticket #126):

external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile: revision 1.3
external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile: revision 1.3
external/gpl2/lvm2/lvm2tools.mk: revision 1.5
common/lib/libc/gmon/mcount.c: revision 1.14
Makefile: revision 1.331
share/mk/Makefile: revision 1.51
external/bsd/fetch/lib/Makefile: revision 1.12
external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile: revision 1.3
tests/lib/libc/net/Makefile: revision 1.12
external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile: revision 1.3
external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile: revision 1.3
distrib/sets/lists/base/mi: revision 1.1213
share/mk/bsd.lib.mk: revision 1.380
external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile: revision 1.3
external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile: revision 1.3
share/mk/bsd.sanitizer.mk: revision 1.1
share/mk/bsd.prog.mk: revision 1.323
external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile: revision 1.3
external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile: revision 1.3
lib/libc/gen/sysctlgetmibinfo.c: revision 1.14

Enhance the support of LLVM sanitizers

Define _REENTRANT for MKSANITIZER build. This is needed for at least stdio
code. This caused new build issued with duplicated symbols in few places
and rump kernel code picking different code paths borrowed from libc.

Handle all this in one go.

Add bsd.sanitizer.mk to share common code used by programs and libraries.

Switch from realall to beforeinstall target in .syms files. This is more
reliable in MKSANITIZER.
 1.13.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.6 13-Dec-2010  pooka branches: 1.6.6;
Don't __weak_alias non-existent symbols. Apparently the alpha
compiler doesn't like it.
 1.5 13-Dec-2010  pooka last of the RUMP_ACTION syscall swappers
 1.4 29-Apr-2008  martin branches: 1.4.8;
Convert to new 2 clause license
 1.3 12-Jun-2005  lukem branches: 1.3.18;
Add missing __RCSID()
 1.2 08-Apr-2004  atatat Weak aliases for sysctlfoobar() functions.
 1.1 25-Mar-2004  atatat branches: 1.1.2;
Move sysctlbyname(), sysctlnametomib(), and sysctlgetmibinfo() from
sysctl(8) into libc, making the minor number jump. Add prototypes to
sys/sysctl.h, fix sets, modify man pages, etc. That oughta cover it.
 1.1.2.1 08-Apr-2004  jdc Pull up revision 1.2 (requested by atatat in ticket #90)

Weak aliases for sysctlfoobar() functions.
 1.3.18.1 18-May-2008  yamt sync with head.
 1.4.8.2 29-Apr-2008  martin Convert to new 2 clause license
 1.4.8.1 29-Apr-2008  martin file sysctlnametomib.c was added on branch christos-time_t on 2008-04-29 06:53:02 +0000
 1.6.6.1 17-Apr-2012  yamt sync with head
 1.35 11-Jul-2024  riastradh syslog(3): Nix trailing whitespace in man page.

No functional change intended.
 1.34 08-Jul-2024  christos PR/58391: Noriyuki Soda: re-adding syslog_ss() to syslog.h and syslog.3
 1.33 03-Jul-2017  wiz branches: 1.33.16; 1.33.18;
Remove workaround for ancient HTML generation code.
 1.32 23-Mar-2017  wiz Remove trailing whitespace.
 1.31 22-Mar-2017  roy openlog(3): add LOG_PTRIM and LOG_NLOG log options.

syslog(3) is the one stop method of logging system events and diagnostics.
When debugging a daemon in the foreground on a terminal, each line is
prefixed with tag[pid]: which is very repetative and can take up valuable
screen estate.
LOG_PTRIM solves this by removing this prefix from stderr output.

There is also the case where the debugging could involve a dry-run and
syslog(3) calls would pollute the system log with incorrect data.
LOG_NLOG solves this by not writing the the system log, but allowing
LOG_PERROR to operate as before.

Initially discussed here:
https://mail-index.netbsd.org/tech-userlevel/2016/10/06/msg010330.html
 1.30 21-Feb-2017  abhinav Fix spelling of "parenthesis".
 1.29 25-Jul-2011  njoly branches: 1.29.24; 1.29.28;
Adjust xref varargs(3) -> stdarg(3)
 1.28 13-May-2010  jruoho Move the structure inside the body text. Some additional markup improvements.
 1.27 05-Apr-2010  joerg \\ -> \e
 1.26 01-Nov-2008  wiz branches: 1.26.2;
New sentence, new line. Mark up NULL with Dv.
 1.25 31-Oct-2008  christos Import syslogd SoC project by Martin Schuette:
- new syslog protocol api syslogp(3) that supports structured data
and draft-rfc timestamps
- reliable tcp connections with queueing
- encrypted connections
 1.24 22-Nov-2006  christos Don't expose _ss functions for 4.0. Requested by core.
 1.23 28-Oct-2006  wiz Remove trailing whitespace. Use .Bl -enum for an enumeration.
 1.22 27-Oct-2006  christos add async-signal-safe versions: syslog_ss and vsyslog_ss
multithread-safe syslog_r and vsyslog_r are not async-signal-safe.
 1.21 26-Oct-2006  wiz Various fixes.
 1.20 25-Oct-2006  christos add _r functions for syslog from OpenBSD
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 06-May-2003  wiz New sentence, new line.
 1.17 02-May-2003  gmcgarry Clarify output. From PR#14290.
 1.16 01-May-2003  wiz Grammar and mdoc fixes from jmc@openbsd.
 1.15 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.14 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.13 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.10 14-Mar-2001  lukem reference <stdarg.h> not <varargs.h>, and separate out the synopsis
for vsyslog(3) from the rest after <stdarg.h>, as per printf(3)/vsprintf(3)
 1.9 22-Mar-1999  garbled branches: 1.9.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.8 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.5 12-Aug-1995  jtc fix typo
 1.4 11-Aug-1995  jtc Updated for LOG_FTP (PR #1312).

Edited the examples section so that they are all separated by a single
blank line, since they're unrelated. SunOS' syslog(3) has a sentance
or two describing each line. We'll either have to come up with our
own text or ignore it. I'm ignoring it for now.
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.12.5 18-Oct-2002  nathanw Catch up to -current.
 1.9.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.9.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.9.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.26.2.2 01-Nov-2008  wiz New sentence, new line. Mark up NULL with Dv.
 1.26.2.1 01-Nov-2008  wiz file syslog.3 was added on branch christos-time_t on 2008-11-01 13:54:02 +0000
 1.29.28.1 21-Apr-2017  bouyer Sync with HEAD
 1.29.24.2 26-Apr-2017  pgoyette Sync with HEAD
 1.29.24.1 20-Mar-2017  pgoyette Sync with HEAD
 1.33.18.1 02-Aug-2025  perseant Sync with HEAD
 1.33.16.1 08-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #930):

lib/libc/include/extern.h: revision 1.30
distrib/sets/lists/base/shl.mi: revision 1.987 (patch)
external/bsd/blocklist/bin/support.c: revision 1.2
external/bsd/blocklist/bin/blocklistd.c: revision 1.5
external/bsd/blocklist/bin/blocklistd.8: revision 1.3
sys/sys/syslog.h: revision 1.42
external/bsd/blocklist/bin/support.h: revision 1.2
external/bsd/blocklist/include/blocklist.h: revision 1.3
crypto/external/bsd/openssh/dist/pfilter.c: revision 1.9
external/bsd/blocklist/lib/shlib_version: revision 1.2
lib/libc/gen/syslog_ss.c: revision 1.4
lib/libc/gen/Makefile.inc: revision 1.218
external/bsd/blocklist/lib/bl.c: revision 1.3
external/bsd/blocklist/README: revision 1.3
external/bsd/blocklist/include/bl.h: revision 1.2
distrib/sets/lists/debug/shl.mi: revision 1.347 (patch)
distrib/sets/lists/comp/mi: revision 1.2462
lib/libc/gen/syslog.3: revision 1.34
lib/libc/gen/syslog.3: revision 1.35
external/bsd/blocklist/libexec/blocklistd-helper: revision 1.8
external/bsd/blocklist/lib/libblocklist.3: revision 1.4
external/bsd/blocklist/lib/libblocklist.3: revision 1.5
external/bsd/blocklist/lib/libblocklist.3: revision 1.6
external/bsd/blocklist/lib/blocklist.c: revision 1.3

Spelling fixes

PR/58391: Noriyuki Soda: re-adding syslog_ss() to syslog.h and syslog.3

syslog(3): Nix trailing whitespace in man page.
No functional change intended.

reference sockpath instead of sockspath

Add blocklist_open2() that can pass a custom logger or NULL for no logging.
Switch internally to use syslog_r. Add compatibility for systems that don't
have syslog_r.

Switch blocklist to use syslog_ss since we are being called from a
signal handler.

bump libblocklist
remove trailing space

Silence a bogus warning when starting up:
NetBSD pf:
No ALTQ support in kernel
ALTQ related functions disabled
FreeBSD pf:
Anchor 'blacklistd' not found.
The anchor is indeed found and working correctly. This patch just
discards stderr's output, like in other places.
(jlduran@github)

update markup (Ed Maste)
 1.58 12-Jan-2017  christos undo SSP damage from -Wsystem-headers
 1.57 12-Jan-2017  christos A little more restructuring so that we don't need mutex stuff in syslog_ss.
 1.56 12-Jan-2017  christos Split syslog.c to:

- syslog_ss.c *_ss api functions (don't use stdio, time)
- syslog.c: *syslog* non _ss api functions (use stdio, time)
- xsyslog.c> common guts.

The motivation for this is not to drag in stdio/locale/floating point/time
for every binary, since syslog_ss() is used in __stack_check_fail() for SSP.
 1.55 26-Oct-2015  roy branches: 1.55.2;
Use strerror(3) instead of strerror_r(3) and an arbitary buffer size which could be too small.
 1.54 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.53 11-Oct-2012  christos take care of the signal safe syslog calls which are not exposed.
 1.52 10-Oct-2012  christos add more locking (when we read and write fields)
 1.51 10-Oct-2012  christos PR/47055: David Holland: Remove static hostname and store the hostname in
syslog_data. Initialize hostname before it is used. While here, add a version
to syslog_data.
 1.50 13-Mar-2012  christos branches: 1.50.2;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.49 15-Oct-2011  christos branches: 1.49.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.48 13-May-2010  christos PR/43300: Takahiro Kambe: LOG_PID and LOG_CONSOLE printed syslogp messages
to the console/stderr since the syslogp conversion.
 1.47 11-Jan-2009  christos merge christos-time_t
 1.46 10-Dec-2008  christos Martin says:

I had added a getaddrinfo()/getnameinfo() lookup to obtain an FQDN even
if gethostname() would return only the local part of the hostname.
I did not really consider that many systems do not have FQDNs and more
importantly that the calls introduce a high latency (timeout) when DNS
is not available.

On the other hand I do not (or no longer) think that using a non-FQDN is
such a big problem here. Those users/admins that do collect logs from
different hosts and want an FQDN should notice the problem quickly
enough and can easily fix it by correctly setting their hostname.
 1.45 03-Nov-2008  cube branches: 1.45.2;
Invert the test for the return value of getaddrinfo(), because that's what
is actually meant there, to do nothing when the name doesn't resolve to an
address.
 1.44 31-Oct-2008  christos fix compile error.
 1.43 31-Oct-2008  christos Import syslogd SoC project by Martin Schuette:
- new syslog protocol api syslogp(3) that supports structured data
and draft-rfc timestamps
- reliable tcp connections with queueing
- encrypted connections
 1.42 22-Oct-2008  dogcow appease lint: warning: assignment in conditional context [159]
 1.41 21-Oct-2008  christos - vsyslog_r only closes if it opened
- maintain opened properly
- preserve the tag (from OpenBSD)
 1.40 12-Jun-2008  christos PR/38539: Ed Ravin: libc/gen/syslog.c always logs to console if LOG_CONS is set.
While here:
1. Don't loop forever, handle closing and opening the log after each send.
2. Release the lock later, after we've possibly printed to the console.
 1.39 22-Nov-2006  christos branches: 1.39.16; 1.39.18;
Don't expose _ss functions for 4.0. Requested by core.
 1.38 05-Nov-2006  christos weak for syslog_ss
 1.37 03-Nov-2006  christos use FD_CLOEXEC instead of 1.
 1.36 02-Nov-2006  christos - verify that the log file is usable, otherwise re-open it.
- if the file is re-opened, clear the connected flag.
- don't check that the file is opened before connecting, because the
file will be opened then.
 1.35 27-Oct-2006  christos need to negate before masking; from abp.
 1.34 27-Oct-2006  christos add async-signal-safe versions: syslog_ss and vsyslog_ss
multithread-safe syslog_r and vsyslog_r are not async-signal-safe.
 1.33 26-Oct-2006  christos don't use strerror_r in the re-entrant case.
 1.32 25-Oct-2006  christos add _r functions for syslog from OpenBSD
 1.31 29-Nov-2005  christos WARNS=4
 1.30 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.29 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.28 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.27 30-Jul-2001  atatat Build a single retry into syslog() so that if someone restarted
syslogd after we called openlog(), we don't just to lose until we call
openlog() again. Or get restarted. This is good for long running
processes that use syslog(), like sendmail, postfix, named, etc.
 1.26 19-Feb-2001  cgd branches: 1.26.2;
convert from __progname to getprogname()
 1.25 30-Dec-2000  martin Be consistent with argument types vs. prototype; use _BSD_VA_LIST_ as
the argument, instead of va_list. Might not make a difference on most
ports, depending on toolchain/MD typedefs. Does make a difference on sparc64,
where it wouldn't compile otherwise.
 1.24 22-Jan-2000  mycroft branches: 1.24.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.23 03-May-1999  christos Fix unaligned access lint warning.
 1.22 16-Mar-1999  is Use SUN_LEN, not sizeof.
 1.21 16-Mar-1999  is Use a struct sockaddr_un, so that the new _PATH_LOG actually fits into it.
 1.20 04-Feb-1999  kleink Protect syslog descriptor state with a mutex. TODO: cleanup handling for
cancellation points.
 1.19 13-Nov-1998  christos delint
 1.18 13-Sep-1998  kleink Use localtime_r() rather than localtime(); removes a potential source of
surprise for the application.
 1.17 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.16 27-Jul-1998  mycroft Delint (partially).
 1.15 18-Jul-1998  lukem use AF_LOCAL instead of AF_UNIX
 1.14 03-Feb-1998  perry remove obsolete register declarations
 1.13 02-Feb-1998  perry merge/update to lite-2
 1.12 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.11 13-Jul-1997  christos Pacify gcc
Fix RCSID's
 1.10 31-Aug-1995  mycroft branches: 1.10.4;
Clean up a little, and fix a fencepost error.
 1.9 30-Aug-1995  jtc Don't overflow fixed sized buffers. Parts of this patch come from
Perry Metzger, Charles Hannum and Paul Kranenburg.
 1.8 11-Apr-1995  cgd fix operator precedence error (pr 951 from Ted Lemon)
 1.7 04-Mar-1995  cgd fix up some RCS Id's i botched.
 1.6 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.5 24-Nov-1993  jtc branches: 1.5.4;
Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 30-Jul-1993  mycroft Add even more RCS frobs.
 1.2 27-Apr-1993  glass improved error handling from ftp.uu.net:bsd-sources
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  perry import lite-2
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.2 02-May-1995  jtc #include "namespace.h"
 1.5.4.1 26-Apr-1995  jtc don't explicitly declare strerror --- <string.h> already provides a prototype
 1.10.4.2 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.10.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.24.4.1 29-Mar-2002  he Pull up revision 1.27 (requested by atatat):
Add a single retry into syslog(), to cope with a restarted syslogd,
so that log messages don't get lost. Most useful for long-running
programs.
 1.26.2.3 21-Jun-2002  nathanw Catch up to -current.
 1.26.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.26.2.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.39.18.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.39.16.1 17-Jun-2008  yamt sync with head.
 1.45.2.3 04-Jan-2009  christos merge with head.
 1.45.2.2 08-Nov-2008  christos time_t changes
 1.45.2.1 03-Nov-2008  christos file syslog.c was added on branch christos-time_t on 2008-11-08 21:45:38 +0000
 1.49.2.2 30-Oct-2012  yamt sync with head
 1.49.2.1 17-Apr-2012  yamt sync with head
 1.50.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.55.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.3 02-Mar-2020  christos fix print-like attrs
 1.2 12-Jan-2017  christos branches: 1.2.4; 1.2.16;
A little more restructuring so that we don't need mutex stuff in syslog_ss.
 1.1 12-Jan-2017  christos Split syslog.c to:

- syslog_ss.c *_ss api functions (don't use stdio, time)
- syslog.c: *syslog* non _ss api functions (use stdio, time)
- xsyslog.c> common guts.

The motivation for this is not to drag in stdio/locale/floating point/time
for every binary, since syslog_ss() is used in __stack_check_fail() for SSP.
 1.2.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.4.1 12-Jan-2017  pgoyette file syslog_private.h was added on branch pgoyette-localcount on 2017-03-20 06:56:57 +0000
 1.4 08-Jul-2024  christos PR/58391: Noriyuki Soda: re-adding syslog_ss() to syslog.h and syslog.3
 1.3 15-Jan-2017  christos branches: 1.3.4; 1.3.26; 1.3.28;
fix *syslog_ss*
 1.2 12-Jan-2017  christos A little more restructuring so that we don't need mutex stuff in syslog_ss.
 1.1 12-Jan-2017  christos Split syslog.c to:

- syslog_ss.c *_ss api functions (don't use stdio, time)
- syslog.c: *syslog* non _ss api functions (use stdio, time)
- xsyslog.c> common guts.

The motivation for this is not to drag in stdio/locale/floating point/time
for every binary, since syslog_ss() is used in __stack_check_fail() for SSP.
 1.3.28.1 02-Aug-2025  perseant Sync with HEAD
 1.3.26.1 08-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #930):

lib/libc/include/extern.h: revision 1.30
distrib/sets/lists/base/shl.mi: revision 1.987 (patch)
external/bsd/blocklist/bin/support.c: revision 1.2
external/bsd/blocklist/bin/blocklistd.c: revision 1.5
external/bsd/blocklist/bin/blocklistd.8: revision 1.3
sys/sys/syslog.h: revision 1.42
external/bsd/blocklist/bin/support.h: revision 1.2
external/bsd/blocklist/include/blocklist.h: revision 1.3
crypto/external/bsd/openssh/dist/pfilter.c: revision 1.9
external/bsd/blocklist/lib/shlib_version: revision 1.2
lib/libc/gen/syslog_ss.c: revision 1.4
lib/libc/gen/Makefile.inc: revision 1.218
external/bsd/blocklist/lib/bl.c: revision 1.3
external/bsd/blocklist/README: revision 1.3
external/bsd/blocklist/include/bl.h: revision 1.2
distrib/sets/lists/debug/shl.mi: revision 1.347 (patch)
distrib/sets/lists/comp/mi: revision 1.2462
lib/libc/gen/syslog.3: revision 1.34
lib/libc/gen/syslog.3: revision 1.35
external/bsd/blocklist/libexec/blocklistd-helper: revision 1.8
external/bsd/blocklist/lib/libblocklist.3: revision 1.4
external/bsd/blocklist/lib/libblocklist.3: revision 1.5
external/bsd/blocklist/lib/libblocklist.3: revision 1.6
external/bsd/blocklist/lib/blocklist.c: revision 1.3

Spelling fixes

PR/58391: Noriyuki Soda: re-adding syslog_ss() to syslog.h and syslog.3

syslog(3): Nix trailing whitespace in man page.
No functional change intended.

reference sockpath instead of sockspath

Add blocklist_open2() that can pass a custom logger or NULL for no logging.
Switch internally to use syslog_r. Add compatibility for systems that don't
have syslog_r.

Switch blocklist to use syslog_ss since we are being called from a
signal handler.

bump libblocklist
remove trailing space

Silence a bogus warning when starting up:
NetBSD pf:
No ALTQ support in kernel
ALTQ related functions disabled
FreeBSD pf:
Anchor 'blacklistd' not found.
The anchor is indeed found and working correctly. This patch just
discards stderr's output, like in other places.
(jlduran@github)

update markup (Ed Maste)
 1.3.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.3.4.1 15-Jan-2017  pgoyette file syslog_ss.c was added on branch pgoyette-localcount on 2017-03-20 06:56:57 +0000
 1.4 25-Apr-1995  jtc termios code has been moved to new libc/termios directory.
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 25-Jul-1993  glass branches: 1.1.1;
adding man pages for termios support functions
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.4 25-Apr-1995  jtc termios code has been moved to new libc/termios directory.
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 25-Jul-1993  glass branches: 1.1.1;
adding man pages for termios support functions
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.6 25-Apr-1995  jtc termios code has been moved to new libc/termios directory.
 1.5 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 15-Dec-1993  jtc More manpage tweaks.
 1.3 30-Nov-1993  jtc "errno" was not being formatted with the .Va macro.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 25-Jul-1993  glass branches: 1.1.1;
adding man pages for termios support functions
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.5 25-Apr-1995  jtc termios code has been moved to new libc/termios directory.
 1.4 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.3 19-Mar-1994  cgd don't forget section number; from Luke Mewburn <lm@rmit.edu.au>
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 25-Jul-1993  glass branches: 1.1.1;
adding man pages for termios support functions
 1.1.1.1 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.20 06-Mar-2013  yamt remove unnecessary casts
 1.19 04-May-2008  tonnerre branches: 1.19.4; 1.19.8; 1.19.28;
Fix a bug in the implementation of seekdir(). If the first entry in
a block has been unlinked, seekdir() may overshoot by one entry.
Thus, _readdir_unlinked() must not skip deleted entries when being
called from seekdir().
Christos agreed.
 1.18 17-May-2006  christos branches: 1.18.18;
PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.17 24-Jan-2006  christos rename __func to _func_unlocked, and add their prototypes in extern.h
instead of exposing them in dirent.h. More locking consistency fixes.
 1.16 24-Jan-2006  christos PR/32609: Tanaka Akira: seekdir blocks if pthread is linked
Do locking consistently to avoid recursive locks (like the bug reported in
this pr), and to avoid leaking locks on errors.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.13 30-Dec-2001  thorpej Fix -Wshadow warnings (gcc 3.1).
 1.12 22-Jan-2000  mycroft branches: 1.12.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.11 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.10 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.9 28-Feb-1998  enami Just nuke cast to the argument of free() rather than changing it
from (caddr_t) to (void *). Lint doesn't complains about it.
 1.8 27-Feb-1998  perry trivial changes to quiet lint.
 1.7 03-Feb-1998  perry remove obsolete register declarations
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up Id's on files previously imported...
 1.3 27-Jul-1994  jtc branches: 1.3.2; 1.3.4;
Add RCS Id's
 1.2 27-Jul-1994  jtc Return NULL and set errno to ENOTDIR if opening a non-directory (POSIX.1,
Section 5.1.2.4). Rename _seekdir to __seekdir, as former is in the
user's namespace.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.2 02-May-1995  jtc #include "namespace.h"
 1.3.4.1 26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.3.2.2 27-Jul-1994  jtc Add RCS Id's
 1.3.2.1 27-Jul-1994  jtc file telldir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:54 +0000
 1.4.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.12.6.1 28-Jan-2002  nathanw Catch up to -current.
 1.18.18.1 18-May-2008  yamt sync with head.
 1.19.28.1 23-Jun-2013  tls resync from head
 1.19.8.2 04-May-2008  tonnerre Fix a bug in the implementation of seekdir(). If the first entry in
a block has been unlinked, seekdir() may overshoot by one entry.
Thus, _readdir_unlinked() must not skip deleted entries when being
called from seekdir().
Christos agreed.
 1.19.8.1 04-May-2008  tonnerre file telldir.c was added on branch christos-time_t on 2008-05-04 18:53:27 +0000
 1.19.4.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.10 25-Apr-1995  jtc termios code has been moved to new libc/termios directory.
 1.9 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.8 19-Sep-1994  mycroft branches: 1.8.2;
Remove the #define KERNEL, now that we don't need it. Too bad we need FREAD and
FWRITE at all. Sigh.
 1.7 23-May-1994  cgd branches: 1.7.2;
clean up import
 1.6 22-Dec-1993  jtc Add explicit "int" return types to silence gcc -Wall.
 1.5 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.4 30-Jul-1993  mycroft Add even more RCS frobs.
 1.3 20-May-1993  cgd get rid of explicit select.h inclusion, and clean headers more
 1.2 20-May-1993  cgd update to use select.h
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 23-May-1994  cgd update from lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 06-Oct-1994  mycroft Update from trunk.
 1.8.2.1 02-May-1995  jtc #include "namespace.h"
 1.17 28-Apr-2024  rillig time.3: clarify that *tloc is always set if tloc != NULL
 1.16 05-Nov-2011  christos there no errors defined for time.
 1.15 24-Apr-2010  dholland branches: 1.15.6;
Edit previous HISTORY patch for style; note our 64-bit time_t change.
Bump date.
 1.14 03-Apr-2010  jruoho Some interesting additions to the history section. From OpenBSD.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.11 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 22-Mar-1999  garbled branches: 1.9.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.8 09-Mar-1999  erh Add missing .El lines.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.5 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
Other misc. tweaks.
 1.3 05-Oct-1993  jtc Changed SYNOPSIS, to use time(), you are supposed to include <time.h>,
not <sys/types.h>.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.12.3 18-Oct-2002  nathanw Catch up to -current.
 1.9.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.15.6.1 10-Nov-2011  yamt sync with head
 1.12 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.11 11-Jan-2009  christos branches: 1.11.8;
merge christos-time_t
 1.10 07-Aug-2003  agc branches: 1.10.40;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 07-Sep-1998  kleink Explicitly cast -1 to time_t, and some KNF nits.
 1.7 30-Mar-1998  kleink Need <time.h> for time() prototype.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 27-Feb-1995  cgd branches: 1.4.4;
merge with 4.4-Lite, keeping local changes. clean up Ids
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.40.1 08-Nov-2008  christos time_t changes
 1.11.8.1 17-Apr-2012  yamt sync with head
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.12 23-Jun-2002  perry Note that times now uses sysconf(_SC_CLK_TCK) ticks, not CLK_TCK
ticks. Although the two are the same, SuS now says you use the former,
not the latter, to get the information. Also, fill in a little
information on just how awful this crusty wreck is.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Boring whitespace fixes.
 1.9 22-Mar-1999  garbled branches: 1.9.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.8 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.7 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.4 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.3 30-Nov-1993  jtc "errno" was not being formatted with the .Va macro.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.12.5 18-Oct-2002  nathanw Catch up to -current.
 1.9.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.9.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.9.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.15 11-Jan-2009  christos merge christos-time_t
 1.14 13-Sep-2005  christos branches: 1.14.28;
compat core reorg.
 1.13 30-Jun-2002  bjh21 Version times() so that programs compiled before the recent change to make
sysconf(_SC_CLK_TCK) return hz will work.

In detail:
__times13() returns values scaled by hz.
times() returns values scaled by 100.
<sys/times.h> renames times() to __times13().

_SC_CLK_TCK has changed from 3 to 39.
sysconf(3) returns 100.
sysconf(39) returns hz.
CLK_TCK is defined as sysconf(39).
 1.12 23-Jun-2002  perry Since CLK_TCK is now a macro expanding into a function call, cache its
output instead of using it willy nilly.
 1.11 22-Jan-2000  mycroft branches: 1.11.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 30-Mar-1998  kleink Need <time.h> for CLK_TCK definition.
 1.7 03-Feb-1998  perry remove obsolete register declarations
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 27-Feb-1995  cgd branches: 1.4.4;
merge with 4.4-Lite, keeping local changes. clean up Ids
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.11.6.1 01-Aug-2002  nathanw Catch up to -current.
 1.14.28.1 08-Nov-2008  christos time_t changes
 1.9 22-Apr-2025  uwe timespec_get(3): add timespec_getres return type, brush up markup
 1.8 22-Apr-2025  nia Merge the manual pages for timespec_get(3) and timespec_getres(3).
 1.7 21-Apr-2025  nia libc: C23: add timespec_getres(3) function

timespec_getres is to timespec_get as clock_getres is to clock_gettime.

PR standards/58608
PR lib/59140
 1.6 21-Apr-2025  nia libc: C23: Add TIME_MONOTONIC as a base for timespec_get

PR standards/58608
 1.5 02-Jun-2020  kamil branches: 1.5.8;
timespec_get(3) was developed by myself

Remove FreeBSD from the authorship as it was just a pullup of small
documentation changes.
 1.4 13-Aug-2018  wiz Sort SEE ALSO.
 1.3 10-Aug-2018  kamil Merge FreeBSD improvements to the man-page of timespec_get(3)

Keep NetBSD references instead of FreeBSD ones included in the FreeBSD
version.
 1.2 04-Oct-2016  wiz branches: 1.2.2; 1.2.14; 1.2.16;
Fix xref.
 1.1 04-Oct-2016  kamil Add timespec_get(3) in <time.h> and enable unconditionally struct timespec

These changes conforms to the C11 standard
References:
- 7.27.1/3 Components of time (struct timespec)
- 7.27.2.5 The timespec_get function

According to ISO/IEC 9899:201x (draft) <time.h> defines the timespec
structure and declares the timespec_get(3) function with TIME_UTC
definition.

According to a C++17 standard draft <ctime> offers the same interface in
the std:: namespace.

The timespec_get function modifies the timespec object pointed by ts
to hold the current calendar time in the given base. The standard notes
only the TIME_UTC base with implementation defined value, set it to 1
as zero is reserved for error handling. Once operation was successful this
function returns passed base, otherwise exits with zero.

The timespec struct was already part of the POSIX standard in <time.h>.

Enable this interface unconditionally in the header to allow to use it
in a code prior C11 and C++17 as an extension.

Review notes from <christos>
 1.2.16.1 10-Jun-2019  christos Sync with HEAD
 1.2.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.2.2.1 04-Oct-2016  pgoyette file timespec_get.3 was added on branch pgoyette-localcount on 2016-11-04 14:48:52 +0000
 1.5.8.1 02-Aug-2025  perseant Sync with HEAD
 1.3 21-Apr-2025  nia libc: C23: Add TIME_MONOTONIC as a base for timespec_get

PR standards/58608
 1.2 04-Oct-2016  christos branches: 1.2.2; 1.2.28;
return 0 on unsupported bases.
 1.1 04-Oct-2016  kamil Add timespec_get(3) in <time.h> and enable unconditionally struct timespec

These changes conforms to the C11 standard
References:
- 7.27.1/3 Components of time (struct timespec)
- 7.27.2.5 The timespec_get function

According to ISO/IEC 9899:201x (draft) <time.h> defines the timespec
structure and declares the timespec_get(3) function with TIME_UTC
definition.

According to a C++17 standard draft <ctime> offers the same interface in
the std:: namespace.

The timespec_get function modifies the timespec object pointed by ts
to hold the current calendar time in the given base. The standard notes
only the TIME_UTC base with implementation defined value, set it to 1
as zero is reserved for error handling. Once operation was successful this
function returns passed base, otherwise exits with zero.

The timespec struct was already part of the POSIX standard in <time.h>.

Enable this interface unconditionally in the header to allow to use it
in a code prior C11 and C++17 as an extension.

Review notes from <christos>
 1.2.28.1 02-Aug-2025  perseant Sync with HEAD
 1.2.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.2.2.1 04-Oct-2016  pgoyette file timespec_get.c was added on branch pgoyette-localcount on 2016-11-04 14:48:52 +0000
 1.2 22-Apr-2025  nia Merge the manual pages for timespec_get(3) and timespec_getres(3).
 1.1 21-Apr-2025  nia libc: C23: add timespec_getres(3) function

timespec_getres is to timespec_get as clock_getres is to clock_gettime.

PR standards/58608
PR lib/59140
 1.1 21-Apr-2025  nia branches: 1.1.4;
libc: C23: add timespec_getres(3) function

timespec_getres is to timespec_get as clock_getres is to clock_gettime.

PR standards/58608
PR lib/59140
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 21-Apr-2025  perseant file timespec_getres.c was added on branch perseant-exfatfs on 2025-08-02 05:54:37 +0000
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 31-Mar-2001  kleink Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.
 1.10 02-Aug-1998  jeremy branches: 1.10.12;
Removed extraneous DESCRIPTION section header.
 1.9 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 20-Oct-1997  christos Bring timezone back to libc.
 1.6 16-Oct-1997  christos moved to libcompat
 1.5 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.4 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.3 10-Jan-1994  jtc Fix spelling errors.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.19 13-Sep-2005  christos compat core reorg.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.16 31-Mar-2001  kleink Emit a link warning for the old timezone() interface; from Nick Hudson.
 1.15 31-Mar-2001  kleink Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.
 1.14 23-Jan-2000  mycroft branches: 1.14.6;
Doh. Remove the __weak_alias() as well...
 1.13 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.12 26-Jul-1998  mycroft constify some tables.
 1.11 03-Feb-1998  perry remove obsolete register declarations
 1.10 20-Oct-1997  christos Bring timezone back to libc.
 1.9 16-Oct-1997  christos moved to libcompat
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 13-Jul-1997  christos Include "extern.h" to get prototype for _tztab
Fix gcc warnings.
Fix RCSID's
 1.6 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.5 27-Feb-1995  cgd branches: 1.5.4;
merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 24-Nov-1993  jtc Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.14.6.2 10-Dec-2002  thorpej Sync with HEAD.
 1.14.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.13 30-Apr-2010  jruoho Interestingly, the committees plan to remove also isascii(3) and toascii(3)
in the future.
 1.12 17-Apr-2008  apb branches: 1.12.10;
Clarify the range of the result from toascii.
 1.11 18-Jan-2007  cbiere isascii() and toascii() are defined for all integers unlike the other
functions. Explicitely mention "undefined behavior".
 1.10 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.9 24-Dec-2004  wiz Add CAVEATS section similar to is*(3) ones. Bump date.
Fix typo in toascii.3 while here.
kleink says "ok".
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.4 05-Feb-1998  perry branches: 1.4.12;
add LIBRARY section to man page
 1.3 01-Nov-1997  kleink Add appropriate conformance notice; noticed while fixing PR standards/4351.
 1.2 16-Jul-1997  mikel add NetBSD RCSid
 1.1 16-Jul-1997  mikel branches: 1.1.1;
Initial revision
 1.1.1.1 16-Jul-1997  mikel import 4.4BSD-Lite2 version
 1.4.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.12.10.2 17-Apr-2008  apb Clarify the range of the result from toascii.
 1.12.10.1 17-Apr-2008  apb file toascii.3 was added on branch christos-time_t on 2008-04-17 16:41:01 +0000
 1.3 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.2 07-Aug-2003  agc branches: 1.2.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 12-Sep-1999  kleink Move the function implementations of (the non-ANSI) isascii() and toascii()
into separate modules to avoid namespace clashes.
 1.2.56.1 30-Oct-2012  yamt sync with head
 1.14 17-Apr-2008  apb branches: 1.14.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.13 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.12 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.11 24-Dec-2004  wiz Add CAVEATS section similar to is*(3) ones. Bump date.
Fix typo in toascii.3 while here.
kleink says "ok".
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.6 16-Sep-2001  wiz Boring whitespace fixes.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 31-May-1997  kleink Add a missing comma.
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.14.10.1 17-Apr-2008  apb file tolower.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.18 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.17 30-Mar-2025  riastradh branches: 1.17.2;
ctype(3): Simplify definitions of ctype/tolower/toupper tables.

Clarify comment while here.

No functional change intended. No change to `readelf -a' output on
amd64 or aarch64.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.16 29-Mar-2025  riastradh libc: Restore ELF symbol sizes for _C_ctype_tab_ &c.

This is needed for dynamic position-dependent executables that refer
directly to _C_type_tab_ to get correct copy relocations to see the
table content.

Unfortunately, such executables won't get a guard page.

Fortunately, referring to _C_ctype_tab_ directly (and not the
indirection _ctype_tab_ as the ctype(3) macros do) is very weird and
unlikely to happen in the real world (none of the public interfaces
use it; it is exported for libc++.so/libstdc++.so to use, but those
aren't pies). So missing the guard page in this case is probably not
so bad.

The symbol sizes are also needed for, e.g., gdb to nicely identify
addresses that lie in the table.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.15 29-Mar-2025  riastradh ctype(3): Put guard pages before the C ctype/tolower/toupper tables.

This also only affects machines where char is signed for now. (But
maybe it would be worth doing unconditionally; users could still try
to pass in explicit `signed char' inputs.)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.14 13-Apr-2013  joerg branches: 1.14.40;
Use more consistent naming for tolower/toupper translation table for the
C locale. From Takehiko Nozaki with changes to use __BUILD_LEGACY.
 1.13 01-Jun-2010  tnozaki branches: 1.13.6; 1.13.12;
more split ctype.h -> sys/ctype_inline.h, sys/ctype_bits.h
 1.12 22-May-2010  tnozaki 1. hide _CTYPE_PRIVATE section in ctype.h, move them to private header ctype_local.h.
2. do not use _CTYPE_NUM_CHARS macro to read data from LC_CTYPE(old BSDCTYPE style) database.
because 1<<CHAR_BIT is MD, so i added MI macro _CTYPE_CACHE_SIZE(1<<8).
3. remove _NB_CACHED_RUNE macro, use _CTYPE_CACHE_SIZE instead.
 1.11 11-Jan-2009  christos merge christos-time_t
 1.10 02-Jan-2009  tnozaki Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES} db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).

[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].

[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().

[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<

old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.9 26-Jul-2003  salo branches: 1.9.38; 1.9.40;
netbsd.org->NetBSD.org
 1.8 13-Jul-1997  christos Fix RCSID's
 1.7 11-May-1995  jtc Winning Strategies has placed this code in the public domain.
 1.6 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.5 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.4 23-Dec-1993  jtc Explicitly declare function return types to silence "gcc -Wall".
 1.3 05-Sep-1993  mycroft Separate the toupper() and tolower() functions so the tables *really* don't get
included unless you need them.
 1.2 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.1 23-Aug-1993  jtc Moved toupper and tolower tables from ctype_.c to their own files --- I
received complaints about using shorts in the table (but i need a range
of -1..255), so now the tables will not be used unless either toupper()
or tolower() (and soon, setlocale()) are used. This can save up to 514
bytes.

In toupper_.c and tolower_.c make sure that our assumption of EOF == -1
holds.

Fixed bug where _toupper_tab_ was initialized pointing to _C_tolower_tab.
 1.9.40.1 04-Jan-2009  christos merge with head.
 1.9.38.1 15-Jan-2009  snj Pull up following revision(s) (requested by tnozaki in ticket #222):
distrib/sets/lists/base/mi: revision 1.788
distrib/utils/libhack/Makefile.inc: revision 1.23
distrib/utils/libhack/Makefile: revision 1.22
etc/mtree/NetBSD.dist: revision 1.387
include/locale.h: revision 1.15
lib/libc/citrus/Makefile.inc: revision 1.6
lib/libc/citrus/citrus_aliasname_local.h: revision 1.1
lib/libc/citrus/citrus_bcs.h: revision 1.5
lib/libc/citrus/citrus_bcs_strtol.c: revision 1.1
lib/libc/citrus/citrus_bcs_strtoul.c: revision 1.1
lib/libc/citrus/citrus_csmapper.c: revision 1.9
lib/libc/citrus/citrus_fix_grouping.h: revision 1.1
lib/libc/citrus/citrus_lc_ctype.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.h: revision 1.1
lib/libc/citrus/citrus_lc_monetary.c: revision 1.1
lib/libc/citrus/citrus_lc_monetary.h: revision 1.1
lib/libc/citrus/citrus_lc_numeric.c: revision 1.1
lib/libc/citrus/citrus_lc_numeric.h: revision 1.1
lib/libc/citrus/citrus_lc_template.h: revision 1.1
lib/libc/citrus/citrus_lc_template_decl.h: revision 1.1
lib/libc/citrus/citrus_lc_time.c: revision 1.1
lib/libc/citrus/citrus_lc_time.h: revision 1.1
lib/libc/citrus/citrus_module.c: revision 1.8
lib/libc/citrus/citrus_namespace.h: revision 1.7
lib/libc/citrus/modules/citrus_euc.c: revision 1.13
lib/libc/gen/Makefile.inc: revision 1.166
lib/libc/gen/isctype.c: revision 1.17 via patch
lib/libc/gen/tolower_.c: revision 1.10
lib/libc/gen/toupper_.c: revision 1.10
lib/libc/iconv/Makefile.inc: revision 1.3
lib/libc/iconv/iconv.c: revision 1.7
lib/libc/locale/Makefile.inc: revision 1.53
lib/libc/locale/___runetype_mb.c: file removal
lib/libc/locale/_wctrans.c: revision 1.7
lib/libc/locale/_wctrans_local.h: revision 1.3
lib/libc/locale/_wctype.c: revision 1.1
lib/libc/locale/_wctype_local.h: revision 1.1
lib/libc/locale/aliasname.c: revision 1.3
lib/libc/locale/aliasname_local.h: revision 1.2
lib/libc/locale/bsdctype.c: revision 1.1
lib/libc/locale/bsdctype.h: revision 1.1
lib/libc/locale/ctypeio.c: revision 1.8
lib/libc/locale/ctypeio.h: revision 1.2
lib/libc/locale/current_locale.c: revision 1.1
lib/libc/locale/dummy_lc_collate.c: revision 1.1
lib/libc/locale/dummy_lc_template.h: revision 1.1
lib/libc/locale/fix_grouping.c: revision 1.1
lib/libc/locale/fix_grouping.h: revision 1.1
lib/libc/locale/generic_lc_all.c: revision 1.1
lib/libc/locale/generic_lc_template.h: revision 1.1
lib/libc/locale/generic_lc_template_decl.h: revision 1.1
lib/libc/locale/global_locale.c: revision 1.1
lib/libc/locale/iswctype.c: file removal
lib/libc/locale/iswctype_mb.c: revision 1.1
lib/libc/locale/iswctype_sb.c: revision 1.6
lib/libc/locale/lcmessages.c: file removal
lib/libc/locale/lcmessages.h: file removal
lib/libc/locale/lcmonetary.c: file removal
lib/libc/locale/lcmonetary.h: file removal
lib/libc/locale/lcnumeric.c: file removal
lib/libc/locale/lcnumeric.h: file removal
lib/libc/locale/lctime.c: file removal
lib/libc/locale/lctime.h: file removal
lib/libc/locale/localeconv.c: revision 1.15
lib/libc/locale/localeio.c: revision 1.2
lib/libc/locale/localeio.h: revision 1.2
lib/libc/locale/localeio_lc_ctype.c: revision 1.1
lib/libc/locale/localeio_lc_messages.c: revision 1.1
lib/libc/locale/localeio_lc_monetary.c: revision 1.1
lib/libc/locale/localeio_lc_numeric.c: revision 1.1
lib/libc/locale/localeio_lc_time.c: revision 1.1
lib/libc/locale/multibyte.h: revision 1.4
lib/libc/locale/multibyte_amd1.c: revision 1.6
lib/libc/locale/multibyte_c90.c: revision 1.5
lib/libc/locale/nb_lc_messages_misc.h: revision 1.1
lib/libc/locale/nb_lc_monetary_misc.h: revision 1.1
lib/libc/locale/nb_lc_numeric_misc.h: revision 1.1
lib/libc/locale/nb_lc_template.h: revision 1.1
lib/libc/locale/nb_lc_template_decl.h: revision 1.1
lib/libc/locale/nb_lc_time_misc.h: revision 1.1
lib/libc/locale/nl_langinfo.c: revision 1.12
lib/libc/locale/rune.c: revision 1.31
lib/libc/locale/rune.h: revision 1.13
lib/libc/locale/rune_local.h: revision 1.11
lib/libc/locale/runeglue.c: revision 1.14
lib/libc/locale/runetable.c: revision 1.18
lib/libc/locale/setlocale.c: revision 1.55 via patch
lib/libc/locale/setlocale_local.h: revision 1.1
lib/libc/locale/setrunelocale.c: file removal
lib/libc/nls/Makefile.inc: revision 1.9
lib/libc/nls/catopen.c: revision 1.26
lib/libc/string/Makefile.inc: revision 1.68
lib/libc/string/wcscmp.c: revision 1.6
lib/libc/string/wcsncmp.c: revision 1.6
lib/libc/string/wcswidth.c: file removal
lib/libc/string/wmemcmp.c: revision 1.4
regress/lib/libc/locale/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/en_US.UTF-8.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.exp.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.in.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.exp.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.in.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.SJIS.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.eucJP.exp.uue: revision 1.2
regress/lib/libc/locale/ctype2/Makefile: revision 1.5
regress/lib/libc/locale/ctype2/ja_JP.ISO-2022-JP-2.in.uue: revision 1.1
regress/lib/libc/locale/ctype2/ja_JP.ISO2022-JP2.in.uue: file removal
regress/lib/libc/locale/ctype3/Makefile: revision 1.5
regress/lib/libc/locale/mbtowc/Makefile: revision 1.3
regress/lib/libc/locale/mbtowc/ja_JP.ISO-2022-JP: revision 1.1
regress/lib/libc/locale/mbtowc/ja_JP.ISO2022-JP: file removal
regress/lib/libc/locale/wcstod/wcstod_test.c: revision 1.2
share/locale/Makefile.locale: revision 1.1
share/locale/Makefile: revision 1.5
share/locale/ctype/Makefile: revision 1.28
share/locale/locale.alias: revision 1.11
share/locale/messages/Makefile: revision 1.5
share/locale/messages/en_US.ISO8859-1.src: file removal
share/locale/messages/en_US.US-ASCII.src: revision 1.1
share/locale/messages/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/messages/ja_JP.ct.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-2.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-5.src: revision 1.1
share/locale/messages/sr_YU.ISO8859-2.src: file removal
share/locale/messages/sr_YU.ISO8859-5.src: file removal
share/locale/messages/sr_YU.UTF-8.src: file removal
share/locale/messages/zh_CN.GB18030.src: file removal
share/locale/messages/zh_TW.eucTW.src: revision 1.1
share/locale/monetary/Makefile: revision 1.5
share/locale/monetary/af_ZA.ISO8859-1.src: revision 1.2
share/locale/monetary/am_ET.UTF-8.src: revision 1.2
share/locale/monetary/be_BY.CP1131.src: file removal
share/locale/monetary/be_BY.CP1251.src: revision 1.2
share/locale/monetary/be_BY.ISO8859-5.src: revision 1.2
share/locale/monetary/be_BY.UTF-8.src: revision 1.2
share/locale/monetary/bg_BG.CP1251.src: revision 1.2
share/locale/monetary/bg_BG.UTF-8.src: revision 1.2
share/locale/monetary/ca_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/cs_CZ.ISO8859-2.src: revision 1.2
share/locale/monetary/cs_CZ.UTF-8.src: revision 1.2
share/locale/monetary/da_DK.ISO8859-1.src: revision 1.2
share/locale/monetary/de_AT.ISO8859-1.src: revision 1.2
share/locale/monetary/de_CH.ISO8859-1.src: revision 1.2
share/locale/monetary/de_DE.ISO8859-1.src: revision 1.2
share/locale/monetary/el_GR.ISO8859-7.src: revision 1.2
share/locale/monetary/en_AU.ISO8859-1.src: revision 1.2
share/locale/monetary/en_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.UTF-8.src: revision 1.2
share/locale/monetary/en_IE.UTF-8.src: revision 1.2
share/locale/monetary/en_NZ.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.US-ASCII.src: revision 1.1
share/locale/monetary/es_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/et_EE.ISO8859-15.src: revision 1.2
share/locale/monetary/fi_FI.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_FR.ISO8859-1.src: revision 1.2
share/locale/monetary/he_IL.UTF-8.src: revision 1.2
share/locale/monetary/hi_IN.ISCII-DEV.src: revision 1.2
share/locale/monetary/hr_HR.ISO8859-2.src: revision 1.2
share/locale/monetary/hu_HU.ISO8859-2.src: revision 1.2
share/locale/monetary/hy_AM.ARMSCII-8.src: revision 1.2
share/locale/monetary/hy_AM.UTF-8.src: revision 1.2
share/locale/monetary/is_IS.ISO8859-1.src: revision 1.2
share/locale/monetary/it_IT.ISO8859-1.src: revision 1.2
share/locale/monetary/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/monetary/ja_JP.UTF-8.src: revision 1.2
share/locale/monetary/ja_JP.eucJP.src: revision 1.2
share/locale/monetary/kk_KZ.PT154.src: revision 1.2
share/locale/monetary/kk_KZ.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.eucKR.src: revision 1.2
share/locale/monetary/lt_LT.ISO8859-13.src: revision 1.2
share/locale/monetary/mn_MN.UTF-8.src: revision 1.2
share/locale/monetary/nl_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/nl_NL.ISO8859-1.src: revision 1.2
share/locale/monetary/no_NO.ISO8859-1.src: revision 1.2
share/locale/monetary/pl_PL.ISO8859-2.src: revision 1.2
share/locale/monetary/pl_PL.UTF-8.src: revision 1.2
share/locale/monetary/pt_BR.ISO8859-1.src: revision 1.2
share/locale/monetary/pt_PT.ISO8859-1.src: revision 1.2
share/locale/monetary/ro_RO.ISO8859-2.src: revision 1.2
share/locale/monetary/ru_RU.CP1251.src: revision 1.2
share/locale/monetary/ru_RU.CP866.src: revision 1.2
share/locale/monetary/ru_RU.ISO8859-5.src: revision 1.2
share/locale/monetary/ru_RU.KOI8-R.src: revision 1.2
share/locale/monetary/ru_RU.UTF-8.src: revision 1.2
share/locale/monetary/sk_SK.ISO8859-2.src: revision 1.2
share/locale/monetary/sl_SI.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_ME.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_RS.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_YU.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_YU.ISO8859-5.src: revision 1.2
share/locale/monetary/sr_YU.UTF-8.src: revision 1.2
share/locale/monetary/sv_SE.ISO8859-1.src: revision 1.2
share/locale/monetary/tr_TR.ISO8859-9.src: revision 1.2
share/locale/monetary/uk_UA.CP1251.src: revision 1.2
share/locale/monetary/uk_UA.ISO8859-5.src: revision 1.2
share/locale/monetary/uk_UA.KOI8-U.src: revision 1.2
share/locale/monetary/uk_UA.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.GB18030.src: revision 1.2
share/locale/monetary/zh_CN.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.eucCN.src: revision 1.2
share/locale/monetary/zh_HK.Big5hkscs.src: revision 1.1
share/locale/monetary/zh_HK.UTF-8.src: revision 1.2
share/locale/monetary/zh_TW.Big5.src: revision 1.2
share/locale/numeric/Makefile: revision 1.4
share/locale/numeric/am_ET.UTF-8.src: file removal
share/locale/numeric/en_US.ISO8859-1.src: file removal
share/locale/numeric/en_US.US-ASCII.src: revision 1.1
share/locale/numeric/ja_JP.eucJP.src: file removal
share/locale/numeric/ko_KR.eucKR.src: file removal
share/locale/numeric/mn_MN.UTF-8.src: file removal
share/locale/numeric/sr_ME.ISO8859-2.src: revision 1.1
share/locale/numeric/sr_YU.ISO8859-2.src: file removal
share/locale/numeric/sr_YU.ISO8859-5.src: file removal
share/locale/numeric/zh_CN.eucCN.src: file removal
share/locale/time/Makefile: revision 1.5
share/locale/time/en_US.ISO8859-1.src: file removal
share/locale/time/en_US.US-ASCII.src: revision 1.1
share/locale/time/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/time/ja_JP.ct.src: revision 1.1
share/locale/time/sr_ME.ISO8859-2.src: revision 1.1
share/locale/time/sr_ME.ISO8859-5.src: revision 1.1
share/locale/time/sr_ME.UTF-8.src: revision 1.1
share/locale/time/sr_YU.ISO8859-2.src: file removal
share/locale/time/sr_YU.ISO8859-5.src: file removal
share/locale/time/sr_YU.UTF-8.src: file removal
share/locale/time/zh_CN.GB18030.src: file removal
share/locale/time/zh_TW.eucTW.src: revision 1.1
usr.bin/locale/locale.c: revision 1.6
usr.bin/mklocale/Makefile: revision 1.12
usr.bin/mklocale/lex.l: revision 1.14
usr.bin/mklocale/mklocaledb.c: revision 1.1
usr.bin/mklocale/yacc.y: revision 1.25
usr.sbin/chrtbl/Makefile: revision 1.8
usr.sbin/chrtbl/ctypeio.c: revision 1.1
usr.sbin/chrtbl/ctypeio.h: revision 1.1
Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES}
db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).
[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].
[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().
[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<
old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.13.12.1 23-Jun-2013  tls resync from head
 1.13.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.14.40.1 02-Aug-2025  perseant Sync with HEAD
 1.17.2.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.17 17-Apr-2008  apb branches: 1.17.10;
Refer to the CAVEATS section of ctype(3) for more information.
 1.16 18-Jan-2007  rillig Added a reference to ctype.3. What's the value of having that page at
all if it isn't referenced by others?

Suggested by Slava Semushin via private mail.
 1.15 05-Oct-2006  rillig Fixed the wording of the <ctype.h> character classification functions by
always using "function" instead of "macro".

Changed "undefined result" into "undefined behavior" for argument values
outside the valid range. Since the character table is allocated via
malloc(), it _may_ happen that it starts at a page boundary, so that
negative values for the argument result in a segmentation fault. In that
case, there is no result at all.
 1.14 24-Dec-2004  wiz Add CAVEATS section similar to is*(3) ones. Bump date.
Fix typo in toascii.3 while here.
kleink says "ok".
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.11 10-Jul-2002  wiz Remove Xrefs to ourselves in SEE ALSO.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 02-Apr-2001  wiz Remove trailing space from comment line.
 1.7 27-Apr-1998  fair branches: 1.7.12;
fix a small nroff bug & sort the references
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 31-May-1997  kleink Add a missing comma.
 1.4 29-Oct-1996  lukem man page is "toupper" not "tolower". from msaitoh@spa.is.uec.ac.jp [misc/2902]
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.4 01-Aug-2002  nathanw Catch up to -current.
 1.7.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.17.10.2 17-Apr-2008  apb Refer to the CAVEATS section of ctype(3) for more information.
 1.17.10.1 17-Apr-2008  apb file toupper.3 was added on branch christos-time_t on 2008-04-17 16:25:37 +0000
 1.18 15-Sep-2025  riastradh ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.17 30-Mar-2025  riastradh branches: 1.17.2;
ctype(3): Simplify definitions of ctype/tolower/toupper tables.

Clarify comment while here.

No functional change intended. No change to `readelf -a' output on
amd64 or aarch64.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.16 29-Mar-2025  riastradh libc: Restore ELF symbol sizes for _C_ctype_tab_ &c.

This is needed for dynamic position-dependent executables that refer
directly to _C_type_tab_ to get correct copy relocations to see the
table content.

Unfortunately, such executables won't get a guard page.

Fortunately, referring to _C_ctype_tab_ directly (and not the
indirection _ctype_tab_ as the ctype(3) macros do) is very weird and
unlikely to happen in the real world (none of the public interfaces
use it; it is exported for libc++.so/libstdc++.so to use, but those
aren't pies). So missing the guard page in this case is probably not
so bad.

The symbol sizes are also needed for, e.g., gdb to nicely identify
addresses that lie in the table.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.15 29-Mar-2025  riastradh ctype(3): Put guard pages before the C ctype/tolower/toupper tables.

This also only affects machines where char is signed for now. (But
maybe it would be worth doing unconditionally; users could still try
to pass in explicit `signed char' inputs.)

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.14 13-Apr-2013  joerg branches: 1.14.40;
Use more consistent naming for tolower/toupper translation table for the
C locale. From Takehiko Nozaki with changes to use __BUILD_LEGACY.
 1.13 01-Jun-2010  tnozaki branches: 1.13.6; 1.13.12;
more split ctype.h -> sys/ctype_inline.h, sys/ctype_bits.h
 1.12 22-May-2010  tnozaki 1. hide _CTYPE_PRIVATE section in ctype.h, move them to private header ctype_local.h.
2. do not use _CTYPE_NUM_CHARS macro to read data from LC_CTYPE(old BSDCTYPE style) database.
because 1<<CHAR_BIT is MD, so i added MI macro _CTYPE_CACHE_SIZE(1<<8).
3. remove _NB_CACHED_RUNE macro, use _CTYPE_CACHE_SIZE instead.
 1.11 11-Jan-2009  christos merge christos-time_t
 1.10 02-Jan-2009  tnozaki Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES} db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).

[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].

[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().

[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<

old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.9 26-Jul-2003  salo branches: 1.9.38; 1.9.40;
netbsd.org->NetBSD.org
 1.8 13-Jul-1997  christos Fix RCSID's
 1.7 11-May-1995  jtc Winning Strategies has placed this code in the public domain.
 1.6 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.5 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.4 23-Dec-1993  jtc Explicitly declare function return types to silence "gcc -Wall".
 1.3 05-Sep-1993  mycroft Separate the toupper() and tolower() functions so the tables *really* don't get
included unless you need them.
 1.2 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.1 23-Aug-1993  jtc Moved toupper and tolower tables from ctype_.c to their own files --- I
received complaints about using shorts in the table (but i need a range
of -1..255), so now the tables will not be used unless either toupper()
or tolower() (and soon, setlocale()) are used. This can save up to 514
bytes.

In toupper_.c and tolower_.c make sure that our assumption of EOF == -1
holds.

Fixed bug where _toupper_tab_ was initialized pointing to _C_tolower_tab.
 1.9.40.1 04-Jan-2009  christos merge with head.
 1.9.38.1 15-Jan-2009  snj Pull up following revision(s) (requested by tnozaki in ticket #222):
distrib/sets/lists/base/mi: revision 1.788
distrib/utils/libhack/Makefile.inc: revision 1.23
distrib/utils/libhack/Makefile: revision 1.22
etc/mtree/NetBSD.dist: revision 1.387
include/locale.h: revision 1.15
lib/libc/citrus/Makefile.inc: revision 1.6
lib/libc/citrus/citrus_aliasname_local.h: revision 1.1
lib/libc/citrus/citrus_bcs.h: revision 1.5
lib/libc/citrus/citrus_bcs_strtol.c: revision 1.1
lib/libc/citrus/citrus_bcs_strtoul.c: revision 1.1
lib/libc/citrus/citrus_csmapper.c: revision 1.9
lib/libc/citrus/citrus_fix_grouping.h: revision 1.1
lib/libc/citrus/citrus_lc_ctype.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.c: revision 1.1
lib/libc/citrus/citrus_lc_messages.h: revision 1.1
lib/libc/citrus/citrus_lc_monetary.c: revision 1.1
lib/libc/citrus/citrus_lc_monetary.h: revision 1.1
lib/libc/citrus/citrus_lc_numeric.c: revision 1.1
lib/libc/citrus/citrus_lc_numeric.h: revision 1.1
lib/libc/citrus/citrus_lc_template.h: revision 1.1
lib/libc/citrus/citrus_lc_template_decl.h: revision 1.1
lib/libc/citrus/citrus_lc_time.c: revision 1.1
lib/libc/citrus/citrus_lc_time.h: revision 1.1
lib/libc/citrus/citrus_module.c: revision 1.8
lib/libc/citrus/citrus_namespace.h: revision 1.7
lib/libc/citrus/modules/citrus_euc.c: revision 1.13
lib/libc/gen/Makefile.inc: revision 1.166
lib/libc/gen/isctype.c: revision 1.17 via patch
lib/libc/gen/tolower_.c: revision 1.10
lib/libc/gen/toupper_.c: revision 1.10
lib/libc/iconv/Makefile.inc: revision 1.3
lib/libc/iconv/iconv.c: revision 1.7
lib/libc/locale/Makefile.inc: revision 1.53
lib/libc/locale/___runetype_mb.c: file removal
lib/libc/locale/_wctrans.c: revision 1.7
lib/libc/locale/_wctrans_local.h: revision 1.3
lib/libc/locale/_wctype.c: revision 1.1
lib/libc/locale/_wctype_local.h: revision 1.1
lib/libc/locale/aliasname.c: revision 1.3
lib/libc/locale/aliasname_local.h: revision 1.2
lib/libc/locale/bsdctype.c: revision 1.1
lib/libc/locale/bsdctype.h: revision 1.1
lib/libc/locale/ctypeio.c: revision 1.8
lib/libc/locale/ctypeio.h: revision 1.2
lib/libc/locale/current_locale.c: revision 1.1
lib/libc/locale/dummy_lc_collate.c: revision 1.1
lib/libc/locale/dummy_lc_template.h: revision 1.1
lib/libc/locale/fix_grouping.c: revision 1.1
lib/libc/locale/fix_grouping.h: revision 1.1
lib/libc/locale/generic_lc_all.c: revision 1.1
lib/libc/locale/generic_lc_template.h: revision 1.1
lib/libc/locale/generic_lc_template_decl.h: revision 1.1
lib/libc/locale/global_locale.c: revision 1.1
lib/libc/locale/iswctype.c: file removal
lib/libc/locale/iswctype_mb.c: revision 1.1
lib/libc/locale/iswctype_sb.c: revision 1.6
lib/libc/locale/lcmessages.c: file removal
lib/libc/locale/lcmessages.h: file removal
lib/libc/locale/lcmonetary.c: file removal
lib/libc/locale/lcmonetary.h: file removal
lib/libc/locale/lcnumeric.c: file removal
lib/libc/locale/lcnumeric.h: file removal
lib/libc/locale/lctime.c: file removal
lib/libc/locale/lctime.h: file removal
lib/libc/locale/localeconv.c: revision 1.15
lib/libc/locale/localeio.c: revision 1.2
lib/libc/locale/localeio.h: revision 1.2
lib/libc/locale/localeio_lc_ctype.c: revision 1.1
lib/libc/locale/localeio_lc_messages.c: revision 1.1
lib/libc/locale/localeio_lc_monetary.c: revision 1.1
lib/libc/locale/localeio_lc_numeric.c: revision 1.1
lib/libc/locale/localeio_lc_time.c: revision 1.1
lib/libc/locale/multibyte.h: revision 1.4
lib/libc/locale/multibyte_amd1.c: revision 1.6
lib/libc/locale/multibyte_c90.c: revision 1.5
lib/libc/locale/nb_lc_messages_misc.h: revision 1.1
lib/libc/locale/nb_lc_monetary_misc.h: revision 1.1
lib/libc/locale/nb_lc_numeric_misc.h: revision 1.1
lib/libc/locale/nb_lc_template.h: revision 1.1
lib/libc/locale/nb_lc_template_decl.h: revision 1.1
lib/libc/locale/nb_lc_time_misc.h: revision 1.1
lib/libc/locale/nl_langinfo.c: revision 1.12
lib/libc/locale/rune.c: revision 1.31
lib/libc/locale/rune.h: revision 1.13
lib/libc/locale/rune_local.h: revision 1.11
lib/libc/locale/runeglue.c: revision 1.14
lib/libc/locale/runetable.c: revision 1.18
lib/libc/locale/setlocale.c: revision 1.55 via patch
lib/libc/locale/setlocale_local.h: revision 1.1
lib/libc/locale/setrunelocale.c: file removal
lib/libc/nls/Makefile.inc: revision 1.9
lib/libc/nls/catopen.c: revision 1.26
lib/libc/string/Makefile.inc: revision 1.68
lib/libc/string/wcscmp.c: revision 1.6
lib/libc/string/wcsncmp.c: revision 1.6
lib/libc/string/wcswidth.c: file removal
lib/libc/string/wmemcmp.c: revision 1.4
regress/lib/libc/locale/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/Makefile: revision 1.4
regress/lib/libc/locale/ctype1/en_US.UTF-8.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.exp.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO-2022-JP.in.uue: revision 1.1
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.exp.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.ISO2022-JP.in.uue: file removal
regress/lib/libc/locale/ctype1/ja_JP.SJIS.exp.uue: revision 1.2
regress/lib/libc/locale/ctype1/ja_JP.eucJP.exp.uue: revision 1.2
regress/lib/libc/locale/ctype2/Makefile: revision 1.5
regress/lib/libc/locale/ctype2/ja_JP.ISO-2022-JP-2.in.uue: revision 1.1
regress/lib/libc/locale/ctype2/ja_JP.ISO2022-JP2.in.uue: file removal
regress/lib/libc/locale/ctype3/Makefile: revision 1.5
regress/lib/libc/locale/mbtowc/Makefile: revision 1.3
regress/lib/libc/locale/mbtowc/ja_JP.ISO-2022-JP: revision 1.1
regress/lib/libc/locale/mbtowc/ja_JP.ISO2022-JP: file removal
regress/lib/libc/locale/wcstod/wcstod_test.c: revision 1.2
share/locale/Makefile.locale: revision 1.1
share/locale/Makefile: revision 1.5
share/locale/ctype/Makefile: revision 1.28
share/locale/locale.alias: revision 1.11
share/locale/messages/Makefile: revision 1.5
share/locale/messages/en_US.ISO8859-1.src: file removal
share/locale/messages/en_US.US-ASCII.src: revision 1.1
share/locale/messages/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/messages/ja_JP.ct.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-2.src: revision 1.1
share/locale/messages/sr_ME.ISO8859-5.src: revision 1.1
share/locale/messages/sr_YU.ISO8859-2.src: file removal
share/locale/messages/sr_YU.ISO8859-5.src: file removal
share/locale/messages/sr_YU.UTF-8.src: file removal
share/locale/messages/zh_CN.GB18030.src: file removal
share/locale/messages/zh_TW.eucTW.src: revision 1.1
share/locale/monetary/Makefile: revision 1.5
share/locale/monetary/af_ZA.ISO8859-1.src: revision 1.2
share/locale/monetary/am_ET.UTF-8.src: revision 1.2
share/locale/monetary/be_BY.CP1131.src: file removal
share/locale/monetary/be_BY.CP1251.src: revision 1.2
share/locale/monetary/be_BY.ISO8859-5.src: revision 1.2
share/locale/monetary/be_BY.UTF-8.src: revision 1.2
share/locale/monetary/bg_BG.CP1251.src: revision 1.2
share/locale/monetary/bg_BG.UTF-8.src: revision 1.2
share/locale/monetary/ca_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/cs_CZ.ISO8859-2.src: revision 1.2
share/locale/monetary/cs_CZ.UTF-8.src: revision 1.2
share/locale/monetary/da_DK.ISO8859-1.src: revision 1.2
share/locale/monetary/de_AT.ISO8859-1.src: revision 1.2
share/locale/monetary/de_CH.ISO8859-1.src: revision 1.2
share/locale/monetary/de_DE.ISO8859-1.src: revision 1.2
share/locale/monetary/el_GR.ISO8859-7.src: revision 1.2
share/locale/monetary/en_AU.ISO8859-1.src: revision 1.2
share/locale/monetary/en_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.ISO8859-1.src: revision 1.2
share/locale/monetary/en_GB.UTF-8.src: revision 1.2
share/locale/monetary/en_IE.UTF-8.src: revision 1.2
share/locale/monetary/en_NZ.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.ISO8859-1.src: revision 1.2
share/locale/monetary/en_US.US-ASCII.src: revision 1.1
share/locale/monetary/es_ES.ISO8859-1.src: revision 1.2
share/locale/monetary/et_EE.ISO8859-15.src: revision 1.2
share/locale/monetary/fi_FI.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_CA.ISO8859-1.src: revision 1.2
share/locale/monetary/fr_FR.ISO8859-1.src: revision 1.2
share/locale/monetary/he_IL.UTF-8.src: revision 1.2
share/locale/monetary/hi_IN.ISCII-DEV.src: revision 1.2
share/locale/monetary/hr_HR.ISO8859-2.src: revision 1.2
share/locale/monetary/hu_HU.ISO8859-2.src: revision 1.2
share/locale/monetary/hy_AM.ARMSCII-8.src: revision 1.2
share/locale/monetary/hy_AM.UTF-8.src: revision 1.2
share/locale/monetary/is_IS.ISO8859-1.src: revision 1.2
share/locale/monetary/it_IT.ISO8859-1.src: revision 1.2
share/locale/monetary/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/monetary/ja_JP.UTF-8.src: revision 1.2
share/locale/monetary/ja_JP.eucJP.src: revision 1.2
share/locale/monetary/kk_KZ.PT154.src: revision 1.2
share/locale/monetary/kk_KZ.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.UTF-8.src: revision 1.2
share/locale/monetary/ko_KR.eucKR.src: revision 1.2
share/locale/monetary/lt_LT.ISO8859-13.src: revision 1.2
share/locale/monetary/mn_MN.UTF-8.src: revision 1.2
share/locale/monetary/nl_BE.ISO8859-1.src: revision 1.2
share/locale/monetary/nl_NL.ISO8859-1.src: revision 1.2
share/locale/monetary/no_NO.ISO8859-1.src: revision 1.2
share/locale/monetary/pl_PL.ISO8859-2.src: revision 1.2
share/locale/monetary/pl_PL.UTF-8.src: revision 1.2
share/locale/monetary/pt_BR.ISO8859-1.src: revision 1.2
share/locale/monetary/pt_PT.ISO8859-1.src: revision 1.2
share/locale/monetary/ro_RO.ISO8859-2.src: revision 1.2
share/locale/monetary/ru_RU.CP1251.src: revision 1.2
share/locale/monetary/ru_RU.CP866.src: revision 1.2
share/locale/monetary/ru_RU.ISO8859-5.src: revision 1.2
share/locale/monetary/ru_RU.KOI8-R.src: revision 1.2
share/locale/monetary/ru_RU.UTF-8.src: revision 1.2
share/locale/monetary/sk_SK.ISO8859-2.src: revision 1.2
share/locale/monetary/sl_SI.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_ME.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_RS.ISO8859-2.src: revision 1.1
share/locale/monetary/sr_YU.ISO8859-2.src: revision 1.2
share/locale/monetary/sr_YU.ISO8859-5.src: revision 1.2
share/locale/monetary/sr_YU.UTF-8.src: revision 1.2
share/locale/monetary/sv_SE.ISO8859-1.src: revision 1.2
share/locale/monetary/tr_TR.ISO8859-9.src: revision 1.2
share/locale/monetary/uk_UA.CP1251.src: revision 1.2
share/locale/monetary/uk_UA.ISO8859-5.src: revision 1.2
share/locale/monetary/uk_UA.KOI8-U.src: revision 1.2
share/locale/monetary/uk_UA.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.GB18030.src: revision 1.2
share/locale/monetary/zh_CN.UTF-8.src: revision 1.2
share/locale/monetary/zh_CN.eucCN.src: revision 1.2
share/locale/monetary/zh_HK.Big5hkscs.src: revision 1.1
share/locale/monetary/zh_HK.UTF-8.src: revision 1.2
share/locale/monetary/zh_TW.Big5.src: revision 1.2
share/locale/numeric/Makefile: revision 1.4
share/locale/numeric/am_ET.UTF-8.src: file removal
share/locale/numeric/en_US.ISO8859-1.src: file removal
share/locale/numeric/en_US.US-ASCII.src: revision 1.1
share/locale/numeric/ja_JP.eucJP.src: file removal
share/locale/numeric/ko_KR.eucKR.src: file removal
share/locale/numeric/mn_MN.UTF-8.src: file removal
share/locale/numeric/sr_ME.ISO8859-2.src: revision 1.1
share/locale/numeric/sr_YU.ISO8859-2.src: file removal
share/locale/numeric/sr_YU.ISO8859-5.src: file removal
share/locale/numeric/zh_CN.eucCN.src: file removal
share/locale/time/Makefile: revision 1.5
share/locale/time/en_US.ISO8859-1.src: file removal
share/locale/time/en_US.US-ASCII.src: revision 1.1
share/locale/time/ja_JP.ISO-2022-JP.src: revision 1.1
share/locale/time/ja_JP.ct.src: revision 1.1
share/locale/time/sr_ME.ISO8859-2.src: revision 1.1
share/locale/time/sr_ME.ISO8859-5.src: revision 1.1
share/locale/time/sr_ME.UTF-8.src: revision 1.1
share/locale/time/sr_YU.ISO8859-2.src: file removal
share/locale/time/sr_YU.ISO8859-5.src: file removal
share/locale/time/sr_YU.UTF-8.src: file removal
share/locale/time/zh_CN.GB18030.src: file removal
share/locale/time/zh_TW.eucTW.src: revision 1.1
usr.bin/locale/locale.c: revision 1.6
usr.bin/mklocale/Makefile: revision 1.12
usr.bin/mklocale/lex.l: revision 1.14
usr.bin/mklocale/mklocaledb.c: revision 1.1
usr.bin/mklocale/yacc.y: revision 1.25
usr.sbin/chrtbl/Makefile: revision 1.8
usr.sbin/chrtbl/ctypeio.c: revision 1.1
usr.sbin/chrtbl/ctypeio.h: revision 1.1
Fixes PR lib/39662, shortcomings in LC_{MONETARY,NUMERIC,TIME,MESSAGES}
db format.
ok'ed by core and releng.
(thanks for agc@, snj@ and i'm sorry for long time patience).
[libc]
- localeio.[ch] and lc*.[ch] in src/lib/libc/locale was replaced by
new locale-db implementation using citrus_db backend,
see src/lib/libc/citrus/citrus_lc_*.[ch].
- add citrus_bcs_strtou?l.c. don't use strtou?l locale implementation
internally, because they're locale-aware function.
- add some stubs for multi-locale issue, see {current,global}_locale.c.
- remove some obsolete file, setrunelocale.c, ___runetype_mb.c.
- remove __savectype() from ctypeio.[ch].
[tools]
- mklocale(1): add new option ``-t'' that generates new style
LC_{MONETARY,NUMERIC,TIME,MESSAGES} locale-db format.
- chrtbl(1): added ctypeio.[ch] for __savectype().
[locale-db]
- added en_US.US-ASCII locale.
- removed some shareable locale definition file:
en_US.US-ASCII -> en_US.ISO8859-1, en_US.UTF-8
zh_CN.eucCN -> zh_CN.GB18030
and more...see src/share/locale/*/Makefile.
- remove obsoleted locale sr_YU, added new locale sr_ME, sr_RS.
- change locale name ja_JP.ISO2022-JP* -> ja_JP.ISO-2022-JP*
for X11's locale.alias file alignments.
- fix regression test, wrong wcs?width(3), NAN/INF usage.

i tested release-build following arch:
i386, amd64, hpc{mips,arm,sh}, sparc64, vax.

citrus_lc_*.[ch] also can read old-plain-text style locale-db.
so that backward compatibility is keeped, but lc*.[ch] can't read
new citrus_db'ed locale-db and localeio.c never check sanity,
so forward compatibility is broken ;-<
old mklocale(1) doesn't know -t option, so you have to rebuild toolchain.
 1.13.12.1 23-Jun-2013  tls resync from head
 1.13.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.14.40.1 02-Aug-2025  perseant Sync with HEAD
 1.17.2.1 01-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #45):

tests/lib/libc/gen/t_ctype.c: revision 1.12
lib/libc/gen/ctype_.c: revision 1.24
lib/libc/locale/rune.c: revision 1.50
tests/lib/libc/gen/Makefile: revision 1.61
lib/libc/gen/tolower_.c: revision 1.18
lib/libc/gen/isctype.c: revision 1.29
distrib/sets/lists/tests/mi: revision 1.1394
lib/libc/gen/toupper_.c: revision 1.18
lib/libc/gen/ctype_guard.h: revision 1.8
lib/libc/locale/Makefile.inc: revision 1.69
lib/libc/gen/ctype.3: revision 1.32
lib/libc/gen/ctype.3: revision 1.33
distrib/sets/lists/debug/mi: revision 1.486
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.1
tests/lib/libc/gen/h_ctype_abuse.c: revision 1.2

ctype(3): New environment variable LIBC_ALLOWCTYPEABUSE.

If set, this does not force the ctype(3) functions to crash when
passed invalid inputs -- instead, they will return nonsense results,
and possibly print warnings to stderr, as is their right in
implementing undefined behaviour.

The nature of the nonsense results is unspecified. Currently, is*()
will always return true (even if that leads to mutually contradictory
conclusions, like isalpha and isdigit, or isgraph and isblank), and
tolower/toupper() will always return EOF. But perhaps in the future
the results may be randomized.

This way, if an application like firefox crashes on ctype abuse, you
can opt to accept the consequences of nonsense results instead by
running `env LIBC_ALLOWCTYPEABUSE= firefox' until the application is
fixed.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
ctype(3): Document LIBC_ALLOWCTYPEABUSE.

If this is pulled up to netbsd-11, we should tweak the text to make
it apply to 11 too.
PR lib/58208: ctype(3) provides poor runtime feedback of abuse

ctype(3): Fix build of tests on machines with unsigned char.
Could maybe phrase this better but this'll do for now.

PR lib/58208: ctype(3) provides poor runtime feedback of abuse
 1.24 03-Jun-2012  joerg Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
 1.23 31-May-2012  joerg Add void for ttyslot prototype.
 1.22 25-Apr-2011  wiz branches: 1.22.4; 1.22.6;
Sort errors.
 1.21 25-Jun-2008  ad branches: 1.21.6;
ttyname_r is another of the strange functions that returns its error code
instead of setting errno.
 1.20 30-Jan-2008  apb branches: 1.20.6;
Mention use of /var/run/dev.db, and add .Xr dev_mkdb 8 .
Could somebody update the HISTORY?
 1.19 26-Sep-2005  wiz branches: 1.19.10;
Punctuation nits; grammar fix.
 1.18 25-Sep-2005  christos ttyname_r returns int.
 1.17 25-Sep-2005  christos add getenv_r and ttyname_r
 1.16 11-Nov-2004  wiz Fix some nits, and bump date for previous.
 1.15 11-Nov-2004  christos It is silly to have to enumerate all the ptys in /etc/ttys in order to
get a valid ttyslot for them. Instead if and entry is not found and we
are a pty, allocate the n + 1 + minor(pty) slot.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 16-Feb-1999  kleink branches: 1.8.12;
Dv vs. Va police.
 1.7 06-Jun-1998  kleink Document the return values of isatty(3) (`true' resp. `false' aren't valid
return values), and add an ERRORS section.
 1.6 01-Jun-1998  kleink Prototype has moved: add inclusion of <stdlib.h> to the synopsis of ttyslot().
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.19.10.1 23-Mar-2008  matt sync with HEAD
 1.20.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.21.6.2 25-Jun-2008  ad ttyname_r is another of the strange functions that returns its error code
instead of setting errno.
 1.21.6.1 25-Jun-2008  ad file ttyname.3 was added on branch christos-time_t on 2008-06-25 11:47:30 +0000
 1.22.6.1 23-Jun-2012  riz Pull up following revision(s) (requested by joerg in ticket #328):
lib/libc/gen/devname.c: revision 1.22
distrib/sparc64/instfs/dot.profile: revision 1.7
distrib/i386/cdroms/install.sh: revision 1.3
tests/lib/libcurses/director/director.c: revision 1.10
lib/libc/include/reentrant.h: revision 1.15
distrib/amd64/cdroms/install.sh: revision 1.3
tests/include/t_paths.c: revision 1.12
share/man/man7/hier.7: revision 1.101
etc/rc.d/sysdb: revision 1.24
include/stdlib.h: revision 1.99
tests/lib/libcurses/Makefile: revision 1.3
distrib/sparc64/cdroms/installcd/install.sh: revision 1.3
distrib/i386/cdroms/Makefile.cdrom: revision 1.27
lib/libc/gen/ttyname.c: revision 1.25
usr.bin/tic/Makefile: revision 1.2
tools/compat/Makefile: revision 1.57
lib/libterminfo/compile.c: revision 1.7
lib/libc/gen/ttyname.c: revision 1.26
lib/libterminfo/compile.c: revision 1.8
tools/compat/Makefile: revision 1.59
tools/compat/cdbw.h: revision 1.1
distrib/i386/installimage/install.sh: revision 1.2
lib/libc/include/namespace.h: revision 1.154
usr.bin/tic/tic.c: revision 1.13
usr.bin/tic/tic.c: revision 1.14
usr.bin/tic/tic.c: revision 1.15
distrib/sets/lists/base/mi: revision 1.996
usr.bin/tic/tic.c: revision 1.16
usr.sbin/dev_mkdb/dev_mkdb.8: revision 1.13
usr.bin/tic/tic.c: revision 1.17
usr.bin/tic/tic.c: revision 1.18
tools/compat/cdbr.h: revision 1.1
distrib/sparc64/instfs/list: revision 1.25
usr.bin/tic/tic.c: revision 1.19
lib/libc/cdb/cdbw.c: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.5
share/terminfo/Makefile: revision 1.3
usr.sbin/dev_mkdb/dev_mkdb.c: revision 1.29
usr.sbin/dev_mkdb/Makefile: revision 1.8
lib/libc/gen/ttyname.3: revision 1.23
lib/libc/gen/ttyname.3: revision 1.24
lib/libc/cdb/cdbr.c: revision 1.3
include/cdbw.h: revision 1.2
distrib/sparc64/cdroms/installcd/Makefile: revision 1.15
lib/libc/gen/devname.3: revision 1.12
tools/compat/compat_defs.h: revision 1.85
tools/compat/compat_defs.h: revision 1.86
lib/libterminfo/term_private.h: revision 1.10
lib/libterminfo/term.c: revision 1.14
usr.bin/tic/tic.1: revision 1.10
lib/libterminfo/term.c: revision 1.15
lib/libterminfo/Makefile.hash: revision 1.5
lib/libterminfo/term.c: revision 1.16
distrib/amd64/installimage/install.sh: revision 1.2
share/man/man5/rc.conf.5: revision 1.152
distrib/sets/lists/tests/mi: revision 1.472
distrib/amd64/cdroms/Makefile.cdrom: revision 1.7
include/paths.h: revision 1.41
bin/ps/ps.1: revision 1.101
lib/libterminfo/terminfo.5.in: revision 1.16
usr.bin/tic/tic.c: revision 1.20
lib/libterminfo/terminfo.5.in: revision 1.17
Prefer __printflike.
Use queue(3)
Replace linear lookup with hash table, reducing runtime by 60%.
Use e* from util.h.
One more strdup -> estrdup.
Maintain nalias and nterm on the fly.
Add void for ttyslot prototype.
Use memcmp in place of strncmp, since length is known to no longer than
either of the arguments.
Fix a number of memory leaks. Keep final loop of the cleanup in tic(1)
under #ifdef __VALGRIND__ though.
Add __predict_true / __predict_false definitions.
Add a special seeder for cdbw_output that gives stable results.
Hook up cdbw(3) for the tool build.
Prototype for cdbw_stable_seeder.
Provide a usable thr_once for !_REENTRANT
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
Switch terminfo(3) to cdb(5).
Fix typos.
Make Alan Barrett happy and add ().
Add cdbr(3) support to tools/compat.
Bump date for previous.
Relax consistency to make it possible to match valid entries.
Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.
 1.22.4.1 30-Oct-2012  yamt sync with head
 1.26 12-Jun-2012  joerg Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.
 1.25 03-Jun-2012  joerg Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
 1.24 25-Jun-2008  ad branches: 1.24.2; 1.24.6; 1.24.22;
ttyname_r is another of the strange functions that returns its error code
instead of setting errno.
 1.23 22-Mar-2006  christos branches: 1.23.20;
Coverity CID 1640: closedir on error.
 1.22 25-Sep-2005  christos ttyname_r returns int.
 1.21 25-Sep-2005  christos add getenv_r and ttyname_r
 1.20 11-Nov-2004  christos Use ioctl to find the pty name directly instead of looking it up in
the database; it is much faster, and the common case these days.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.17 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.16 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.15 26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.14 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.13 27-Feb-1998  perry changes to quiet lint.
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.10 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
 1.9 02-May-1995  mycroft branches: 1.9.4;
Use POSIX tty semantics.
 1.8 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.7 28-Jan-1994  cgd branches: 1.7.4;
patch from sms@WLV.IIPO.GTEGSC.COM (Steven M. Schultz) to kill mem leak
 1.6 28-Dec-1993  jtc #include <string.h> to bring function prototypes into scope.
 1.5 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.4 30-Jul-1993  mycroft Add even more RCS frobs.
 1.3 21-Apr-1993  proven Opps, dbopen doesn't have an underscore. Fixed.
 1.2 21-Apr-1993  proven Fixed these twon files to use db_open instead of hash_open.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.4.2 02-May-1995  jtc #include "namespace.h"
 1.7.4.1 26-Apr-1995  jtc don't explicitly declare strcpy --- <string.h> already provides a prototype
 1.9.4.2 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.4.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.23.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.24.22.1 23-Jun-2012  riz Pull up following revision(s) (requested by joerg in ticket #328):
lib/libc/gen/devname.c: revision 1.22
distrib/sparc64/instfs/dot.profile: revision 1.7
distrib/i386/cdroms/install.sh: revision 1.3
tests/lib/libcurses/director/director.c: revision 1.10
lib/libc/include/reentrant.h: revision 1.15
distrib/amd64/cdroms/install.sh: revision 1.3
tests/include/t_paths.c: revision 1.12
share/man/man7/hier.7: revision 1.101
etc/rc.d/sysdb: revision 1.24
include/stdlib.h: revision 1.99
tests/lib/libcurses/Makefile: revision 1.3
distrib/sparc64/cdroms/installcd/install.sh: revision 1.3
distrib/i386/cdroms/Makefile.cdrom: revision 1.27
lib/libc/gen/ttyname.c: revision 1.25
usr.bin/tic/Makefile: revision 1.2
tools/compat/Makefile: revision 1.57
lib/libterminfo/compile.c: revision 1.7
lib/libc/gen/ttyname.c: revision 1.26
lib/libterminfo/compile.c: revision 1.8
tools/compat/Makefile: revision 1.59
tools/compat/cdbw.h: revision 1.1
distrib/i386/installimage/install.sh: revision 1.2
lib/libc/include/namespace.h: revision 1.154
usr.bin/tic/tic.c: revision 1.13
usr.bin/tic/tic.c: revision 1.14
usr.bin/tic/tic.c: revision 1.15
distrib/sets/lists/base/mi: revision 1.996
usr.bin/tic/tic.c: revision 1.16
usr.sbin/dev_mkdb/dev_mkdb.8: revision 1.13
usr.bin/tic/tic.c: revision 1.17
usr.bin/tic/tic.c: revision 1.18
tools/compat/cdbr.h: revision 1.1
distrib/sparc64/instfs/list: revision 1.25
usr.bin/tic/tic.c: revision 1.19
lib/libc/cdb/cdbw.c: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.5
share/terminfo/Makefile: revision 1.3
usr.sbin/dev_mkdb/dev_mkdb.c: revision 1.29
usr.sbin/dev_mkdb/Makefile: revision 1.8
lib/libc/gen/ttyname.3: revision 1.23
lib/libc/gen/ttyname.3: revision 1.24
lib/libc/cdb/cdbr.c: revision 1.3
include/cdbw.h: revision 1.2
distrib/sparc64/cdroms/installcd/Makefile: revision 1.15
lib/libc/gen/devname.3: revision 1.12
tools/compat/compat_defs.h: revision 1.85
tools/compat/compat_defs.h: revision 1.86
lib/libterminfo/term_private.h: revision 1.10
lib/libterminfo/term.c: revision 1.14
usr.bin/tic/tic.1: revision 1.10
lib/libterminfo/term.c: revision 1.15
lib/libterminfo/Makefile.hash: revision 1.5
lib/libterminfo/term.c: revision 1.16
distrib/amd64/installimage/install.sh: revision 1.2
share/man/man5/rc.conf.5: revision 1.152
distrib/sets/lists/tests/mi: revision 1.472
distrib/amd64/cdroms/Makefile.cdrom: revision 1.7
include/paths.h: revision 1.41
bin/ps/ps.1: revision 1.101
lib/libterminfo/terminfo.5.in: revision 1.16
usr.bin/tic/tic.c: revision 1.20
lib/libterminfo/terminfo.5.in: revision 1.17
Prefer __printflike.
Use queue(3)
Replace linear lookup with hash table, reducing runtime by 60%.
Use e* from util.h.
One more strdup -> estrdup.
Maintain nalias and nterm on the fly.
Add void for ttyslot prototype.
Use memcmp in place of strncmp, since length is known to no longer than
either of the arguments.
Fix a number of memory leaks. Keep final loop of the cleanup in tic(1)
under #ifdef __VALGRIND__ though.
Add __predict_true / __predict_false definitions.
Add a special seeder for cdbw_output that gives stable results.
Hook up cdbw(3) for the tool build.
Prototype for cdbw_stable_seeder.
Provide a usable thr_once for !_REENTRANT
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
Switch terminfo(3) to cdb(5).
Fix typos.
Make Alan Barrett happy and add ().
Add cdbr(3) support to tools/compat.
Bump date for previous.
Relax consistency to make it possible to match valid entries.
Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.
 1.24.6.2 25-Jun-2008  ad ttyname_r is another of the strange functions that returns its error code
instead of setting errno.
 1.24.6.1 25-Jun-2008  ad file ttyname.c was added on branch christos-time_t on 2008-06-25 11:47:30 +0000
 1.24.2.1 30-Oct-2012  yamt sync with head
 1.13 11-Jan-2009  christos merge christos-time_t
 1.12 11-Nov-2004  christos branches: 1.12.34;
It is silly to have to enumerate all the ptys in /etc/ttys in order to
get a valid ttyslot for them. Instead if and entry is not found and we
are a pty, allocate the n + 1 + minor(pty) slot.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 01-Jun-1998  kleink Need <stdlib.h> for ttyslot() prototype.
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
 1.5 27-Feb-1995  cgd branches: 1.5.4;
merge with 4.4-Lite, keeping local changes. clean up Ids
 1.4 24-Nov-1993  jtc Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.12.34.1 08-Nov-2008  christos time_t changes
 1.4 10-Mar-1995  jtc ctime.3 and tzset.3 manpages have been moved to libc/time.
 1.3 27-Feb-1995  cgd merge with 4.4-Lite, keeping local changes. clean up Ids
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.19 02-May-2011  jruoho Clarify STANDARDS (i.e. cf. ualarm(3) is no longer in POSIX).
 1.18 29-Apr-2010  jruoho Properly mark the standard that "deprecated" all of these.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.15 07-Feb-2002  ross Generate <>& symbolically.
 1.14 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.13 16-Sep-2001  wiz Boring whitespace fixes.
 1.12 22-Mar-1999  garbled branches: 1.12.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.11 13-Nov-1998  christos document the return value of ualarm when setitimer fails to (useconds_t)-1,
also cast the return value in the source to the same to shut up lint.
 1.10 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 25-Nov-1997  kleink Per XPG4.2, use useconds_t as argument and return type.
 1.7 27-Sep-1997  hubertf Fix some typos reported by entropy@tardis.bernstein.com.
Fixed PR lib/4154.
 1.6 17-Jan-1997  perry change sigpause(2) to sigsuspend(2) or sigpause(3), depending
Also try to fix other bad references to sig* man pages.
Fixes pr-2885 from Jonathan Stone
These SEE ALSO sections are still bloody messes (sigh)
 1.5 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.4 17-Oct-1994  cgd either change or update references to sigvec(), as appropriate
 1.3 10-Jan-1994  jtc branches: 1.3.2;
Fix spelling errors.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.2.1 17-Oct-1994  cgd from trunk.
 1.12.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.12.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.12.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.11 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.10 07-Aug-2003  agc branches: 1.10.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 13-Nov-1998  christos document the return value of ualarm when setitimer fails to (useconds_t)-1,
also cast the return value in the source to the same to shut up lint.
 1.7 25-Nov-1997  kleink Per XPG4.2, use useconds_t as argument and return type; eliminate use of the
`register' keyword.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.56.1 30-Oct-2012  yamt sync with head
 1.9 30-Apr-2010  jruoho Deprecated in POSIX (rev. 2008).
 1.8 30-Apr-2008  martin branches: 1.8.8;
Convert TNF licenses to new 2 clause variant
 1.7 16-Apr-2003  wiz branches: 1.7.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.5 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.4 07-Feb-2002  ross Generate <>& symbolically.
 1.3 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.2 11-Oct-1999  kleink branches: 1.2.8;
Fix some formatting mistakes of mine.
 1.1 13-Sep-1999  kleink branches: 1.1.2;
Add an XSH5 ulimit()/<ulimit.h> implementation.
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.8.3 22-Mar-2002  nathanw Catch up to -current.
 1.2.8.2 08-Mar-2002  nathanw Catch up to -current.
 1.2.8.1 08-Oct-2001  nathanw Catch up to -current.
 1.7.30.1 18-May-2008  yamt sync with head.
 1.8.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.8.8.1 30-Apr-2008  martin file ulimit.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.3 28-Apr-2008  martin branches: 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 26-May-2002  wiz branches: 1.2.30;
__STDC__ is always defined on NetBSD.
 1.1 13-Sep-1999  kleink branches: 1.1.10;
Add an XSH5 ulimit()/<ulimit.h> implementation.
 1.1.10.1 21-Jun-2002  nathanw Catch up to -current.
 1.2.30.1 18-May-2008  yamt sync with head.
 1.3.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3.8.1 28-Apr-2008  martin file ulimit.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.13 14-Jun-2014  apb Document the relationship between uname(3) and sysctl(7) variables.
 1.12 30-Mar-2011  jruoho branches: 1.12.10; 1.12.20;
.Li -> .Em.
 1.11 27-Apr-2010  jruoho Use .In for includes and .Va when listing the structure members.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 05-Feb-1998  perry branches: 1.6.12;
add LIBRARY section to man page
 1.5 03-Feb-1998  perry .Bx'ize
 1.4 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.3 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.2 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.6.12.3 18-Oct-2002  nathanw Catch up to -current.
 1.6.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.6.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.12.20.1 10-Aug-2014  tls Rebase.
 1.12.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12 14-Jun-2014  apb If sysctl kern.version returns a string that's too long
to fit in {struct utsname}.version then just use the
truncated value.
 1.11 20-Mar-2012  matt branches: 1.11.2; 1.11.8;
Use C89 definitions.
Remove use of __P
 1.10 15-Jan-2007  cbiere branches: 1.10.36;
Bail out on the first sysctl() error as suggested by Pierre Pronchery in
PR lib/35403. christos agreed it's cleaner.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.7 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.6 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.5 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.4 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.3 13-Jul-1997  christos Fix RCSID's
 1.2 25-Feb-1995  cgd branches: 1.2.4;
merge with Lite, keep local changes. clean up id usage
 1.1 07-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 07-May-1994  cgd various sysctl-related libc functions
 1.2.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.36.1 17-Apr-2012  yamt sync with head
 1.11.8.1 10-Aug-2014  tls Rebase.
 1.11.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30 08-May-2019  bad Clarify that strunvisx() and strnunvisx() take the same flags as unvis().
Document VIS_NOESCAPE for unvis().
Bump date.
 1.29 24-Oct-2017  abhinav branches: 1.29.4;
Add missing functions from the SYNOPSIS to the NAME section
 1.28 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.27 15-Dec-2012  wiz Add article. Remove trailing whitespace.
 1.26 15-Dec-2012  uwe Add BUGS section that explains that names VIS_HTTP1808 and VIS_HTTP1866
are wrong (hi, christos).

ok christos@
 1.25 15-Dec-2012  uwe RFC 1866 does not define any "URI encoding". It defines HTML 2.0 that
includes SGML numerical character references (&#nnn;) and entity
references (&foo;) for Added Latin 1 and a subset of Numeric and
Special Graphic.
 1.24 15-Dec-2012  uwe Minor markup fixes.
 1.23 17-Mar-2011  wiz branches: 1.23.4; 1.23.10;
Fix SYNOPSIS. Error found by martin.
 1.22 13-Mar-2011  wiz Add serial comma, quote minus, add HISTORY for strnunvis and strnunvisx.
 1.21 12-Mar-2011  christos Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
 1.20 28-Nov-2010  wiz Remove superfluous comma.
 1.19 27-Nov-2010  christos Implement VIS_NOESCAPE and VIS_HTTP1866.
 1.18 10-Feb-2009  christos Add RFC 2045 MIME Quoted-Printable support.
 1.17 10-Nov-2005  christos branches: 1.17.30;
Fix the code example.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.14 23-Mar-2002  christos - Add VIS_HTTPSTYLE from FreeBSD.
- svis, strsvis, strsvisx were not reversible, because they did not encode
\\ unless it was passed in the extras array.
- Fix documentation to match the proper signature of the functions.
 1.13 07-Feb-2002  ross generate & symbolically
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.10 16-Sep-2001  wiz Boring whitespace fixes.
 1.9 28-Apr-1998  fair branches: 1.9.12;
Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 03-Feb-1998  perry .Bx'ize
 1.6 12-Oct-1995  jtc Manpage fixes from Jochen Pohl. Aligns the prototypes in the SYNOPSIS
section with the actual function declarations. Also fixes decription
of _SC_CLK_TCK in sysconf(3). See PR #1587 and PR #1589 for details.
 1.5 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.4 10-Jan-1994  jtc Fix spelling errors.
 1.3 04-Oct-1993  jtc Consistantly cross reference the other functions/programs in the vis/unvis
"family".
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.12.4 25-Apr-2002  nathanw Catch up to -current.
 1.9.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.9.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.9.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.17.30.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.23.10.1 25-Feb-2013  tls resync with head
 1.23.4.1 23-Jan-2013  yamt sync with head
 1.29.4.1 10-Jun-2019  christos Sync with HEAD
 1.45 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.44 26-Sep-2014  roy Revert prior patch as it breaks `vis -l` as pointed out by apb.
 1.43 26-Sep-2014  roy Remove \$ as a hidden marker as vis(3) wasn't setting it
and it clobbered VIS_SHELL | VIS_CSTYLE.
 1.42 26-Sep-2014  roy Decode any printable characters encoded with VIS_CSTYLE so
unvis(3) works with vis.c r1.25
 1.41 15-Dec-2012  matt Since the struct is const, no reason for the name member to be const.
 1.40 14-Dec-2012  christos Reduce the number of relative relocation by allocating space in the
structure directly (Jilles Tjoelker @ FreeBSD)
 1.39 13-Mar-2012  christos branches: 1.39.2;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.38 18-Nov-2011  christos initialize t to protect against empty string (Kamil Dudka)
 1.37 06-Nov-2011  christos handle \x sequences like c does
 1.36 18-Mar-2011  martin branches: 1.36.4;
Test the proper array index. Discovered by sparc64 automatic test runs.
 1.35 13-Mar-2011  mrg cast "~0" to (size_t) when passing to a size_t taking function.
fixes lint build errors.
 1.34 12-Mar-2011  christos Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
 1.33 27-Feb-2011  christos Add <stdint.h> for uint8_t from Jess Thrysoee
 1.32 27-Nov-2010  christos branches: 1.32.2;
fix lint warning.
 1.31 27-Nov-2010  christos Implement VIS_NOESCAPE and VIS_HTTP1866.
 1.30 11-Feb-2009  christos remove debugging. pointed by enami
 1.29 10-Feb-2009  christos Add RFC 2045 MIME Quoted-Printable support.
 1.28 13-Sep-2005  christos branches: 1.28.30;
compat core reorg.
 1.27 16-May-2005  lukem More whitespace consistency tweaks
 1.26 16-May-2005  lukem Whitespace consistency fixes.
 1.25 19-Apr-2005  rillig Converted all arguments for the <ctype.h> functions to (unsigned char).
Fixes PR 21165. Approved by christos.
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 03-Jul-2002  pooka adapt for vis()/svis() check separation
 1.22 23-Mar-2002  christos - Add VIS_HTTPSTYLE from FreeBSD.
- svis, strsvis, strsvisx were not reversible, because they did not encode
\\ unless it was passed in the extras array.
- Fix documentation to match the proper signature of the functions.
 1.21 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.20 29-Jan-2002  tv Add hooks to allow compiling for non-NetBSD hosts.
 1.19 22-Jan-2000  mycroft branches: 1.19.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.18 07-Dec-1999  wennmach Back out last change; now vis takes care not to produce ambigous
encodings.
 1.17 01-Dec-1999  wennmach Make unvis and strunvis grok strings produced by svis et al.
 1.16 20-Sep-1999  lukem branches: 1.16.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.15 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.14 02-Dec-1998  thorpej Warn about references to the compatibility unvis(), and direct the user to
include <vis.h> to generate the correct reference.
 1.13 13-Nov-1998  christos delint
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 22-Oct-1997  thorpej Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.10 22-Oct-1997  fvdl New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.
 1.9 20-Oct-1997  thorpej branches: 1.9.2;
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.8 16-Oct-1997  christos change second argument of unvis from char to int
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix gcc warning
Fix RCSID's
 1.5 25-Feb-1995  cgd branches: 1.5.4;
fix prototype that i botched.
 1.4 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.2.1 22-Oct-1997  thorpej Pull up from trunk:

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.
 1.16.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.19.6.3 25-Apr-2002  nathanw Catch up to -current.
 1.19.6.2 22-Mar-2002  nathanw Catch up to -current.
 1.19.6.1 08-Mar-2002  nathanw Catch up to -current.
 1.28.30.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.32.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.36.4.3 23-Jan-2013  yamt sync with head
 1.36.4.2 17-Apr-2012  yamt sync with head
 1.36.4.1 10-Nov-2011  yamt sync with head
 1.39.2.1 25-Feb-2013  tls resync with head
 1.22 15-May-2024  riastradh usleep(3): Note the historical rake that was stepped upon.

PR 58184
 1.21 22-Apr-2024  jdolecek it's nanosleep(2), not nanosleep(3)
 1.20 22-Apr-2024  jdolecek allow usleep(3) with useconds >= 1000000

update manpage to mention this interface is obsolete, remove
EINVAL from the ERRORS and mention EINTR instead.

PR lib/58184 by Taylor R Campbell
 1.19 29-Apr-2010  jruoho branches: 1.19.56;
No more usleep(3) in POSIX; "use nanosleep(2) instead".
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.16 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.15 04-Sep-2002  wiz completion, not completition; mark up errno; use \- instead of -.
 1.14 07-Feb-2002  ross Generate <>& symbolically.
 1.13 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.12 16-Sep-2001  wiz Boring whitespace fixes.
 1.11 21-Aug-2000  soren branches: 1.11.2;
Typo.
 1.10 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 24-Nov-1997  kleink Per XPG4.2:
* Change argument to type useconds_t, return an int.
* If an interval of 1,000,000 or more microseconds was requested, fail with
-1/EINVAL.
 1.7 02-Nov-1997  mycroft s/u_int/unsigned int/
 1.6 20-Sep-1997  mikel crib text from sleep(3) to document response to signals; fixes PR 4008
 1.5 19-Jul-1997  jtc Implement sleep() and usleep() in terms of nanosleep(). Uses only one
syscall instead of eight, and doesn't have any interactions with alarm
or interval timers.
 1.4 12-May-1997  mikel xref sigsuspend(2), not obsolete sigpause(2).
 1.3 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.11.2.4 17-Sep-2002  nathanw Catch up to -current.
 1.11.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.11.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.11.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.19.56.2 20-Jul-2024  martin Pull up following revision(s) (requested by rin in ticket #751):

lib/libc/gen/usleep.3: revision 1.22

usleep(3): Note the historical rake that was stepped upon.
PR 58184
 1.19.56.1 28-Apr-2024  martin Pull up following revision(s) (requested by jdolecek in ticket #678):

lib/libc/gen/usleep.c: revision 1.21
lib/libc/gen/usleep.3: revision 1.20
lib/libc/gen/usleep.3: revision 1.21

allow usleep(3) with useconds >= 1000000

update manpage to mention this interface is obsolete, remove
EINVAL from the ERRORS and mention EINTR instead.

PR lib/58184 by Taylor R Campbell

it's nanosleep(2), not nanosleep(3)
 1.21 22-Apr-2024  jdolecek allow usleep(3) with useconds >= 1000000

update manpage to mention this interface is obsolete, remove
EINVAL from the ERRORS and mention EINTR instead.

PR lib/58184 by Taylor R Campbell
 1.20 25-Jun-2012  abs branches: 1.20.42;
Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.19 28-Apr-2008  martin branches: 1.19.4; 1.19.8;
Remove clause 3 and 4 from TNF licenses
 1.18 08-Oct-2006  elad branches: 1.18.16;
PR/19444: IIMURA Takuji: usleep(0); seems to microsleep(1);

Patch applied, thanks!
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 24-Nov-1997  kleink Per XPG4.2:
* Change argument to type useconds_t, return an int.
* If an interval of 1,000,000 or more microseconds was requested, fail with
-1/EINVAL.
 1.15 19-Aug-1997  mikel fix overflow problem found by Rick Byers <rickb@iaw.on.ca>; fix by
<entropy@tardis.bernstein.com> in PR lib/4005.
 1.14 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.13 19-Jul-1997  kleink __RCSID() police; from jbernard@tater.mines.edu in PR lib/3890.
 1.12 19-Jul-1997  jtc Implement sleep() and usleep() in terms of nanosleep(). Uses only one
syscall instead of eight, and doesn't have any interactions with alarm
or interval timers.
 1.11 13-Jul-1997  christos Add prototype for sleephandler
Fix RCSID's
 1.10 26-Oct-1995  pk branches: 1.10.2;
Eliminate race by stopping timer before restarting it with remaining time
(one more system call).
 1.9 20-Oct-1995  pk Eliminate race in the "normal" case of not being interrupted by another signal.
 1.8 16-Oct-1995  pk 1) Turn off timer before resetting signal disposition.
2) Set signal mask before signal action, to avoid held SIGALRMs
bursting in after unsetting the handler.
 1.7 03-May-1995  mycroft branches: 1.7.2;
Explicitly unblock SIGALRM while waiting.
 1.6 21-Mar-1995  mycroft Clone from sleep(), with the logic for returning a value removed.
 1.5 28-Feb-1995  jtc Changed <sys/signal.h> to <signal.h>
 1.4 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 26-Apr-1995  jtc #include "namespace.h" where appropriate.
 1.7.2.2 26-Oct-1995  pk Eliminate race by stopping timer before restarting it with remaining time
(one more system call).
 1.7.2.1 20-Oct-1995  pk Update from trunk: race conditions.
 1.10.2.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.18.16.1 18-May-2008  yamt sync with head.
 1.19.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.19.8.1 28-Apr-2008  martin file usleep.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.19.4.1 30-Oct-2012  yamt sync with head
 1.20.42.1 28-Apr-2024  martin Pull up following revision(s) (requested by jdolecek in ticket #678):

lib/libc/gen/usleep.c: revision 1.21
lib/libc/gen/usleep.3: revision 1.20
lib/libc/gen/usleep.3: revision 1.21

allow usleep(3) with useconds >= 1000000

update manpage to mention this interface is obsolete, remove
EINVAL from the ERRORS and mention EINTR instead.

PR lib/58184 by Taylor R Campbell

it's nanosleep(2), not nanosleep(3)
 1.22 19-Oct-2014  njoly Do not use hard-coded values with ENAMETOOLONG, use symbolic constants
instead.
 1.21 29-Apr-2010  jruoho Note that also POSIX has deprecated utime(3).
 1.20 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.17 01-Oct-2002  wiz \-1 and .Dv NULL.
 1.16 29-Apr-2002  simonb Remove <sys/types.h> from synopsis, as per latest SUS/Posix specs.
 1.15 07-Feb-2002  ross Generate <>& symbolically.
 1.14 22-Mar-1999  garbled branches: 1.14.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.13 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.12 28-Apr-1998  fair Fix mdoc .Xr reference for syntax or correctness (e.g. exec(2) versus exec(3)).
Make other mdoc corrections as inspection dictated.
 1.11 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.10 05-Feb-1998  perry add LIBRARY section to man page
 1.9 09-Sep-1997  jtc Changed order of STANDARDS and HISTORY subheads to conform with
specification in mdoc(7).
 1.8 14-Jul-1997  kleink Add missing `STANDARDS' compliance statements. As we #define _POSIX_VERSION
to 199009L, bump existing statements to 1003.1-1990.
 1.7 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.6 05-Oct-1993  jtc Add #include <utime.h> to SYNOPSIS.
 1.5 16-Aug-1993  jtc Add STANDARDS section, utime is now 1003.1 compliant.
 1.4 14-Aug-1993  jtc Merged in RETURN VALUES and ERRORS sections from utimes(2), since
utime(3) is just a wrapper.
 1.3 13-Aug-1993  jtc If utimbuf pointer is NULL, set access and modification times to the
current time.
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14.12.4 18-Oct-2002  nathanw Catch up to -current.
 1.14.12.3 21-Jun-2002  nathanw Catch up to -current.
 1.14.12.2 22-Mar-2002  nathanw Catch up to -current.
 1.14.12.1 08-Mar-2002  nathanw Catch up to -current.
 1.14 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.13 23-Mar-2010  drochner branches: 1.13.6;
remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 30-Mar-1998  kleink Need <stddef.h> for NULL definition.
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 25-Feb-1995  cgd branches: 1.5.4;
merge with Lite, keep local changes. clean up id usage
 1.4 26-Aug-1993  jtc branches: 1.4.4;
Declare rcsid strings so they are stored in text segment.
 1.3 13-Aug-1993  jtc If utimbuf pointer is NULL, set access and modification times to the
current time.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 02-May-1995  jtc #include "namespace.h"
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.13.6.1 30-Oct-2012  yamt sync with head
 1.3 01-Aug-2023  mrg fix simple mis-matched function prototype and definitions.

most of these are like, eg

void foo(int[2]);

with either of these

void foo(int*) { ... }
void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
 1.2 16-Sep-2019  kamil Remove _INCOMPLETE_XOPEN_C063, no longer needed
 1.1 03-Nov-2012  christos branches: 1.1.2; 1.1.4; 1.1.34;
add utimens and lutimens wrappers using utimensat.
 1.1.34.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.1.4.1 03-Nov-2012  yamt file utimens.c was added on branch yamt-pagecache on 2013-01-16 05:32:24 +0000
 1.1.2.2 03-Nov-2012  christos add utimens and lutimens wrappers using utimensat.
 1.1.2.1 03-Nov-2012  christos file utimens.c was added on branch tls-maxphys on 2012-11-03 19:39:22 +0000
 1.10 15-Oct-2011  christos close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.9 05-Feb-2009  lukem sign-compare fix
 1.8 11-Jan-2009  christos merge christos-time_t
 1.7 28-Apr-2008  martin branches: 1.7.8;
Remove clause 3 and 4 from TNF licenses
 1.6 09-May-2004  kleink branches: 1.6.24;
Need namespace.h for internal names of fseeko, strlcpy.
 1.5 17-Nov-2002  itojun branches: 1.5.2;
make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.4 01-Aug-2002  nathanw #include <string.h> for prototypes of strlen and strcpy.
 1.3 28-Jul-2002  christos branches: 1.3.2;
add utmpname()
 1.2 28-Jul-2002  christos make this behave like utmp, ie. return all entries and setutent() rewinds.
 1.1 27-Jul-2002  christos Add utmp processing functions
 1.3.2.4 10-Dec-2002  thorpej Sync with HEAD.
 1.3.2.3 13-Aug-2002  nathanw Catch up to -current.
 1.3.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.3.2.1 28-Jul-2002  nathanw file utmp.c was added on branch nathanw_sa on 2002-08-01 03:28:12 +0000
 1.5.2.1 11-May-2004  tron Pull up revision 1.6 (requested by kleink in ticket #294):
Need namespace.h for internal names of fseeko, strlcpy.
 1.6.24.1 18-May-2008  yamt sync with head.
 1.7.8.2 23-Nov-2008  christos fix utmp{,x} issues:
- add old utmp format support. Ugly and difficult to get right. For now
try to deal by detecting the size of the file and seeing if it is a
multiple of sizeof(struct utmp50).
- fix NULL pointer in cvt.
- version the UTMPX database, and detect if we have an old or new one
and act accordingly.
 1.7.8.1 28-Apr-2008  christos file utmp.c was added on branch christos-time_t on 2008-11-23 21:46:05 +0000
 1.35 23-May-2015  christos use VIS_NOLOCALE
 1.34 23-May-2015  mlelstv strvisx is used here to encode binary data, but the encoding
depends on locale settings and the result might not be accepted
or even misinterpreted by the strunvis decoder. As a workaround
encode manually as a string of octal numbers.

strvisx should learn how enforce such an encoding by itself.
 1.33 05-Feb-2015  christos fix incorrect type
 1.32 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.31 05-Sep-2013  pooka Avoid strict-alias problem flagged by certain compilers (e.g. Centos one):
libc/gen/utmpx.c:89: error: dereferencing pointer 'otv' does break strict-aliasing rules

reviewed by Christos (thanks!)
 1.30 24-Jun-2012  christos branches: 1.30.2;
fix old style definitions; XXX: gcc should have picked them up but it did not.
 1.29 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.28 15-Oct-2011  christos branches: 1.28.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.27 17-Sep-2011  christos Never invoke utmp_update() recursively if we are root. Instead close the
read-only file so it can be opened later. It can happen when a setuid
program utmp_update, seteuid(ruid) -> getutxent() -> seteuid(0) -> pututxent()
 1.26 11-Jan-2009  christos merge christos-time_t
 1.25 28-Apr-2008  martin branches: 1.25.8;
Remove clause 3 and 4 from TNF licenses
 1.24 26-Nov-2006  christos branches: 1.24.16;
PR/35129: David A. Holland: exit in utmpx code should be _exit
 1.23 13-Sep-2005  christos compat core reorg.
 1.22 11-Nov-2004  christos Don't create the lastlogx file with 0 mode.
 1.21 06-Sep-2003  wiz Add __warn_references for deprecated lastlogxname. Okayed by christos.
 1.20 26-Aug-2003  wiz Make getlastlogx have the pathname to the lastlogx database as first
argument, to be consistent with updlastlogx.

Approved by christos, reviewed by kleink.

[The lastlogxname function should not be used any longer.]
 1.19 25-Aug-2003  matt When updating wtmpx, if the write fails make sure to close the file (to
release the lock held on it). Use O_SHLOCK when adding just one record
since O_APPEND will enforce the atomicity that is required.
 1.18 24-Aug-2003  kleink Need namespace.h to generate references to internal names.
 1.17 26-Feb-2003  christos keep track if we have the file opened as readonly or readwrite, so that
we don't need to call update_utmp, if our euid has changed, but we still
have a write reference to the file. Solves problem with chrooting processes.
 1.16 26-Nov-2002  christos lib/19176: Onno van der Linden: execl is called with too few arguments.
 1.15 17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.14 25-Oct-2002  wiz Add some _DIAGASSERTS(). Ok'd by christos.
 1.13 28-Sep-2002  christos fix typo
 1.12 28-Sep-2002  christos check for write and close errors, from wiz
 1.11 26-Sep-2002  wiz Move comment that says 'the following are extensions' to the right place.
Approved by christos.
 1.10 28-Jul-2002  christos use the fname we passed in.
 1.9 27-Jul-2002  christos add lastlogx implementation.
 1.8 27-Jul-2002  christos reset fp when we are done with it.
 1.7 23-Jul-2002  simonb Sprinkle some KNF.
 1.6 15-Apr-2002  christos - open for r+, then w+, then r.
- fix fread and fwrite error checking.
 1.5 04-Apr-2002  christos add two more gnu-like functions.
 1.4 11-Mar-2002  simonb Include <stdlib.h> for exit() prototype.
 1.3 05-Mar-2002  christos branches: 1.3.2;
add updwtmpx(); requested by tron.
 1.2 25-Feb-2002  christos catch up with ut_name->ut_user change
 1.1 22-Feb-2002  christos A simple utmpx implementation. Nothing uses it yet.
TODO: write the lastlog*() stuff.
 1.3.2.8 10-Dec-2002  thorpej Sync with HEAD.
 1.3.2.7 11-Nov-2002  nathanw Catch up to -current
 1.3.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.5 02-Aug-2002  thorpej Add missing <stdlib.h> -- must have been a merge botch.
 1.3.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.3.2.3 25-Apr-2002  nathanw Catch up to -current.
 1.3.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.3.2.1 05-Mar-2002  nathanw file utmpx.c was added on branch nathanw_sa on 2002-03-08 21:35:20 +0000
 1.24.16.1 18-May-2008  yamt sync with head.
 1.25.8.4 23-Nov-2008  christos remove debugging printf.
 1.25.8.3 23-Nov-2008  christos fix utmp{,x} issues:
- add old utmp format support. Ugly and difficult to get right. For now
try to deal by detecting the size of the file and seeing if it is a
multiple of sizeof(struct utmp50).
- fix NULL pointer in cvt.
- version the UTMPX database, and detect if we have an old or new one
and act accordingly.
 1.25.8.2 08-Nov-2008  christos time_t changes
 1.25.8.1 28-Apr-2008  christos file utmpx.c was added on branch christos-time_t on 2008-11-08 21:45:38 +0000
 1.28.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.28.2.2 30-Oct-2012  yamt sync with head
 1.28.2.1 17-Apr-2012  yamt sync with head
 1.30.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14 08-May-2010  wiz Remove double quotes around missing function in BUGS section.
 1.13 06-May-2010  jruoho Small markup improvements.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 01-Jun-1998  kleink Prototype has moved: change inclusion of <unistd.h> to <stdlib.h> in the
synopsis of valloc().
 1.6 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.5 12-Feb-1998  kleink Sync prototype with <unistd.h> (which DTRT all the time).
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.11 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.10 07-Aug-2003  agc branches: 1.10.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 27-Feb-1998  perry trivial changes to quiet lint.
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
 1.5 25-Feb-1995  cgd branches: 1.5.4;
merge with Lite, keep local changes. clean up id usage
 1.4 19-Oct-1994  cgd beware cast & variable types.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.10.56.1 30-Oct-2012  yamt sync with head
 1.16 16-Jan-2014  christos Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.15 17-Jul-2011  joerg branches: 1.15.2; 1.15.8;
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.14 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.13 13-Sep-2005  christos compat core reorg.
 1.12 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.9 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.8 28-Jan-2002  tv Fix previous to actually include config.h.
 1.7 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.6 19-Feb-2001  cgd branches: 1.6.2;
convert from __progname to getprogname()
 1.5 30-Dec-2000  martin Be consistent with argument types vs. prototype; use _BSD_VA_LIST_ as
the argument, instead of va_list. Might not make a difference on most
ports, depending on toolchain/MD typedefs. Does make a difference on sparc64,
where it wouldn't compile otherwise.
 1.4 17-Aug-1999  mycroft Make some needed weak aliases.
 1.3 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.2 13-Jul-1997  christos Fix RCSID's
Use "namespace.h"
 1.1 15-Apr-1996  jtc branches: 1.1.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.1.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.6.2.3 21-Jun-2002  nathanw Catch up to -current.
 1.6.2.2 22-Mar-2002  nathanw Catch up to -current.
 1.6.2.1 08-Mar-2002  nathanw Catch up to -current.
 1.15.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.2.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.3 06-Jun-2014  joerg branches: 1.3.4;
Fix conditionals.
 1.2 06-Jun-2014  christos be friendlier to nbcompat
 1.1 16-Jan-2014  christos branches: 1.1.2; 1.1.4;
Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.1.4.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.4.1 16-Jan-2014  yamt file verrc.c was added on branch yamt-pagecache on 2014-05-22 11:36:52 +0000
 1.1.2.1 10-Aug-2014  tls Rebase.
 1.3.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.4.1 06-Jun-2014  tls file verrc.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.15 17-Jul-2011  joerg 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.14 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.13 13-Sep-2005  christos compat core reorg.
 1.12 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.9 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.8 28-Jan-2002  tv Fix previous to actually include config.h.
 1.7 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.6 19-Feb-2001  cgd branches: 1.6.2;
convert from __progname to getprogname()
 1.5 30-Dec-2000  martin Be consistent with argument types vs. prototype; use _BSD_VA_LIST_ as
the argument, instead of va_list. Might not make a difference on most
ports, depending on toolchain/MD typedefs. Does make a difference on sparc64,
where it wouldn't compile otherwise.
 1.4 17-Aug-1999  mycroft Make some needed weak aliases.
 1.3 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.2 13-Jul-1997  christos Fix RCSID's
Use "namespace.h"
 1.1 15-Apr-1996  jtc branches: 1.1.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.1.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.6.2.3 21-Jun-2002  nathanw Catch up to -current.
 1.6.2.2 22-Mar-2002  nathanw Catch up to -current.
 1.6.2.1 08-Mar-2002  nathanw Catch up to -current.
 1.50 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.49 05-Aug-2017  wiz Remove superfluous Pp.
 1.48 04-Aug-2017  ginsbach There are more than four types of encoding. The combination of
VIS_CSTYLE | VIS_OCTAL is different from either separately.
 1.47 23-Apr-2017  christos fix typo (Leonardo Taccari)
 1.46 23-Apr-2017  christos Add VIS_DQ (for OpenBSD compat)
 1.45 08-Jun-2016  wiz branches: 1.45.2;
Fix typo. From Kurt Jaeger via Brooks Davis and FreeBSD.
 1.44 14-Jan-2016  christos add stravis(3) from OpenBSD
 1.43 23-May-2015  christos Add VIS_NOLOCALE to avoid ambiguous conversions.
 1.42 26-Sep-2014  wiz Simplify even more.
 1.41 26-Sep-2014  wiz Simplify/fix macro usage. Bump date for previous.
 1.40 26-Sep-2014  christos add VIS_META/VIS_SHELL support to encode all shell metacharacters.
XXX: /etc/rc.d/wizd fix $
 1.39 20-Feb-2013  christos we don't have multibyte.3 (yet)
 1.38 20-Feb-2013  wiz Sort SEE ALSO.
XXX: multibyte(3) is dangling.
 1.37 20-Feb-2013  christos More fixes from J.R. Oldroyd. We introduce a new function that can
retrieve and return if there has been a conversion error, so that
it can keep performing char-by-char processing if a multi-byte
conversion occurred. Also some more code cleanups in the "extra"
processing.
 1.36 13-Feb-2013  wiz Mark up LC_CTYPE as environment variable.
 1.35 13-Feb-2013  christos multi-byte doc from J.R. Oldroyd
 1.34 15-Dec-2012  wiz Add article.
 1.33 15-Dec-2012  uwe Add RFC 2045 (for VIS_MIMESTYLE) to "SEE ALSO".
Use space between "RFC" and the number.
 1.32 15-Dec-2012  uwe Misc formatting fixes.
 1.31 15-Dec-2012  uwe Typos: fix -> fit; length size -> size.
 1.30 15-Dec-2012  uwe Fix pasto: VIS_MIMESTYLE produces =XX, not %XX
 1.29 14-Dec-2012  christos fix pasto (Brooks Davies)
 1.28 14-Dec-2012  christos Add VIS_GLOB (Brooks Davies)
 1.27 17-May-2011  joerg branches: 1.27.4; 1.27.10;
Trailing white space
 1.26 17-May-2011  enami Use Pq or Po macro for better output rather than putting raw open paren
at the end of line.
 1.25 13-Mar-2011  wiz Add serial comma, quote minus, fix NetBSD version in HISTORY.
 1.24 12-Mar-2011  christos Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
 1.23 10-Feb-2009  christos Add RFC 2045 MIME Quoted-Printable support.
 1.22 09-Apr-2006  jschauma branches: 1.22.30;
document that VIS_CSTYLE encodes space (SP 040) as '\s'.
 1.21 25-Jan-2006  rillig The VIS_HTTPSTYLE does not use $ for encoding special characters, but %.
 1.20 15-Jan-2005  lukem Reference RFC1738 instead of RFC1808 for '%xx' encoding.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.17 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.16 23-Mar-2002  christos - Add VIS_HTTPSTYLE from FreeBSD.
- svis, strsvis, strsvisx were not reversible, because they did not encode
\\ unless it was passed in the extras array.
- Fix documentation to match the proper signature of the functions.
 1.15 07-Feb-2002  ross Generate <>& symbolically.
 1.14 16-Sep-2001  wiz Standardize section headers, sort sections, sort SEE ALSO, punctuation
and misc. fixes.
 1.13 05-Jun-2001  wiz Whitespace fixes, punctuation fix, NetBSD -> Nx.
 1.12 25-Nov-1999  wennmach branches: 1.12.6;
Added description of svis, strsvis, strsvisx.

Fixed several minor errors concerning vis, strvis, strvisx, tyops.
 1.11 24-Mar-1999  mycroft branches: 1.11.6;
Remove blank lines.
 1.10 05-Feb-1998  perry add LIBRARY section to man page
 1.9 03-Feb-1998  perry .Bx'ize
 1.8 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.7 23-Apr-1996  scottr branches: 1.7.8;
comprised -> composed. Closes PR 2345.
 1.6 25-Feb-1995  cgd merge with Lite, keep local changes. clean up id usage
 1.5 09-Apr-1994  mycroft There's a big difference between NULL and NUL.
 1.4 10-Jan-1994  jtc Fix spelling errors.
 1.3 04-Oct-1993  jtc Consistantly cross reference the other functions/programs in the vis/unvis
"family".
 1.2 30-Jul-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.8.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.11.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.6.5 18-Oct-2002  nathanw Catch up to -current.
 1.12.6.4 25-Apr-2002  nathanw Catch up to -current.
 1.12.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.12.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.12.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.22.30.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.27.10.1 25-Feb-2013  tls resync with head
 1.27.4.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.27.4.1 23-Jan-2013  yamt sync with head
 1.45.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.88 17-Mar-2024  andvar Add missing "e" in few words, in comments and one log message.
 1.87 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.86 13-Aug-2023  riastradh vis(3): Per KNF, sys/param.h comes before sys/types.h.

Which is nice because that's also lexicographic.
 1.85 13-Aug-2023  riastradh vis(3): Need <stdint.h> for SIZE_MAX, per C standard.

From Kyle Evans <kevans@FreeBSD.org>.

Followup to PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.84 13-Aug-2023  riastradh vis(3): Sort includes. No functional change intended.

Prompted by PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.83 12-Aug-2023  riastradh vis(3): Fix one more buffer overrun in an edge case.

PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.82 12-Aug-2023  riastradh vis(3): Fix main part of PR lib/57573.

From Kyle Evans <kevans@FreeBSD.org>.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.81 12-Aug-2023  riastradh vis(3): Avoid potential arithmetic overflow in maxolen.

Can't easily prove that this overflow is impossible, so let's add a
check.

Prompted by PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.80 12-Aug-2023  riastradh vis(3): Call wcslen(start) only once.

It had better not change between these two times!

Prompted by PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.79 12-Aug-2023  riastradh vis(3): Avoid arithmetic overflow before calloc(3).

Prompted by PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.78 12-Aug-2023  riastradh vis(3): Make mbslength unsigned.

Sprinkle assertions and comments justifying the proposition that it
would never go negative if signed.

Obviates need to worry about mblength > SSIZE_MAX.

Prompted by PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.77 12-Aug-2023  riastradh vis(3): Make maxolen unsigned size_t, not ssize_t.

It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too. So there appears to have never been any reason for this to be
signed.

Part of PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.76 29-Jun-2023  riastradh vis(3): Avoid nonportable MIN in portable code.
 1.75 18-Jun-2021  christos branches: 1.75.2;
PR/56260: Alex Richardson: Out-of-bounds stack read in lib/libc/gen/vis.c
Also sync with other FreeBSD changes.
 1.74 27-Nov-2017  christos branches: 1.74.6;
Use 16x instead of 4x the amount of space since each wint_t can result in
4 bytes of 4 characters ("\ooo") each.
 1.73 23-Apr-2017  christos branches: 1.73.4;
Add VIS_DQ (for OpenBSD compat)
 1.72 12-Feb-2017  christos fix off-by-one, found by asan.
 1.71 14-Jan-2016  christos branches: 1.71.2; 1.71.4;
add stravis(3) from OpenBSD
 1.70 26-May-2015  christos use isgraph_l suggested by joerg@
 1.69 23-May-2015  christos fix the tools build.
 1.68 23-May-2015  christos Grr need to deal with isgraph(3). Is there a better way?
 1.67 23-May-2015  christos Add VIS_NOLOCALE to avoid ambiguous conversions.
 1.66 26-Sep-2014  roy Cannot encode \$ in VIS_CSTYLE as that looks like `vis -l` encoding.
 1.65 26-Sep-2014  roy Don't encode any characters in VIS_CSTYLE that have a special meaning
in unvis(3), such as n r b, etc.
 1.64 26-Sep-2014  christos no c99 for tools.
 1.63 26-Sep-2014  christos add VIS_META/VIS_SHELL support to encode all shell metacharacters.
XXX: /etc/rc.d/wizd fix $
 1.62 08-Sep-2014  christos get rid of MB_STRZ as suggested by joerg.
 1.61 08-Sep-2014  christos PR/49185: Conrad Meyer: strvisx: Handle zero-length input strings gracefully.
(don't abuse 0 to mean compute string length internally)
 1.60 21-Feb-2013  joerg No ctassert in tool build
 1.59 20-Feb-2013  christos Minor nits, and make it compile in FreeBSD (NBBY needs sys/params.h)
 1.58 20-Feb-2013  tron Don't declare a variable inside a "for" construct because it breaks the
tool build which doesn't use C99.
 1.57 20-Feb-2013  christos Make the masks 64 bit wide so that they fit 6 character wide conversions.
Explain what's wrong with MB_LEN_MAX currently.
 1.56 20-Feb-2013  riz Initialize 'clen' to 0, to avoid "may be used uninitialized" warning.
 1.55 20-Feb-2013  christos Fix whitespace
 1.54 20-Feb-2013  christos More fixes from J.R. Oldroyd. We introduce a new function that can
retrieve and return if there has been a conversion error, so that
it can keep performing char-by-char processing if a multi-byte
conversion occurred. Also some more code cleanups in the "extra"
processing.
 1.53 15-Feb-2013  christos More fixes from: J.R. Oldroyd
- The input loop control that I changed yesterday to:
while (mbslength >= 0) {
There are circumstances where this causes an extra \000 to
be added at the end of some tests. This error was showing
in my own tests here, but I did not notice it yesterday.
(I really need to add my tests to the test suite, catching
every error by eye is hard.) To fix, I've now changed the
code to increment mbslength only if mbslength == 1 to start
with. (Note that this check for "== 1" is why the arg to
strvisx() in vis(1) must be 1, not mbilen.)

- The cast sequence when manually inserting bytes after a
multibyte conversion error:
*src = (wint_t)(u_char)*mbsrc;
is wrong. This is causing problems in the case when an
8859-1 input string is processed in the UTF-8 locale.
It needs to be:
*src = (wint_t)*mbsrc;
Without the (u_char) all the locale mismatch combinations
then work.

- The code:
if (mblength < len)
len = mblength;
needs to be there. It resets len for the single character
input case after we've actually processed two input
characters (c and nextc) because we incremented mbslength
at the start of the loop. Without this code, single
character conversions end up with a \000 or other byte
appended.
 1.52 14-Feb-2013  christos off by one.
 1.51 13-Feb-2013  christos remove patch botches.
 1.50 13-Feb-2013  christos Fix from J.R. Oldroyd for wide chars > 2
 1.49 13-Feb-2013  christos Handle invalid character sequences.
 1.48 13-Feb-2013  pooka Match prototype with reality to fix tool build on platforms where
wint_t != int.
 1.47 13-Feb-2013  christos explain we we want wide character support here.
 1.46 13-Feb-2013  christos Wide char support from J.R. Oldroyd
 1.45 14-Dec-2012  christos Add VIS_GLOB (Brooks Davies)
 1.44 12-Mar-2011  christos branches: 1.44.4; 1.44.10;
Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
 1.43 12-Mar-2011  christos avoid c99
 1.42 12-Mar-2011  christos Prepare for strnvis functionality by providing a length to the encoding
functions.
 1.41 23-Nov-2009  plunky fix VIS_HTTPSTYLE to not convert "safe" ($-_.+) and "extra" (!*'(),)
characters as mentioned in rfc1738 and rfc1808 and, I think intended
all along in this code but the logic was inverted.

Don't use strchr as it also matches the NUL character which we want
to escape, just compare against the chars directly as done in the
FreeBSD code.
 1.40 11-Feb-2009  christos fix typo * -> & from enami.
 1.39 10-Feb-2009  christos Add RFC 2045 MIME Quoted-Printable support.
 1.38 04-Sep-2008  lukem branches: 1.38.6; 1.38.8;
In strsvisx(), don't attempt to read the "next" character past the end
of the provided length.
 1.37 25-Jul-2008  dsl Change the gross #defines HVIS and SVIS into local functions.
 1.36 29-Apr-2008  martin branches: 1.36.2;
Convert to new 2 clause license
 1.35 28-Aug-2006  christos branches: 1.35.16;
Remove ad clause. Approved by board@
 1.34 18-Nov-2005  martin Make the MAKEEXTRALIST macro safe to be called with string literals as
third argument - the old version relies on the compiler to use the same
address for identical strings.

Spotted by segv at netctl dot net in libnbcompat context, details
in PR pkg/32097.
 1.33 28-May-2005  lukem convert to ANSI prototypes. some KNF
 1.32 28-May-2005  lukem missed a free(3) in previous
 1.31 28-May-2005  lukem Use malloc(3) instead of the non-standard alloca(3) in MAKEEXTRALIST(),
check the return value of malloc(3) and return "" (or equiv) upon failure,
and free the result of the malloc(3).
 1.30 20-May-2005  lukem Use a more standard TNF license (than one that has clause 3 for UCB
& refers to "THE REGENTS").
Confirmed with Lex, who added it.
 1.29 16-May-2005  lukem Remove clause 3 from the UCB license.

XXX: the separate TNF copyright block should be converted to a standard TNF one
 1.28 17-Apr-2005  christos PR/21165: Christian Biere: ctype function misuse
 1.27 26-Feb-2004  enami Fix indent and other whitespace usage.
 1.26 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.25 16-Jul-2003  dsl If VIS_CSTYLE is specified, use \ to escape any printable characters
(especially \ itself, and anything else in 'extra').
Fix strvis() and strvisx() to pass 0..255 to isgraph() etc.
 1.24 03-Jul-2002  pooka adapt for vis()/svis() check separation
 1.23 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.22 23-Mar-2002  christos - Add VIS_HTTPSTYLE from FreeBSD.
- svis, strsvis, strsvisx were not reversible, because they did not encode
\\ unless it was passed in the extras array.
- Fix documentation to match the proper signature of the functions.
 1.21 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.20 21-Jan-2002  tv Add hooks for reachover builds from src/tools/compat.
 1.19 22-Jan-2000  mycroft branches: 1.19.6;
Delint.
 1.18 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.17 07-Dec-1999  wennmach In SVIS, encode all characters on the extra list either in C-style
fashion (if possible) or as octal representation (else).
 1.16 28-Nov-1999  wennmach Suggested by christos:
o unexpand spaces to tabs
o don't initialize non-static array extra[]; \0 terminate extra[]
using an explicit assignment instead
 1.15 25-Nov-1999  wennmach Added new functions

char *
svis(char *dst, int c, int flag, int nextc, const char *extra);

int
strsvis(char *dst, const char *src, int flag, const char *extra);

int
strsvisx(char *dst, const char *src, size_t len, int flag,
const char *extra);

These functions correspond to vis(), strvis(), and strvisx() but have an
additional argument extra, pointing to a NUL terminated list of characters.
These characters will be copied encoded or backslash-escaped into dst. These
functions are useful e. g. to remove the special meaning of certain
characters to shells.

To implement the new functions, vis underwent a major rewrite. Most functions
now use a central macro, SVIS. Performance increase ~ factor 2.

Reviewed by Christos.
 1.14 17-Nov-1999  wennmach Add some casts to u_char to get vis working again for characters > 0177
in VIS_OCTAL mode. Also, change the mask for the most significant tribble
to 03.

Reviewed by christos.

Fixes PR 8802.
 1.13 20-Sep-1999  lukem branches: 1.13.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.12 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.11 13-Nov-1998  christos branches: 1.11.2;
delint
 1.10 13-Nov-1998  christos delint
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.6 25-Feb-1995  cgd branches: 1.6.4;
merge with Lite, keep local changes. clean up id usage
 1.5 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.4 03-Aug-1993  mycroft I'm really mad now. Not only did this `new' version have exactly the same
bugs as the `old' one, but it was almost identical!
 1.3 30-Jul-1993  mycroft Latest versions from uunet.
 1.2 15-Jul-1993  cgd (1) compare against UCHAR_MAX, don't use isascii().
(2) strvis() didn't work on 0-length input strings
(3) strvisx() didn't work at all
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.11.2.1 20-Nov-1999  he Pull up revision 1.14 (requested by wennmach):
Add some casts to u_char to get vis working again for characters
> 0177 in VIS_OCTAL mode. Also, change the mask for the most
significant tribble to 03. Fixes PR#8802.
 1.13.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.6.7 01-Aug-2002  nathanw Catch up to -current.
 1.19.6.6 21-Jun-2002  nathanw Catch up to -current.
 1.19.6.5 25-Apr-2002  nathanw Catch up to -current.
 1.19.6.4 22-Mar-2002  nathanw Correct merge botch.
 1.19.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.19.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.19.6.1 28-Jan-2002  nathanw Catch up to -current.
 1.35.16.1 18-May-2008  yamt sync with head.
 1.36.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.38.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.38.6.2 04-Sep-2008  lukem In strsvisx(), don't attempt to read the "next" character past the end
of the provided length.
 1.38.6.1 04-Sep-2008  lukem file vis.c was added on branch christos-time_t on 2008-09-04 09:41:45 +0000
 1.44.10.1 25-Feb-2013  tls resync with head
 1.44.4.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.44.4.1 23-Jan-2013  yamt sync with head
 1.71.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.71.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.71.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.73.4.2 09-Dec-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1923):

lib/libc/gen/vis.c: revision 1.75-1.86
tests/lib/libc/gen/t_vis.c: revision 1.10-1.14

PR 56260: fix out-of-bounds stack read.

vis(3): Avoid nonportable MIN in portable code.

vis(3) tests: Add xfail test for encoding overflow.

From Kyle Evans <kevans%FreeBSD.org@localhost>.
PR lib/57573

vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

vis(3): Make maxolen unsigned size_t, not ssize_t.
It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too. So there appears to have never been any reason for this to be
signed.
Part of PR lib/57573.

vis(3): Make mbslength unsigned.
Sprinkle assertions and comments justifying the proposition that it
would never go negative if signed.
Obviates need to worry about mblength > SSIZE_MAX.
Prompted by PR lib/57573.

vis(3): Avoid arithmetic overflow before calloc(3).
Prompted by PR lib/57573.

vis(3): Call wcslen(start) only once.
It had better not change between these two times!
Prompted by PR lib/57573.

vis(3): Avoid potential arithmetic overflow in maxolen.
Can't easily prove that this overflow is impossible, so let's add a
check.
Prompted by PR lib/57573.

vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans%FreeBSD.org@localhost>.

vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

vis(3): Sort includes. No functional change intended.
Prompted by PR lib/57573.

vis(3): Need <stdint.h> for SIZE_MAX, per C standard.
From Kyle Evans <kevans%FreeBSD.org@localhost>.
Followup to PR lib/57573.

vis(3): Per KNF, sys/param.h comes before sys/types.h.
Which is nice because that's also lexicographic.
 1.73.4.1 16-Jan-2018  martin Pull up the following, requested by maya in #411:

lib/libc/gen/vis.c 1.74

Use 16x instead of 4x the amount of space since each wint_t
can result in 4 bytes of 4 characters ("\ooo") each.
 1.74.6.1 09-Dec-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1774):

lib/libc/gen/vis.c: revision 1.75-1.86
tests/lib/libc/gen/t_vis.c: revision 1.10-1.14

PR 56260: fix out-of-bounds stack read.

vis(3): Avoid nonportable MIN in portable code.

vis(3) tests: Add xfail test for encoding overflow.

From Kyle Evans <kevans%FreeBSD.org@localhost>.
PR lib/57573

vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

vis(3): Make maxolen unsigned size_t, not ssize_t.
It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too. So there appears to have never been any reason for this to be
signed.
Part of PR lib/57573.

vis(3): Make mbslength unsigned.
Sprinkle assertions and comments justifying the proposition that it
would never go negative if signed.
Obviates need to worry about mblength > SSIZE_MAX.
Prompted by PR lib/57573.

vis(3): Avoid arithmetic overflow before calloc(3).
Prompted by PR lib/57573.

vis(3): Call wcslen(start) only once.
It had better not change between these two times!
Prompted by PR lib/57573.

vis(3): Avoid potential arithmetic overflow in maxolen.
Can't easily prove that this overflow is impossible, so let's add a
check.
Prompted by PR lib/57573.

vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans%FreeBSD.org@localhost>.

vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

vis(3): Sort includes. No functional change intended.
Prompted by PR lib/57573.

vis(3): Need <stdint.h> for SIZE_MAX, per C standard.
From Kyle Evans <kevans%FreeBSD.org@localhost>.
Followup to PR lib/57573.

vis(3): Per KNF, sys/param.h comes before sys/types.h.
Which is nice because that's also lexicographic.
 1.75.2.1 09-Dec-2023  martin Pull up following revision(s) (requested by riastradh in ticket #485):

lib/libc/gen/vis.c: revision 1.76-1.86
tests/lib/libc/gen/t_vis.c: revision 1.10-1.14

vis(3): Avoid nonportable MIN in portable code.

vis(3) tests: Add xfail test for encoding overflow.

From Kyle Evans <kevans%FreeBSD.org@localhost>.
PR lib/57573

vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

vis(3): Make maxolen unsigned size_t, not ssize_t.
It is initialized once either to *dlen, which is unsigned size_t, or
to wcslen(start) * MB_MAX_LEN + 1, and wcslen returns unsigned size_t
too. So there appears to have never been any reason for this to be
signed.
Part of PR lib/57573.

vis(3): Make mbslength unsigned.
Sprinkle assertions and comments justifying the proposition that it
would never go negative if signed.
Obviates need to worry about mblength > SSIZE_MAX.
Prompted by PR lib/57573.

vis(3): Avoid arithmetic overflow before calloc(3).
Prompted by PR lib/57573.

vis(3): Call wcslen(start) only once.
It had better not change between these two times!
Prompted by PR lib/57573.

vis(3): Avoid potential arithmetic overflow in maxolen.
Can't easily prove that this overflow is impossible, so let's add a
check.
Prompted by PR lib/57573.

vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans%FreeBSD.org@localhost>.

vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

vis(3): Sort includes. No functional change intended.
Prompted by PR lib/57573.

vis(3): Need <stdint.h> for SIZE_MAX, per C standard.
From Kyle Evans <kevans%FreeBSD.org@localhost>.
Followup to PR lib/57573.

vis(3): Per KNF, sys/param.h comes before sys/types.h.
Which is nice because that's also lexicographic.
 1.16 16-Jan-2014  christos Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.15 17-Jul-2011  joerg branches: 1.15.2; 1.15.8;
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.14 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.13 13-Sep-2005  christos compat core reorg.
 1.12 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.9 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.8 28-Jan-2002  tv Fix previous to actually include config.h.
 1.7 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.6 19-Feb-2001  cgd branches: 1.6.2;
convert from __progname to getprogname()
 1.5 30-Dec-2000  martin Be consistent with argument types vs. prototype; use _BSD_VA_LIST_ as
the argument, instead of va_list. Might not make a difference on most
ports, depending on toolchain/MD typedefs. Does make a difference on sparc64,
where it wouldn't compile otherwise.
 1.4 17-Aug-1999  mycroft Make some needed weak aliases.
 1.3 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.2 13-Jul-1997  christos Use "namespace.h"
Fix RCSID's
 1.1 15-Apr-1996  jtc branches: 1.1.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.1.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.6.2.3 21-Jun-2002  nathanw Catch up to -current.
 1.6.2.2 22-Mar-2002  nathanw Catch up to -current.
 1.6.2.1 08-Mar-2002  nathanw Catch up to -current.
 1.15.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.2.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.3 06-Jun-2014  joerg branches: 1.3.4;
Fix conditionals.
 1.2 06-Jun-2014  christos be friendlier to nbcompat
 1.1 16-Jan-2014  christos branches: 1.1.2; 1.1.4;
Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.1.4.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.4.1 16-Jan-2014  yamt file vwarnc.c was added on branch yamt-pagecache on 2014-05-22 11:36:52 +0000
 1.1.2.1 10-Aug-2014  tls Rebase.
 1.3.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.4.1 06-Jun-2014  tls file vwarnc.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.15 17-Jul-2011  joerg 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.14 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.13 13-Sep-2005  christos compat core reorg.
 1.12 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.9 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.8 28-Jan-2002  tv Fix previous to actually include config.h.
 1.7 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.6 19-Feb-2001  cgd branches: 1.6.2;
convert from __progname to getprogname()
 1.5 30-Dec-2000  martin Be consistent with argument types vs. prototype; use _BSD_VA_LIST_ as
the argument, instead of va_list. Might not make a difference on most
ports, depending on toolchain/MD typedefs. Does make a difference on sparc64,
where it wouldn't compile otherwise.
 1.4 17-Aug-1999  mycroft Make some needed weak aliases.
 1.3 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.2 13-Jul-1997  christos Use "namespace.h"
Fix RCSID's
 1.1 15-Apr-1996  jtc branches: 1.1.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.1.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.6.2.3 21-Jun-2002  nathanw Catch up to -current.
 1.6.2.2 22-Mar-2002  nathanw Catch up to -current.
 1.6.2.1 08-Mar-2002  nathanw Catch up to -current.
 1.9 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.8 07-Aug-2003  agc branches: 1.8.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.8.56.1 17-Apr-2012  yamt sync with head
 1.10 20-Mar-2012  matt Use C89 definitions.
Remove use of __P
 1.9 23-Mar-2010  drochner branches: 1.9.6;
remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.9.6.1 17-Apr-2012  yamt sync with head
 1.4 06-Apr-2016  christos revert part of previous; not needed.
 1.3 06-Apr-2016  christos - clarify si_signo difference for waitid and wait6 as per POSIX.
- implement it.
- document WIFCONTINUED
 1.2 03-Apr-2016  christos simplify
 1.1 03-Apr-2016  christos userland bits for wait6/waitid.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.7 22-Jan-2000  mycroft branches: 1.7.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
 1.4 25-Feb-1995  cgd branches: 1.4.4;
merge with Lite, keep local changes. clean up id usage
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 1.2 30-Jul-1993  mycroft Add even more RCS frobs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.4.1 02-May-1995  jtc #include "namespace.h"
 1.4.4.1 19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.7.6.1 21-Jun-2002  nathanw Catch up to -current.
 1.14 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.13 13-Sep-2005  christos don't use the weak names directly, so that the compat code works.
 1.12 13-Sep-2005  christos compat core reorg.
 1.11 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.8 22-Apr-2002  bjh21 When testing __STDC__, consistently use #ifdef rather than #if. The Sun
Workshop 5.0 C compiler defines __STDC__ to 0 unless it's in full-ANSI mode,
and in full ANSI mode it won't give us 64-bit integers (at least on a 32-bit
CPU).
 1.7 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.6 28-Jan-2002  tv Fix previous to actually include config.h.
 1.5 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.4 17-Aug-1999  mycroft branches: 1.4.10;
Make some needed weak aliases.
 1.3 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.2 13-Jul-1997  christos Use "namespace.h"
Fix RCSID's
 1.1 15-Apr-1996  jtc branches: 1.1.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.1.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.4.10.4 21-Jun-2002  nathanw Catch up to -current.
 1.4.10.3 25-Apr-2002  nathanw Catch up to -current.
 1.4.10.2 22-Mar-2002  nathanw Catch up to -current.
 1.4.10.1 08-Mar-2002  nathanw Catch up to -current.
 1.3 06-Jun-2014  joerg branches: 1.3.4;
Fix conditionals.
 1.2 06-Jun-2014  christos be friendlier to nbcompat
 1.1 16-Jan-2014  christos branches: 1.1.2; 1.1.4;
Add the {v,}{err,warn}c flavors, from FreeBSD.
 1.1.4.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.4.1 16-Jan-2014  yamt file warnc.c was added on branch yamt-pagecache on 2014-05-22 11:36:52 +0000
 1.1.2.1 10-Aug-2014  tls Rebase.
 1.3.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.4.1 06-Jun-2014  tls file warnc.c was added on branch tls-maxphys on 2014-08-20 00:02:14 +0000
 1.14 18-Jun-2007  ginsbach Follow the example of other nbtool compat functions, like dirname, and
don't create if it is determined that the system in question doesn't need
them. This cleans up build warnings on systems with err.h (HAVE_ERR_H)
for example Mac OS X 10.3.
 1.13 13-Sep-2005  christos don't use the weak names directly, so that the compat code works.
 1.12 13-Sep-2005  christos compat core reorg.
 1.11 16-Jul-2005  christos Add missing _.
 1.10 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.7 31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.6 28-Jan-2002  tv Fix previous to actually include config.h.
 1.5 28-Jan-2002  tv Make compilable from src/tools/compat.
 1.4 17-Aug-1999  mycroft branches: 1.4.10;
Make some needed weak aliases.
 1.3 17-Jul-1997  thorpej "Fix" the non-__indr_reference verions of the user-callable versions
of these functions. This is somewhat of a kludge, but there is not
much else we can do for this case.

Because of how the callable versions are created, by CPP trickery
and inclusion of another .c file, we cannot allow the included .c
file to pull in "namespace.h", since it undoes the CPP trickery we
have performed. Introduce a CPP macro that prevents the included .c
file from pulling in "namespace.h".
 1.2 13-Jul-1997  christos Use "namespace.h"
Fix RCSID's
 1.1 15-Apr-1996  jtc branches: 1.1.2;
Split each function in err.c out into its own file. This is needed
for systems without weak or indirect references.
 1.1.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.4.10.3 21-Jun-2002  nathanw Catch up to -current.
 1.4.10.2 22-Mar-2002  nathanw Catch up to -current.
 1.4.10.1 08-Mar-2002  nathanw Catch up to -current.
 1.5 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.4 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.3 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.2 24-Apr-2006  jld \*[Am] for an ampersand, not *[Am].
 1.1 13-Jul-2004  seb Add wordexp(3). The wordexp function performs shell-style word expansions.
This implementation is wrapper around the undocumented wordexp sh(1)
built-in command.

From FreeBSD.
Provided in PR lib/26123.
Approved by kleink@.
 1.4 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.3 12-Feb-2009  lukem sign-compare fix
 1.2 29-Nov-2005  christos branches: 1.2.30;
WARNS=4
 1.1 13-Jul-2004  seb Add wordexp(3). The wordexp function performs shell-style word expansions.
This implementation is wrapper around the undocumented wordexp sh(1)
built-in command.

From FreeBSD.
Provided in PR lib/26123.
Approved by kleink@.
 1.2.30.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.7 02-Mar-2020  christos Add sysloglike attr.
 1.6 02-Mar-2020  christos PR/55041: Fix printf format in syslog(3) error message.
 1.5 18-Apr-2017  maya branches: 1.5.12;
always initialize iovcnt

from clang static analyzer
 1.4 22-Mar-2017  kre Unbreak build, init variable (not a false alarm for this one.)
 1.3 22-Mar-2017  roy openlog(3): add LOG_PTRIM and LOG_NLOG log options.

syslog(3) is the one stop method of logging system events and diagnostics.
When debugging a daemon in the foreground on a terminal, each line is
prefixed with tag[pid]: which is very repetative and can take up valuable
screen estate.
LOG_PTRIM solves this by removing this prefix from stderr output.

There is also the case where the debugging could involve a dry-run and
syslog(3) calls would pollute the system log with incorrect data.
LOG_NLOG solves this by not writing the the system log, but allowing
LOG_PERROR to operate as before.

Initially discussed here:
https://mail-index.netbsd.org/tech-userlevel/2016/10/06/msg010330.html
 1.2 12-Jan-2017  christos branches: 1.2.2; 1.2.4;
A little more restructuring so that we don't need mutex stuff in syslog_ss.
 1.1 12-Jan-2017  christos Split syslog.c to:

- syslog_ss.c *_ss api functions (don't use stdio, time)
- syslog.c: *syslog* non _ss api functions (use stdio, time)
- xsyslog.c> common guts.

The motivation for this is not to drag in stdio/locale/floating point/time
for every binary, since syslog_ss() is used in __stack_check_fail() for SSP.
 1.2.4.3 26-Apr-2017  pgoyette Sync with HEAD
 1.2.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.4.1 12-Jan-2017  pgoyette file xsyslog.c was added on branch pgoyette-localcount on 2017-03-20 06:56:57 +0000
 1.2.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.5.12.1 08-Apr-2020  martin Merge changes from current as of 20200406

RSS XML Feed