Home | History | Annotate | only in /src/lib/libc/stdlib
History log of /src/lib/libc/stdlib
RevisionDateAuthorComments
 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 Import of most recent XPG4DL dated 2000.06.23.
 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_abs.c was added on branch netbsd-1-3 on 1997-11-08 21:59:51 +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 Import of most recent XPG4DL dated 2000.06.23.
 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_div.c was added on branch netbsd-1-3 on 1997-11-08 21:59:52 +0000
 1.2.116.1 02-Aug-2025  perseant Sync with HEAD
 1.2 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.1 04-Aug-2008  matt branches: 1.1.2; 1.1.8; 1.1.76;
Add C99 functions imaxabs and imaxdiv.
 1.1.76.1 02-Aug-2025  perseant Sync with HEAD
 1.1.8.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.1.8.1 04-Aug-2008  matt file Lint_imaxabs.c was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 04-Aug-2008  wrstuden file Lint_imaxabs.c was added on branch wrstuden-revivesa on 2008-09-18 04:39:22 +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 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 Import of most recent XPG4DL dated 2000.06.23.
 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_labs.c was added on branch netbsd-1-3 on 1997-11-08 21:59:53 +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 Import of most recent XPG4DL dated 2000.06.23.
 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_ldiv.c was added on branch netbsd-1-3 on 1997-11-08 21:59:54 +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 07-Mar-2000  kleink branches: 1.2.118;
Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.2.118.1 02-Aug-2025  perseant Sync with HEAD
 1.105 20-Jul-2025  dholland lib/libc/stdlib: sort MLINKS (p comes before q)
 1.104 02-Mar-2025  riastradh libc: New _r variants of heapsort, mergesort, qsort.

Also kheapsort_r for kernel/standalone use.

These variants allow the caller to pass a cookie through to the
comparison function, e.g. if you want to sort an array of indices
into a buffer.

qsort_r is new in POSIX.1-2024; the others are obvious analogues of
our nonstandard extensions for heapsort and mergesort.

PR lib/58931: qsort_r() missing
 1.103 23-Sep-2024  christos Move lintflags to jemalloc Makefile.inc fragment
 1.102 23-Sep-2024  christos get the variable name right
 1.101 23-Sep-2024  christos Handle multiple versions of jemalloc
 1.100 24-Jul-2024  kre Improve the man for strtoi() (and consequently strtou())

PR lib/58461 PR lib/58453

Improve the wording so it is clearer exactly what strtoi() is
intended to do in various cases.

While here, add, in the most minimalist way possible, the
strtoi_l(), and so also strtou_l(), functions, which seem to
have been previously undocumented.

Do some linguistic gymnastics so that the conversion of the
page from strtoi(3) -> strtou(3) will not generate "an unitmax_t"
which is incorrect, we need "a unitmax_t" - one of those was
easy to fix in the Makefile sed script, the others would have
been more difficult, so reword instead.
 1.99 07-Jun-2024  riastradh branches: 1.99.2;
libc: Pacify lint on aarch64.
 1.98 27-Jan-2024  christos fix i386 lint
 1.97 20-Jan-2024  christos generate strtou.3 from strtoi.3, grammar police
 1.96 19-Jan-2024  christos Add lint flags for jemalloc
 1.95 04-Mar-2019  christos branches: 1.95.2; 1.95.10;
Hook for jemalloc
 1.94 05-Jan-2018  snj branches: 1.94.4;
add strfmon_l man page links
 1.93 11-Jul-2017  joerg Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
 1.92 01-Apr-2016  msaitoh branches: 1.92.8;
Add malloc.conf.5 (link to jemalloc.3).
 1.91 07-Nov-2015  nros Add the C11 function aligned_alloc to libc.
 1.90 01-May-2015  christos - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
 1.89 17-Feb-2015  joerg Introduce reallocarr(3) for easy (re)allocation of memory with overflow
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory
leaks on allocation failures and it doesn't depend on malloc(0) != NULL
for correct error checking. Compared to plain realloc, it also avoids
the problem of intermediate integer overflows. The trade-off is the use
of void * to side step C type system with regard to generic pointer to
pointer.
 1.88 05-Feb-2015  christos Revert addition to reallocarray to the malloc man page, but keep
the examples. Add separate manual page to reallocarray explaining
what are the problems with it.
 1.87 05-Feb-2015  christos Add and use reallocarray() to prevent a multiplication overflow in allocation.
Reported by Guido Vranken, thanks!
 1.86 18-Jan-2015  christos man page for strtonum.3
 1.85 16-Jan-2015  christos Add strtonum implemented as a wrapper of strtoi.
 1.84 16-Jan-2015  christos strtoi and strtou additions
 1.83 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.82 20-Jul-2014  christos branches: 1.82.2;
Our hdestroy implementation was non-conformant because it freed the key of
each entry. Add a new function hdestroy1 that allows the user to control
what gets freed. Pointed out by Pedro Giffuni at FreeBSD.
 1.81 08-Jan-2014  christos branches: 1.81.2;
add ptsname_r
 1.80 02-Dec-2013  lneto changed lua_Number to int64_t
 1.79 26-Apr-2013  christos add {at_,}quick_exit(3) from FreeBSD
 1.78 14-Sep-2011  christos branches: 1.78.2; 1.78.8;
add re-entrant versions of the hash functions based on the GNU api.
 1.77 13-Apr-2011  jruoho Collect also the division functions to single place, div(3).
 1.76 13-Apr-2011  jruoho Collect abs(3), labs(3), llabs(3), and imaxabs(3) to a single small page.
 1.75 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.74 03-May-2010  jruoho Split the implementation details of malloc(3) to a separate jemalloc(3)
manual page. This way malloc(3) can follow the standard terse format used
elsewhere in the libc, while additional details can be added to jemalloc(3).

Note HISTORY and AUTHORS in jemalloc(3), and add some reading material to
SEE ALSO.
 1.73 31-Jul-2009  dsl Add the 'abs', 'div' and 'erand48' sources to stdlib/Makefile.inc.
Change the arch files only include the .S files.
This adds imaxdiv() to some archs where it was missing.
 1.72 20-Jul-2009  joerg Add a fast, platform independent hash function to libc.
The algorithm used is the Jenkins hash. The name (mi_vector_hash)
reflects the nature of the hash function.
Add glue for libc ATF tests and include a test case to make sure that
(mis)alignment and endianess are handled correctly.

Bump libc minor to 169.
 1.71 26-Oct-2008  mrg branches: 1.71.4;
define and use LIBCDIR in terms of .CURDIR. fixes compat/lib/libc build.
 1.70 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.69 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.68 28-Nov-2007  christos branches: 1.68.8;
Sync phk malloc.c with the latest one from FreeBSD. This gives us the
same api as jemalloc by:

- adding posix_memalign()
- moving calloc in the same file
- renaming malloc_options -> _malloc_options
 1.67 19-Nov-2007  ad Enable posix_memalign().
 1.66 06-Oct-2007  ad Use jemalloc as the default allocator unless USE_JEMALLOC=no.
 1.65 22-Mar-2006  drochner branches: 1.65.10;
build erand48_ieee754.c on everything but vax
 1.64 15-Mar-2006  kleink Add strtof(3) and strtold(3); welcome libc 12.137.
 1.63 25-Jan-2006  kleink Drop in gdtoa as a replacement for dtoa, strtod() from stdlib/strtod.c.
 1.62 20-Jan-2006  christos Kill _Exit; breaks build on cygwin and this implementation "is not exactly
equivalent to calling _exit".
 1.61 25-Sep-2005  christos add getenv_r and ttyname_r
 1.60 13-Sep-2005  christos compat core reorg.
 1.59 06-Jul-2005  drochner Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.58 03-Apr-2005  christos Add FreeBSD's strfmon(3). From Rui Paulo. No bump this time. Take advantage
of the getpwent_r bump.
 1.57 05-Aug-2004  yamt branches: 1.57.2;
actually add _Exit.
 1.56 27-May-2004  christos unix/98 pty functions and manual pages.
 1.55 07-Apr-2003  kleink branches: 1.55.2;
Observed in other places: move __unsetenv13.c near unsetenv.c, only
group name space wrappers separately.
 1.54 07-Apr-2003  drochner compile unsetenv(3) into libc or you'll mess up your system
 1.53 29-Nov-2002  lukem add strsuftoll(3) and strsuftollx(3) - parse a string for a number
with an optional suffix, product (two numbers separated by `x'), and
provide range checking
 1.52 28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.51 16-Feb-2001  msaitoh branches: 1.51.2;
add hcreate.3
 1.50 14-Feb-2001  cgd build new hsearch() code
 1.49 08-Jan-2001  lukem link sradixsort(3) -> radixsort(3)
 1.48 21-Dec-2000  itojun first import of citrus LC_CTYPE locale. singlebyte only at this moment.
shot-term TODO:
- enable multibyte locales. this includes loadable locale modules
(#ifdef DLRUNE).
- populate LC_CTYPE definition files.
- other functions such as iconv()
- make libc functions more friendly with multibyte.
- multilingualize other LC_xx
- torture tests

XXX don't forget to "make depend" when you rebuild libc, multibyte.c is
moved from lib/libc/stdlib to lib/libc/locale.
 1.47 02-Apr-2000  christos branches: 1.47.2; 1.47.4;
New getopt_long from Thomas Klausner and Dieter Baron
 1.46 08-Mar-2000  kleink No longer need internal names for strtoq() and strtouq().
 1.45 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.44 02-Aug-1999  lukem replace malloc(3) with one from freebsd which documents our new malloc.c
(also from freebsd). comment out references to reallocf with .\"XXX"
for now. i also fixed some roff misuse as well.
replace calloc(3), free(3) and realloc(3) with links to malloc(3)
 1.43 26-Jun-1999  tls The 'new malloc' (phk's malloc, from FreeBSD) is now our only malloc.
 1.42 17-Jun-1999  tls add FreeBSD's malloc, compiled in only if MALLOC_NEW is set in mk.conf
 1.41 24-Feb-1999  drochner use ${ARCHDIR} instead of ${.CURDIR}/arch/${MACHINE_ARCH} where appropriate
libc builds on pmax again
 1.40 22-Feb-1999  christos t{search,find,walk,delete} from OpenBSD via Neil A. Carson
 1.39 06-Feb-1999  kleink Add l64a_r(), a reentrant version of l64a(); found in the Multithreading
Extension of SVID4.
 1.38 14-Jun-1998  kleink Add a manual page for a64l() and l64a().
 1.37 02-Feb-1998  perry realpath is now part of getcwd.c in gen/; man page moved to gen, too.
 1.36 01-Feb-1998  frueauf Add _strtoq.c back to SRCS+= which seemed to get lost while reordering it.
 1.35 30-Jan-1998  perry update to lite-2
 1.34 05-Nov-1997  cgd A foolish consistency... gen, net, and string all get MD sources
specified by including a Makefile.inc from the appropriate MD directory.
stdlib doesn't do that, but there's no reason that it shouldn't (and
it'd be nice to eliminate the 'if's from the MI stdlib Makefile.inc).
 1.33 15-Jul-1997  kleink branches: 1.33.2;
Link rand_r(3) to rand(3).
 1.32 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.31 23-Apr-1997  mrg move str[fp]time into libc/time.
 1.30 21-Apr-1997  mrg add strptime() to libc.
 1.29 19-Nov-1996  jtc Added rand_r()
 1.28 16-Oct-1996  perry Nuked machine specific conditionals for tahoe.
 1.27 28-Dec-1995  thorpej New-style RCS ids.
 1.26 25-Apr-1995  ragge Changed abs.S to abs.c for vax.
 1.25 22-Mar-1995  jtc Enable qabs(), a quad_t version of abs() and labs().
 1.24 21-Mar-1995  jtc New function qdiv. Like div and ldiv, but works with quad_t's.
 1.23 10-Feb-1995  cgd list the files needed on the alpha.
 1.22 22-Dec-1994  cgd specify man pages the new way.
 1.21 16-Jun-1994  mycroft Add merge.c and mergesort.3.
 1.20 20-May-1994  jtc 44lite moved cfree() to libcompat
 1.19 17-May-1994  mycroft Add realpath(3).
 1.18 17-Mar-1994  jtc Remove machine-dependent atof() implementations; use machine independant
version that wraps strtod() instead.
 1.17 03-Jan-1994  jtc Integrate strtoq() and strtouq() from bsd-sources on uunet.
 1.16 05-Dec-1993  briggs Changed occurance of MACHINE_ARCH == "hp300" to MACHINE_ARCH == "m68k"
 1.15 05-Dec-1993  cgd get pc532 moved into ns32k; that's is MACHINE_ARCH
 1.14 04-Dec-1993  cgd update for .S and MACHINE_ARCH
 1.13 22-Oct-1993  jtc Added 1170's a64l() & l64a() functions.
 1.12 19-Oct-1993  cgd fixes from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de> to:
(1) don't clobber the MLINKS variable in rpc
(2) install the rand48 man page in stdlib
 1.11 13-Oct-1993  jtc Split cfree() out of calloc.c.
If a user compiling in a strict ANSI or strict POSIX environment uses his
own function named cfree (which is legal, since cfree is not in a restricted
namespace) and calloc, the link will fail due to the cfree in calloc.c.
 1.10 09-Oct-1993  jtc Added rand48 manual page.
 1.9 09-Oct-1993  jtc Make it possible to use machine dependant versions of div and ldiv functions.
Use the new i386 versions of div and ldiv.
 1.8 08-Oct-1993  jtc Use machine dependant version of labs.[cs] if one is present.
If not one of the enumerated list of machines, use the C language
versions of abs, labs, and atof.
 1.7 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.6 07-Oct-1993  cgd make an arch directory in libc, and move all machine dirs into it
 1.5 17-Sep-1993  phil pc532 specifics.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 09-Jul-1993  cgd don't include an extra atof.c...
 1.2 09-Jul-1993  cgd update for better FP routines, from AT&T & elsewhere
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.33.2.1 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for assembly routines.
 1.47.4.1 13-Mar-2001  he Pull up revisions 1.50-1.51 (requested by cgs):
Replace hcreate() / hsearch() / hdestroy() implementation with
one that actually works as it's supposed to.
 1.47.2.1 28-May-2000  minoura Citrus Project XPG4DL, an implementation of I18N (locale) framework,
is imported.
 1.51.2.2 10-Dec-2002  thorpej Sync with HEAD.
 1.51.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.55.2.1 12-Aug-2004  jmc Pullup rev 1.57 (requested by yamt in ticket #750)

Actually add _Exit.
 1.57.2.1 04-Aug-2005  tron Pull up revision 1.59 (requested by drochner in ticket #632):
Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.65.10.2 09-Jan-2008  matt sync with HEAD
 1.65.10.1 06-Nov-2007  matt sync with HEAD
 1.68.8.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.71.4.2 26-Oct-2008  mrg define and use LIBCDIR in terms of .CURDIR. fixes compat/lib/libc build.
 1.71.4.1 26-Oct-2008  mrg file Makefile.inc was added on branch christos-time_t on 2008-10-26 07:43:08 +0000
 1.78.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.78.8.1 23-Jun-2013  tls resync from head
 1.78.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.81.2.1 10-Aug-2014  tls Rebase.
 1.82.2.3 08-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1288):
distrib/sets/lists/man/mi: revisions 1.1521, 1.1522
lib/libc/stdlib/Makefile.inc: revision 1.92
Add malloc.conf.5 (link to jemalloc.3).
--
Add malloc.conf.0 to fix build with MKCATPAGES
 1.82.2.2 16-May-2015  snj branches: 1.82.2.2.4;
Pull up following revision(s) (requested by christos in ticket #781):
common/lib/libc/stdlib/strtoi.c: revision 1.2
common/lib/libc/stdlib/strtou.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.113
distrib/sets/lists/tests/mi: revision 1.617
lib/libc/include/namespace.h: revision 1.178
lib/libc/stdlib/Makefile.inc: revision 1.90 via patch
lib/libc/stdlib/strtoi.3: revisions 1.1, 1.2
lib/libc/stdlib/strtol.3: revision 1.32
lib/libc/stdlib/strtou.3: revisions 1.1, 1.2
lib/libc/stdlib/strtoul.3: revisions 1.30, 1.31
tests/lib/libc/stdlib/Makefile: revision 1.25
tests/lib/libc/stdlib/t_strtoi.c: revision 1.1
- new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
--
Sort ERRORS and SEE ALSO.
--
Sort ERRORS and SEE ALSO.
--
Sort SEE ALSO.
 1.82.2.1 22-Apr-2015  snj Pull up following revision(s) (requested by roy in ticket #648):
common/lib/libc/stdlib/_strtoi.h: revisions 1.1, 1.2
common/lib/libc/stdlib/strtoi.c: revision 1.1
common/lib/libc/stdlib/strtou.c: revision 1.1
distrib/sets/lists/base/ad.aarch64: patch
distrib/sets/lists/base/ad.arm: patch
distrib/sets/lists/base/ad.mips: patch
distrib/sets/lists/base/ad.powerpc: patch
distrib/sets/lists/base/md.amd64: patch
distrib/sets/lists/base/md.sparc64: patch
distrib/sets/lists/base/shl.mi: patch
distrib/sets/lists/comp/mi: revision 1.1939
distrib/sets/lists/debug/ad.aarch64: patch
distrib/sets/lists/debug/ad.arm: patch
distrib/sets/lists/debug/ad.mips: patch
distrib/sets/lists/debug/ad.powerpc: patch
distrib/sets/lists/debug/md.amd64: patch
distrib/sets/lists/debug/md.sparc64: patch
distrib/sets/lists/debug/shl.mi: patch
include/inttypes.h: revision 1.11
lib/libc/shlib_version: patch
lib/libc/stdlib/Makefile.inc: revision 1.84
lib/libc/stdlib/strtol.3: revisions 1.27-1.31
lib/libc/stdlib/strtoul.3: revisions 1.26-1.29
sys/lib/libkern/Makefile.libkern: revision 1.37
sys/lib/libkern/libkern.h: revision 1.117
tools/compat/Makefile: revision 1.73
tools/compat/compat_defs.h: revision 1.101
tools/compat/configure.ac: revision 1.83
tools/compat/configure: revision 1.82
tools/compat/nbtool_config.h.in: revision 1.36
add strto{i,u} from Kamil Rytarowski as discussed in tech-userlevel.
--
strtoi and strtou additions
--
strtoi and strtou for the kernel
--
strtoi and strtou additions
--
strtoi and strtou man pages
--
strto{i,u}
--
regen
--
Remove trailing whitespace.
--
match variable names with man page (Kamil Rytarowski)
--
cleanups from (Kamil Rytarowski)
--
add strtoi strtou (Kamil Rytarowski)
--
PR/49640: Kamil Rytarowski: Improve error printing
--
Use existing month for Dd.
 1.82.2.2.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.92.8.1 29-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #127):
tests/libexec/ld.elf_so/h_thread_local_dtor.c: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h: revision 1.17
lib/libc/stdlib/atexit.h: file removal
lib/libc/stdlib/exit.c: revision 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h: revision 1.8
lib/libc/stdlib/exit.c: revision 1.17
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.178
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h: revision 1.21
distrib/sets/lists/debug/shl.mi: revision 1.179
distrib/sets/lists/debug/mi: revision 1.219
lib/libpthread/pthread.c: revision 1.150
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h: revision 1.14
libexec/ld.elf_so/symbols.map: revision 1.2
include/dlfcn.h: revision 1.25
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h: revision 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h: revision 1.18
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h: revision 1.17
distrib/sets/lists/tests/mi: revision 1.755
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h: revision 1.20
lib/libc/dlfcn/dlfcn_elf.c: revision 1.14
tests/libexec/ld.elf_so/t_thread_local_dtor.sh: revision 1.1
tests/lib/libpthread/t_thread_local_dtor.sh: revision 1.1
lib/libc/stdlib/Makefile.inc: revision 1.93
lib/libc/include/atexit.h: revision 1.1
lib/libc/include/atexit.h: revision 1.2
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.180
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h: revision 1.14
lib/libc/stdlib/cxa_thread_atexit.c: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h: revision 1.5
libexec/ld.elf_so/rtld.c: revision 1.185
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h: revision 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h: revision 1.19
tests/libexec/ld.elf_so/Makefile: revision 1.9
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h: revision 1.14
tests/lib/libpthread/h_thread_local_dtor.cpp: revision 1.1
distrib/sets/lists/tests/shl.mi: revision 1.11
tests/lib/libpthread/Makefile: revision 1.13
libexec/ld.elf_so/rtld.h: revision 1.129
external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h: revision 1.6
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
Fix filename of new debug file
Add misising DEBUGLIB file
Avoid common declaration.
Drop TLS variant checks, emutls is enough for VAX and Sun2.
 1.94.4.1 10-Jun-2019  christos Sync with HEAD
 1.95.10.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #792):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)

generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.95.2.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1870):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.99.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 20-Jan-2006  christos Kill _Exit; breaks build on cygwin and this implementation "is not exactly
equivalent to calling _exit".
 1.2 12-Jun-2005  lukem Add missing __RCSID()
 1.1 01-Mar-2003  bjh21 Add _Exit(), for C99 and POSIX-2001.
Proposed on tech-userlevel to a resounding silence in April last year.
 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 13-Apr-2003  kleink Warn if the old unsetenv() is referenced.
 1.1 07-Apr-2003  kleink 1003.1-2001 has introduced unsetenv() which differs from the current
implementation in not permitting a "name=value" argument.
* Add a conforming __unsetenv13() and do function renaming for
unsetenv(); preserve old symbol with old behavior.
* Make visible setenv() and unsetenv() for 1003.1-2001 feature selection
macros; resolves PR standards/20479.
 1.15 02-Jan-2024  christos pass lint.
 1.14 18-Jul-2023  riastradh libc: Use RB_TREE_INITIALIZER to nix initfini.c/_env.c coupling.

Doesn't actually help to remove _env.c from programs that don't use
it, though, because various internal things like __diagassert13 still
call getenv.
 1.13 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.12 12-Mar-2022  nia _env: use reallocarr
 1.11 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.10 22-Feb-2020  kamil Avoid NULL pointer arithmetics on environ

_env.c:260:9, pointer expression with base 0 overflowed to 0
_env.c:260:9, load of null pointer of type 'char *'
 1.9 20-Jan-2015  christos branches: 1.9.16;
Fix non _REENTRANT build.
 1.8 09-Sep-2013  tron Don't scrub the environment unless we are going to change it. This should
prevent crashes in applications which carefully and manually construct
a temporary environment and later restore the original environment
like Emacs 24.

Problem reported by Thomas Klausner on "pkgsrc-users" mailing list.
 1.7 19-Aug-2013  matt Put the startup code in .text.startup
 1.6 06-Oct-2011  christos branches: 1.6.2; 1.6.4; 1.6.8; 1.6.10; 1.6.16;
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.5 17-Nov-2010  tron Include "namespace.h" to get namespace protection.
 1.4 16-Nov-2010  tron Implement mark & sweep garbage collection as suggested by Enami Tsugutomo
on "current-users" mailing list. Garbage collection is performed if:
1.) We previously allocated memory for the environment array which
is no longer used because the application overwrote "environ".
2.) We find a non-NULL pointer in the allocated environment array after
the end of the environment. This happens if the applications attempts
to clear the environment with something like "environ[0] = NULL;".
 1.3 16-Nov-2010  enami Fix typos in comment.
 1.2 14-Nov-2010  tron 1.) Rename internal function __findvar() to __findenvvar().
2.) Add a wrapper function __findenv() which implements the previous
*internal* interface. It turns out that ld.elf_so(1) and pthread(3)
both use it.

Stripping e.g. "LD_LIBRARY_PATH" from the environment while running
setuid binaries works again now.
 1.1 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.6.16.1 14-Sep-2013  bouyer Pull up following revision(s) (requested by tron in ticket #940):
lib/libc/stdlib/_env.c: revision 1.8
Don't scrub the environment unless we are going to change it. This should
prevent crashes in applications which carefully and manually construct
a temporary environment and later restore the original environment
like Emacs 24.
Problem reported by Thomas Klausner on "pkgsrc-users" mailing list.
 1.6.10.1 14-Sep-2013  bouyer Pull up following revision(s) (requested by tron in ticket #940):
lib/libc/stdlib/_env.c: revision 1.8
Don't scrub the environment unless we are going to change it. This should
prevent crashes in applications which carefully and manually construct
a temporary environment and later restore the original environment
like Emacs 24.
Problem reported by Thomas Klausner on "pkgsrc-users" mailing list.
 1.6.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.4.1 14-Sep-2013  bouyer Pull up following revision(s) (requested by tron in ticket #940):
lib/libc/stdlib/_env.c: revision 1.8
Don't scrub the environment unless we are going to change it. This should
prevent crashes in applications which carefully and manually construct
a temporary environment and later restore the original environment
like Emacs 24.
Problem reported by Thomas Klausner on "pkgsrc-users" mailing list.
 1.6.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.9.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10 23-Feb-2020  kamil Change the previous cast from unsigned int to unsigned long

This code produces the same result and is consistent with the previous
lines. Only the least significant 16 bites (unsigned short) are meaningful.
 1.9 22-Feb-2020  kamil Avoid undefined behavior in the rand48(3) implementation

Instead of implicid promotion to signed int,
explicitly cast the arguments to unsigned int.

_rand48.c:53:27, signed integer overflow:
58989 * 58970 cannot be represented in type 'int'

_rand48.c:53:38, signed integer overflow:
-2093025904 + -1496809120 cannot be represented in type 'int'

_rand48.c:53:57, signed integer overflow:
57068 * 42787 cannot be represented in type 'int'

New and old code produce the same code as tested with:

#include <stdio.h>
#include <stdlib.h>

#define COUNT 1000 * 1000

int
main(void)
{
FILE *fp;
int i;

fp = fopen("numbers.txt", "w+");
if (!fp)
abort();

for(i = 0; i < COUNT; i++) {
fprintf(fp, "%f\n", drand48());
fprintf(fp, "%ld\n", lrand48());
fprintf(fp, "%ld\n", mrand48());
}

fclose(fp);

return 0;
}
 1.8 22-Feb-2020  kamil Improve readability of __dorand48()

Break long lines into shorter instructions per line.

No Functional Change.
 1.7 12-Jun-2005  lukem branches: 1.7.86;
Add missing __RCSID()
 1.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 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.4 09-Jan-1998  perry RCS Id Police.
 1.3 14-Oct-1993  jtc Rename intenral _rand_foo variables to __rand_foo, as _rand_foo is in the
user's namespace.
 1.2 13-Oct-1993  jtc Change _dorand48 to __dorand48, as _dorand48 is in the user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.7.86.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.4 13-Sep-2005  christos branches: 1.4.20;
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 28-Apr-2001  kleink branches: 1.1.2;
* Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.1.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.2.1 28-Apr-2001  nathanw file _strtoimax.c was added on branch nathanw_sa on 2001-10-08 20:21:01 +0000
 1.4.20.1 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.6 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.5 13-Sep-2005  christos branches: 1.5.20;
compat core reorg.
 1.4 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.3 12-Jun-2005  lukem Add missing __RCSID()
 1.2 07-Mar-2000  kleink Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.5.20.1 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.5 08-Mar-2000  kleink No longer need internal names for strtoq() and strtouq().
 1.4 03-Feb-1998  perry remove obsolete register declarations
 1.3 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.2 17-Jul-1997  thorpej branches: 1.2.2;
Do the non-__indr_reference versions like the cat*(3) functions.
 1.1 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.2.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.6 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.5 13-Sep-2005  christos branches: 1.5.20;
compat core reorg.
 1.4 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.3 12-Jun-2005  lukem Add missing __RCSID()
 1.2 07-Mar-2000  kleink Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.5.20.1 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.5 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.4 13-Sep-2005  christos branches: 1.4.20;
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 28-Apr-2001  kleink branches: 1.1.2;
* Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.1.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.1.2.1 28-Apr-2001  nathanw file _strtoumax.c was added on branch nathanw_sa on 2001-10-08 20:21:02 +0000
 1.4.20.1 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.5 08-Mar-2000  kleink No longer need internal names for strtoq() and strtouq().
 1.4 03-Feb-1998  perry remove obsolete register declarations
 1.3 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.2 17-Jul-1997  thorpej branches: 1.2.2;
Do the non-__indr_reference versions like the cat*(3) functions.
 1.1 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.2.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.10 06-May-2010  jruoho Note POSIX compliance.
 1.9 30-Apr-2008  martin branches: 1.9.8;
Convert TNF licenses to new 2 clause variant
 1.8 16-Apr-2003  wiz branches: 1.8.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.7 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 19-Nov-1999  enami branches: 1.5.6;
Don't pass so many args to .Nd macro. It just overflows.
 1.4 22-Mar-1999  garbled branches: 1.4.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.3 06-Feb-1999  kleink Add l64a_r(), a reentrant version of l64a(); found in the Multithreading
Extension of SVID4.
 1.2 14-Jun-1998  kleink It's 1998, actually.
 1.1 14-Jun-1998  kleink Add a manual page for a64l() and l64a().
 1.4.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.5.6.2 22-Mar-2002  nathanw Catch up to -current.
 1.5.6.1 08-Mar-2002  nathanw Catch up to -current.
 1.8.30.1 18-May-2008  yamt sync with head.
 1.9.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.9.8.1 30-Apr-2008  martin file a64l.3 was added on branch christos-time_t on 2008-04-30 13:10:52 +0000
 1.10 08-Jun-2012  abs ANSI prototypes
 1.9 26-Jul-2003  salo branches: 1.9.56;
netbsd.org->NetBSD.org
 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 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 local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.3 11-May-1995  jtc branches: 1.3.4;
Winning Strategies has placed this code in the public domain.
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 22-Oct-1993  jtc Added 1170's a64l() & l64a() functions.
 1.3.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.9.56.1 30-Oct-2012  yamt sync with head
 1.13 12-Jun-2012  jdf Use correct macro (.Nm is only used within the NAME section, for section 3
manpages).

Patch provided by Bug Hunting.
 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 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-Aug-2002  yamt bump .Dd for my previous commit.
 1.9 10-Aug-2002  yamt note that abort(3) causes streams flushed and closed.
from OpenBSD.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 05-Feb-1998  perry branches: 1.7.12;
add LIBRARY section to man page
 1.6 30-Jan-1998  perry update to lite-2
 1.5 10-Jul-1997  mikel xref exit(3) not exit(2)
 1.4 19-May-1997  kleink * Remove incorrect comment: as per POSIX.1, calling abort() _does_ flush
and close open streams.
* Document that calling abort() removes temporary files.
Fixes PR/2967 from Peter Seebach <seebs@taniemarie.solon.com>.
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.3 13-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.12.56.1 30-Oct-2012  yamt sync with head
 1.15 08-Jun-2012  abs ANSI prototypes
 1.14 18-May-2011  dsl branches: 1.14.4;
Remove __P()
 1.13 30-Jan-2009  ad Make threaded programs die correctly:

kill(getpid(), SIGFOO) -> raise(SIGFOO)
 1.12 07-Aug-2003  agc branches: 1.12.38;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 12-Oct-1998  kleink Exit via _exit() rather than exit(), as the latter would cause exit handlers
installed using atexit() to be executed which is supposed to happen on
`normal termination' of the process only, whereas abort() is specifically
defined to cause `abnormal termination'.
 1.10 30-Jan-1998  perry update to lite-2
 1.9 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.8 19-May-1997  kleink Remove misleading comment in abort() function; fixes PR/2966 from
Peter Seebach <seebs@taniemarie.solon.com>.
 1.7 24-Oct-1996  jtc POSIX.1 requires that stdio buffers be flushed on abort.
 1.6 28-Dec-1995  thorpej New-style RCS ids.
 1.5 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.4 28-Feb-1995  jtc Changed <sys/signal.h> to <signal.h>
 1.3 26-Aug-1993  jtc branches: 1.3.4;
Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 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.12.38.1 02-Feb-2009  snj Pull up following revision(s) (requested by ad in ticket #399):
lib/libc/misc/stack_protector.c: revision 1.3
lib/libc/stdlib/abort.c: revision 1.13
lib/libc/thread-stub/thread-stub.c: revision 1.21
Make threaded programs die correctly:
kill(getpid(), SIGFOO) -> raise(SIGFOO)
 1.14.4.1 30-Oct-2012  yamt sync with head
 1.14 13-Apr-2011  jruoho Collect abs(3), labs(3), llabs(3), and imaxabs(3) to a single small page.
 1.13 04-Aug-2008  matt branches: 1.13.6;
Add C99 functions imaxabs and imaxdiv.
 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 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 28-Apr-2002  zuntum Xref fabs(3)

OK'd by Jaromir Dolecek
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.7 06-Mar-2000  kleink branches: 1.7.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 30-Jan-1998  perry update to lite-2
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 04-Oct-1993  jtc SEE ALSO items not comma separated.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.6.4 21-Jun-2002  nathanw Catch up to -current.
 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.12.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.13.6.1 04-Aug-2008  matt file abs.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.8 08-Jun-2012  abs ANSI prototypes
 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 30-Jan-1998  perry update to lite-2
 1.5 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 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.3 18-Aug-2024  riastradh aligned_alloc(3): Nix trailing whitespace. Add RCS id.
 1.2 27-Jul-2018  maya branches: 1.2.12;
C17 conformance: aligned_alloc's size doesn't need to be a multiple of
alignment any more.

Thanks Joseph Myers for the heads up.
 1.1 07-Nov-2015  nros branches: 1.1.14; 1.1.16;
Add the C11 function aligned_alloc to libc.
 1.1.16.1 10-Jun-2019  christos Sync with HEAD
 1.1.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.2.12.1 02-Aug-2025  perseant Sync with HEAD
 1.16 24-Oct-2012  wiz Whitespace improvements.
 1.15 24-Oct-2012  christos explain a bit more what's wrong with alloca(3)
 1.14 21-Mar-2011  jruoho branches: 1.14.4; 1.14.10;
Fix xref; security(8) -> security(7).
 1.13 03-May-2010  jruoho Note the problems with SSP.
 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-Aug-2002  yamt note that alloca can't report error.
from OpenBSD.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor 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 05-Feb-1998  perry add LIBRARY section to man page
 1.5 30-Jan-1998  perry update to lite-2
 1.4 15-Jul-1997  mikel xref getpagesize(3) not nonexistent pagesize(2), sort xrefs
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.12.4 13-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.14.10.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.14.4.1 30-Oct-2012  yamt sync with head
 1.2 26-Apr-2013  wiz branches: 1.2.2; 1.2.8;
Bump date for adding the function to NetBSD. Fix xref.
 1.1 26-Apr-2013  christos add {at_,}quick_exit(3) from FreeBSD
 1.2.8.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.2.8.1 26-Apr-2013  yamt file at_quick_exit.3 was added on branch yamt-pagecache on 2014-05-22 11:36:54 +0000
 1.2.2.2 23-Jun-2013  tls resync from head
 1.2.2.1 26-Apr-2013  tls file at_quick_exit.3 was added on branch tls-maxphys on 2013-06-23 06:21:06 +0000
 1.11 26-Apr-2013  wiz Add commas in list.
 1.10 26-Apr-2013  christos add {at_,}quick_exit(3) from FreeBSD
 1.9 07-Aug-2003  agc branches: 1.9.56; 1.9.62;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 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.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 30-Jan-1998  perry update to lite-2
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 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.9.62.1 23-Jun-2013  tls resync from head
 1.9.56.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 18-Oct-2025  riastradh atexit(3): Sprinkle comments about __cxa_atexit assertion.

Also archive dead codesourcery.com link.

No functional change intended -- comments only.
 1.34 14-Oct-2025  christos revert now that tsan has been made to call atexit() when dso == NULL.
lsan and asan will need to be fixed too.
 1.33 13-Oct-2025  christos Disable the dso assertion for now because the thread sanitizer calls:
tsan_interceptors_posix.cpp: if (REAL(__cxa_atexit)(&finalize, 0, 0))
 1.32 06-Nov-2017  joerg Assert that __cxa_atexit is not used with NULL as DSO. Don't use
__cxa_atexit directly from atexit, they have different behavior.
 1.31 02-Nov-2017  kamil Revert previous on demand.

Rationale:

The DSO handle is a required part of the (external) __cxa_atexit interface.
The atexit mapping is an implementation detail and not part of the public
interface. Doing it directly creates UB as it involves casting function
pointers between incompatible types.

-- Joerg
 1.30 02-Nov-2017  kamil Correct handling of __cxa_atexit(a,b,NULL) in libc

In the NetBSD implementation and suggested by Itanium C++ ABI, we wrap
the atexit(x) call as __cxa_atexit(x,NULL,NULL).

__cxa_atexit() is an internal function for the usage of C++.

Correct a bug that __cxa_atexit(x,y,NULL) is handled in the same way as
atexit(x) (which is simplified to __cxa_atexit(x,NULL,NULL).

This misbehavior has been detected in the Thread Sanitizer port to NetBSD.

Patch reviewed by <christos>

Sponsored by <The NetBSD Foundation>
 1.29 19-Apr-2015  joerg Redo __aeabi_atexit by shuffling the arguments and dropping the code in
libstdc++.
 1.28 18-Apr-2015  joerg Add __aeabi_atexit alias for another case of NIH on ARM.
 1.27 20-Jan-2015  christos Fix non _REENTRANT build.
 1.26 19-Aug-2013  matt branches: 1.26.4;
Put the startup code in .text.startup
 1.25 26-Apr-2013  christos add {at_,}quick_exit(3) from FreeBSD
 1.24 08-Oct-2009  pooka branches: 1.24.6; 1.24.12;
When converting the locking path of mutex+counter to a real recursive
mutex, it's a good idea to convert the unlock path too so that the
recursive mutex gets released as many times as it was locked.
Fixes pthread + cxa deadlock.
 1.23 28-Apr-2008  martin branches: 1.23.8;
Remove clause 3 and 4 from TNF licenses
 1.22 25-Feb-2008  xtraeme branches: 1.22.2;
There's no need to do the mutex_trylock dance anymore in __cxa_finalize(),
just using mutex_lock() is enough.
 1.21 25-Feb-2008  xtraeme Add a comment for __libc_atexit_init() missed in previous that was
available in the original patch.
 1.20 25-Feb-2008  xtraeme Make the atexit mutex recursive and initialize it in __libc_init()
as suggested by ad@, based on the patch provided by Sverre Froyen
in lib/37654.

Reviewed by ad@ and jmcneill@.
 1.19 08-Aug-2007  kristerw branches: 1.19.2; 1.19.6;
Keep track of atexit functions that are added while processing
atexit functions, to ensure that the new functions will be called.
 1.18 08-Aug-2007  kristerw Ensure that the struct atexit_handler has been removed from the list
of pending atexit handlers before the structure is reused. This prevents
__cxa_finalize from going into an infinite loop when an atexit handler
register a new atexit handler as in:

#include <stdlib.h>

void two(void) {
}

void one(void) {
atexit(two);
}

int main(void) {
atexit(one);
return 0;
}
 1.17 12-Jun-2005  lukem branches: 1.17.4; 1.17.6;
Add missing __RCSID()
 1.16 19-Mar-2003  nathanw branches: 1.16.6;
When implementing a recursive mutex, it helps if you remember to
decrement the recursion count.

Fixes the problem of uic dying with a no-next-thread assertion while
building kdeadmin3; reported by Perry Metzger and others on
tech-pkg.
 1.15 04-Mar-2003  thorpej Fix lib/20558:
A dynamically linked program invokes the rtld cleanup routine via
an atexit handler. This rtld cleanup routine invokes _fini() for
shared libraries, which in-turn invoke __cxa_finalize() with their
DSO handle. By luck, this happens to work okay for non-threaded
programs, but for a threaded program, this leads to deadlock (sometimes
manifested as an assertion failure, if the program didn't actually
create any threads).

Fixed by teaching __cxa_finalize() that it can be recursively invoked,
adjusting the handler list manipulation accordingly.
 1.14 01-Mar-2003  thorpej Rewrite atexit(3), and add support for __cxa_atexit()/__cxa_finalize(),
as specified by the C++ ABI for Itanium. Despite the ABI document's name,
many of the items in it are implemented for other architectures.

See the following URL for a reference:

http://www.codesourcery.com/cxx-abi/abi.html#dso-dtor

Fixes lib/18379 (from Joel Baker).
 1.13 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.12 20-Sep-1999  lukem branches: 1.12.10;
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 18-Oct-1998  kleink Protect __atexit manipulation and traversal with a mutex.
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 30-Jan-1998  perry update to lite-2
 1.7 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.6 28-Dec-1995  thorpej New-style RCS ids.
 1.5 14-Jun-1995  jtc define __atexit pointer
 1.4 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.10.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.16.6.1 23-Sep-2007  bouyer Pull up following revision(s) (requested by kristerw in ticket #1843):
lib/libc/stdlib/atexit.c: revisions 1.18, 1.19
Ensure that the struct atexit_handler has been removed from the list
of pending atexit handlers before the structure is reused. This
prevents libc from going into an infinite loop, or to fail
to call registered atexit-handlers in some cases.
 1.17.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.17.4.1 28-Aug-2007  liamjfoy Pull up following revision(s) (requested by kristerw in ticket #839):
lib/libc/stdlib/atexit.c: revision 1.18
lib/libc/stdlib/atexit.c: revision 1.19
Ensure that the struct atexit_handler has been removed from the list
of pending atexit handlers before the structure is reused. This prevents
__cxa_finalize from going into an infinite loop when an atexit handler
register a new atexit handler.

Keep track of atexit functions that are added while processing
atexit functions, to ensure that the new functions will be called.
 1.19.6.1 24-Mar-2008  keiichi sync with head.
 1.19.2.1 23-Mar-2008  matt sync with HEAD
 1.22.2.1 18-May-2008  yamt sync with head.
 1.23.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.23.8.1 28-Apr-2008  martin file atexit.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.24.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.12.1 23-Jun-2013  tls resync from head
 1.24.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.4.2 21-Apr-2015  snj Pull up following revision(s) (requested by joerg in ticket #712):
lib/libc/stdlib/atexit.c: revision 1.29
external/gpl3/gcc/dist/libstdc++-v3/libsupc++/atexit_arm.cc: revision 1.2
Redo __aeabi_atexit by shuffling the arguments and dropping the code in
libstdc++.
 1.26.4.1 19-Apr-2015  msaitoh Pull up following revision(s) (requested by joerg in ticket #708):
lib/libc/stdlib/atexit.c: revision 1.28
Add __aeabi_atexit alias for another case of NIH on ARM.
 1.12 11-Jul-2017  joerg Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
 1.11 28-Apr-2008  martin branches: 1.11.8; 1.11.56;
Remove clause 3 and 4 from TNF licenses
 1.10 01-Mar-2003  thorpej branches: 1.10.30;
Rewrite atexit(3), and add support for __cxa_atexit()/__cxa_finalize(),
as specified by the C++ ABI for Itanium. Despite the ABI document's name,
many of the items in it are implemented for other architectures.

See the following URL for a reference:

http://www.codesourcery.com/cxx-abi/abi.html#dso-dtor

Fixes lib/18379 (from Joel Baker).
 1.9 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 22-Mar-1999  kleink branches: 1.8.12;
Add 3 additional slots to the statically allocated exit handler array to
guarantee the ANSI-defined 32 registrations being possible despite those exit
handler registrations made by the startup code (a.out: 2, ELF: 3).
 1.7 18-Oct-1998  kleink Protect __atexit manipulation and traversal with a mutex.
 1.6 30-Jan-1998  perry update to lite-2
 1.5 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 14-Jun-1995  jtc add extern qualifier to __atexit pointer declaration
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.12.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.10.30.1 18-May-2008  yamt sync with head.
 1.11.56.1 29-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #127):
tests/libexec/ld.elf_so/h_thread_local_dtor.c: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h: revision 1.17
lib/libc/stdlib/atexit.h: file removal
lib/libc/stdlib/exit.c: revision 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h: revision 1.8
lib/libc/stdlib/exit.c: revision 1.17
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.178
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h: revision 1.21
distrib/sets/lists/debug/shl.mi: revision 1.179
distrib/sets/lists/debug/mi: revision 1.219
lib/libpthread/pthread.c: revision 1.150
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h: revision 1.14
libexec/ld.elf_so/symbols.map: revision 1.2
include/dlfcn.h: revision 1.25
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h: revision 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h: revision 1.18
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h: revision 1.17
distrib/sets/lists/tests/mi: revision 1.755
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h: revision 1.20
lib/libc/dlfcn/dlfcn_elf.c: revision 1.14
tests/libexec/ld.elf_so/t_thread_local_dtor.sh: revision 1.1
tests/lib/libpthread/t_thread_local_dtor.sh: revision 1.1
lib/libc/stdlib/Makefile.inc: revision 1.93
lib/libc/include/atexit.h: revision 1.1
lib/libc/include/atexit.h: revision 1.2
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.180
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h: revision 1.14
lib/libc/stdlib/cxa_thread_atexit.c: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h: revision 1.5
libexec/ld.elf_so/rtld.c: revision 1.185
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h: revision 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h: revision 1.19
tests/libexec/ld.elf_so/Makefile: revision 1.9
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h: revision 1.14
tests/lib/libpthread/h_thread_local_dtor.cpp: revision 1.1
distrib/sets/lists/tests/shl.mi: revision 1.11
tests/lib/libpthread/Makefile: revision 1.13
libexec/ld.elf_so/rtld.h: revision 1.129
external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h: revision 1.6
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
Fix filename of new debug file
Add misising DEBUGLIB file
Avoid common declaration.
Drop TLS variant checks, emutls is enough for VAX and Sun2.
 1.11.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11.8.1 28-Apr-2008  martin file atexit.h was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 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 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.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 30-Jan-1998  perry update to lite-2
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 04-Oct-1993  jtc Remove BUGS section, as atof() is now implemented in terms of strtod().
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 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.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-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 30-Jan-1998  perry update to lite-2
 1.8 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.7 28-Dec-1995  thorpej New-style RCS ids.
 1.6 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.5 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 09-Jul-1993  cgd update for better FP routines, from AT&T & elsewhere
 1.2 11-May-1993  proven Prototype now matches declaration.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.56.1 30-Oct-2012  yamt sync with head
 1.11 13-Jun-2018  eadler libc: remove explicit cast NULL in atoi

There isn't any reason to cast NULL so just remove it. A similar change
was already made in DragonFly and FreeBSD (by me).

ok fly@
 1.10 07-Aug-2003  agc branches: 1.10.96;
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 20-Aug-2002  wiz Remove superfluous double quotes and a superfluous Ns.
 1.7 10-Jul-2002  yamt import CAVEATS sections from OpenBSD.
with little tweak by me.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 05-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 30-Jan-1998  perry update to lite-2
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.12.4 27-Aug-2002  nathanw Catch up to -current.
 1.5.12.3 01-Aug-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.10.96.1 25-Jun-2018  pgoyette Sync with HEAD
 1.15 13-Jun-2018  eadler libc: remove explicit cast NULL in atoi

There isn't any reason to cast NULL so just remove it. A similar change
was already made in DragonFly and FreeBSD (by me).

ok fly@
 1.14 07-Jan-2018  kamil branches: 1.14.2;
Revert namespacing of atoi(3)

Sanitizers can handle recursive interceptions in some / most cases, if they
will cause damage the problem will be not workaroundable without libc
changes - I will be back to it.

Keep namespace of asctime() as this can be a cancellation point according
to POSIX. Right now it's not implemented on NetBSD. Defer it for later.

Keep weak symbols and namespace for wait6(2) as this could be a
cancellation point as well. Defer this for later.

Sanitizers's [recursive] interceptors are a hack and moving one way or
another can cause new sets of problems. Recursive ones can be useful and
cause problems (on Linux there are known with with signal handlers).

Sponsored by <The NetBSD Foundation>
 1.13 05-Jan-2018  kamil Register new weak symbol in libc for internal usage: atoi

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.

Add atoi to namespace.h.

Register a new __weak_alias() entry for atoi() in atoi.c.

atoi() is used internally in getrpcent(), rresvport_af(), ftok(), err(),
__llvm_profile_write_file(), llvm_gcda_start_file(), citrus_iconv_open(),
getprotoent_r(), __rpc_uaddr2taddr_af(), __res_nopt_rdata() and
servent_parseline().

This revision switches the internal usage to the internal symbol.

Sponsored by <The NetBSD Foundation>
 1.12 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.11 07-Aug-2003  agc branches: 1.11.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 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-Jan-1998  perry update to lite-2
 1.7 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.6 28-Dec-1995  thorpej New-style RCS ids.
 1.5 14-Jun-1995  jtc add explicit return type
 1.4 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.56.1 30-Oct-2012  yamt sync with head
 1.14.2.1 25-Jun-2018  pgoyette Sync with HEAD
 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-Feb-1998  perry branches: 1.5.12;
add LIBRARY section to man page
 1.4 30-Jan-1998  perry update to lite-2
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 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.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 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 30-Jan-1998  perry update to lite-2
 1.6 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.56.1 30-Oct-2012  yamt sync with head
 1.6 08-Sep-2003  wiz Use St -isoC-9X instead of St -isoC9X, to be in sync with groff.
 1.5 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.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 07-Feb-2002  ross Generate <>& symbolically.
 1.2 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.1 06-Mar-2000  kleink branches: 1.1.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.1.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.1.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.6 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.5 27-Oct-2003  lukem branches: 1.5.56;
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.4 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.3 03-Jun-2003  uwe Add atoll(3) to libnbcompat. We need it when building target's gcc
for a 64-bit target on a 32-bit host.

NB: There seems to be a bug in either gcc itself or the way we import
it, b/c the incorrect #define HAVE_ATOLL is picked from (e.g. for
sparc64) gnu/usr.bin/gcc/arch/sparc64/auto-host.h - so when gen*
auxilary (host) programs are built in gnu/usr.bin/gcc/backend, they
incorrectly pick-up target's HAVE_ATOLL.

For now providing atoll(3) in libnbcompat is a simple and sufficient
workaround.
 1.2 07-Mar-2000  kleink Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.5.56.1 30-Oct-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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.6 05-Feb-1998  perry branches: 1.6.12;
add LIBRARY section to man page
 1.5 30-Jan-1998  perry update to lite-2
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 10-Jan-1994  jtc Fix spelling errors.
 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 30-Jan-1998  perry import lite-2
 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.16 31-May-2022  andvar fix various typos in comments, documentation and messages.
 1.15 04-Mar-2012  christos base0 == NULL is allowed when nmemb == 0, in fact the nsdispatch code calls
bsearch this way.
 1.14 27-Nov-2010  christos branches: 1.14.6;
ansify
 1.13 29-Nov-2005  christos WARNS=4
 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-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 15-Nov-1998  christos delint
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 30-Jan-1998  perry update to lite-2
 1.6 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14.6.1 17-Apr-2012  yamt sync with head
 1.8 02-Aug-1999  lukem replace malloc(3) with one from freebsd which documents our new malloc.c
(also from freebsd). comment out references to reallocf with .\"XXX"
for now. i also fixed some roff misuse as well.
replace calloc(3), free(3) and realloc(3) with links to malloc(3)
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 30-Jan-1998  perry update to lite-2
 1.5 12-Nov-1996  lukem fix the the typos
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 14-Oct-1993  jtc Removed trailing comma from SEE ALSO section.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14 28-Nov-2007  christos Sync phk malloc.c with the latest one from FreeBSD. This gives us the
same api as jemalloc by:

- adding posix_memalign()
- moving calloc in the same file
- renaming malloc_options -> _malloc_options
 1.13 07-Aug-2003  agc branches: 1.13.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 31-Jul-2002  jdolecek restore the previous form of the condition checking malloc() return value, which
was changed in previous revision
 1.11 31-Jul-2002  itojun allow calloc(0, x) and calloc(x, 0). sync w/openbsd
 1.10 30-Jul-2002  itojun die if integer overflow. from openbsd
 1.9 03-Feb-1998  perry branches: 1.9.10; 1.9.12; 1.9.14;
remove obsolete register declarations
 1.8 30-Jan-1998  perry update to lite-2
 1.7 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.6 28-Dec-1995  thorpej New-style RCS ids.
 1.5 30-Nov-1993  jtc Changed to use memset() instead of bzero().
 1.4 13-Oct-1993  jtc Split cfree() out of calloc.c.
If a user compiling in a strict ANSI or strict POSIX environment uses his
own function named cfree (which is legal, since cfree is not in a restricted
namespace) and calloc, the link will fail due to the cfree in calloc.c.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.14.3 02-Aug-2002  lukem Pull up revision 1.12 (requested by lukem):
restore the previous form of the condition checking malloc() return value, which
was changed in previous revision
 1.9.14.2 02-Aug-2002  lukem Pull up revision 1.11 (requested by itojun in ticket #598):
allow calloc(0, x) and calloc(x, 0). sync w/openbsd
 1.9.14.1 31-Jul-2002  lukem Pull up revision 1.10 (requested by itojun in ticket #585):
die if integer overflow. from openbsd
 1.9.12.1 01-Aug-2002  nathanw Catch up to -current.
 1.9.10.1 04-Sep-2002  itojun pullup 1.10-1.12 (itojun)
allow calloc(0, x) and calloc(x, 0). sync w/openbsd
 1.13.22.1 09-Jan-2008  matt sync with HEAD
 1.2 20-May-1994  mycroft Clean up deleted files.
 1.1 13-Oct-1993  jtc Split cfree() out of calloc.c.
If a user compiling in a strict ANSI or strict POSIX environment uses his
own function named cfree (which is legal, since cfree is not in a restricted
namespace) and calloc, the link will fail due to the cfree in calloc.c.
 1.1 11-Jul-2017  joerg branches: 1.1.4;
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
 1.1.4.2 29-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #127):
tests/libexec/ld.elf_so/h_thread_local_dtor.c: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h: revision 1.17
lib/libc/stdlib/atexit.h: file removal
lib/libc/stdlib/exit.c: revision 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h: revision 1.8
lib/libc/stdlib/exit.c: revision 1.17
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.178
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h: revision 1.21
distrib/sets/lists/debug/shl.mi: revision 1.179
distrib/sets/lists/debug/mi: revision 1.219
lib/libpthread/pthread.c: revision 1.150
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h: revision 1.14
libexec/ld.elf_so/symbols.map: revision 1.2
include/dlfcn.h: revision 1.25
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h: revision 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h: revision 1.18
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h: revision 1.17
distrib/sets/lists/tests/mi: revision 1.755
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h: revision 1.20
lib/libc/dlfcn/dlfcn_elf.c: revision 1.14
tests/libexec/ld.elf_so/t_thread_local_dtor.sh: revision 1.1
tests/lib/libpthread/t_thread_local_dtor.sh: revision 1.1
lib/libc/stdlib/Makefile.inc: revision 1.93
lib/libc/include/atexit.h: revision 1.1
lib/libc/include/atexit.h: revision 1.2
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.180
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h: revision 1.14
lib/libc/stdlib/cxa_thread_atexit.c: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h: revision 1.5
libexec/ld.elf_so/rtld.c: revision 1.185
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h: revision 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h: revision 1.19
tests/libexec/ld.elf_so/Makefile: revision 1.9
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h: revision 1.14
tests/lib/libpthread/h_thread_local_dtor.cpp: revision 1.1
distrib/sets/lists/tests/shl.mi: revision 1.11
tests/lib/libpthread/Makefile: revision 1.13
libexec/ld.elf_so/rtld.h: revision 1.129
external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h: revision 1.6
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
Fix filename of new debug file
Add misising DEBUGLIB file
Avoid common declaration.
Drop TLS variant checks, emutls is enough for VAX and Sun2.
 1.1.4.1 11-Jul-2017  bouyer file cxa_thread_atexit.c was added on branch netbsd-8 on 2017-08-29 09:43:16 +0000
 1.16 24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.15 17-Dec-2016  abhinav Fix typo
 1.14 03-May-2011  wiz branches: 1.14.26;
Remove \*[q] -- not necessary, just use plain double quotes instead.
 1.13 13-Apr-2011  jruoho Collect also the division functions to single place, div(3).
 1.12 04-Aug-2008  matt branches: 1.12.6;
Add C99 functions imaxabs and imaxdiv.
 1.11 07-Aug-2003  agc branches: 1.11.32;
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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.7 06-Mar-2000  kleink branches: 1.7.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 30-Jan-1998  perry update to lite-2
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 21-Mar-1995  jtc add cross references to qdiv(3)
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 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.11.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.12.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.12.6.1 04-Aug-2008  matt file div.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.14.26.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8 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.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 30-Jan-1998  perry update to lite-2
 1.5 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 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.6 12-Jun-2005  lukem Add missing __RCSID()
 1.5 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.4 09-Jan-1998  perry RCS Id Police.
 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 14-Oct-1993  jtc branches: 1.2.8;
Rename intenral _rand_foo variables to __rand_foo, as _rand_foo is in the
user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.9 22-Mar-2006  drochner <math.h> is just needed for the ldexp() call in erand48() -
remove unnecessary dependency
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 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.4 09-Jan-1998  perry RCS Id Police.
 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-Oct-1993  jtc branches: 1.2.8;
Change _dorand48 to __dorand48, as _dorand48 is in the user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.2 31-Mar-2006  drochner switch byteorder of seed to match previous (and documented) behaviour
 1.1 22-Mar-2006  drochner Rewrite erand48() to put the random bits into the mantissa by simple
bitshifts instead of calling ldexp() three times.
(for ieee doubles only -- vax can't use it, so the old version
needs to stay around)
This removes the dependency on ldexp() which also didn't participate in
the usual __RENAME game, thus lead to confusion.
In addition, this version is almost 3 times as fast for me.
 1.17 01-Sep-2019  sevan Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf
 1.16 26-Apr-2013  christos branches: 1.16.28; 1.16.30;
add {at_,}quick_exit(3) from FreeBSD
 1.15 02-Jan-2012  dholland branches: 1.15.6;
Clarify the behavior of exit(x) for out-of-range x. PR 45769
 1.14 07-Aug-2003  agc branches: 1.14.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 10-May-2003  wiz Misc fixes from jmc@openbsd.
 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 New sentence, new line. From Robert Elz.
 1.10 10-Aug-2002  yamt bump .Dd .
 1.9 10-Aug-2002  yamt note only 8 bits of exit-status is passed.
from OpenBSD.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 22-Mar-2001  cgd document EXIT_SUCCESS and EXIT_FAILURE, since they've been around
since ANSI and (for portability, since ANSI) in some circles they're
the preferred exit status codes.
 1.6 29-Aug-1998  lukem branches: 1.6.12;
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 05-Feb-1998  perry add LIBRARY section to man page
 1.4 30-Jan-1998  perry update to lite-2
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.12.5 18-Oct-2002  nathanw Catch up to -current.
 1.6.12.4 13-Aug-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.14.56.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.56.1 17-Apr-2012  yamt sync with head
 1.15.6.1 23-Jun-2013  tls resync from head
 1.16.30.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.16.28.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17 14-Jul-2017  joerg Drop TLS variant checks, emutls is enough for VAX and Sun2.
 1.16 11-Jul-2017  joerg Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
 1.15 18-May-2011  dsl branches: 1.15.36;
Remove __P()
 1.14 07-Mar-2011  joerg Pass down ELF Auxillary Vectors for static NetBSD binaries too.
Rename __libc_init to _libc_init and call it explicitly from CSU code.
This enforces the constructor run order for newly linked programs.
Keep it as constructor with run-once semantic for binary compatibility.
Implement dl_iterate_phdr for statically linked programs.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.13 09-Sep-2010  skrll Only do the __libc_init hack in libc, i.e. remove it from ld.elf_so.

This fixes hppa ld.elf_so by reducing the number of PLABELs required to
the number before the hack was applied.

Hi Joerg!
 1.12 28-Jun-2010  joerg Ensure that initfini.c is referenced by exit.c. The start up code has to
reference the latter as a return of main() results in a call to exit(3),
so this ensures that the libc constructors are run for statically linked
programs. Fixes PR 37454.
 1.11 30-Oct-2007  skrll branches: 1.11.12; 1.11.20;
Build a local copy of exit that doesn't call __cxa_finalize. It's not
needed and drags in a lot of libc via free.
 1.10 07-Aug-2003  agc branches: 1.10.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 01-Mar-2003  thorpej Rewrite atexit(3), and add support for __cxa_atexit()/__cxa_finalize(),
as specified by the C++ ABI for Itanium. Despite the ABI document's name,
many of the items in it are implemented for other architectures.

See the following URL for a reference:

http://www.codesourcery.com/cxx-abi/abi.html#dso-dtor

Fixes lib/18379 (from Joel Baker).
 1.8 18-Oct-1998  kleink Protect __atexit manipulation and traversal with a mutex.
 1.7 03-Feb-1998  perry remove obsolete register declarations
 1.6 30-Jan-1998  perry update to lite-2
 1.5 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.22.1 06-Nov-2007  matt sync with HEAD
 1.11.20.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.11.12.2 12-Sep-2010  snj Pull up following revision(s) (requested by skrll in ticket #1451):
lib/libc/stdlib/exit.c: revision 1.13
Only do the __libc_init hack in libc, i.e. remove it from ld.elf_so.
This fixes hppa ld.elf_so by reducing the number of PLABELs required to
the number before the hack was applied.
 1.11.12.1 16-Jul-2010  riz Pull up following revision(s) (requested by joerg in ticket #1423):
lib/libc/stdlib/exit.c: revision 1.12
lib/libc/misc/initfini.c: revision 1.6
Ensure that initfini.c is referenced by exit.c. The start up code has to
reference the latter as a return of main() results in a call to exit(3),
so this ensures that the libc constructors are run for statically linked
programs. Fixes PR 37454.
 1.15.36.1 29-Aug-2017  bouyer Pull up following revision(s) (requested by joerg in ticket #127):
tests/libexec/ld.elf_so/h_thread_local_dtor.c: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h: revision 1.17
lib/libc/stdlib/atexit.h: file removal
lib/libc/stdlib/exit.c: revision 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h: revision 1.8
lib/libc/stdlib/exit.c: revision 1.17
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.178
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h: revision 1.21
distrib/sets/lists/debug/shl.mi: revision 1.179
distrib/sets/lists/debug/mi: revision 1.219
lib/libpthread/pthread.c: revision 1.150
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h: revision 1.14
libexec/ld.elf_so/symbols.map: revision 1.2
include/dlfcn.h: revision 1.25
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h: revision 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h: revision 1.18
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h: revision 1.17
distrib/sets/lists/tests/mi: revision 1.755
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h: revision 1.20
lib/libc/dlfcn/dlfcn_elf.c: revision 1.14
tests/libexec/ld.elf_so/t_thread_local_dtor.sh: revision 1.1
tests/lib/libpthread/t_thread_local_dtor.sh: revision 1.1
lib/libc/stdlib/Makefile.inc: revision 1.93
lib/libc/include/atexit.h: revision 1.1
lib/libc/include/atexit.h: revision 1.2
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h: revision 1.14
distrib/sets/lists/debug/shl.mi: revision 1.180
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h: revision 1.14
lib/libc/stdlib/cxa_thread_atexit.c: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp: revision 1.1
tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.1
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h: revision 1.5
libexec/ld.elf_so/rtld.c: revision 1.185
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h: revision 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h: revision 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h: revision 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h: revision 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h: revision 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h: revision 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h: revision 1.19
tests/libexec/ld.elf_so/Makefile: revision 1.9
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h: revision 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h: revision 1.14
tests/lib/libpthread/h_thread_local_dtor.cpp: revision 1.1
distrib/sets/lists/tests/shl.mi: revision 1.11
tests/lib/libpthread/Makefile: revision 1.13
libexec/ld.elf_so/rtld.h: revision 1.129
external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h: revision 1.6
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
Fix filename of new debug file
Add misising DEBUGLIB file
Avoid common declaration.
Drop TLS variant checks, emutls is enough for VAX and Sun2.
 1.7 02-Aug-1999  lukem replace malloc(3) with one from freebsd which documents our new malloc.c
(also from freebsd). comment out references to reallocf with .\"XXX"
for now. i also fixed some roff misuse as well.
replace calloc(3), free(3) and realloc(3) with links to malloc(3)
 1.6 28-Apr-1998  fair fix mdoc references and mistakes
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 30-Jan-1998  perry update to lite-2
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.26 25-May-2025  rillig getenv.3: setenv conforms to IEEE 1003.1-2001
 1.25 26-Oct-2010  wiz branches: 1.25.58;
Improve wording after consultation with njoly.
 1.24 25-Oct-2010  njoly Make putenv(3) fails with EINVAL for a null pointer, or for a string
that either miss or start with a `=' character.

Adjust man page and testcase accordingly.
 1.23 16-Oct-2010  njoly Make setenv(3) follow the standard, by rejecting invalid strings. It
now fails with EINVAL errno when variable is NULL, empty or contains
an `=' character; or value is NULL.

Adjust the man page accordingly, and exercize them in the existing
environment testcase.
 1.22 01-Oct-2010  wiz Fix a typo, remove trailing whitespace.
 1.21 01-Oct-2010  christos make putenv POSIX compliant.
 1.20 23-Sep-2010  njoly Add empty line in ERRORS section.
 1.19 26-Sep-2005  wiz Punctuation nits; grammar fix.
 1.18 25-Sep-2005  christos add getenv_r and ttyname_r
 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-Apr-2003  drochner unsetenv(3) returns "int" now
 1.14 07-Apr-2003  kleink 1003.1-2001 has introduced unsetenv() which differs from the current
implementation in not permitting a "name=value" argument.
* Add a conforming __unsetenv13() and do function renaming for
unsetenv(); preserve old symbol with old behavior.
* Make visible setenv() and unsetenv() for 1003.1-2001 feature selection
macros; resolves PR standards/20479.
 1.13 10-Aug-2002  yamt result of getenv should be treated as read-only.
from OpenBSD.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.10 06-Feb-1998  kleink branches: 1.10.12;
Update standards section for putenv().
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 30-Jan-1998  perry update to lite-2
 1.7 28-Dec-1995  thorpej New-style RCS ids.
 1.6 08-Apr-1994  cgd fix it to be the way i *meant* it to be...
 1.5 07-Apr-1994  mycroft From Mark Weaver: Fix typo.
 1.4 01-Apr-1994  cgd specify what the args's contents must be
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.12.4 13-Aug-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.25.58.1 02-Aug-2025  perseant Sync with HEAD
 1.37 11-Feb-2022  rillig libc/getenv: remove trailing whitespace

No binary change.
 1.36 20-Jan-2015  christos Fix non _REENTRANT build.
 1.35 14-Nov-2010  tron 1.) Rename internal function __findvar() to __findenvvar().
2.) Add a wrapper function __findenv() which implements the previous
*internal* interface. It turns out that ld.elf_so(1) and pthread(3)
both use it.

Stripping e.g. "LD_LIBRARY_PATH" from the environment while running
setuid binaries works again now.
 1.34 14-Nov-2010  tron Set errno to ENOENT if we reject the environment variable name in
getenv_r() instead of leaving it unchanged.
 1.33 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.32 10-Nov-2010  enami Clear all entries past the NULL while scrubing environ vector.
 1.31 10-Nov-2010  enami Indent using tab rather than four spaces.
 1.30 04-Nov-2010  christos scrub the whole array, not just the first n malloced entries.
 1.29 03-Nov-2010  christos Handle the case where a program attempted to cleanup the environment by
setting *environ = NULL;
 1.28 02-Nov-2010  enami - Simplify the code
- Reword the comment.
 1.27 01-Nov-2010  enami Double the array only when really necessary. Otherwise memory will be
exhausted if user modifies the variable envrion itself repeatedly..
 1.26 24-Oct-2010  tron Double the size of the allocate environment vector when we resize it.
This should speed up extending the environment via setenv(3).
 1.25 02-Oct-2010  tron Make sure that all extra elements of the environment vector are set
to NULL. This stop su(1) from crashing.
 1.24 01-Oct-2010  christos make putenv POSIX compliant.
 1.23 29-Sep-2010  enami If new length is exactly equals to the current length,
there is nothing to do.
 1.22 25-Sep-2010  christos be more conservative about allocing.
 1.21 25-Sep-2010  tron Remember memory used by allocated environment variables instead of
using a bitmap. This deals with the case where a variable is first
set via setenv(3) or putenv(3), then overwritten by changing
"environ" directory and afterwards overwritten with setenv(3) again.

This stops "zsh" from crashing under NetBSD-current.

Code reviewed by Christos Zoulas.
 1.20 23-Sep-2010  christos Use a bit array to keep track of malloced environment entries so we can
free them.
 1.19 31-Oct-2008  christos branches: 1.19.2;
make __findenv return the offset for the new entry to be inserted when
the string is not found, to avoid an additional scan of the environ array
in setenv.
 1.18 25-Sep-2005  christos branches: 1.18.26;
add getenv_r and ttyname_r
 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 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.15 19-Dec-2000  christos branches: 1.15.2;
fix nested extern declaration.
 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 15-Nov-1998  christos delint
 1.11 11-Sep-1998  kleink Add a multiple-reader/single-writer lock to protect environ.
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 30-Jan-1998  perry update to lite-2
 1.8 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.7 20-Dec-1996  cgd const poisoning: __findenv()'s first arg should be const char * (lint)
 1.6 28-Dec-1995  thorpej New-style RCS ids.
 1.5 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.4 15-Oct-1993  jtc branches: 1.4.4;
Rename _findenv() to __findenv(), as _findenv is in the user's namespace.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 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.15.2.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.18.26.1 22-Nov-2010  riz Pull up following revision(s) (requested by tron in ticket #1474):
lib/libc/stdlib/getenv.c: revision 1.33 via patch
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
results e.g. for " getenv("A=3DB") " if an environment variable "A"
with value "B=3DC" exists.
 1.19.2.2 31-Oct-2008  christos make __findenv return the offset for the new entry to be inserted when
the string is not found, to avoid an additional scan of the environ array
in setenv.
 1.19.2.1 31-Oct-2008  christos file getenv.c was added on branch christos-time_t on 2008-10-31 17:46:05 +0000
 1.36 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.35 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.34 05-Jun-2014  wiz Remove trailing whitespace.
 1.33 05-Jun-2014  christos Bring getopt(3) inline with getopt_long(3): recognize option:: as an optional
option.
 1.32 22-Mar-2010  joerg branches: 1.32.12; 1.32.22;
Use .In for header files instead of .Ar Pa and variations.
 1.31 23-Sep-2003  wiz Slight syncing with OpenBSD version.
 1.30 10-Sep-2003  wiz Use standard section headers, suggested by jmc@openbsd. Sort sections.
 1.29 10-Sep-2003  wiz Pull over some improvements from OpenBSD's v1.26 of this file, including
SEE ALSO and RETURN VALUES sections.
 1.28 10-Sep-2003  itojun getopt return value has to be held in int, not char.
 1.27 09-Sep-2003  wiz Fix typos and declare a missing variable in example. From Quentin Garnier in PR 22733.
 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 27-Jun-2003  wiz Quote question mark.
 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-Aug-2002  yamt fix sample code. from openbsd.
 1.22 07-Feb-2002  ross generate & symbolically
 1.21 07-Feb-2002  ross Generate <>& symbolically.
 1.20 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.19 25-Jan-2000  elric branches: 1.19.6;
Added a tab before a '}' to put the brace in the right place.
 1.18 02-Dec-1999  kleink Change the declaration of the argv argument to getopt(3) from "char * const *"
(as originally declared in System V) to "char * const []", as was done in
1003.2 and subsequently propagated into XPG4.
From Andrew Cagney in PR lib/8930.
 1.17 19-Nov-1999  kristerw Typos (from OpenBSD)
 1.16 22-Mar-1999  garbled branches: 1.16.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.15 07-Feb-1999  bad getopt() does not return -1 when encountering an unknown option.
Also, minor KNF nit in an example.
 1.14 29-Jul-1998  ross English.
 1.13 28-Apr-1998  fair fix mdoc references and mistakes
 1.12 05-Feb-1998  perry add LIBRARY section to man page
 1.11 30-Jan-1998  perry update to lite-2
 1.10 09-Jan-1998  perry RCS Id Police.
 1.9 04-Jun-1997  mikel optarg -> optstring and rewording from Brian Grayson in PR misc/3697.
 1.8 06-May-1994  jtc merge back in our changes (mostly POSIX.2 pedanticism)
 1.7 06-May-1994  jtc sync with 44lite
 1.6 10-Jan-1994  jtc Fix spelling errors.
 1.5 13-Oct-1993  jtc Document (well, really just mention) external variable optopt.
Add trailing semicolons to the extern variables in the SYNOPSIS section
like all of the other manpages with extern variables.
 1.4 12-Oct-1993  jtc POSIX.2 requires special behavior if the first character of the optstring
argument is a colon.
Updated the manpage to reflect the above change, and expanded the example to
the one used by the POSIX.2 rationale, as it more clearly explains how
the new behavior is to be used.
The manpage should be rewritten --- it is much more confusing than it
should be.
 1.3 14-Sep-1993  jtc POSIX.2 has changed getopt to return -1 instead of EOF (to decouple getopt()
from standard i/o). This change is more pedantic than functional as EOF
is defined to be -1.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 30-Jan-1998  perry import lite-2
 1.1.1.2 06-May-1994  jtc 44lite getopt.[c3]
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.16.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.6.4 13-Aug-2002  nathanw Catch up to -current.
 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 08-Oct-2001  nathanw Catch up to -current.
 1.32.22.1 10-Aug-2014  tls Rebase.
 1.32.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.31 29-Jun-2024  rin getopt.c: Migrate from lib/libc/stdlib to common/lib/libc/stdlib
 1.30 19-Jan-2024  christos add some const
 1.29 05-Jun-2014  christos Bring getopt(3) inline with getopt_long(3): recognize option:: as an optional
option.
 1.28 20-Mar-2009  joerg branches: 1.28.12; 1.28.22;
ANSIfy. Remove conditional macros around __RCSID.
 1.27 29-Nov-2005  christos branches: 1.27.30;
WARNS=4
 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 20-Jan-2003  dsl Fix lib/17248 properly
'ls -l-' now reports unknown option -- -
'env -' and 'su -' both work ok
(change approved by christos)
 1.24 21-Jun-2002  wiz Undo last two, until I have time to take a good look at the problems.
 1.23 13-Jun-2002  wiz According to POSIX, "-" (the string) is an exception and should not
be parsed as option. Restore behaviour broken by previous commit.
Mirrors second part of patch from lib/17248.
 1.22 13-Jun-2002  wiz Fix '-' handling. POSIX only recognizes "--" as end-of-options.
Problem noted in lib/17248 by David Laight, including a patch.
Part of this patch was used.
 1.21 24-Apr-2001  joda don't claim that options are illegal, cf lib/12715
 1.20 19-Feb-2001  cgd branches: 1.20.2;
nuke a ref to __progname that somehow crept in
 1.19 19-Feb-2001  cgd convert from __progname to getprogname()
 1.18 20-Dec-2000  christos fix nested extern
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 02-Dec-1999  kleink Change the declaration of the argv argument to getopt(3) from "char * const *"
(as originally declared in System V) to "char * const []", as was done in
1003.2 and subsequently propagated into XPG4.
From Andrew Cagney in PR lib/8930.
 1.15 20-Sep-1999  lukem branches: 1.15.4;
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 09-Jan-1999  kleink 1003.2-92 specifies the string "--" to be recognized as the option list
delimiter as opposed to any string merely beginning with '-''-'; change to
match the standard. From Simon J. Gerraty <sjg@quick.com.au> in PR lib/6762.
 1.12 03-Feb-1998  perry include <unistd.h> instead of <stdlib.h> to fix a compile error caused
by the fact that the prototype for getopt has moved to unistd.h
 1.11 30-Jan-1998  perry update to lite-2
 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.8 28-Dec-1995  thorpej New-style RCS ids.
 1.7 06-May-1994  jtc merge back in our changes (mostly POSIX.2 pedanticism)
 1.6 06-May-1994  jtc sync with 44lite
 1.5 12-Oct-1993  jtc POSIX.2 requires special behavior if the first character of the optstring
argument is a colon.
Updated the manpage to reflect the above change, and expanded the example to
the one used by the POSIX.2 rationale, as it more clearly explains how
the new behavior is to be used.
The manpage should be rewritten --- it is much more confusing than it
should be.
 1.4 14-Sep-1993  jtc POSIX.2 has changed getopt to return -1 instead of EOF (to decouple getopt()
from standard i/o). This change is more pedantic than functional as EOF
is defined to be -1.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 30-Jan-1998  perry import lite-2
 1.1.1.2 06-May-1994  jtc 44lite getopt.[c3]
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.15.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.20.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.20.2.2 21-Jun-2002  nathanw Catch up to -current.
 1.20.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.27.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.28.22.1 10-Aug-2014  tls Rebase.
 1.28.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22 04-Jan-2022  uwe getopt_long(3): "index" is an argument, not a field.
 1.21 04-Jan-2022  uwe getopt_long(3): use NULL, not 0, for flag in the example.
 1.20 09-Dec-2018  christos fix grammar.
 1.19 03-Jul-2017  wiz branches: 1.19.4; 1.19.6;
Remove workaround for ancient HTML generation code.
 1.18 02-Jul-2007  ginsbach Document that getopt_long(3) can and will accept unique abbreviated long
option names. This feature has been present since getopt_long(3) was first
released in NetBSD 1.5. This is also standard GNU getopt_long(3) behavior.
 1.17 28-Jun-2006  mjl s,floride,fluoride,
 1.16 02-Dec-2005  yamt note that "argv" is not really const.
 1.15 18-Apr-2005  wiz Document index argument, and mention that long_options
needs to be terminated with a structure containing zeroes.
Slightly modified version of patch from PR 30002 by Kailash Sethuraman.
Bump date.
 1.14 07-Aug-2003  agc branches: 1.14.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 29-May-2003  kleink KNF example: NULL vs. 0, space after switch.
 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-Oct-2002  wiz Grammar fixes and markup improvements.
 1.10 02-Oct-2002  wiz completely with only one "el".
 1.9 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.8 03-Jun-2002  wiz Fix SYNOPSIS, noted by Martin Macok on tech-userlevel.
 1.7 07-Feb-2002  ross branches: 1.7.2;
generate & symbolically
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.4 26-Nov-2000  wiz branches: 1.4.2;
Reorder sections to conform more to mdoc.samples; remove non-mdoc
section header; fix two typos.
 1.3 07-Apr-2000  wiz small fixes; not yet complete
 1.2 02-Apr-2000  christos Remove sections relevant to getopt, and add implementation differences.
 1.1 23-Jul-1999  mcr getopt long functionality
 1.4.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.4.2.4 21-Jun-2002  nathanw Catch up to -current.
 1.4.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.7.2.1 04-Jun-2002  lukem Pull up revision 1.8 (requested by wiz in ticket #148):
Fix SYNOPSIS, noted by Martin Macok on tech-userlevel.
 1.14.4.1 07-May-2005  snj Pull up revision 1.15 (requested by wiz in ticket #1432):
Document index argument, and mention that long_options
needs to be terminated with a structure containing zeroes.
Slightly modified version of patch from PR 30002 by Kailash Sethuraman.
Bump date.
 1.19.6.1 10-Jun-2019  christos Sync with HEAD
 1.19.4.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.28 19-Jan-2024  christos add some const
 1.27 01-Sep-2015  kamil ANSIfy getopt(3) - this is the REPLACE_GETOPT version from getopt_long(3)

For the reference, this version still passes the current set of ATF tests
for the getopt(3) function.

This version is by default unused.
 1.26 01-Sep-2015  kamil Constness correction for the getopt(3) function under REPLACE_GETOPT

Use the __UNCONST() macro, which is used in the other parts for the same
argument nargv, but under the !REPLACE_GETOPT namespace.
 1.25 20-Mar-2009  joerg ANSIfy. Remove conditionals around __RCSID.
 1.24 09-Nov-2007  christos branches: 1.24.16;
always compile getopt_long. some ifdef reduction. more to come.
 1.23 06-Nov-2007  christos Revert previous. This mess of ifdefs needs to be killed.
 1.22 06-Nov-2007  christos move the test to replace getopt higher up, before we need to include anything.
 1.21 05-Jul-2007  ginsbach branches: 1.21.4;
Fix several end cases:

o If a long option looks like an ambiguous abbreviation of two or more long
options, but all the possible interpretations would return the same
value, then just return that value without complaining that it's
ambiguous.

o If a long option could be interpreted either as an exact match for one
long option, or as an abbreviation for one or more other long options,
then treat it as the exact match.

These changes align NetBSD's getopt_long(3) with the current behavior of
GNU getopt_long(3), the de facto standard, and FreeBSD's getopt_long(3).
 1.20 04-Oct-2006  wiz Switch from 4-clause to 2-clause BSD license.
Ok dillo@, board@.
 1.19 02-Dec-2005  yamt don't make internal functions pretend to take a const argument.
 1.18 29-Nov-2005  christos WARNS=4
 1.17 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.16 27-Oct-2003  lukem branches: 1.16.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.15 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.14 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.13 04-Nov-2001  lukem fix WARNS=2 (-Wshadow) warnings
 1.12 24-Apr-2001  joda don't claim that options are illegal, cf lib/12715
 1.11 12-Feb-2001  cgd branches: 1.11.2;
don't extern char *__progname; it's never used!
 1.10 04-Jan-2001  lukem sprinkle _DIAGASSERT() around
 1.9 26-Nov-2000  wiz Be SUS-conformant regarding return value when option argument is missing.
Handle "-" correctly.
 1.8 25-Aug-2000  thorpej Some (popular) programs expect to be able to re-initialize `optind'
to 0 and have getopt(3)/getopt_long(3) continue to function properly.
This happens to work with GNU getopt_long(3), so mimmick the behavior.

Fixes pkg/10980 (Manuel Bouyer): rsyncd was relying on this behavior.
 1.7 08-Jul-2000  sommerfeld Correct format mismatch for field widths
 1.6 09-Jun-2000  nathanw branches: 1.6.2;
Don't segfault when complaining about an invalid single-character option.

When complaining about a long option which requires an argument,
print the actual option, not some pointer-garbage.

(Hint: "%c" and "%s" are different.)
 1.5 02-Apr-2000  christos branches: 1.5.2;
Add "namespace.h" and include <getopt.h> since we moved the stuff out
of <unistd.h>
 1.4 02-Apr-2000  christos New getopt_long from Thomas Klausner and Dieter Baron
 1.3 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.2 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.1 23-Jul-1999  mcr getopt long functionality
 1.5.2.1 23-Jun-2000  minoura Import of most recent XPG4DL dated 2000.06.23.
 1.6.2.2 17-Oct-2000  tv Pullup 1.7 [releng]:
Correct format mismatch for field widths
 1.6.2.1 25-Aug-2000  thorpej Pull up rev. 1.8:
Some (popular) programs expect to be able to re-initialize `optind'
to 0 and have getopt(3)/getopt_long(3) continue to function properly.
This happens to work with GNU getopt_long(3), so mimmick the behavior.

Fixes pkg/10980 (Manuel Bouyer): rsyncd was relying on this behavior.
 1.11.2.4 22-Mar-2002  nathanw Catch up to -current.
 1.11.2.3 08-Mar-2002  nathanw Catch up to -current.
 1.11.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.11.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.16.2.1 22-Jun-2004  tron Pull up revision 1.17 (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.21.4.1 09-Jan-2008  matt sync with HEAD
 1.24.16.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 15-Aug-2018  martin PR standards/53525: move getsubopt to stdlib.h
 1.15 03-Jul-2017  wiz branches: 1.15.4; 1.15.6;
Remove workaround for ancient HTML generation code.
 1.14 17-Nov-2009  wiz Mention that it is included in IEEE Std 1003.1-2008.
 1.13 17-Nov-2009  wiz Mention that getsubopt is an XSI extension for IEEE Std 1003.1, 2004 Edition. Bump date.
 1.12 19-Oct-2009  joerg Fix header to include. From Kristaps Dzonsons.
 1.11 07-Aug-2003  agc branches: 1.11.38; 1.11.46;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 10-May-2003  wiz Misc fixes from jmc@openbsd.
 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 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.5 24-Apr-2001  joda don't claim that options are illegal, cf lib/12715
 1.4 05-Feb-1998  perry branches: 1.4.12;
add LIBRARY section to man page
 1.3 03-Feb-1998  perry .Bx'ize
 1.2 31-Jan-1998  thorpej RCS ID police, and add explicit return value to getsubopt().
 1.1 30-Jan-1998  perry branches: 1.1.1;
Initial revision
 1.1.1.1 30-Jan-1998  perry import lite-2
 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.11.46.1 21-Apr-2010  matt sync to netbsd-5
 1.11.38.1 20-Oct-2009  snj Pull up following revision(s) (requested by joerg in ticket #1106):
lib/libc/stdlib/getsubopt.3: revision 1.12
Fix header to include. From Kristaps Dzonsons.
 1.15.6.1 10-Jun-2019  christos Sync with HEAD
 1.15.4.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.10 30-Aug-2018  christos Allow being compiled as a tool.
 1.9 25-Jun-2012  abs branches: 1.9.30; 1.9.32;
Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.8 09-May-2004  kleink branches: 1.8.50;
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.7 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.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 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.4 03-Feb-1998  perry remove obsolete register declarations
 1.3 31-Jan-1998  thorpej Pull in <string.h> to get strcmp() prototype.
 1.2 31-Jan-1998  thorpej RCS ID police, and add explicit return value to getsubopt().
 1.1 30-Jan-1998  perry branches: 1.1.1;
Initial revision
 1.1.1.1 30-Jan-1998  perry import lite-2
 1.8.50.1 30-Oct-2012  yamt sync with head
 1.9.32.1 10-Jun-2019  christos Sync with HEAD
 1.9.30.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4 30-Apr-2008  martin branches: 1.4.8;
Convert TNF licenses to new 2 clause variant
 1.3 28-May-2004  wiz branches: 1.3.24;
Uppercase Dt argument; \-1, not -1; sort SEE ALSO; & -> \*[Am].
 1.2 28-May-2004  wiz Drop trailing whitespace.
 1.1 27-May-2004  christos unix/98 pty functions and manual pages.
 1.3.24.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 grantpt.3 was added on branch christos-time_t on 2008-04-30 13:10:52 +0000
 1.15 21-Feb-2023  rillig hcreate.3: fix typo
 1.14 07-Feb-2017  christos PR/51958: Ngie Cooper: ESRCH error description in hcreate(3) contains typo
for action
 1.13 20-Jul-2014  christos branches: 1.13.6; 1.13.10;
amend the new destroy function to take function pointers.
 1.12 20-Jul-2014  wiz Remove trailing whitespace. Sort SEE ALSO. Add comma in list.
 1.11 20-Jul-2014  christos Our hdestroy implementation was non-conformant because it freed the key of
each entry. Add a new function hdestroy1 that allows the user to control
what gets freed. Pointed out by Pedro Giffuni at FreeBSD.
 1.10 15-Sep-2011  wiz branches: 1.10.8; 1.10.18;
Various fixes, mostly missing words or letters.
 1.9 14-Sep-2011  christos add re-entrant versions of the hash functions based on the GNU api.
 1.8 01-May-2010  jruoho Improvements to wording and markup.

In addition, list more bugs and caveats. Namely, the NetBSD implementation
(like the FreeBSD one where this was ported to) requires that the comparison
keys are allocated dynamically, and that hdestroy() will try to free(3) each
key. This obviously severely limits the portability, given that other
implementations (for example, the Linux one) make no such assumptions. Both
approaches are legitimate, and thus the real bug is in the ambiguity of the
standard.
 1.7 30-Apr-2008  martin branches: 1.7.8;
Convert TNF licenses to new 2 clause variant
 1.6 16-Apr-2003  wiz branches: 1.6.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.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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.2 14-Feb-2001  cgd branches: 1.2.2; 1.2.4;
update for current status of implementation
 1.1 14-Feb-2001  cgd move db/man/hcreate.3 to stdlib/hcreate.3
 1.2.4.2 13-Mar-2001  he Pull up revisions 1.1-1.2 (new, requested by cgd):
Replace hcreate() / hsearch() / hdestroy() implementation with
one that actually works as it's supposed to.
 1.2.4.1 14-Feb-2001  he file hcreate.3 was added on branch netbsd-1-5 on 2001-03-13 21:19:18 +0000
 1.2.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.2.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.2.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.6.30.1 18-May-2008  yamt sync with head.
 1.7.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.7.8.1 30-Apr-2008  martin file hcreate.3 was added on branch christos-time_t on 2008-04-30 13:10:52 +0000
 1.10.18.1 10-Aug-2014  tls Rebase.
 1.10.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.10.1 21-Apr-2017  bouyer Sync with HEAD
 1.13.6.1 20-Mar-2017  pgoyette Sync with HEAD
 1.13 13-Mar-2022  kre Avoid referencing uninit'd memory.
 1.12 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.11 12-Mar-2022  nia hcreate(3): use reallocarr instead of malloc(x * y)
 1.10 20-Jul-2014  christos amend the new destroy function to take function pointers.
 1.9 20-Jul-2014  christos Our hdestroy implementation was non-conformant because it freed the key of
each entry. Add a new function hdestroy1 that allows the user to control
what gets freed. Pointed out by Pedro Giffuni at FreeBSD.
 1.8 17-Sep-2011  christos branches: 1.8.8; 1.8.18;
remove the advertising clause so it can be used by the OpenJDK.
 1.7 14-Sep-2011  christos add re-entrant versions of the hash functions based on the GNU api.
 1.6 21-Jul-2008  lukem branches: 1.6.6;
Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.5 23-Apr-2004  simonb branches: 1.5.26;
s/this this/this/.
 1.4 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.3 21-Feb-2001  lukem branches: 1.3.4;
fix _DIAGASSERT usage in hsearch()
 1.2 19-Feb-2001  ross LP64
 1.1 14-Feb-2001  cgd add new, from scratch implementation of hsearch() et al that actually works
 1.3.4.2 13-Mar-2001  he Pull up revisions 1.1-1.3 (new, requested by cgd):
Replace hcreate() / hsearch() / hdestroy() implementation with
one that actually works as it's supposed to.
 1.3.4.1 21-Feb-2001  he file hcreate.c was added on branch netbsd-1-5 on 2001-03-13 21:19:36 +0000
 1.5.26.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.6.2 21-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.6.6.1 21-Jul-2008  lukem file hcreate.c was added on branch christos-time_t on 2008-07-21 12:05:44 +0000
 1.8.18.1 10-Aug-2014  tls Rebase.
 1.8.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17 16-Nov-2008  ad Our qsort() is inappropriate for kernel use because it makes recursive
calls. Replace it with a kheapsort() function in kernel. Pointed out
by tron@.
 1.16 11-Mar-2008  rmind branches: 1.16.10;
Use size_t to avoid overflow when sorting large arrays. While here, ANSIfy.
Obtained from FreeBSD (das@).
 1.15 28-Nov-2004  jmc branches: 1.15.16; 1.15.22;
Add heapsort to libnbcompat
 1.14 07-Sep-2003  wiz branches: 1.14.4;
Fix typos in comments; from Brian Poole via jmc@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 22-Jan-2000  mycroft 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 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.6 28-Dec-1995  thorpej branches: 1.6.2;
New-style RCS ids.
 1.5 23-Mar-1995  jtc removed unnecessary #include <stddef.h>
 1.4 16-Jun-1994  mycroft Add RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 16-Jun-1994  mycroft Import from 4.4-Lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.14.4.1 06-Apr-2005  he Pull up revision 1.15 (requested by jmc in ticket #1026):
Convert remaining host tools for amiga to correct cross tools.
Now allows complete amiga builds on non-NetBSD and non-BSD hosts.
 1.15.22.1 24-Mar-2008  keiichi sync with head.
 1.15.16.1 23-Mar-2008  matt sync with HEAD
 1.16.10.1 04-Jan-2009  christos merge with head.
 1.5 13-Apr-2011  jruoho Collect abs(3), labs(3), llabs(3), and imaxabs(3) to a single small page.
 1.4 13-Apr-2011  jruoho Fix another bug (no 'imaxint_t' type).
 1.3 13-Apr-2011  jruoho Fix obvious bug.
 1.2 21-Mar-2010  jruoho Emphasize imaxint_t.
 1.1 04-Aug-2008  matt branches: 1.1.2; 1.1.8;
Add C99 functions imaxabs and imaxdiv.
 1.1.8.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.1.8.1 04-Aug-2008  matt file imaxabs.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 04-Aug-2008  wrstuden file imaxabs.3 was added on branch wrstuden-revivesa on 2008-09-18 04:39:22 +0000
 1.1 04-Aug-2008  matt branches: 1.1.2; 1.1.8;
Add C99 functions imaxabs and imaxdiv.
 1.1.8.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.1.8.1 04-Aug-2008  matt file imaxabs.c was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 04-Aug-2008  wrstuden file imaxabs.c was added on branch wrstuden-revivesa on 2008-09-18 04:39:22 +0000
 1.2 13-Apr-2011  jruoho Collect also the division functions to single place, div(3).
 1.1 04-Aug-2008  matt branches: 1.1.2; 1.1.8;
Add C99 functions imaxabs and imaxdiv.
 1.1.8.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.1.8.1 04-Aug-2008  matt file imaxdiv.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 04-Aug-2008  wrstuden file imaxdiv.3 was added on branch wrstuden-revivesa on 2008-09-18 04:39:22 +0000
 1.1 04-Aug-2008  matt branches: 1.1.2; 1.1.8;
Add C99 functions imaxabs and imaxdiv.
 1.1.8.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.1.8.1 04-Aug-2008  matt file imaxdiv.c was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 04-Aug-2008  wrstuden file imaxdiv.c was added on branch wrstuden-revivesa on 2008-09-18 04:39:22 +0000
 1.5 30-Apr-2010  jruoho Rewrite the HISTORY section.
 1.4 10-Mar-2009  joerg Fix prologue.
 1.3 12-Jul-2005  wiz branches: 1.3.2; 1.3.32;
Remove superfluous Pp.
 1.2 06-Jul-2005  drochner add some clarification, and refer to POSIX
partly borrowed from FreeBSD
 1.1 06-Jul-2005  drochner Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.3.32.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.3.2.3 04-Aug-2005  tron Pull up revision 1.2 (requested by drochner in ticket #632):
add some clarification, and refer to POSIX
partly borrowed from FreeBSD
 1.3.2.2 04-Aug-2005  tron Pull up revision 1.1 (requested by drochner in ticket #632):
Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.3.2.1 12-Jul-2005  tron file insque.3 was added on branch netbsd-3 on 2005-08-04 17:33:23 +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 06-Jul-2005  drochner branches: 1.2.2; 1.2.46;
tolerate NULL pointers at some places
 1.1 06-Jul-2005  drochner Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.2.46.1 30-Oct-2012  yamt sync with head
 1.2.2.3 04-Aug-2005  tron Pull up revision 1.2 (requested by drochner in ticket #632):
tolerate NULL pointers at some places
 1.2.2.2 04-Aug-2005  tron Pull up revision 1.1 (requested by drochner in ticket #632):
Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.2.2.1 06-Jul-2005  tron file insque.c was added on branch netbsd-3 on 2005-08-04 17:33:23 +0000
 1.12 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.11 05-Dec-2021  rillig jemalloc.3: fix malformed CVS Id
 1.10 25-Oct-2017  abhinav Add malloc.conf to the NAME section
Remove Pp before Bd at few places
 1.9 20-Jul-2013  wiz Use Mt for email addresses.
 1.8 21-Jun-2011  wiz branches: 1.8.2; 1.8.8; 1.8.12;
Sort sections.
 1.7 21-Jun-2011  jruoho Note the potential danger in the options. Fixes PR lib/31112.
 1.6 08-Jun-2011  njoly Fix prologue macros order.
 1.5 14-May-2010  jruoho branches: 1.5.4;
Use standard section headers.
 1.4 13-May-2010  wiz Join %U.
 1.3 03-May-2010  jruoho Fix previous commit by also moving the type of _malloc_options. In addition,
add a (commented) note that _malloc_message should be documented better.
 1.2 03-May-2010  jruoho Move the '_malloc_options' variable from malloc(3) to jemalloc(3).
 1.1 03-May-2010  jruoho Split the implementation details of malloc(3) to a separate jemalloc(3)
manual page. This way malloc(3) can follow the standard terse format used
elsewhere in the libc, while additional details can be added to jemalloc(3).

Note HISTORY and AUTHORS in jemalloc(3), and add some reading material to
SEE ALSO.
 1.5.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.12.1 23-Jul-2013  riastradh sync with HEAD
 1.8.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.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.64 13-Dec-2023  mrg make malloc_usable_size() visible with old jemalloc.

it's in <malloc.h> and applications like firefox expect it.

XXX: pullup-10
 1.63 14-Oct-2023  ad A few more branch hints.
 1.62 14-Oct-2023  ad Cherry pick a fix from FreeBSD:

commit 80bc871bdd4a8254ce19a65a54c8c918dd3ddd11
Author: Konstantin Belousov <kib@FreeBSD.org>
Date: Sat Sep 12 18:16:46 2009 +0000

MFC r196861:
Handle zero size for posix_memalign. Return NULL or unique address
according to the 'V' option.
 1.61 14-Oct-2023  ad Cherry pick a fix from FreeBSD:

commit 52d7a117c0fe8bd0226d964f4272131700035f12
Author: Jason Evans <jasone@FreeBSD.org>
Date: Thu Aug 14 17:03:29 2008 +0000

Re-order the terms of an expression in arena_run_reg_dalloc() to correctly
detect whether the integer division table is large enough to handle the
divisor. Before this change, the last two table elements were never used,
thus causing the slow path to be used for those divisors.
 1.60 14-Oct-2023  ad Fix a bug in the rbtree conversion.
 1.59 14-Oct-2023  mrg fix compile error on 32-bit platforms.
 1.58 13-Oct-2023  ad Convert to use Matt Thomas's rbtree, which the env code probably already
pulls into libc. amd64 object size before and after:

text data bss dec hex filename
21001 88 365 21454 53ce jemalloc.po
14991 184 429 15604 3cf4 jemalloc.po

libmicro on AMD Athlon Silver 3050e comparing this and the revision before
previous (i.e. the old code, versus arena changes + rbtree changes):

exit_10_nolibc 135.168300 128.07790[ +5.5%]
fork_100 180.539040 149.63721[ +20.7%]
fork_1000 200.421650 167.09660[ +19.9%]
mallocT2_10 0.132920 0.13317[ -0.2%]
mallocT2_100 0.136350 0.13635[ +0.0%]
mallocT2_100k 0.258690 0.26641[ -3.0%]
mallocT2_10k 0.223340 0.22733[ -1.8%]
mallocT2_1k 0.137170 0.14254[ -3.9%]
malloc_10 0.100540 0.10849[ -7.9%]
malloc_100 0.107290 0.10753[ -0.2%]
malloc_100k 0.193560 0.19355[ +0.0%]
malloc_10k 0.173250 0.17454[ -0.7%]
malloc_1k 0.113490 0.11335[ +0.1%]
 1.57 13-Oct-2023  ad Minor changes to jemalloc100 (the old one that only vax etc currently uses).

- Don't use TLS nor pretend to hash out arenas to reduce lock contention,
because NetBSD uses thr_curcpu() to choose arena (i.e. per-CPU arenas).

- In a single threaded process, don't prepare "ncpus" worth of arenas,
allocate only one.

- Use getpagesize() since it caches the return.

- Sprinkle branch hints.

- Make MALLOC_TRACE and MALLOC_DEBUG work again.
 1.56 07-May-2023  skrll RISC-V support that works on QEMU with a single hart.

Thanks for Simon Burge for plic(4).
 1.55 30-Nov-2022  skrll branches: 1.55.2;
Trailing whitespace
 1.54 30-Aug-2021  christos Remove lint workarounds
 1.53 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.52 03-May-2020  mrg turn off TLS for mips on old jemalloc. it doesn't work.
 1.51 22-Apr-2020  rin Use __mc68010__ to distinguish m68000 (sun2) from other m68k ports;
__mc68000__ is defined both for m68000 and m68k.
 1.50 22-Apr-2020  rin Fix previous for libhack, where _REENTRANT is not defined;
arenas_map_key is used only when NO_TLS && _REENTRANT.
 1.49 21-Apr-2020  joerg Switch to using TLS in old jemalloc for everywhere but VAX and sun2.
 1.48 13-Jan-2020  joerg Fix atfork malloc handling to include all the locks in old jemalloc.
 1.47 13-Jan-2020  joerg Fix aarch64 definition in old jemalloc

There is no platform-specific reason for avoiding TLS. The tiny
allocations should be aligned the same as small allocations for ABI
reasons.
 1.46 28-Mar-2019  christos fix compilation for non _REENTRANT
 1.45 25-Jul-2018  kamil Avoid undefined behavior in left bit shift in jemalloc(3)

Change the type of shifted value to unsigned to prevent altering the
signedness bit.

jemalloc.c:1707:14, left shift of 1 by 31 places cannot be represented in type 'int'
jemalloc.c:1724:15, left shift of 1 by 31 places cannot be represented in type 'int'
jemalloc.c:1840:28, left shift of 1 by 31 places cannot be represented in type 'int'

Detected with micro-UBSan in the user mode.
 1.44 01-Dec-2017  mrg branches: 1.44.2; 1.44.4;
normalise some indentation. NFC.
 1.43 16-Nov-2017  skrll The HPPA architectures (1.1 and 2.0) both define quadruple-word (128-bit)
floating point types. Adjust alignment to match.
 1.42 19-May-2017  christos branches: 1.42.2;
remove accidental __strong_alias additions, noticed by coypu.
 1.41 19-May-2017  christos use strerror_r_ss()
 1.40 12-Apr-2016  joerg lib/50791: Instead of using sorting the arena chunks by address only,
sort by size of the longest run and address as tie break. Avoids long
linear searches for code heavy on medium sized allocations.
 1.39 24-Jan-2016  christos vmparam.h is a kernel header.
 1.38 26-Jul-2015  martin Defer using pthread keys until we are threaded.
From Christos, fixes PR port-arm/50087 by allowing malloc calls prior
to libpthread initialization.
 1.37 20-Jan-2015  christos Fix non _REENTRANT build.
 1.36 19-Sep-2014  matt Tell it about riscv. Fix mips64 case so that SIZEOF_PTR_2POW is 3.
 1.35 03-Sep-2014  matt OR1K support
 1.34 10-Aug-2014  matt branches: 1.34.2;
Changes to existing files to enable building AARCH64 userland.
evbarm64-el
This is clang only. While gcc4.8 supports aarch64, no netbsd support has
been written for aarch64 with gcc4.8.
 1.33 16-Jul-2014  riastradh Hold arenas_mtx across (still unused) _malloc_pre/postfork (PR 47428).
 1.32 25-Feb-2014  martin branches: 1.32.2;
Powerpc seems to expect minimum 8 byte alignment from malloc as well.
 1.31 17-Feb-2014  martin Bounce the minimum allocation alignement for sparc64 and amd64 as well,
to sync with their default gcc configuration.
We could relax this again later, after a filing a defect report with the
ISO C comitee and getting an answer contradicting the gcc teams
interpretation (and then fix the gcc target configurations instead).
 1.30 05-Feb-2014  skrll Err on the safe side for small memory allocations and provide 4byte
alignment by default. Override this to 8byte alignment for alpha and arm
eabi.

Someone (tm) can review this change once the standards and compiler(s)
have sorted themselves out.
 1.29 12-Sep-2013  joerg NetBSD certainly supports TLS in static applications if it supports TLS
on the platform at all.
 1.28 21-Mar-2012  christos branches: 1.28.2;
rename umax2s->size_t2s function per apb's request.
 1.27 21-Mar-2012  matt Use C89 function definition
 1.26 21-Mar-2012  he Cast an int argument to umax2s() to size_t.
 1.25 21-Mar-2012  christos uintmax_t -> size_t (never called with larger than size_t)
 1.24 18-May-2011  christos branches: 1.24.4; 1.24.6;
cleanup saving and restoring errno, and make it similar.
 1.23 13-May-2011  christos don't let readlink trash errno.;
 1.22 26-Feb-2011  njoly Switch from floating point to fixed point integer for run sizes maths.
From FreeBSD (part of revision 1.154).
 1.21 04-Mar-2010  enami branches: 1.21.2;
Fix race condition on reallocation of huge category.

We need to remove the old region before mremap() since if it relesae the
old region, other thread may map it for the same huge category allocation
and insert it to the tree before we acquire a lock after mremap().

Fixes PR/42876.
 1.20 12-Feb-2009  lukem Apply some of FreeBSD libc/stdlib/malloc.c rev 1.162
to fix sign-compare issues.
 1.19 23-Jun-2008  ad branches: 1.19.4; 1.19.6; 1.19.8; 1.19.12;
Split choose_arena() back out into inline and non-inline portions.
 1.18 05-Jun-2008  ad Check to see if MALLOC_OPTIONS is actually set in the environment before
doing issetugid().
 1.17 08-Mar-2008  ad branches: 1.17.2; 1.17.4;
Redo the CPU-based arena selection slightly differently. With the latest
libpthread and kernel, this mysteriously works without a problem.
 1.16 04-Dec-2007  christos branches: 1.16.4;
- use a non localized version of strerror_r.
- kill localized declarations and let namespace.h do its work.
 1.15 01-Dec-2007  ad Back out the per-cpu arena changes. With this, ld.so magically stops
loading libc/libpthread twice -- which does not make sense, because it
has its own private malloc().
 1.14 30-Nov-2007  dsl Fix the other half of the 'store int as a thread specific pointer'/
 1.13 30-Nov-2007  christos converting a pointer to unsigned is bad; use uintptr_t.
 1.12 29-Nov-2007  ad Make the allocation arenas per-CPU in the most optimistic case, but
continue to 'stripe' by thread in case of contention.
 1.11 19-Nov-2007  ad Enable posix_memalign().
 1.10 22-Oct-2007  simonb branches: 1.10.2;
Revert the CSE parts of the previous change. "run" is calculated with
a different value for "pageind" each time through the loop, so we can't
precalculate it.

Fixes awk core dump issues on powerpc 405.
 1.9 19-Oct-2007  christos - do some CSE.
- pass lint
 1.8 16-Oct-2007  yamt use mremap for huge -> huge realloc.
fix PR/31425 (Nicolas Joly) and possibly PR/36175 (Brian de Alwis).
 1.7 15-Oct-2007  yamt make lint happy.
 1.6 15-Oct-2007  yamt malloc_print_stats: print huge_allocated correctly. it's already in bytes.
 1.5 15-Oct-2007  yamt use MAP_ALIGNED.
 1.4 09-Oct-2007  ad Add defs for hppa. From he@.
 1.3 07-Oct-2007  he On sparc64, both __sparc__ and __sparc64__ is defined. Avoid redefinition
of size constants for sparc64.

This code still produces many, many lint warnings due to "may loose accuracy"
when mixing long/int, and also warnings related to <<.
 1.2 05-Oct-2007  ad Port to NetBSD. Note: posix_memalign() is here, but it's not exported
via the headers yet.
 1.1 05-Oct-2007  ad Pull in jemalloc from FreeBSD:

FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.147 2007/06/15 22:00:16 jasone Exp
 1.10.2.4 23-Mar-2008  matt sync with HEAD
 1.10.2.3 09-Jan-2008  matt sync with HEAD
 1.10.2.2 06-Nov-2007  matt sync with HEAD
 1.10.2.1 22-Oct-2007  matt file jemalloc.c was added on branch matt-armv6 on 2007-11-06 23:11:18 +0000
 1.16.4.1 24-Mar-2008  keiichi sync with head.
 1.17.4.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.17.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.2.1 17-Jun-2008  yamt sync with head.
 1.19.12.1 21-Apr-2010  matt sync to netbsd-5
 1.19.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.19.6.2 23-Jun-2008  ad Split choose_arena() back out into inline and non-inline portions.
 1.19.6.1 23-Jun-2008  ad file jemalloc.c was added on branch christos-time_t on 2008-06-23 10:46:26 +0000
 1.19.4.1 13-Mar-2010  riz Pull up following revision(s) (requested by enami in ticket #1327):
lib/libc/stdlib/jemalloc.c: revision 1.21
Fix race condition on reallocation of huge category.
We need to remove the old region before mremap() since if it relesae the
old region, other thread may map it for the same huge category allocation
and insert it to the tree before we acquire a lock after mremap().
Fixes PR/42876.
 1.21.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.24.6.3 03-Nov-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1121):
lib/libc/stdlib/jemalloc.c: revision 1.33
Hold arenas_mtx across (still unused) _malloc_pre/postfork (PR 47428).
 1.24.6.2 23-Apr-2012  riz Back out changes committed as part of ticket #195 which were apparently
not intended as part of the pullup request. Should fix netbsd-6 build.
 1.24.6.1 23-Apr-2012  riz Pull up following revision(s) (requested by manu in ticket #195):
lib/libskey/skeysubr.c: revision 1.27
lib/libkvm/kvm_getloadavg.c: revision 1.11
lib/libwrap/update.c: revision 1.9
lib/liby/yyerror.c: revision 1.9
lib/libpuffs/puffs_ops.3: revision 1.30
lib/libwrap/misc.c: revision 1.10
lib/libwrap/hosts_access.c: revision 1.20
lib/libpuffs/pnode.c: revision 1.11
lib/libperfuse/subr.c: revision 1.17
lib/libpuffs/pnode.c: revision 1.12
lib/libperfuse/subr.c: revision 1.18
lib/libwrap/options.c: revision 1.15
lib/libwrap/fix_options.c: revision 1.11
lib/libperfuse/ops.c: revision 1.52
lib/libperfuse/ops.c: revision 1.53
lib/libperfuse/ops.c: revision 1.54
lib/libwrap/hosts_ctl.c: revision 1.5
lib/libintl/gettext.c: revision 1.27
lib/libwrap/shell_cmd.c: revision 1.6
lib/libpuffs/dispatcher.c: revision 1.39
lib/libperfuse/perfuse_priv.h: revision 1.27
lib/libwrap/socket.c: revision 1.19
lib/libpuffs/puffs.3: revision 1.50
lib/libperfuse/perfuse_priv.h: revision 1.28
lib/libpuffs/puffs_priv.h: revision 1.45
lib/libpuffs/puffs.3: revision 1.51
lib/libperfuse/perfuse_priv.h: revision 1.29
lib/libwrap/percent_x.c: revision 1.5
lib/libpuffs/puffs.3: revision 1.52
lib/libperfuse/debug.c: revision 1.11
sys/fs/puffs/puffs_vnops.c: revision 1.165
lib/libwrap/tcpd.h: revision 1.13
sys/fs/puffs/puffs_vnops.c: revision 1.166
lib/libwrap/eval.c: revision 1.7
sys/fs/puffs/puffs_msgif.h: revision 1.78
sys/fs/puffs/puffs_vfsops.c: revision 1.101
lib/libwrap/rfc931.c: revision 1.9
lib/libwrap/clean_exit.c: revision 1.5
lib/libpuffs/puffs.h: revision 1.120
lib/libc/stdlib/jemalloc.c: revision 1.27
lib/librmt/rmtlib.c: revision 1.26
lib/libpuffs/puffs.h: revision 1.121
sys/fs/puffs/puffs_sys.h: revision 1.79
lib/librumpclient/rumpclient.c: revision 1.48
lib/libwrap/refuse.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.26
lib/libperfuse/perfuse.c: revision 1.27
tests/fs/puffs/t_fuzz.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.28
lib/libpuffs/dispatcher.c: revision 1.40
sys/fs/puffs/puffs_node.c: revision 1.24
lib/libwrap/diag.c: revision 1.9
lib/libintl/textdomain.c: revision 1.13
Use C89 function definition
Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.
PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
Split file system.
Comma fixes.
Remove dangling &quot;and&quot;.
Bump date for previous.
- Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
a newly created vnode but has been made redundant along time ago since
uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and RECLAIM
(how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
Do not set PUFFS_KFLAG_CACHE_FS_TTL for PUFFS tests
 1.24.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.24.4.1 17-Apr-2012  yamt sync with head
 1.28.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.2.1 10-Aug-2014  tls Rebase.
 1.34.2.3 10-May-2016  martin Fix merge botch for #1161
 1.34.2.2 09-May-2016  snj Pull up following revision(s) (requested by joerg in ticket #1161):
lib/libc/stdlib/jemalloc.c: revision 1.40
lib/50791: Instead of using sorting the arena chunks by address only,
sort by size of the longest run and address as tie break. Avoids long
linear searches for code heavy on medium sized allocations.
 1.34.2.1 24-Nov-2015  martin Pull up following revision(s) (requested by manu in ticket #829):
lib/libpthread_dbg/pthread_dbg.c: revision 1.43 (via patch)
lib/libpthread/pthread_int.h: revision 1.91-1.92 (via patch)
lib/libc/stdlib/jemalloc.c: revision 1.37-1.38
lib/libpthread/pthread_tsd.c: revision 1.12-1.14 (via patch)
include/limits.h: revision 1.34 (via patch)
lib/libpthread/pthread.c: revision 1.146-1.147 (via patch)
lib/libpthread/pthread_key_create.3: revision 1.7 (via patch)

libpthread:

Make PTHREAD_KEYS_MAX dynamically adjustable
NetBSD's PTHREAD_KEYS_MAX is set to 256, which is low compared to
other systems like Linux (1024) or MacOS X (512). As a result some
setups tested on Linux will exhibit problems on NetBSD because of
pthread_keys usage beyond the limit. This happens for instance on
Apache with various module loaded, and in this case no particular
developper can be blamed for going beyond the limit, since several
modules from different sources contribute to the problem.
This patch makes the limit conigurable through the PTHREAD_KEYS_MAX
environement variable. If undefined, the default remains unchanged
(256). In any case, the value cannot be lowered below POSIX-mandated
_POSIX_THREAD_KEYS_MAX (128).

While there:
- use EXIT_FAILURE instead of 1 when calling err(3) in libpthread.
- Reset _POSIX_THREAD_KEYS_MAX to POSIX mandated 128, instead of 256.

Fix previous: Can't use calloc/malloc before we complete initialization
of the thread library, because malloc uses pthread_foo_specific, and it will
end up initializing itself incorrectly.

Thanks rump for not letting us use even mmap during initialization.

libc/jemalloc:

Fix non _REENTRANT build.
Defer using pthread keys until we are threaded.
From Christos, fixes PR port-arm/50087 by allowing malloc calls prior
to libpthread initialization.
 1.42.2.1 23-Nov-2017  martin Pull up the gcc 5.5 import and assorted fixes, requested by mrg in ticket #381:

external/gpl3/gcc/dist/fixincludes/tests/base/iso/stdlib_c99.h up to 1.1.1.1
external/gpl3/gcc/dist/gcc/config/arm/t-phoenix up to 1.1.1.1
external/gpl3/gcc/dist/gcc/config/phoenix.h up to 1.1.1.1
external/gpl3/gcc/dist/gcc/config/aarch64/aarch64-freebsd.h up to 1.1.1.1
external/gpl3/gcc/dist/gcc/config/aarch64/t-aarch64-freebsd up to 1.1.1.1
external/gpl3/gcc/dist/gcc/doc/gcov-dump.1 up to 1.1.1.1
external/gpl3/gcc/dist/gcc/doc/gcov-dump.texi up to 1.1.1.1
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/lfts_config.h up to 1.1.1.1
external/gpl3/gcc/dist/gcc/config/i386/pcommitintrin.h delete
external/gpl3/gcc/dist/gcc/config/i386/stringop.opt delete
external/gpl3/gcc/lib/libgcc/Makefile.wrapper delete
external/gpl3/gcc/dist/ChangeLog up to 1.1.1.10
external/gpl3/gcc/dist/LAST_UPDATED up to 1.9
external/gpl3/gcc/dist/MD5SUMS up to 1.9
external/gpl3/gcc/dist/NEWS up to 1.7
external/gpl3/gcc/dist/config.sub up to 1.11
external/gpl3/gcc/dist/configure up to 1.11
external/gpl3/gcc/dist/configure.ac up to 1.10
external/gpl3/gcc/dist/INSTALL/binaries.html up to 1.5
external/gpl3/gcc/dist/INSTALL/build.html up to 1.6
external/gpl3/gcc/dist/INSTALL/configure.html up to 1.6
external/gpl3/gcc/dist/INSTALL/download.html up to 1.5
external/gpl3/gcc/dist/INSTALL/finalinstall.html up to 1.5
external/gpl3/gcc/dist/INSTALL/gfdl.html up to 1.5
external/gpl3/gcc/dist/INSTALL/index.html up to 1.5
external/gpl3/gcc/dist/INSTALL/old.html up to 1.5
external/gpl3/gcc/dist/INSTALL/prerequisites.html up to 1.6
external/gpl3/gcc/dist/INSTALL/specific.html up to 1.6
external/gpl3/gcc/dist/INSTALL/test.html up to 1.5
external/gpl3/gcc/dist/config/ChangeLog up to 1.1.1.10
external/gpl3/gcc/dist/contrib/ChangeLog up to 1.1.1.10
external/gpl3/gcc/dist/contrib/gcc_update up to 1.1.1.4
external/gpl3/gcc/dist/contrib/reghunt/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/contrib/regression/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/fixincludes/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/fixincludes/fixincl.x up to 1.1.1.6
external/gpl3/gcc/dist/fixincludes/inclhack.def up to 1.1.1.6
external/gpl3/gcc/dist/fixincludes/tests/base/math.h up to 1.1.1.3
external/gpl3/gcc/dist/fixincludes/tests/base/stdio.h up to 1.1.1.5
external/gpl3/gcc/dist/fixincludes/tests/base/stdlib.h up to 1.1.1.3
external/gpl3/gcc/dist/fixincludes/tests/base/iso/stdio_iso.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/BASE-VER up to 1.1.1.8
external/gpl3/gcc/dist/gcc/ChangeLog up to 1.15
external/gpl3/gcc/dist/gcc/DATESTAMP up to 1.1.1.11
external/gpl3/gcc/dist/gcc/Makefile.in up to 1.14
external/gpl3/gcc/dist/gcc/asan.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/auto-profile.c up to 1.3
external/gpl3/gcc/dist/gcc/bb-reorder.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/builtins.c up to 1.10
external/gpl3/gcc/dist/gcc/calls.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/cgraph.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/cgraph.h up to 1.1.1.5
external/gpl3/gcc/dist/gcc/cgraphclones.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/cgraphunit.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/combine.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/common.opt up to 1.6
external/gpl3/gcc/dist/gcc/config.gcc up to 1.37
external/gpl3/gcc/dist/gcc/coverage.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/coverage.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/cselib.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/data-streamer-in.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/data-streamer-out.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/diagnostic.c up to 1.4
external/gpl3/gcc/dist/gcc/dwarf2out.c up to 1.8
external/gpl3/gcc/dist/gcc/explow.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/expmed.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/expr.c up to 1.10
external/gpl3/gcc/dist/gcc/fold-const.c up to 1.1.1.11
external/gpl3/gcc/dist/gcc/function.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/function.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/fwprop.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/gcc.c up to 1.15
external/gpl3/gcc/dist/gcc/gcov-dump.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/gcov-io.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/gcov-tool.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/gcov.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/gcse.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/gengtype-lex.c up to 1.7
external/gpl3/gcc/dist/gcc/genmatch.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/gimple-fold.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/gimple-ssa-strength-reduction.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/gimplify.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/graphite-isl-ast-to-gimple.c up to 1.3
external/gpl3/gcc/dist/gcc/incpath.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/internal-fn.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/ipa-comdats.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/ipa-cp.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/ipa-devirt.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/ipa-icf-gimple.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/ipa-icf-gimple.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/ipa-icf.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/ipa-icf.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/ipa-inline-transform.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/ipa-polymorphic-call.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/ipa-prop.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/ipa-pure-const.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/ipa-split.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/ipa-visibility.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/ira-build.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/ira-costs.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/ira-int.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/ira-lives.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/loop-doloop.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/loop-invariant.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/lra-constraints.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/lra-remat.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/lto-cgraph.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/lto-streamer.h up to 1.1.1.5
external/gpl3/gcc/dist/gcc/match.pd up to 1.1.1.3
external/gpl3/gcc/dist/gcc/omp-low.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/params.def up to 1.1.1.5
external/gpl3/gcc/dist/gcc/postreload.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/pretty-print.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/real.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/ree.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/rtl.h up to 1.1.1.6
external/gpl3/gcc/dist/gcc/sel-sched.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/simplify-rtx.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/system.h up to 1.6
external/gpl3/gcc/dist/gcc/toplev.c up to 1.2
external/gpl3/gcc/dist/gcc/tree-call-cdce.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-cfg.c up to 1.8
external/gpl3/gcc/dist/gcc/tree-chkp-opt.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/tree-chkp.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/tree-chrec.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-data-ref.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/tree-eh.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/tree-inline.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/tree-inline.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-loop-distribution.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-nested.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-predcom.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-profile.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-ssa-ccp.c up to 1.8
external/gpl3/gcc/dist/gcc/tree-ssa-loop-im.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-ssa-loop-ivopts.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-ssa-loop-prefetch.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-ssa-math-opts.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/tree-ssa-pre.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-ssa-reassoc.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/tree-ssa-sccvn.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/tree-ssa-strlen.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-ssa-structalias.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/tree-ssa-tail-merge.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/tree-ssa-threadedge.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/tree-ssa-uninit.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-ssa.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-vect-data-refs.c up to 1.1.1.9
external/gpl3/gcc/dist/gcc/tree-vect-loop-manip.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/tree-vrp.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/tsan.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/ubsan.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/value-prof.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/c/ChangeLog up to 1.1.1.8
external/gpl3/gcc/dist/gcc/c/c-decl.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/c/c-objc-common.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/c/c-parser.c up to 1.1.1.5
external/gpl3/gcc/dist/gcc/c/c-typeck.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/c-family/ChangeLog up to 1.1.1.7
external/gpl3/gcc/dist/gcc/c-family/c-ada-spec.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/c-family/c-common.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/c-family/c-cppbuiltin.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/c-family/c-gimplify.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/c-family/c-omp.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/c-family/c-opts.c up to 1.5
external/gpl3/gcc/dist/gcc/common/config/i386/i386-common.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/aarch64/aarch64-simd.md up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/aarch64/aarch64.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/config/aarch64/aarch64.md up to 1.1.1.6
external/gpl3/gcc/dist/gcc/config/arm/arm-builtins.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/arm/arm-protos.h up to 1.1.1.5
external/gpl3/gcc/dist/gcc/config/arm/arm.c up to 1.4
external/gpl3/gcc/dist/gcc/config/arm/arm.h up to 1.15
external/gpl3/gcc/dist/gcc/config/arm/arm.md up to 1.12
external/gpl3/gcc/dist/gcc/config/arm/freebsd.h up to 1.4
external/gpl3/gcc/dist/gcc/config/arm/neon.md up to 1.1.1.5
external/gpl3/gcc/dist/gcc/config/avr/avr.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/config/avr/avr.md up to 1.1.1.7
external/gpl3/gcc/dist/gcc/config/avr/avr.opt up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/avr/gen-avr-mmcu-specs.c up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/avr/gen-avr-mmcu-texi.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/i386/avx2intrin.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/avx512bwintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512dqintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512fintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512ifmaintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512ifmavlintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512pfintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512vbmiintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512vbmivlintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512vlbwintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512vldqintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/avx512vlintrin.h up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/i386/cpuid.h up to 1.4
external/gpl3/gcc/dist/gcc/config/i386/driver-i386.c up to 1.7
external/gpl3/gcc/dist/gcc/config/i386/gmm_malloc.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/i386-builtin-types.def up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/i386-c.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/i386.c up to 1.14
external/gpl3/gcc/dist/gcc/config/i386/i386.h up to 1.6
external/gpl3/gcc/dist/gcc/config/i386/i386.md up to 1.1.1.9
external/gpl3/gcc/dist/gcc/config/i386/i386.opt up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/ia32intrin.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/lwpintrin.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/mmx.md up to 1.1.1.5
external/gpl3/gcc/dist/gcc/config/i386/pmm_malloc.h up to 1.4
external/gpl3/gcc/dist/gcc/config/i386/rdseedintrin.h up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/i386/rtmintrin.h up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/i386/sse.md up to 1.1.1.8
external/gpl3/gcc/dist/gcc/config/i386/x86-64.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/i386/x86intrin.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/nds32/nds32.md up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/pa/pa-64.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/pa/pa.h up to 1.7
external/gpl3/gcc/dist/gcc/config/rl78/rl78-expand.md up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/rl78/rl78-real.md up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/rl78/rl78-virt.md up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/rs6000/altivec.md up to 1.1.1.9
external/gpl3/gcc/dist/gcc/config/rs6000/dfp.md up to 1.1.1.5
external/gpl3/gcc/dist/gcc/config/rs6000/predicates.md up to 1.1.1.7
external/gpl3/gcc/dist/gcc/config/rs6000/rs6000-c.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/config/rs6000/rs6000.c up to 1.17
external/gpl3/gcc/dist/gcc/config/rs6000/rs6000.md up to 1.1.1.9
external/gpl3/gcc/dist/gcc/config/rs6000/rs6000.opt up to 1.1.1.6
external/gpl3/gcc/dist/gcc/config/rs6000/vector.md up to 1.1.1.6
external/gpl3/gcc/dist/gcc/config/rs6000/vsx.md up to 1.1.1.10
external/gpl3/gcc/dist/gcc/config/s390/s390-modes.def up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/s390/s390.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/config/s390/s390.md up to 1.1.1.6
external/gpl3/gcc/dist/gcc/config/s390/vx-builtins.md up to 1.1.1.3
external/gpl3/gcc/dist/gcc/config/sh/sh-mem.cc up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/sh/sh.c up to 1.9
external/gpl3/gcc/dist/gcc/config/sh/sh_treg_combine.cc up to 1.1.1.2
external/gpl3/gcc/dist/gcc/config/sparc/sparc.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/config/sparc/sparc.md up to 1.7
external/gpl3/gcc/dist/gcc/config/xtensa/xtensa.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/xtensa/xtensa.h up to 1.1.1.4
external/gpl3/gcc/dist/gcc/config/xtensa/xtensa.md up to 1.1.1.4
external/gpl3/gcc/dist/gcc/cp/ChangeLog up to 1.1.1.11
external/gpl3/gcc/dist/gcc/cp/call.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/cp/class.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/cp/constexpr.c up to 1.1.1.3
external/gpl3/gcc/dist/gcc/cp/cp-gimplify.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/cp/decl.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/cp/error.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/cp/init.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/cp/mangle.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/cp/name-lookup.c up to 1.1.1.6
external/gpl3/gcc/dist/gcc/cp/parser.c up to 1.1.1.10
external/gpl3/gcc/dist/gcc/cp/pt.c up to 1.1.1.8
external/gpl3/gcc/dist/gcc/cp/semantics.c up to 1.1.1.9
external/gpl3/gcc/dist/gcc/cp/tree.c up to 1.1.1.7
external/gpl3/gcc/dist/gcc/cp/typeck.c up to 1.1.1.9
external/gpl3/gcc/dist/gcc/doc/aot-compile.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/cppinternals.info up to 1.7
external/gpl3/gcc/dist/gcc/doc/extend.texi up to 1.1.1.8
external/gpl3/gcc/dist/gcc/doc/fsf-funding.7 up to 1.7
external/gpl3/gcc/dist/gcc/doc/gc-analyze.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/gcc.texi up to 1.1.1.5
external/gpl3/gcc/dist/gcc/doc/gccinstall.info up to 1.7
external/gpl3/gcc/dist/gcc/doc/gccint.info up to 1.7
external/gpl3/gcc/dist/gcc/doc/gcj-dbtool.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/gcj.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/gcj.info up to 1.7
external/gpl3/gcc/dist/gcc/doc/gcov-tool.1 up to 1.1.1.3
external/gpl3/gcc/dist/gcc/doc/gcov-tool.texi up to 1.1.1.2
external/gpl3/gcc/dist/gcc/doc/gcov.texi up to 1.6
external/gpl3/gcc/dist/gcc/doc/generic.texi up to 1.1.1.4
external/gpl3/gcc/dist/gcc/doc/gfdl.7 up to 1.7
external/gpl3/gcc/dist/gcc/doc/gfortran.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/gij.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/gpl.7 up to 1.7
external/gpl3/gcc/dist/gcc/doc/grmic.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/install.texi up to 1.1.1.8
external/gpl3/gcc/dist/gcc/doc/invoke.texi up to 1.12
external/gpl3/gcc/dist/gcc/doc/jcf-dump.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/jv-convert.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/lto.texi up to 1.1.1.3
external/gpl3/gcc/dist/gcc/doc/passes.texi up to 1.1.1.4
external/gpl3/gcc/dist/gcc/doc/rebuild-gcj-db.1 up to 1.7
external/gpl3/gcc/dist/gcc/doc/rtl.texi up to 1.1.1.4
external/gpl3/gcc/dist/gcc/jit/ChangeLog up to 1.1.1.3
external/gpl3/gcc/dist/gcc/lto/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/gcc/lto/lto-lang.c up to 1.1.1.4
external/gpl3/gcc/dist/gcc/objc/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/gcc/objcp/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/gnattools/ChangeLog up to 1.1.1.7
external/gpl3/gcc/dist/gotools/ChangeLog up to 1.1.1.3
external/gpl3/gcc/dist/include/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/intl/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/libbacktrace/ChangeLog up to 1.1.1.8
external/gpl3/gcc/dist/libcc1/ChangeLog up to 1.1.1.3
external/gpl3/gcc/dist/libcpp/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/libcpp/line-map.c up to 1.1.1.6
external/gpl3/gcc/dist/libdecnumber/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/libgcc/ChangeLog up to 1.1.1.11
external/gpl3/gcc/dist/libgcc/config.host up to 1.16
external/gpl3/gcc/dist/libgcc/libgcc2.c up to 1.1.1.4
external/gpl3/gcc/dist/libgcc/libgcov-driver.c up to 1.1.1.2
external/gpl3/gcc/dist/libgcc/unwind-c.c up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/aarch64/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/alpha/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/arm/unwind-arm.c up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/arm/unwind-arm.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/bfin/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/i386/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/libbid/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/libgcc/config/m68k/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/nios2/linux-unwind.h up to 1.1.1.2
external/gpl3/gcc/dist/libgcc/config/pa/linux-unwind.h up to 1.1.1.4
external/gpl3/gcc/dist/libgcc/config/rs6000/t-crtstuff up to 1.1.1.2
external/gpl3/gcc/dist/libgcc/config/sh/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/sparc/lb1spc.S up to 1.1.1.2
external/gpl3/gcc/dist/libgcc/config/tilepro/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/xtensa/ieee754-df.S up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/xtensa/ieee754-sf.S up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/xtensa/linux-unwind.h up to 1.1.1.3
external/gpl3/gcc/dist/libgcc/config/xtensa/t-elf up to 1.1.1.2
external/gpl3/gcc/dist/libgcc/config/xtensa/t-linux up to 1.1.1.2
external/gpl3/gcc/dist/libgcc/config/xtensa/t-windowed up to 1.1.1.2
external/gpl3/gcc/dist/libgcc/config/xtensa/unwind-dw2-xtensa.c up to 1.4
external/gpl3/gcc/dist/libgomp/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/libgomp/env.c up to 1.1.1.4
external/gpl3/gcc/dist/libgomp/hashtab.h up to 1.1.1.2
external/gpl3/gcc/dist/libgomp/libgomp.info up to 1.7
external/gpl3/gcc/dist/libiberty/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/libiberty/cp-demangle.c up to 1.1.1.5
external/gpl3/gcc/dist/libiberty/vprintf-support.c up to 1.2
external/gpl3/gcc/dist/libitm/ChangeLog up to 1.1.1.7
external/gpl3/gcc/dist/libitm/libitm.info up to 1.1.1.6
external/gpl3/gcc/dist/libobjc/ChangeLog up to 1.1.1.10
external/gpl3/gcc/dist/libsanitizer/ChangeLog up to 1.1.1.7
external/gpl3/gcc/dist/libsanitizer/asan/asan_globals.cc up to 1.1.1.3
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc up to 1.5
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc up to 1.9
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h up to 1.3
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc up to 1.6
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h up to 1.10
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_procmaps_netbsd.cc up to 1.3
external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc up to 1.1.1.2
external/gpl3/gcc/dist/libsanitizer/tsan/tsan_platform_linux.cc up to 1.3
external/gpl3/gcc/dist/libsanitizer/tsan/tsan_rtl.cc up to 1.1.1.3
external/gpl3/gcc/dist/libssp/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/libstdc++-v3/ChangeLog up to 1.1.1.11
external/gpl3/gcc/dist/libstdc++-v3/acinclude.m4 up to 1.4
external/gpl3/gcc/dist/libstdc++-v3/config.h.in up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/configure up to 1.8
external/gpl3/gcc/dist/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/config/os/mingw32-w64/error_constants.h up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/doxygen/mainpage.html up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/doc/html/api.html up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/doc/html/faq.html up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/doc/html/ext/lwg-active.html up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/html/ext/lwg-closed.html up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/html/ext/lwg-defects.html up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/abi.html up to 1.1.1.6
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/bugs.html up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/ext_demangling.html up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/memory.html up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/mt_allocator_impl.html up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/source_code_style.html up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/source_organization.html up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/status.html up to 1.1.1.6
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/api.xml up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/faq.xml up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/abi.xml up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/allocator.xml up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/appendix_contributing.xml up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/extensions.xml up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/intro.xml up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/mt_allocator.xml up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/status_cxx2011.xml up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/doc/xml/manual/status_cxx2014.xml up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/Makefile.am up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/include/Makefile.in up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/include/bits/allocator.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/basic_ios.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/basic_string.h up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/include/bits/basic_string.tcc up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/c++config up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/include/bits/hashtable.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/ios_base.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/istream.tcc up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/list.tcc up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/locale_classes.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/locale_conv.h up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/bits/mask_array.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/predefined_ops.h up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/bits/regex.h up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/bits/regex.tcc up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/bits/regex_compiler.h up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/bits/shared_ptr_base.h up to 1.1.1.6
external/gpl3/gcc/dist/libstdc++-v3/include/bits/slice_array.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/sstream.tcc up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/stl_iterator.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/stl_map.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/stl_multimap.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/stl_multiset.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/stl_set.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/stl_stack.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/bits/stl_tree.h up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/include/bits/uniform_int_dist.h up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/bits/unique_ptr.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/c_global/cmath up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/include/debug/safe_iterator.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/debug/string up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/algorithm up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/any up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/chrono up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/fs_dir.h up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/fs_fwd.h up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/fs_ops.h up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/fs_path.h up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/functional up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/optional up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/ratio up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/string_view up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/string_view.tcc up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/system_error up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/tuple up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/include/experimental/type_traits up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/include/ext/new_allocator.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/ext/pointer.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/std/atomic up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/std/chrono up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/std/complex up to 1.5
external/gpl3/gcc/dist/libstdc++-v3/include/std/functional up to 1.1.1.7
external/gpl3/gcc/dist/libstdc++-v3/include/std/istream up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/include/std/scoped_allocator up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/std/sstream up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/std/thread up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/std/tuple up to 1.1.1.6
external/gpl3/gcc/dist/libstdc++-v3/include/std/utility up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/include/tr1/cmath up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/libsupc++/cxxabi.h up to 1.1.1.4
external/gpl3/gcc/dist/libstdc++-v3/python/libstdcxx/v6/printers.py up to 1.1.1.5
external/gpl3/gcc/dist/libstdc++-v3/python/libstdcxx/v6/xmethods.py up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/src/c++11/codecvt.cc up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/src/c++11/cxx11-shim_facets.cc up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/src/c++11/shared_ptr.cc up to 1.1.1.3
external/gpl3/gcc/dist/libstdc++-v3/src/filesystem/Makefile.in up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/src/filesystem/dir.cc up to 1.1.1.2
external/gpl3/gcc/dist/libstdc++-v3/src/filesystem/ops.cc up to 1.1.1.3
external/gpl3/gcc/dist/lto-plugin/ChangeLog up to 1.1.1.9
external/gpl3/gcc/dist/lto-plugin/lto-plugin.c up to 1.1.1.4
external/gpl3/gcc/dist/maintainer-scripts/ChangeLog up to 1.1.1.10
external/gpl3/gcc/lib/libasan/Makefile up to 1.18
external/gpl3/gcc/lib/libgcc/arch/i386/defs.mk up to 1.5
external/gpl3/gcc/lib/libgcc/arch/m68000/defs.mk up to 1.7
external/gpl3/gcc/lib/libgcc/arch/x86_64/defs.mk up to 1.4
external/gpl3/gcc/lib/libgcc/libgcc/Makefile up to 1.28
external/gpl3/gcc/lib/libgcc/libgcov/arch/alpha/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/arm/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/armeb/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/earm/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmeb/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmhf/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmhfeb/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv4/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv4eb/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv6/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv6eb/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv6hf/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv6hfeb/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv7/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv7eb/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv7hf/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/earmv7hfeb/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/hppa/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/i386/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/ia64/gcov-iov.h up to 1.5
external/gpl3/gcc/lib/libgcc/libgcov/arch/m68000/gcov-iov.h up to 1.9
external/gpl3/gcc/lib/libgcc/libgcov/arch/m68k/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/mips64eb/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/mips64el/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/mipseb/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/mipsel/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/powerpc/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/powerpc64/gcov-iov.h up to 1.6
external/gpl3/gcc/lib/libgcc/libgcov/arch/sh3eb/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/sh3el/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/sparc/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/sparc64/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/vax/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libgcc/libgcov/arch/x86_64/gcov-iov.h up to 1.10
external/gpl3/gcc/lib/libiberty/defs.mk up to 1.14
external/gpl3/gcc/lib/libiberty/arch/ia64/config.h up to 1.6
external/gpl3/gcc/lib/liblto_plugin/Makefile up to 1.9
external/gpl3/gcc/lib/libstdc++-v3/Makefile up to 1.28
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h up to 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/arm/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h up to 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/gstdint.h up to 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earm/gstdint.h up to 1.15
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h up to 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h up to 1.19
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/defs.mk up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h up to 1.17
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h up to 1.22
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/defs.mk up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/i386/gstdint.h up to 1.14
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/gstdint.h up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h up to 1.16
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/defs.mk up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/gstdint.h up to 1.9
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/gstdint.h up to 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/gstdint.h up to 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h up to 1.20
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h up to 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/gstdint.h up to 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/gstdint.h up to 1.12
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h up to 1.22
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h up to 1.10
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/gstdint.h up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/defs.mk up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h up to 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h up to 1.22
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/defs.mk up to 1.5
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h up to 1.21
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/defs.mk up to 1.6
external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h up to 1.23
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/defs.mk up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/vax/gstdint.h up to 1.13
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h up to 1.25
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/defs.mk up to 1.7
external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/gstdint.h up to 1.15
external/gpl3/gcc/lib/libstdc++-v3/include/bits/Makefile up to 1.19
external/gpl3/gcc/lib/libubsan/Makefile up to 1.3
external/gpl3/gcc/usr.bin/Makefile.backend up to 1.6
external/gpl3/gcc/usr.bin/Makefile.inc up to 1.29
external/gpl3/gcc/usr.bin/backend/Makefile up to 1.39
external/gpl3/gcc/usr.bin/common/Makefile up to 1.5
external/gpl3/gcc/usr.bin/frontend/Makefile up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/alpha/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/alpha/configargs.h up to 1.23
external/gpl3/gcc/usr.bin/gcc/arch/alpha/defs.mk up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/alpha/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/arm/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/arm/configargs.h up to 1.26
external/gpl3/gcc/usr.bin/gcc/arch/arm/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/arm/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/armeb/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/armeb/configargs.h up to 1.27
external/gpl3/gcc/usr.bin/gcc/arch/armeb/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/armeb/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/earm/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/earm/configargs.h up to 1.24
external/gpl3/gcc/usr.bin/gcc/arch/earm/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/earm/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/earmeb/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmeb/configargs.h up to 1.20
external/gpl3/gcc/usr.bin/gcc/arch/earmeb/defs.mk up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmeb/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmhf/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmhf/configargs.h up to 1.21
external/gpl3/gcc/usr.bin/gcc/arch/earmhf/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/earmhf/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmhfeb/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmhfeb/configargs.h up to 1.19
external/gpl3/gcc/usr.bin/gcc/arch/earmhfeb/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmhfeb/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv4/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv4/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv4/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv4/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv4eb/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv4eb/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv4eb/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv4eb/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv6/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv6/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv6/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv6/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv6eb/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv6eb/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv6eb/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv6eb/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hf/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hf/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hf/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hf/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hfeb/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hfeb/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hfeb/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv6hfeb/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv7/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv7/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv7/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv7/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv7eb/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv7eb/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv7eb/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv7eb/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hf/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hf/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hf/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hf/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hfeb/bversion.h up to 1.7
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hfeb/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hfeb/defs.mk up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/earmv7hfeb/plugin-version.h up to 1.10
external/gpl3/gcc/usr.bin/gcc/arch/hppa/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/hppa/configargs.h up to 1.24
external/gpl3/gcc/usr.bin/gcc/arch/hppa/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/hppa/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/i386/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/i386/configargs.h up to 1.31
external/gpl3/gcc/usr.bin/gcc/arch/i386/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/i386/i386-builtin-types.inc up to 1.4
external/gpl3/gcc/usr.bin/gcc/arch/i386/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/ia64/auto-host.h up to 1.5
external/gpl3/gcc/usr.bin/gcc/arch/ia64/bversion.h up to 1.5
external/gpl3/gcc/usr.bin/gcc/arch/ia64/configargs.h up to 1.6
external/gpl3/gcc/usr.bin/gcc/arch/ia64/defs.mk up to 1.5
external/gpl3/gcc/usr.bin/gcc/arch/ia64/plugin-version.h up to 1.5
external/gpl3/gcc/usr.bin/gcc/arch/m68000/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/m68000/configargs.h up to 1.18
external/gpl3/gcc/usr.bin/gcc/arch/m68000/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/m68000/plugin-version.h up to 1.9
external/gpl3/gcc/usr.bin/gcc/arch/m68k/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/m68k/configargs.h up to 1.21
external/gpl3/gcc/usr.bin/gcc/arch/m68k/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/m68k/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/mips64eb/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/mips64eb/configargs.h up to 1.22
external/gpl3/gcc/usr.bin/gcc/arch/mips64eb/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/mips64eb/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/mips64el/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/mips64el/configargs.h up to 1.23
external/gpl3/gcc/usr.bin/gcc/arch/mips64el/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/mips64el/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/mipseb/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/mipseb/configargs.h up to 1.22
external/gpl3/gcc/usr.bin/gcc/arch/mipseb/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/mipseb/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/mipsel/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/mipsel/configargs.h up to 1.23
external/gpl3/gcc/usr.bin/gcc/arch/mipsel/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/mipsel/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/powerpc/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/powerpc/configargs.h up to 1.28
external/gpl3/gcc/usr.bin/gcc/arch/powerpc/defs.mk up to 1.13
external/gpl3/gcc/usr.bin/gcc/arch/powerpc/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/bversion.h up to 1.5
external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/configargs.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/defs.mk up to 1.6
external/gpl3/gcc/usr.bin/gcc/arch/powerpc64/plugin-version.h up to 1.5
external/gpl3/gcc/usr.bin/gcc/arch/sh3eb/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/sh3eb/configargs.h up to 1.24
external/gpl3/gcc/usr.bin/gcc/arch/sh3eb/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/sh3eb/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/sh3el/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/sh3el/configargs.h up to 1.26
external/gpl3/gcc/usr.bin/gcc/arch/sh3el/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/sh3el/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/sparc/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/sparc/configargs.h up to 1.26
external/gpl3/gcc/usr.bin/gcc/arch/sparc/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/sparc/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/sparc64/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/sparc64/configargs.h up to 1.26
external/gpl3/gcc/usr.bin/gcc/arch/sparc64/defs.mk up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/sparc64/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/vax/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/vax/configargs.h up to 1.24
external/gpl3/gcc/usr.bin/gcc/arch/vax/defs.mk up to 1.12
external/gpl3/gcc/usr.bin/gcc/arch/vax/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/gcc/arch/x86_64/bversion.h up to 1.8
external/gpl3/gcc/usr.bin/gcc/arch/x86_64/configargs.h up to 1.33
external/gpl3/gcc/usr.bin/gcc/arch/x86_64/defs.mk up to 1.13
external/gpl3/gcc/usr.bin/gcc/arch/x86_64/i386-builtin-types.inc up to 1.4
external/gpl3/gcc/usr.bin/gcc/arch/x86_64/plugin-version.h up to 1.11
external/gpl3/gcc/usr.bin/include/arch/i386.mk up to 1.3
external/gpl3/gcc/usr.bin/include/arch/x86_64.mk up to 1.3
external/gpl3/gcc/usr.bin/libcpp/arch/ia64/config.h up to 1.4
distrib/sets/lists/comp/md.amd64 1.252
distrib/sets/lists/comp/md.i386 1.175
distrib/sets/lists/comp/shl.mi 1.309
distrib/sets/lists/debug/shl.mi 1.187
external/gpl3/gcc/lib/liblto_plugin/Makefile 1.6
lib/libc/stdlib/jemalloc.c 1.43

Update gcc to gcc 5.5.
Bump lib minor for liblto_plugin.so link with -liberty.
The HPPA architectures (1.1 and 2.0) both define quadruple-word
(128-bit) floating point types. Adjust alignment to match.
 1.44.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.44.4.1 10-Jun-2019  christos Sync with HEAD
 1.44.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.55.2.1 18-Dec-2023  martin Pull up following revision(s) (requested by mrg in ticket #501):

lib/libc/stdlib/jemalloc.c: revision 1.64

make malloc_usable_size() visible with old jemalloc.

it's in <malloc.h> and applications like firefox expect it.
 1.9 22-Oct-2013  matt Reduce amount of casts and make LP64 safe.
 1.8 12-Jun-2005  lukem branches: 1.8.44; 1.8.50;
Add missing __RCSID()
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 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.4 09-Jan-1998  perry RCS Id Police.
 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-Oct-1993  jtc branches: 1.2.8;
Change _dorand48 to __dorand48, as _dorand48 is in the user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.8.50.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.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.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 26-Jul-2003  salo branches: 1.13.56;
netbsd.org->NetBSD.org
 1.12 22-Jan-2000  mycroft 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 06-Feb-1999  kleink Add l64a_r(), a reentrant version of l64a(); found in the Multithreading
Extension of SVID4.
 1.8 15-Nov-1998  christos delint
 1.7 14-Jun-1998  kleink Per XPG4.2, if the `value' argument evaluates to 0L, don't return a NULL
pointer but a pointer to an empty string.
 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 11-May-1995  jtc branches: 1.4.4;
Winning Strategies has placed this code in the public domain.
 1.3 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 22-Oct-1993  jtc Added 1170's a64l() & l64a() functions.
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.13.56.1 17-Apr-2012  yamt sync with head
 1.12 13-Apr-2011  jruoho Collect abs(3), labs(3), llabs(3), and imaxabs(3) to a single small page.
 1.11 04-Aug-2008  matt branches: 1.11.6;
Add C99 functions imaxabs and imaxdiv.
 1.10 07-Aug-2003  agc branches: 1.10.32;
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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.6 06-Mar-2000  kleink branches: 1.6.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 30-Jan-1998  perry update to lite-2
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 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.10.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.11.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.11.6.1 04-Aug-2008  matt file labs.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.8 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.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 30-Jan-1998  perry update to lite-2
 1.5 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 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.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 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.4 09-Jan-1998  perry RCS Id Police.
 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 14-Oct-1993  jtc branches: 1.2.8;
Rename intenral _rand_foo variables to __rand_foo, as _rand_foo is in the
user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.14 13-Apr-2011  jruoho Collect also the division functions to single place, div(3).
 1.13 04-Aug-2008  matt branches: 1.13.6;
Add C99 functions imaxabs and imaxdiv.
 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 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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.8 06-Mar-2000  kleink branches: 1.8.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 30-Jan-1998  perry update to lite-2
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 21-Mar-1995  jtc add cross references to qdiv(3)
 1.3 21-Mar-1995  jtc ldiv takes long arguments
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.12.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.13.6.1 04-Aug-2008  matt file ldiv.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.8 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.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 30-Jan-1998  perry update to lite-2
 1.5 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 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.8 13-Apr-2011  jruoho Collect abs(3), labs(3), llabs(3), and imaxabs(3) to a single small page.
 1.7 04-Aug-2008  matt branches: 1.7.6;
Add C99 functions imaxabs and imaxdiv.
 1.6 08-Sep-2003  wiz branches: 1.6.32;
Use St -isoC-9X instead of St -isoC9X, to be in sync with groff.
 1.5 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.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 07-Feb-2002  ross Generate <>& symbolically.
 1.2 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.1 06-Mar-2000  kleink branches: 1.1.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.1.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.1.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.6.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.7.6.1 04-Aug-2008  matt file llabs.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +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 07-Aug-2003  agc branches: 1.3.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.2 07-Mar-2000  kleink Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.3.56.1 30-Oct-2012  yamt sync with head
 1.8 13-Apr-2011  jruoho Collect also the division functions to single place, div(3).
 1.7 04-Aug-2008  matt branches: 1.7.6;
Add C99 functions imaxabs and imaxdiv.
 1.6 08-Sep-2003  wiz branches: 1.6.32;
Use St -isoC-9X instead of St -isoC9X, to be in sync with groff.
 1.5 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.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 07-Feb-2002  ross Generate <>& symbolically.
 1.2 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.1 06-Mar-2000  kleink branches: 1.1.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.1.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.1.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.1.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.6.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.7.6.1 04-Aug-2008  matt file lldiv.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +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 07-Aug-2003  agc branches: 1.3.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.2 07-Mar-2000  kleink Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.3.56.1 30-Oct-2012  yamt sync with head
 1.6 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.5 03-Nov-2010  christos Handle the case where a program attempted to cleanup the environment by
setting *environ = NULL;
 1.4 25-Sep-2010  tron Remember memory used by allocated environment variables instead of
using a bitmap. This deals with the case where a variable is first
set via setenv(3) or putenv(3), then overwritten by changing
"environ" directory and afterwards overwritten with setenv(3) again.

This stops "zsh" from crashing under NetBSD-current.

Code reviewed by Christos Zoulas.
 1.3 23-Sep-2010  christos Use a bit array to keep track of malloced environment entries so we can
free them.
 1.2 21-Oct-2009  snj Remove 3rd and 4th clauses in christos' license. OK christos.
 1.1 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.9 22-Oct-2013  matt Reduce amount of casts and make LP64 safe.
 1.8 12-Jun-2005  lukem branches: 1.8.44; 1.8.50;
Add missing __RCSID()
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 15-Nov-1998  christos delint
 1.5 09-Jan-1998  perry RCS Id Police.
 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 14-Oct-1993  jtc branches: 1.3.8;
Rename intenral _rand_foo variables to __rand_foo, as _rand_foo is in the
user's namespace.
 1.2 13-Oct-1993  jtc Change _dorand48 to __dorand48, as _dorand48 is in the user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.3.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.8.50.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.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 12-Jul-2005  wiz branches: 1.3.2;
Remove superfluous Pp, sort sections.
 1.2 06-Jul-2005  drochner fix for non-const lsearch() arg, also fix return values and the
description of the comparision function, and refer to POSIX
partly borrowed from FreeBSD
 1.1 06-Jul-2005  drochner Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.3.2.3 04-Aug-2005  tron Pull up revision 1.2 (requested by drochner in ticket #632):
fix for non-const lsearch() arg, also fix return values and the
description of the comparision function, and refer to POSIX
partly borrowed from FreeBSD
 1.3.2.2 04-Aug-2005  tron Pull up revision 1.1 (requested by drochner in ticket #632):
Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.3.2.1 12-Jul-2005  tron file lsearch.3 was added on branch netbsd-3 on 2005-08-04 17:33:23 +0000
 1.7 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.6 20-Mar-2012  matt Remove use of __P
Switch to using C89 definitions.
 1.5 18-May-2011  dsl branches: 1.5.4;
Remove __P()
 1.4 16-Jul-2005  christos branches: 1.4.2;
revert previous, my include files were out of day.
 1.3 16-Jul-2005  christos Fix prototype inconsistency, discovered by lint2 fixes.
 1.2 06-Jul-2005  drochner The source array of lsearch() shouldn't be "const".
Being here, cleanup the const castaway stuff.
 1.1 06-Jul-2005  drochner Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.4.2.3 04-Aug-2005  tron Pull up revision 1.2 (requested by drochner in ticket #632):
The source array of lsearch() shouldn't be "const".
Being here, cleanup the const castaway stuff.
 1.4.2.2 04-Aug-2005  tron Pull up revision 1.1 (requested by drochner in ticket #632):
Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.4.2.1 16-Jul-2005  tron file lsearch.c was added on branch netbsd-3 on 2005-08-04 17:33:23 +0000
 1.5.4.2 30-Oct-2012  yamt sync with head
 1.5.4.1 17-Apr-2012  yamt sync with head
 1.2 26-Jun-1999  tls The 'new malloc' (phk's malloc, from FreeBSD) is now our only malloc.
 1.1 17-Jun-1999  tls add FreeBSD's malloc, compiled in only if MALLOC_NEW is set in mk.conf
 1.48 01-Jun-2016  wiz Fix manually applied patch. Mark up NULL with Dv.
 1.47 01-Jun-2016  pgoyette Document return value for realloc(3) when size is 0. From PR lib/47384
 1.46 07-Nov-2015  wiz Sort SEE ALSO.
 1.45 07-Nov-2015  nros Add the C11 function aligned_alloc to libc.
 1.44 26-Jul-2015  wiz Spacing; Fn -> Xr for jemalloc.
 1.43 26-Jul-2015  kamil Add history of allocators

Idea accepted by <christos>
No objctions from <riastradh>
 1.42 26-Jul-2015  kamil mandoc lint
 1.41 06-Feb-2015  wiz Remove trailing whitespace.
 1.40 05-Feb-2015  christos Revert addition to reallocarray to the malloc man page, but keep
the examples. Add separate manual page to reallocarray explaining
what are the problems with it.
 1.39 05-Feb-2015  christos Add and use reallocarray() to prevent a multiplication overflow in allocation.
Reported by Guido Vranken, thanks!
 1.38 03-May-2010  jruoho Fix previous commit by also moving the type of _malloc_options. In addition,
add a (commented) note that _malloc_message should be documented better.
 1.37 03-May-2010  jruoho Move the '_malloc_options' variable from malloc(3) to jemalloc(3).
 1.36 03-May-2010  jruoho Move the examples to where they belong, in EXAMPLES.
 1.35 03-May-2010  jruoho Split the implementation details of malloc(3) to a separate jemalloc(3)
manual page. This way malloc(3) can follow the standard terse format used
elsewhere in the libc, while additional details can be added to jemalloc(3).

Note HISTORY and AUTHORS in jemalloc(3), and add some reading material to
SEE ALSO.
 1.34 03-May-2010  jruoho Add more markup.
 1.33 30-Apr-2010  jruoho Also: in the example EOVERFLOW is probably better than ENOMEM.
 1.32 30-Apr-2010  jruoho As err(3) instructs, use EXIT_FAILURE in the example.
 1.31 30-Apr-2010  jruoho Steal the "malloc() vs. calloc()" -idiom from the OpenBSD's malloc(3).

While it may be debated how useful this is, good idiomatic usage examples
are exactly the kind of thing one would hope to see more in manual pages.
 1.30 20-Jul-2009  pooka Re-add explanation of how to correctly use realloc.
 1.29 18-May-2009  wiz Grammar fix.
 1.28 13-May-2009  wiz Revert parts of v1.25 (jemalloc):
Re-add RCS Id, remove superfluous .Pp, join line, comment out limits(1) xref.
 1.27 12-Mar-2009  joerg Explicitly mark : as literal, use Pq.
 1.26 15-Oct-2007  yamt branches: 1.26.16;
we don't have reallocf.
 1.25 06-Oct-2007  ad Update for jemalloc.
 1.24 24-Apr-2006  wiz branches: 1.24.10;
Bump date for previous.
 1.23 24-Apr-2006  liamjfoy - add a missing ;
- use 'size' instead of 'nsize', makes more sense

ok christos@
 1.22 25-Feb-2006  wiz Fix some typos.
 1.21 19-Sep-2003  itojun add warning on realloc() size de-synchronization. from openbsd
 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 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.18 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.17 20-Aug-2002  wiz Mark up NULL and ENOMEM.
 1.16 11-Aug-2002  yamt - more description about realloc.
- mention errno.
- add FILES section for malloc.conf.
from openbsd.
 1.15 07-Feb-2002  ross Generate <>& symbolically.
 1.14 15-Jan-2002  wiz Use Aq for email address.
 1.13 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.12 09-Jan-2000  hubertf branches: 1.12.6;
Document that errno is set to ENOMEM if no memory can be allocated.
 1.11 10-Sep-1999  kleink Restore the behaviour of not setting errno to ENOMEM when allocating 0
units of storage and returning a null pointer in System V mode; this was
broken by the `fix' in rev. 1.24. Also, as it is stated in ISO C that
such operation does not constitute an allocation failure, do not abort()
even if the `X' option is set.

Amusingly enough the SVID, Fourth Edition, specifies the `unique pointer'
return behaviour for this kind of allocation, so this is kind of mis-named.
 1.10 02-Aug-1999  lukem replace malloc(3) with one from freebsd which documents our new malloc.c
(also from freebsd). comment out references to reallocf with .\"XXX"
for now. i also fixed some roff misuse as well.
replace calloc(3), free(3) and realloc(3) with links to malloc(3)
 1.9 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.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 30-Jan-1998  perry update to lite-2
 1.6 15-Jul-1997  mikel xref getpagesize(3) not obsolete getpagesize(2), sort xrefs
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 17-Aug-1995  jtc pagesize(2) -> getpagesize(2)
 1.3 15-Dec-1993  jtc Remove unwanted comma from NAME section.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.6.7 18-Oct-2002  nathanw Catch up to -current.
 1.12.6.6 27-Aug-2002  nathanw Catch up to -current.
 1.12.6.5 13-Aug-2002  nathanw Catch up to -current.
 1.12.6.4 22-Mar-2002  nathanw Catch up to -current.
 1.12.6.3 08-Mar-2002  nathanw Catch up to -current.
 1.12.6.2 28-Jan-2002  nathanw Catch up to -current.
 1.12.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.24.10.1 06-Nov-2007  matt sync with HEAD
 1.26.16.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.60 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.59 13-Jan-2017  christos use getpagesize(3).
 1.58 12-Jan-2017  christos Avoid sysconf: __sysconf -> sysctlgetmibinfo -> strtoimax -> locale, etc.
 1.57 12-Jan-2017  christos make this smaller.
 1.56 18-Sep-2014  christos branches: 1.56.2;
make more descriptors that we open as close-on-exec
 1.55 30-Dec-2012  dholland typo in comment, from Abhinav Upadhyay in PR 47385
 1.54 18-May-2011  christos branches: 1.54.4; 1.54.10;
cleanup saving and restoring errno, and make it similar.
 1.53 13-May-2011  christos don't let readlink trash errno.;
 1.52 03-Feb-2008  christos fix posix_memalign; we are not going to support alignments > pagesize in
this implementation.
 1.51 12-Dec-2007  macallan make this compile again
 1.50 04-Dec-2007  christos move decls for _malloc_{pre,post}fork() to extern.h
 1.49 28-Nov-2007  christos Sync phk malloc.c with the latest one from FreeBSD. This gives us the
same api as jemalloc by:

- adding posix_memalign()
- moving calloc in the same file
- renaming malloc_options -> _malloc_options
 1.48 24-Nov-2006  christos branches: 1.48.8;
fix spelling of accidentally; from Zapher
 1.47 08-Oct-2006  elad PR/34602: sushant: Bug in malloc implementation contains dead code in
free_pages()

Applied patch from Mindaugas <unex at linija org> (in #NetBSD-code), thanks
 1.46 24-Dec-2005  perry __inline__ -> inline
 1.45 29-Nov-2005  christos WARNS=4
 1.44 12-Jun-2005  lukem Add missing __RCSID()
 1.43 05-Oct-2003  junyoung Style fixes to reduce diff size against the FreeBSD version, notably:
- Use NULL where appropriate.
- No need to pull in stdint.h.
- Get rid of "register" keywords in the hope that the compiler will
do a better job for us. :-)
- Every message ends with a period.
- MMAP() macro is supposed to return MAP_FAILED rather than -1 if it
fails.
- De-__P.
 1.42 23-Jul-2003  itojun call malloc_init() on first call to free/realloc, to make malloc.conf to
take effect. in response to PR 22223
 1.41 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.40 09-Dec-2002  chris Add a couple of missing THREAD_UNLOCK's, for the error exit path.

No functional change on Mainline, however SA branch probably needs this.
 1.39 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.38 06-May-2001  christos More fixes:

1. use uintptr_t instead of u_long
2. check for overflow in map_pages and malloc_pages
3. bring in fixes from FreeBSD [int -> size_t, and a missing THREAD_UNLOCK]
4. rewrite map_pages to use sbrk() only to grow memory (avoids extra syscall
and elides bug in brk(2) that ross is fixing)
5. restore the break point to its original value if the mmap(2) for the page
directory or the alignment sbrk breaks.

reviewed by: chuq and ross
tested by: make build and reboot
Now memtest nearly works; unfortunately there is no way currently to lower
the break point as we free, so memtest keeps trying to reduce memory when
mlock() fails and that does not work.
 1.37 03-May-2001  christos PR/12810: Chris ?: malloc core-dumps when given large number as the argument.
This is because integer overflow occurs in the computation of the size of
the page directory array. We now detect that, and return ENOMEM.
 1.36 19-Feb-2001  cgd branches: 1.36.2;
convert from __progname to getprogname()
 1.35 05-Jan-2001  jdolecek we now have utrace, support it here
 1.34 20-Dec-2000  christos fix sbrk casts
 1.33 06-Jul-2000  christos avoid losing precision warnings
 1.32 20-May-2000  simonb Disable malloc's hints to the kernel - now that the madvise() syscall
actually does something, this can be expensive. From discussion on
current-users.

Note that the man page is already correct - we imported malloc.c from
FreeBSD before they made the same change but malloc.3 after...
 1.31 07-Apr-2000  enami Fix the bug introduced in rev 1.28 and actually caused failure on alpha;
In the function malloc_make_chunks, don't define the local variable ``l'',
which is used to hold the actual size of pginfo, as size_t. Define it as
a signed integer as before. We expect it to become zero or negative value,
and we know that it is much smaller than pagesize and it is small enough to
fit in signed interger.
 1.30 07-Apr-2000  enami Backout the previous backing out.
 1.29 31-Jan-2000  thorpej Back out the previous 2 revs. The delint'ing of this file caused
something to break horribly on the Alpha.
 1.28 23-Jan-2000  mycroft Delint.
 1.27 23-Jan-2000  mycroft Partially delint, and a few microoptimizations.
 1.26 10-Sep-1999  kleink Restore the behaviour of not setting errno to ENOMEM when allocating 0
units of storage and returning a null pointer in System V mode; this was
broken by the `fix' in rev. 1.24. Also, as it is stated in ISO C that
such operation does not constitute an allocation failure, do not abort()
even if the `X' option is set.

Amusingly enough the SVID, Fourth Edition, specifies the `unique pointer'
return behaviour for this kind of allocation, so this is kind of mis-named.
 1.25 22-Aug-1999  kleink Need "namespace.h".
 1.24 08-Jul-1999  thorpej Make sure errno is set to ENOMEM if we return NULL.
 1.23 05-Jul-1999  thorpej index -> ldx (and similar in some related variable names). Avoids a lint
warning.
 1.22 05-Jul-1999  thorpej Oops, back out 1.21. Christos and I apparently stepped on each other.
 1.21 05-Jul-1999  christos s/index/idx/
s/EXTRA_SANITY/MALLOC_EXTRA_SANITY/
const poisoning
use sysconf to get the pagesize
 1.20 05-Jul-1999  thorpej Compute page size related parameters at run-time.
 1.19 05-Jul-1999  thorpej EXTRA_SANITY -> MALLOC_EXTRA_SANITY, consistently.
 1.18 04-Jul-1999  thorpej Only define MADV_FREE do MADV_DONTNEED if it's not already defined
by <sys/mman.h>.
 1.17 26-Jun-1999  tls The 'new malloc' (phk's malloc, from FreeBSD) is now our only malloc.
 1.16 29-Jan-1999  kleink Protect access of state with a mutex. Miscellaneous notes:
* still needs an implementation-independent ("reentrant.h") method for
disabling cancellation,
* break a leg to leave realloc() `storage compaction' as was for non-reentrant
code,
* use of stdio in assertion code is unsafe.
 1.15 15-Nov-1998  christos delint
 1.14 26-Aug-1998  perry make memcpy into memmove in some cases
 1.13 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 30-Jan-1998  perry update to lite-2
 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.8 07-Apr-1997  christos PR/3448: Bill Sommerfeld: Change "p" to __STRING(p)
 1.7 20-Dec-1996  cgd don't confuse long and int; pointed out by lint
 1.6 17-Jan-1996  jtc branches: 1.6.2;
The C standard says (about realloc) that "If size is zero and ptr is
not a null pointer, the object it points to is freed." Reported by
Peter Seebach in PR #1806.
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 19-Oct-1994  cgd branches: 1.4.2;
casting types.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 02-May-1995  jtc #include "namespace.h"
 1.6.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.36.2.6 10-Dec-2002  thorpej Sync with HEAD.
 1.36.2.5 25-Mar-2002  nathanw Bind libc's pthread desires to _libc_pthread_*, rather than pthread_*, to
prevent accidental use of pthread libraries that aren't actually integrated
with libc.
 1.36.2.4 11-Mar-2002  nathanw Use an ordinary mutex for malloc now that internal spinlocks aren't exported.
 1.36.2.3 01-Jan-2002  wdk pt_spin_t has been renamed to pthread_spin_t
 1.36.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.36.2.1 08-Aug-2001  nathanw Add THREAD_LOCK stubs that use the library's spinlocks.
(XXX why spinlocks instead of a normal mutex?)
 1.48.8.2 23-Mar-2008  matt sync with HEAD
 1.48.8.1 09-Jan-2008  matt sync with HEAD
 1.54.10.1 25-Feb-2013  tls resync with head
 1.54.4.1 23-Jan-2013  yamt sync with head
 1.56.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.12 26-Apr-2017  abhinav Clean up the NAME section.

The entries in the NAME section of these man pages have man pages of their
own, so it doesn't make sense to have their names here, instead they
should be just described in the body (similar to what we do in math(3) man page).

This also helps whatis(1) and apropos(1), as otherwise you would see multiple
results with the same name in the output, while there is actually only one page
with that name.

Good example is:

$ apropos -n 2 -M realloc
realloc (3) general memory allocation operations
realloc (3) general purpose memory allocation functions

The first line is there because memory(3) man page had realloc in its
NAME section. This commit will fix this issue.

ok wiz@
 1.11 11-Sep-2011  jruoho Note memoryallocators(9) in this perhaps too generally named page.
 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  enami Sort SEE ALSO and remove trailing comma.
 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 30-Jan-1998  perry update to lite-2
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 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.17 02-Mar-2025  riastradh libc: New _r variants of heapsort, mergesort, qsort.

Also kheapsort_r for kernel/standalone use.

These variants allow the caller to pass a cookie through to the
comparison function, e.g. if you want to sort an array of indices
into a buffer.

qsort_r is new in POSIX.1-2024; the others are obvious analogues of
our nonstandard extensions for heapsort and mergesort.

PR lib/58931: qsort_r() missing
 1.16 23-May-2018  joerg branches: 1.16.14;
Simplify to avoid pointless null pointer arithmetic.
 1.15 12-Aug-2017  ginsbach branches: 1.15.2;
PR lib/50316: Gracefully handle a zero number of members argument.

Taken from FreeBSD (which fixed this same issue long ago).

XXX: pullup-8
XXX: pullup-7
XXX: pullup-6
 1.14 13-Mar-2012  christos branches: 1.14.10; 1.14.24;
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 18-May-2011  dsl branches: 1.13.4; 1.13.6;
Remove __P()
 1.12 12-Feb-2009  lukem fix sign-compare issue
 1.11 07-Aug-2003  agc branches: 1.11.42;
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 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 15-Nov-1998  christos delint
 1.6 03-Feb-1998  perry remove obsolete register declarations
 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 local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.3 28-Dec-1995  thorpej branches: 1.3.2;
New-style RCS ids.
 1.2 16-Jun-1994  mycroft Add RCS ids.
 1.1 16-Jun-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 16-Jun-1994  mycroft Import from 4.4-Lite.
 1.3.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.11.42.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.6.1 31-Aug-2017  martin Pull up following revision(s) (requested by ginsbach in ticket #1495):
lib/libc/stdlib/merge.c: revision 1.15
PR lib/50316: Gracefully handle a zero number of members argument.
Taken from FreeBSD (which fixed this same issue long ago).
XXX: pullup-8
XXX: pullup-7
XXX: pullup-6
 1.13.4.1 17-Apr-2012  yamt sync with head
 1.14.24.1 20-Aug-2017  snj Pull up following revision(s) (requested by ginsbach in ticket #214):
lib/libc/stdlib/merge.c: revision 1.15
PR lib/50316: Gracefully handle a zero number of members argument.
Taken from FreeBSD (which fixed this same issue long ago).
 1.14.10.1 04-Sep-2017  snj Pull up following revision(s) (requested by ginsbach in ticket #1495):
lib/libc/stdlib/merge.c: revision 1.15
PR lib/50316: Gracefully handle a zero number of members argument.
Taken from FreeBSD (which fixed this same issue long ago).
 1.15.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.16.14.1 02-Aug-2025  perseant Sync with HEAD
 1.2 21-Jul-2009  joerg Add HISTORY.
 1.1 20-Jul-2009  joerg Add a fast, platform independent hash function to libc.
The algorithm used is the Jenkins hash. The name (mi_vector_hash)
reflects the nature of the hash function.
Add glue for libc ATF tests and include a test case to make sure that
(mis)alignment and endianess are handled correctly.

Bump libc minor to 169.
 1.5 11-Dec-2013  joerg Allow kernel code to access constant databases by moving cdbr(3) and the
required mi_vector_hash(3) into src/common.
 1.4 21-Oct-2011  joerg branches: 1.4.2; 1.4.8;
sys/endian.h might not exist in the src/tools case
 1.3 19-Mar-2010  joerg Namespace protection for mi_vector_hash.
 1.2 04-Feb-2010  roy Include nbtool_config.h as we need to be part of the terminfo toolchain.
 1.1 20-Jul-2009  joerg Add a fast, platform independent hash function to libc.
The algorithm used is the Jenkins hash. The name (mi_vector_hash)
reflects the nature of the hash function.
Add glue for libc ATF tests and include a test case to make sure that
(mis)alignment and endianess are handled correctly.

Bump libc minor to 169.
 1.4.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.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.8 22-Oct-2013  matt Reduce amount of casts and make LP64 safe.
 1.7 12-Jun-2005  lukem branches: 1.7.44; 1.7.50;
Add missing __RCSID()
 1.6 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.5 09-Jan-1998  perry RCS Id Police.
 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 14-Oct-1993  jtc branches: 1.3.8;
Rename intenral _rand_foo variables to __rand_foo, as _rand_foo is in the
user's namespace.
 1.2 13-Oct-1993  jtc Change _dorand48 to __dorand48, as _dorand48 is in the user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.3.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.7.50.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.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.10 21-Dec-2000  itojun first import of citrus LC_CTYPE locale. singlebyte only at this moment.
shot-term TODO:
- enable multibyte locales. this includes loadable locale modules
(#ifdef DLRUNE).
- populate LC_CTYPE definition files.
- other functions such as iconv()
- make libc functions more friendly with multibyte.
- multilingualize other LC_xx
- torture tests

XXX don't forget to "make depend" when you rebuild libc, multibyte.c is
moved from lib/libc/stdlib to lib/libc/locale.
 1.9 01-Apr-2000  erh Make mbstowcs and wcstombs work correctly when handed NULL pointers.
 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 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 05-Mar-1995  jtc Changed the multibyte character functions so they work with the native
single byte character set.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-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.10 22-Oct-2013  matt Reduce amount of casts and make LP64 safe.
 1.9 12-Jun-2005  lukem branches: 1.9.44; 1.9.50;
Add missing __RCSID()
 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 15-Nov-1998  christos delint
 1.4 09-Jan-1998  perry RCS Id Police.
 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-Oct-1993  jtc branches: 1.2.8;
Change _dorand48 to __dorand48, as _dorand48 is in the user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.9.50.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.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.8 11-Jan-2025  wiz aligned_alloc appeared in C11.

Ok maya@
 1.7 06-Dec-2019  nros branches: 1.7.10;
Fix manpage due to updated aligned_alloc behavior

Since aligned_alloc does not demand that size is to be multiple of alignment
anymore, don't make that claim in the man page.
 1.6 27-Jul-2018  maya it's C18, not C17.
 1.5 27-Jul-2018  maya Claim C17 (although I'm unsure), add a note about C11's requirements.
 1.4 27-Jul-2018  maya C17 conformance: aligned_alloc's size doesn't need to be a multiple of
alignment any more.

Thanks Joseph Myers for the heads up.
 1.3 07-Nov-2015  wiz branches: 1.3.14; 1.3.16;
Use Dv for NULL.
 1.2 07-Nov-2015  nros Add the C11 function aligned_alloc to libc.
 1.1 19-Nov-2007  ad branches: 1.1.4;
Enable posix_memalign().
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 19-Nov-2007  matt file posix_memalign.3 was added on branch matt-armv6 on 2008-01-09 01:34:16 +0000
 1.3.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.16.1 10-Jun-2019  christos Sync with HEAD
 1.3.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.7.10.1 02-Aug-2025  perseant Sync with HEAD
 1.11 06-Aug-2025  gutteridge posix_openpt.3: note O_CLOFORK is also now supported
 1.10 15-Nov-2022  gutteridge branches: 1.10.6;
posix_openpt.3: add a history section
 1.9 04-Oct-2022  gutteridge posix_openpt.3: reflect changes from r. 1.45 of tty_ptm.c
 1.8 28-Sep-2022  gutteridge posix_openpt.3: reflect flag changes from r. 1.44 of tty_ptm.c

Some flags are now accepted, others are still ignored. (E.g., other
BSDs would return EINVAL if O_RDWR wasn't passed, and we now accept
O_NONBLOCK but not O_CLOEXEC.)
 1.7 06-Sep-2022  gutteridge posix_openpt.3: add caveats about oflags

The NetBSD implementation differs from other BSDs in that it does not
return EINVAL if invalid oflags are submitted, since it completely
ignores them. This is surprising to upstream projects that may expect
otherwise.
 1.6 05-May-2011  wiz Add missing preposition.
 1.5 05-May-2011  jruoho Fix lead paragraph.
 1.4 30-Apr-2008  martin branches: 1.4.8;
Convert TNF licenses to new 2 clause variant
 1.3 28-May-2004  wiz branches: 1.3.24;
Uppercase Dt argument; \-1, not -1; sort SEE ALSO; & -> \*[Am].
 1.2 28-May-2004  wiz Drop trailing whitespace.
 1.1 27-May-2004  christos unix/98 pty functions and manual pages.
 1.3.24.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 posix_openpt.3 was added on branch christos-time_t on 2008-04-30 13:10:52 +0000
 1.10.6.1 08-Aug-2025  martin Pull up following revision(s) (requested by gutteridge in ticket #8):

tests/lib/libc/ttyio/t_ptm.c: revision 1.3
lib/libc/stdlib/posix_openpt.3: revision 1.11
sys/kern/tty_ptm.c: revision 1.47

tty_ptm.c: support setting O_CLOFORK here as well

t_ptm.c: now also validate O_CLOFORK can be set

posix_openpt.3: note O_CLOFORK is also now supported
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 27-May-2004  christos branches: 1.1.24;
unix/98 pty functions and manual pages.
 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 posix_openpt.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.13 02-Jan-2022  uwe ptsname(3): fix equivalence example

The buffer is static, don't make it appear that we are returning a
pointer to a local variable.
 1.12 07-Feb-2018  pgoyette Fix typos, as reported by Eitan Adler. Update dates.
 1.11 09-Sep-2017  kamil Correct the documentatin of ptsname_r(3)

This function returns "int" not "char *": errno on failure, 0 on success.
 1.10 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.9 10-Jan-2014  wiz whitespace.
 1.8 08-Jan-2014  christos return the same errors as linux for ptsname_r
 1.7 08-Jan-2014  christos add ptsname_r
 1.6 19-Oct-2012  apb Use the correct field name when describing the equivalence between
ptsname(3) and ioctl TIOCPTSNAME. It should be pm.sn, not pm.ps.
 1.5 30-Apr-2008  martin branches: 1.5.4; 1.5.8; 1.5.28;
Convert TNF licenses to new 2 clause variant
 1.4 01-Jul-2004  kleink branches: 1.4.24;
Make the spelling of reentrant match the rest of the system.
 1.3 28-May-2004  wiz Uppercase Dt argument; \-1, not -1; sort SEE ALSO; & -> \*[Am].
 1.2 28-May-2004  wiz Drop trailing whitespace.
 1.1 27-May-2004  christos unix/98 pty functions and manual pages.
 1.4.24.1 18-May-2008  yamt sync with head.
 1.5.28.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.28.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 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 ptsname.3 was added on branch christos-time_t on 2008-04-30 13:10:52 +0000
 1.5.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.5.4.1 30-Oct-2012  yamt sync with head
 1.4 08-Jan-2014  christos return the same errors as linux for ptsname_r
 1.3 08-Jan-2014  christos add ptsname_r
 1.2 28-Apr-2008  martin branches: 1.2.4; 1.2.8; 1.2.28;
Remove clause 3 and 4 from TNF licenses
 1.1 27-May-2004  christos branches: 1.1.24;
unix/98 pty functions and manual pages.
 1.1.24.1 18-May-2008  yamt sync with head.
 1.2.28.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 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 pty.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.2.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.21 20-Jan-2015  christos Fix non _REENTRANT build.
 1.20 25-Apr-2013  matt Remove weak_alias since that's now in the compat_putenv.c
 1.19 14-Nov-2010  tron branches: 1.19.6; 1.19.12;
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.18 03-Nov-2010  christos Handle the case where a program attempted to cleanup the environment by
setting *environ = NULL;
 1.17 25-Oct-2010  njoly Make putenv(3) fails with EINVAL for a null pointer, or for a string
that either miss or start with a `=' character.

Adjust man page and testcase accordingly.
 1.16 05-Oct-2010  enami Avoid unnecessary malloc(). Since __findenv() kindly treats
equal sign as an end of string, we can pass the string of
form "key=value" to lookup "key".
 1.15 02-Oct-2010  tron Restore binary compatibility with applications which use putenv(3)
on constant strings (e.g. postdrop(1)):
- Don't write to the environment string passed to putenv(3).
- Don't overwrite the value of an existing environment string
unless the memory was actually allocated by setenv(3).
 1.14 02-Oct-2010  tron Remember that we didn't malloc() memory for an environment variable
if it has been set via putenv(3).
 1.13 01-Oct-2010  christos make putenv POSIX compliant.
 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-Jan-1998  perry 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.5 28-Dec-1995  thorpej branches: 1.5.2;
New-style RCS 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 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 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.9 04-Aug-2008  matt branches: 1.9.6;
Add C99 functions imaxabs and imaxdiv.
 1.8 07-Aug-2003  agc branches: 1.8.32;
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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.4 06-Mar-2000  kleink branches: 1.4.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 28-Dec-1995  thorpej New-style RCS ids.
 1.1 22-Mar-1995  jtc Enable qabs(), a quad_t version of abs() and labs().
 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.8.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.9.6.1 04-Aug-2008  matt file qabs.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.7 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.6 07-Aug-2003  agc branches: 1.6.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.2 28-Dec-1995  thorpej branches: 1.2.2;
New-style RCS ids.
 1.1 22-Mar-1995  jtc Enable qabs(), a quad_t version of abs() and labs().
 1.2.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.6.56.1 30-Oct-2012  yamt sync with head
 1.9 04-Aug-2008  matt branches: 1.9.6;
Add C99 functions imaxabs and imaxdiv.
 1.8 07-Aug-2003  agc branches: 1.8.32;
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 06-Mar-2000  kleink branches: 1.5.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 1.2 21-Mar-1995  jtc LDIV -> QDIV
 1.1 21-Mar-1995  jtc New function qdiv. Like div and ldiv, but works with quad_t's.
 1.5.6.2 22-Mar-2002  nathanw Catch up to -current.
 1.5.6.1 08-Mar-2002  nathanw Catch up to -current.
 1.8.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.6.2 04-Aug-2008  matt Add C99 functions imaxabs and imaxdiv.
 1.9.6.1 04-Aug-2008  matt file qdiv.3 was added on branch christos-time_t on 2008-08-04 21:29:28 +0000
 1.7 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.6 07-Aug-2003  agc branches: 1.6.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.2 28-Dec-1995  thorpej branches: 1.2.2;
New-style RCS ids.
 1.1 21-Mar-1995  jtc New function qdiv. Like div and ldiv, but works with quad_t's.
 1.2.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.6.56.1 30-Oct-2012  yamt sync with head
 1.16 20-Jul-2025  dholland qsort.3: add bits missed when qsort_r was added, including bumping the date.
 1.15 02-Mar-2025  riastradh libc: New _r variants of heapsort, mergesort, qsort.

Also kheapsort_r for kernel/standalone use.

These variants allow the caller to pass a cookie through to the
comparison function, e.g. if you want to sort an array of indices
into a buffer.

qsort_r is new in POSIX.1-2024; the others are obvious analogues of
our nonstandard extensions for heapsort and mergesort.

PR lib/58931: qsort_r() missing
 1.14 19-Sep-2014  wiz branches: 1.14.28;
Sort sections. From Henning Petersen in PR 49222.
 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 10-May-2003  wiz Misc fixes from jmc@openbsd.
 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 29-Jan-2003  heinz Provide some more details for papers by Bentley/M.D. McIlroy and by
P.M. McIlroy (after short e-mail conversation with M.D. McIlroy on
www@).
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.7 29-Aug-1998  lukem branches: 1.7.12;
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 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.4 28-Dec-1995  thorpej branches: 1.4.8;
New-style RCS ids.
 1.3 16-Jun-1994  mycroft Add RCS ids.
 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 16-Jun-1994  mycroft Import from 4.4-Lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.8.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 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.14.28.1 02-Aug-2025  perseant Sync with HEAD
 1.24 02-Mar-2025  riastradh libc: New _r variants of heapsort, mergesort, qsort.

Also kheapsort_r for kernel/standalone use.

These variants allow the caller to pass a cookie through to the
comparison function, e.g. if you want to sort an array of indices
into a buffer.

qsort_r is new in POSIX.1-2024; the others are obvious analogues of
our nonstandard extensions for heapsort and mergesort.

PR lib/58931: qsort_r() missing
 1.23 19-May-2017  christos branches: 1.23.22;
The BSD qsort() performs tail recursion elimination on the second
side of the array being partitioned to save on stack space. Greater
savings can be gained by choosing recursion for the smaller side
of the partition and eliminating recursion for the larger side.
This also results in a small but measurable performance gain.
(From OpenBSD)
 1.22 26-May-2012  christos don't trigger diagassert for a null array with 0 elements or 0 elementsize.
 1.21 18-May-2011  dsl branches: 1.21.4;
Remove __P()
 1.20 01-Jun-2009  yamt qsort: remove the "switch to insertion sort" optimization because it
causes catastrophic performance for certain inputs.
 1.19 30-Jan-2009  lukem sign-compare fix
 1.18 11-Jan-2009  christos merge christos-time_t
 1.17 16-Nov-2008  ad Our qsort() is inappropriate for kernel use because it makes recursive
calls. Replace it with a kheapsort() function in kernel. Pointed out
by tron@.
 1.16 16-Nov-2008  ad Make qsort() available in libkern.
 1.15 11-Mar-2008  rmind branches: 1.15.10;
Use size_t to avoid overflow when sorting large arrays. While here, ANSIfy.
Obtained from FreeBSD (das@).
 1.14 24-Dec-2005  perry branches: 1.14.10; 1.14.16;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 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 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 15-Nov-1998  christos delint
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.7 19-Jun-1997  mikel avoid unportable arithmetic on void pointers
 1.6 19-Dec-1996  cgd use __inline and __asm, rather than inline and asm. By default (without -g)
lint won't accept the latter two, but will accept the former two as valid.
As far as gcc's concerned, they're the same.
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 16-Jun-1994  mycroft Add RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 16-Jun-1994  mycroft Import from 4.4-Lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14.16.1 24-Mar-2008  keiichi sync with head.
 1.14.10.1 23-Mar-2008  matt sync with HEAD
 1.15.10.1 04-Jan-2009  christos merge with head.
 1.21.4.1 30-Oct-2012  yamt sync with head
 1.23.22.1 02-Aug-2025  perseant Sync with HEAD
 1.3 26-Jul-2015  christos From Timo Buhrmester: Fix wrong parameter description
 1.2 26-Apr-2013  wiz branches: 1.2.2; 1.2.8;
Bump date after adding function to NetBSD.
 1.1 26-Apr-2013  christos add {at_,}quick_exit(3) from FreeBSD
 1.2.8.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.2.8.1 26-Apr-2013  yamt file quick_exit.3 was added on branch yamt-pagecache on 2014-05-22 11:36:54 +0000
 1.2.2.2 23-Jun-2013  tls resync from head
 1.2.2.1 26-Apr-2013  tls file quick_exit.3 was added on branch tls-maxphys on 2013-06-23 06:21:06 +0000
 1.1 26-Apr-2013  christos branches: 1.1.2; 1.1.8;
add {at_,}quick_exit(3) from FreeBSD
 1.1.8.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.8.1 26-Apr-2013  yamt file quick_exit.c was added on branch yamt-pagecache on 2014-05-22 11:36:54 +0000
 1.1.2.2 23-Jun-2013  tls resync from head
 1.1.2.1 26-Apr-2013  tls file quick_exit.c was added on branch tls-maxphys on 2013-06-23 06:21:06 +0000
 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 07-Jun-2001  simonb Add sradixsort to the NAME section.
 1.9 16-Mar-2001  fair Add documentation of nmemb parameter, per PR 10567
 1.8 12-Jan-2001  jdolecek branches: 1.8.2;
slighly clarify how endbyte is used, so that this matches implementation more closely
 1.7 13-Dec-2000  garbled Radixsort wants a const u_char ** as a fisrt argument, not just a
u_char **. Fix this manpage.
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 03-Feb-1998  perry .Bx'ize
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 16-Jun-1994  mycroft Add RCS ids.
 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 16-Jun-1994  mycroft Import from 4.4-Lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.22 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.21 29-Oct-2021  nia reallocarr does not set errno.
 1.20 29-Oct-2021  nia radixsort(3): use reallocarr instead of malloc(x * y)
 1.19 05-Sep-2009  dsl Ansify functions and remove __P/
 1.18 21-Aug-2009  dsl The 'table' of character weights is allowed to be NULL.
The SETUP define sorts it out (in the slowest and nastiest possible way!)
Broken by rev 1.12 almost 10 years ago!
 1.17 12-Feb-2009  lukem Fix sign-compare issues
 1.16 24-Dec-2005  perry branches: 1.16.30;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 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 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.13 20-Sep-1999  lukem 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 03-Feb-1998  perry remove obsolete register declarations
 1.10 30-Jan-1998  perry update to lite-2
 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 local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.7 19-Dec-1996  cgd use __inline and __asm, rather than inline and asm. By default (without -g)
lint won't accept the latter two, but will accept the former two as valid.
As far as gcc's concerned, they're the same.
 1.6 28-Dec-1995  thorpej branches: 1.6.2;
New-style RCS ids.
 1.5 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.4 16-Jun-1994  mycroft Add RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 30-Jan-1998  perry import lite-2
 1.1.1.2 16-Jun-1994  mycroft Import from 4.4-Lite.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.16.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.12 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.11 24-Mar-2006  kleink Xref rnd(4).
 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;
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 30-Jan-1998  perry update to lite-2
 1.4 15-Jul-1997  kleink Document rand_r().
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 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 30-Jan-1998  perry import lite-2
 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.12 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.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 16-Sep-1999  lukem whitespace knf
 1.8 15-Nov-1998  christos delint
 1.7 30-Jan-1998  perry update to lite-2
 1.6 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.5 28-Dec-1995  thorpej New-style RCS ids.
 1.4 19-Oct-1994  cgd cast type
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.56.1 30-Oct-2012  yamt sync with head
 1.14 16-Feb-2021  riastradh Correct floating-point terminology.

Might want to harmonize the printf(3) and wprintf(3) descriptions of
`%a'.
 1.13 22-Feb-2020  kamil Reorder words to fix grammar

Noted by <leot>
 1.12 22-Feb-2020  kamil rand48: Document that short integers are unsigned
 1.11 31-Mar-2006  drochner branches: 1.11.86;
correct multiplicand in pseudorandom generation
 1.10 10-May-2003  wiz branches: 1.10.6;
Misc fixes from jmc@openbsd.
 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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.6 05-Jul-2000  msaitoh branches: 1.6.2;
remove extra period in SEE ALL section
 1.5 28-Apr-1998  fair fix mdoc references and mistakes
 1.4 05-Feb-1998  perry add LIBRARY section to man page
 1.3 28-Dec-1995  thorpej New-style RCS ids.
 1.2 17-Sep-1994  mycroft Swap the definition of {lrand,nrand} with {mrand,jrand} to reflect reality.
 1.1 09-Oct-1993  jtc branches: 1.1.2;
Added rand48 manual page.
 1.1.2.1 06-Oct-1994  mycroft Update from trunk.
 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.10.6.1 24-Apr-2006  ghen Pull up following revision(s) (requested by drochner in ticket #1286):
lib/libc/stdlib/rand48.3: revision 1.11
correct multiplicand in pseudorandom generation
 1.11.86.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6 18-May-2011  dsl Remove __P()
 1.5 22-Mar-2006  drochner <math.h> is just needed for the ldexp() call in erand48() -
remove unnecessary dependency
 1.4 09-Jan-1998  perry RCS Id Police.
 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-Oct-1993  jtc branches: 1.2.8;
Change _dorand48 to __dorand48, as _dorand48 is in the user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.6 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.5 07-Aug-2003  agc branches: 1.5.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.3 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.2 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.1 19-Nov-1996  jtc Added rand_r()
 1.5.56.1 30-Oct-2012  yamt sync with head
 1.23 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.22 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.21 12-Jun-2014  christos update for new signatures
 1.20 15-Oct-2011  rmind branches: 1.20.8; 1.20.18;
Mention POSIX conformance of some functions, when they appeared, sprinkle .Xr.
 1.19 28-Feb-2008  christos mention RANDOM_MAX
 1.18 07-Aug-2003  agc branches: 1.18.22; 1.18.28;
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 07-Feb-2002  ross generate & symbolically
 1.14 07-Feb-2002  ross Generate <>& symbolically.
 1.13 08-Jan-2002  thorpej Make a note about the alignment requirement of the state array
passed to initstate(3). This is actually documented in comments
in the code.
 1.12 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.11 09-Jun-2001  assar remove confusing comparison with srand (it does not return the old seed)
use .Sh AUTHORS and .An for author
 1.10 05-Oct-2000  itojun branches: 1.10.2;
make random(3) manpage meet with actual implementation.
argument to srandom() and initstate() were changed in
lib/libc/stdlib/random.c 1.28 -> 1.29, and manpage was left behind.
 1.9 22-Mar-1999  garbled branches: 1.9.2; 1.9.10;
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 references and mistakes
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 04-Feb-1998  kleink Per XPG4.2, change the `n' argument of initstate() to size_t. (Since it was
recently changed from int to long (lite-2 import), I saw no reason to delay
this `alignment'.)
 1.5 30-Jan-1998  perry update to lite-2
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 04-Oct-1993  jtc Change <stdlib> to <stdlib.h> in SYNOPSIS.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.10.2 14-Jan-2002  he Pull up revision 1.13 (requested by he):
Document alignment requirements of the state array passed to
initstate(3). Earlier only documented in comments in the code.
 1.9.10.1 17-Oct-2000  tv Pullup 1.10 [itojun]:
make random(3) manpage meet with actual implementation.
argument to srandom() and initstate() were changed in
lib/libc/stdlib/random.c 1.28 -> 1.29, and manpage was left behind.
 1.9.2.1 14-Jan-2002  he Pull up revision 1.13 (requested by thorpej):
Note alignment requirement of the state array passed to initstate(3).
This was formerly only documented in the comments in the code.
 1.10.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.10.2.4 22-Mar-2002  nathanw Catch up to -current.
 1.10.2.3 08-Mar-2002  nathanw Catch up to -current.
 1.10.2.2 28-Jan-2002  nathanw Catch up to -current.
 1.10.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.18.28.1 24-Mar-2008  keiichi sync with head.
 1.18.22.1 23-Mar-2008  matt sync with HEAD
 1.20.18.1 10-Aug-2014  tls Rebase.
 1.20.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.23 26-Nov-2003  jdolecek improve random number generation by using largest 31-bit prime
as denominator; regenerate the randtbl[] with new generator

patch provided in lib/22853 by KIHARA Hideto; code actually present
in libkern/random.c since 1994/06/03

matches similar change done in glibc in 1995, and FreeBSD & OpenBSD in 1996
 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 18-Jan-2003  christos s/_REENT/_REENTRANT/
 1.20 08-Jan-2002  thorpej Make this actually work on LP64 platforms. It has been broken
since some "cleanups" in the master (UCB?) version of this file
were made in 1994 (which assumed the size of long is 4 bytes).

This fixes krb5-enabled logins on the Alpha.
 1.19 22-Jan-2000  mycroft branches: 1.19.4; 1.19.6;
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 15-Nov-1998  christos branches: 1.16.2;
delint
 1.15 19-Oct-1998  kleink Slight formatting glitch.
 1.14 09-Sep-1998  kleink Addendum to previous commit: remove stdio usage from sections during which
random_mutex is locked, because
* a cancellation point may occur during fprintf(), and no cancellation handler
had been installed, and
* the XSH5 specifcation of these functions does not permit output to stderr.
Therefore, in initstate() and setstate(), return a null pointer if the supplied
state is not valid. This also fixes a bug in setstate() which caused corrupt
state information being used despite printing an error message.
 1.13 09-Sep-1998  kleink Add a mutex to protect the state.
 1.12 26-Jul-1998  mycroft constify some tables.
 1.11 28-Feb-1998  perry changes to (partially) quiet lint.
 1.10 06-Feb-1998  kleink Cast size_t to long for printing.
 1.9 04-Feb-1998  kleink Per XPG4.2, change the `n' argument of initstate() to size_t. (Since it was
recently changed from int to long (lite-2 import), I saw no reason to delay
this `alignment'.)
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 30-Jan-1998  perry 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.4 28-Dec-1995  thorpej branches: 1.4.2;
New-style RCS ids.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.16.2.1 14-Jan-2002  he Pull up revision 1.20 (via patch, requested by thorpej):
Make this work on LP64 platforms. Fixes krb5-enabled logins on
Alpha.
 1.19.6.2 28-Jan-2002  nathanw Catch up to -current.
 1.19.6.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.19.4.1 14-Jan-2002  he Pull up revision 1.20 (requested by thorpej):
Make this work on LP64 platforms. This fixes krb5-enabled logins
on the alpha platform.
 1.10 02-Aug-1999  lukem replace malloc(3) with one from freebsd which documents our new malloc.c
(also from freebsd). comment out references to reallocf with .\"XXX"
for now. i also fixed some roff misuse as well.
replace calloc(3), free(3) and realloc(3) with links to malloc(3)
 1.9 28-Apr-1998  fair fix mdoc references and mistakes
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 30-Jan-1998  perry update to lite-2
 1.6 18-Nov-1997  enami Remove an extra comma at the end of SEE ALSO list.
 1.5 18-Nov-1997  enami Use .Sh RETURN VALUES instead of .Pp, as malloc.3 or free.3 does.
 1.4 28-Dec-1995  thorpej New-style RCS ids.
 1.3 10-Jan-1994  jtc Fix spelling errors.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7 31-Aug-2022  riastradh reallocarr(3): Touch up xrefs.
 1.6 31-Aug-2022  riastradh reallocarr(3): Bump date. Note overflow is handled internally.
 1.5 31-Aug-2022  riastradh reallocarr(3): Clarify semantics.
 1.4 28-Jul-2015  kamil Compatibility fixes in reallocarr(3)

Make this work on !NetBSD platforms:
- replace __CTASSERT() with platform agnostic solution SQRT_SIZE_MAX
- include nbtool_config.h for cross builds to get definition of __RCSID()
- restore errno in the last rare code path for platforms affecting errno(2)
in memcpy(2)

While there: rename parameter name 'num' to 'number' to be in sync with
the calloc(3) parameter naming.

Reported by scole_mail at the current-users ml.
 1.3 19-Feb-2015  wiz Add EXAMPLES section, from Youri Mouton.
Bump date.
 1.2 18-Feb-2015  wiz Fix Xref. Split line, Ox doesn't take word arguments.
 1.1 17-Feb-2015  joerg Introduce reallocarr(3) for easy (re)allocation of memory with overflow
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory
leaks on allocation failures and it doesn't depend on malloc(0) != NULL
for correct error checking. Compared to plain realloc, it also avoids
the problem of intermediate integer overflows. The trade-off is the use
of void * to side step C type system with regard to generic pointer to
pointer.
 1.5 20-Aug-2015  kamil Minor alterations to reallocarr(3)

Add comment about division.
Mark error branches with __predict_false().
Reduce one branch with the OR trick.
 1.4 20-Aug-2015  joerg Fix portability.
 1.3 28-Jul-2015  kamil Compatibility fixes in reallocarr(3)

Make this work on !NetBSD platforms:
- replace __CTASSERT() with platform agnostic solution SQRT_SIZE_MAX
- include nbtool_config.h for cross builds to get definition of __RCSID()
- restore errno in the last rare code path for platforms affecting errno(2)
in memcpy(2)

While there: rename parameter name 'num' to 'number' to be in sync with
the calloc(3) parameter naming.

Reported by scole_mail at the current-users ml.
 1.2 16-Jul-2015  kamil Reorder memcpy(3) and save errno


This change is for safety as memcpy(3) might change it.

Approved by <riastradh>
 1.1 17-Feb-2015  joerg Introduce reallocarr(3) for easy (re)allocation of memory with overflow
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory
leaks on allocation failures and it doesn't depend on malloc(0) != NULL
for correct error checking. Compared to plain realloc, it also avoids
the problem of intermediate integer overflows. The trade-off is the use
of void * to side step C type system with regard to generic pointer to
pointer.
 1.7 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.6 27-Nov-2022  gutteridge reallocarray.3: minor grammar and style tweaks
 1.5 28-Oct-2022  wiz put reallocarray() in the public namespace

reallocarray() will be part of the next POSIX release, see
https://austingroupbugs.net/view.php?id=1218

adapt an errno value to match POSIX expectations

As discussed on tech-userlevel
 1.4 26-Jul-2015  kamil Add license header (the NetBSD 2-clause version) with (C) TNF
 1.3 06-Feb-2015  wiz Remove trailing whitespace.
 1.2 05-Feb-2015  christos Remove incorrect comment about size; mention that the malloc ambiguity is
part of the C standard.
 1.1 05-Feb-2015  christos Revert addition to reallocarray to the malloc man page, but keep
the examples. Add separate manual page to reallocarray explaining
what are the problems with it.
 1.12 28-Oct-2022  wiz put reallocarray() in the public namespace

reallocarray() will be part of the next POSIX release, see
https://austingroupbugs.net/view.php?id=1218

adapt an errno value to match POSIX expectations

As discussed on tech-userlevel
 1.11 26-Feb-2021  christos arrange for tools build
 1.10 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.9 07-Oct-2017  christos remove recallocarray
 1.8 07-Oct-2017  christos add recallocarray
 1.7 06-Apr-2016  roy Revert prior, no idea why it was causing me problems, but it no longer does.
 1.6 05-Apr-2016  roy Stop calling reallocarr and just do the same bounds checking but without
messing around with copying pointers which was causing ssh to crash.
 1.5 26-Jul-2015  kamil reallocarray(3) cleanup

Add missing NetBSD CVS Id
Don't define twice _OPENBSD_SOURCE
 1.4 10-Mar-2015  christos Behave in an OpenBSD compatible way for 0.
 1.3 17-Feb-2015  christos use reallocarr()
 1.2 17-Feb-2015  joerg Move reallocarray under _OPENBSD_SOURCE where it belongs.
 1.1 05-Feb-2015  christos Add and use reallocarray() to prevent a multiplication overflow in allocation.
Reported by Guido Vranken, thanks!
 1.4 02-Feb-1998  perry realpath is now part of getcwd.c in gen/; man page moved to gen, too.
 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.6 02-Feb-1998  perry realpath is now part of getcwd.c in gen/; man page moved to gen, too.
 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 local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.3 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.2 28-Dec-1995  thorpej branches: 1.2.2;
New-style RCS ids.
 1.1 17-May-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 17-May-1994  mycroft branches: 1.1.1.1.4;
New from 4.4-Lite. Needed for some 4.4 FS utilities.
 1.1.1.1.4.1 02-May-1995  jtc #include "namespace.h"
 1.2.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 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 06-Jul-2005  drochner branches: 1.2.2; 1.2.46;
tolerate NULL pointers at some places
 1.1 06-Jul-2005  drochner Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.2.46.1 30-Oct-2012  yamt sync with head
 1.2.2.3 04-Aug-2005  tron Pull up revision 1.2 (requested by drochner in ticket #632):
tolerate NULL pointers at some places
 1.2.2.2 04-Aug-2005  tron Pull up revision 1.1 (requested by drochner in ticket #632):
Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
 1.2.2.1 06-Jul-2005  tron file remque.c was added on branch netbsd-3 on 2005-08-04 17:33:23 +0000
 1.8 12-Jun-2005  lukem Add missing __RCSID()
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 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.4 09-Jan-1998  perry RCS Id Police.
 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 14-Oct-1993  jtc branches: 1.2.8;
Rename intenral _rand_foo variables to __rand_foo, as _rand_foo is in the
user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.45 12-Aug-2021  andvar fix typos in "environment" word.
 1.44 20-Jan-2015  christos Fix non _REENTRANT build.
 1.43 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.42 03-Nov-2010  christos Handle the case where a program attempted to cleanup the environment by
setting *environ = NULL;
 1.41 16-Oct-2010  njoly Make setenv(3) follow the standard, by rejecting invalid strings. It
now fails with EINVAL errno when variable is NULL, empty or contains
an `=' character; or value is NULL.

Adjust the man page accordingly, and exercize them in the existing
environment testcase.
 1.40 02-Oct-2010  tron Restore binary compatibility with applications which use putenv(3)
on constant strings (e.g. postdrop(1)):
- Don't write to the environment string passed to putenv(3).
- Don't overwrite the value of an existing environment string
unless the memory was actually allocated by setenv(3).
 1.39 01-Oct-2010  christos make putenv POSIX compliant.
 1.38 30-Sep-2010  tron Be slightly more careful about freeing memory allocated for environment
variables: only free memory if the current value points to the same
memory area as the allocated block. This will prevent crashes if an
application changes the order of the environment array.

Unfortunately this is still not enough to stop zsh 4.2.* from crashing.
zsh 4.3.* works fine before and after this change.
 1.37 25-Sep-2010  tron Remember the correct pointer which we will free later.
 1.36 25-Sep-2010  tron Remember memory used by allocated environment variables instead of
using a bitmap. This deals with the case where a variable is first
set via setenv(3) or putenv(3), then overwritten by changing
"environ" directory and afterwards overwritten with setenv(3) again.

This stops "zsh" from crashing under NetBSD-current.

Code reviewed by Christos Zoulas.
 1.35 24-Sep-2010  christos Fix memory leaks; thanks Enami!
 1.34 23-Sep-2010  christos Use a bit array to keep track of malloced environment entries so we can
free them.
 1.33 23-Sep-2010  christos PR/43899: Nicolas Joly: setenv(3)/unsetenv(3) memory leak.
Partial fix: Don't allocate a new string if the length is equal to the
old length, because presumably the old string was also nul terminated
so it has the extra byte needed.
The real fix is to keep an adjunct array of bits, one for each environment
variable and keep track if the entry was allocated or not so that we can
free it in unsetenv.
 1.32 02-Dec-2009  enami Retain old variables when failed to allocate memory.
 1.31 01-Nov-2008  christos branches: 1.31.2;
use the right variable in memcpy.
 1.30 31-Oct-2008  christos make __findenv return the offset for the new entry to be inserted when
the string is not found, to avoid an additional scan of the environ array
in setenv.
 1.29 17-Feb-2005  christos remove extraneous `*' that caused a core-dump.
 1.28 17-Feb-2005  christos do some manual CSE.
 1.27 17-Feb-2005  tron Fix lint warning caused by last change.
 1.26 17-Feb-2005  enami Jump to just before the copy instead of after it. Saves 8 byte on i386.
 1.25 17-Feb-2005  enami Simplify, KNF and plug leaks. Compile test only.
 1.24 17-Feb-2005  christos Simplify and KNF. Instead of keeping track if the pointer was allocated,
keep a copy of the pointer itself and only re-use it if the current
environment is equal to the saved pointer. Idea from OpenBSD. Avoids
problem of re-allocing a non-allocated pointer if a program resets the
environment after it has been grown.
 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 07-Apr-2003  kleink 1003.1-2001 has introduced unsetenv() which differs from the current
implementation in not permitting a "name=value" argument.
* Add a conforming __unsetenv13() and do function renaming for
unsetenv(); preserve old symbol with old behavior.
* Make visible setenv() and unsetenv() for 1003.1-2001 feature selection
macros; resolves PR standards/20479.
 1.21 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.20 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.19 20-Dec-2000  christos branches: 1.19.2;
avoid nested extern declaration
 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 15-Nov-1998  christos delint
 1.14 11-Sep-1998  kleink Add a multiple-reader/single-writer lock to protect environ.
 1.13 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 30-Jan-1998  perry update to lite-2
 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.8 28-Dec-1995  thorpej branches: 1.8.2;
New-style RCS ids.
 1.7 14-Jun-1995  jtc add explicit return type
 1.6 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.5 15-Oct-1993  jtc branches: 1.5.4;
Rename _findenv() to __findenv(), as _findenv is in the user's namespace.
 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 18-Apr-1993  mycroft Eliminate GCC 2 warning due to prototype not being in scope.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 30-Jan-1998  perry import lite-2
 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.8.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.19.2.2 10-Dec-2002  thorpej Sync with HEAD.
 1.19.2.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.31.2.2 01-Nov-2008  christos use the right variable in memcpy.
 1.31.2.1 01-Nov-2008  christos file setenv.c was added on branch christos-time_t on 2008-11-01 00:54:48 +0000
 1.7 12-Jun-2005  lukem Add missing __RCSID()
 1.6 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.5 15-Nov-1998  christos delint
 1.4 09-Jan-1998  perry RCS Id Police.
 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 14-Oct-1993  jtc branches: 1.2.8;
Rename intenral _rand_foo variables to __rand_foo, as _rand_foo is in the
user's namespace.
 1.1 07-Oct-1993  brezak Rand48 routines from martin@ntkupc1.tuwien.ac.at (Martin Birgmeier)
 1.2.8.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.8 07-Dec-2017  kre Fix obvious typo (cut&pasto or whatever) - there's only one value that
specifies the number of digits after the decimal point (oh, sorry, the
"radix character") the other specifies the number before...

While here, add a little more info on the effects of using the #n value.
 1.7 16-Aug-2017  wiz Typo fix.
 1.6 16-Aug-2017  joerg Add missing strfmon_l. Noticed by Bruno Haible. Add test case.
 1.5 18-Mar-2014  riastradh branches: 1.5.18;
Merge riastradh-drm2 to HEAD.
 1.4 20-Jul-2013  wiz Use Mt for email addresses.
 1.3 04-Apr-2005  wiz branches: 1.3.44; 1.3.50; 1.3.56;
Remove duplicate words; grammar fix.
 1.2 04-Apr-2005  wiz Drop trailing whitespace.
 1.1 03-Apr-2005  christos Add FreeBSD's strfmon(3). From Rui Paulo. No bump this time. Take advantage
of the getpwent_r bump.
 1.3.56.1 23-Jul-2013  riastradh sync with HEAD
 1.3.50.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.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.5.18.1 29-Aug-2017  martin Pull up following revision(s) (requested by joerg in ticket #215):
tests/lib/libc/locale/t_strfmon.c: revision 1.1
tests/lib/libc/locale/Makefile: revision 1.12
lib/libc/stdlib/strfmon.c: revision 1.11
distrib/sets/lists/debug/mi: revision 1.224
include/monetary.h: revision 1.3
distrib/sets/lists/tests/mi: revision 1.761
lib/libc/stdlib/strfmon.3: revision 1.6
lib/libc/stdlib/strfmon.3: revision 1.7
Add missing strfmon_l. Noticed by Bruno Haible. Add test case.
Typo fix.
 1.22 27-Jun-2025  andvar Fix various typos, mainly in comments.
 1.21 27-Nov-2023  christos branches: 1.21.2;
Restore original code now that the broken test has been fixed.
 1.20 19-Nov-2023  christos minimize diffs with FreeBSD.
 1.19 28-Sep-2023  martin Fix padding for formats with mutliple padded values.
PR lib/57633, fix from FreeBSD.
 1.18 18-Aug-2022  christos fix whitespace prefix behavior
 1.17 17-Aug-2022  christos PR/56967: John Zaitseff: Reduce diff with FreeBSD, fixes various bugs.
 1.16 23-May-2022  andvar s/beggining/beginning/ in comments.
 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 05-Dec-2021  msaitoh s/supress/suppress/
 1.13 27-Nov-2017  maya use calloc rather than malloc + memset 0
 1.12 27-Nov-2017  christos Fix various bugs with strfmon:
- Avoid out of bounds access for the currency_symbol[3] when the symbol
is shorter (as it happens with the C locale where it is empty)
- Don't compare pointers to NUL, it is not helpful.
- Make the default sep_by_space 1 as suggested in:
https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_111.html
- Use the correct number of bytes for memmove(3)

XXX: pullup-8
 1.11 16-Aug-2017  joerg Add missing strfmon_l. Noticed by Bruno Haible. Add test case.
 1.10 21-Mar-2012  christos branches: 1.10.24;
unsigned char portability casts
 1.9 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.8 14-Aug-2011  christos branches: 1.8.2;
no need for the snprintf/asprintf dance; use fixed width formats.
 1.7 30-Jan-2009  lukem sign-compare fix
 1.6 27-Mar-2008  christos Fix another integer overflow issue discovered by Maksymilian Arciemowicz.
On top of this, limit the range of getnumber to 0x00ffffff to make sure
that adding two of them does not cause an integer overflow.
 1.5 18-Mar-2008  christos Avoid integer overflow; reported by Maksymilian Arciemowicz.
 1.4 19-Mar-2006  christos branches: 1.4.4; 1.4.6; 1.4.10; 1.4.14; 1.4.16;
Coverity CID 1560: Don't leak memory when multiple currency symbols are present
 1.3 02-Dec-2005  yamt redo the previous; constify rather than making a string writable.
 1.2 29-Nov-2005  christos WARNS=4
 1.1 03-Apr-2005  christos Add FreeBSD's strfmon(3). From Rui Paulo. No bump this time. Take advantage
of the getpwent_r bump.
 1.4.16.1 24-Mar-2008  keiichi sync with head.
 1.4.14.2 07-Apr-2008  jdc Pull up revision 1.6 (requested by mjf in ticket #1115).

Fix another integer overflow issue discovered by Maksymilian Arciemowicz.
On top of this, limit the range of getnumber to 0x00ffffff to make sure
that adding two of them does not cause an integer overflow.
 1.4.14.1 19-Mar-2008  bouyer Pull up following revision(s) (requested by mjf in ticket #1102):
lib/libc/stdlib/strfmon.c: revision 1.5
Avoid integer overflow; reported by Maksymilian Arciemowicz.
 1.4.10.1 23-Mar-2008  matt sync with HEAD
 1.4.6.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.4.4.2 07-Apr-2008  jdc Pull up revision 1.6 (requested by mjf in ticket #1115).

Fix another integer overflow issue discovered by Maksymilian Arciemowicz.
On top of this, limit the range of getnumber to 0x00ffffff to make sure
that adding two of them does not cause an integer overflow.
 1.4.4.1 19-Mar-2008  bouyer Pull up following revision(s) (requested by mjf in ticket #1102):
lib/libc/stdlib/strfmon.c: revision 1.5
Avoid integer overflow; reported by Maksymilian Arciemowicz.
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.10.24.1 29-Aug-2017  martin Pull up following revision(s) (requested by joerg in ticket #215):
tests/lib/libc/locale/t_strfmon.c: revision 1.1
tests/lib/libc/locale/Makefile: revision 1.12
lib/libc/stdlib/strfmon.c: revision 1.11
distrib/sets/lists/debug/mi: revision 1.224
include/monetary.h: revision 1.3
distrib/sets/lists/tests/mi: revision 1.761
lib/libc/stdlib/strfmon.3: revision 1.6
lib/libc/stdlib/strfmon.3: revision 1.7
Add missing strfmon_l. Noticed by Bruno Haible. Add test case.
Typo fix.
 1.21.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 23-Apr-1997  mrg move str[fp]time into libc/time.
 1.2 23-Apr-1997  jtc Use standard locale data rather than providing a local copy.

Sync'd function prototype with the one used in Solaris 2.5. There have
been many format specifiers added to the Solaris version which are not
implemented in our version. This needs to be fixed.
 1.1 21-Apr-1997  mrg add strptime() to libc.
 1.11 14-Dec-2010  jruoho Reference strsuftoll(3) and orders(7) with each other.
 1.10 01-May-2010  jruoho Note that the return type sould arguably be intmax_t instead of long long.
 1.9 01-May-2010  jruoho Remove the (incorrect) note about inconsistent return values. Name the exit
code as EXIT_FAILURE instead of integer 1.
 1.8 01-May-2010  jruoho Add more bugs. Namely, besides the return values that are confusing, no
function in a modern standard C library, exposed by <stdlib.h>, should be as
easy to (buffer) overflow as strsuftollx(3).

In addition, improvements to wording and markup.
 1.7 30-Apr-2008  martin branches: 1.7.8;
Convert TNF licenses to new 2 clause variant
 1.6 12-Apr-2007  lukem branches: 1.6.10;
Use IEC 60027-2 prefixes for 2^n based prefixes.
 1.5 05-Mar-2004  lukem Explicitly use base 10 when parsing numbers, to enforce the "decimal number"
semantics that the comments referred to and as per dd(1) (which was the
origin of this functionality).
 1.4 13-Feb-2004  wiz Spell the plural of suffix "suffixes", not "suffices".
Inspired by PR 24400 by Todd Vierling.
 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 29-Nov-2002  wiz branches: 1.2.2;
a <-> an fixes.
 1.1 29-Nov-2002  lukem add strsuftoll(3) and strsuftollx(3) - parse a string for a number
with an optional suffix, product (two numbers separated by `x'), and
provide range checking
 1.2.2.2 10-Dec-2002  thorpej Sync with HEAD.
 1.2.2.1 29-Nov-2002  thorpej file strsuftoll.3 was added on branch nathanw_sa on 2002-12-10 06:25:54 +0000
 1.6.10.1 18-May-2008  yamt sync with head.
 1.7.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.7.8.1 30-Apr-2008  martin file strsuftoll.3 was added on branch christos-time_t on 2008-04-30 13:10:52 +0000
 1.10 09-Jun-2024  mrg m68k vs GCC 12: apply -fno-stack-protector to a few things.

i've looked at the C code here and i can't see any real problems,
and in at least the strsuftoll.c case, i'm convinced it is not a
real problem for the reported case, and indicates a GCC bug.

for strsuftoll.c, this fixes basic parsing of almost any input.
the simple test case is "dd count=1". in my testing, it was only
the front-end strsuftoll() that needs the checking removed, the
sub-functions are fine.

for citrus_module.c, this fixes "env LC_CTYPE=en_US.UTF-8 locale",
and i was able to reduce to only _citrus_find_getops().

for blake2_prov.c, i chose to apply to the whole file to avoid
editing a 3rd-party source.

these issues and their source-file fixes were discovered by rin@.
 1.9 22-Oct-2011  christos Put a recursion limit to avoid DoS attacks (Maksymilian Arciemowicz)
While there do minor KNF, and do as the manual says: exit with EXIT_FAILURE
 1.8 28-Apr-2008  martin branches: 1.8.8;
Remove clause 3 and 4 from TNF licenses
 1.7 12-Apr-2007  lukem branches: 1.7.10;
Use IEC 60027-2 prefixes for 2^n based prefixes.
 1.6 05-Mar-2004  lukem Explicitly use base 10 when parsing numbers, to enforce the "decimal number"
semantics that the comments referred to and as per dd(1) (which was the
origin of this functionality).
 1.5 17-Jan-2004  dbj print max rather than min in error message when number
parsed by strsuftollx is greater than max
 1.4 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.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 08-Feb-2003  itohy Use definition in "namespace.h" to rename functions, not home grown.
 1.1 29-Nov-2002  lukem branches: 1.1.2;
add strsuftoll(3) and strsuftollx(3) - parse a string for a number
with an optional suffix, product (two numbers separated by `x'), and
provide range checking
 1.1.2.2 10-Dec-2002  thorpej Sync with HEAD.
 1.1.2.1 29-Nov-2002  thorpej file strsuftoll.c was added on branch nathanw_sa on 2002-12-10 06:25:54 +0000
 1.7.10.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 strsuftoll.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.30 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.29 07-Nov-2016  riastradh Use the keywords `underflow' and `overflow' in ERANGE summary.
 1.28 07-Nov-2016  riastradh Fix phrasing about `out-of-band' and `sentinel value'.

Either an out-of-band channel, or an in-band sentinel value, could
indicate an error, but an out-of-band sentinel value is a silly
proposition.

Noted by uwe@.
 1.27 04-Nov-2016  riastradh Distinguish altogether invalid syntax from trailing garbage.
 1.26 04-Nov-2016  riastradh EXIT_FAILURE police
 1.25 04-Nov-2016  riastradh Fix infinity detection with isinf(d), not d == HUGE_VAL.

Negative infinity counts as overflow too.

Simplify.
 1.24 04-Nov-2016  riastradh Add example for strtod.

This illustrates all the cases you might be interested in and asserts
theorems in those cases.
 1.23 04-Nov-2016  riastradh Fix description of ERANGE cases again.

Do use the technical terms `overflow' and `underflow', because strtod
sets ERANGE precisely to indicate either of these two conditions, and
they are the right keywords that one might be looking for.

Note that strtod may set ERANGE even if it returns noninfinity and
nonzero -- specifically, if the result is subnormal. This part was
wrong before I `fixed' it and remained wrong after I `fixed' it
earlier this year.
 1.22 17-Mar-2016  wiz branches: 1.22.2;
Bump date for previous.
 1.21 17-Mar-2016  riastradh strtod yields ERANGE for below-subnormal magnitudes, not underflow.

For a floating-point computation, in the language of IEEE 754,
`underflow' means the output was rounded and is too small to be
represented *normally*.

There are many nonzero floating-point numbers to which the exact
output may have been rounded -- namely subnormals. The condition
under which strtod returns ERANGE for small magnitudes is when the
magnitude of the exact result is so small it is rounded to zero, not
even to a subnormal.

While here, use parallel language about large magnitudes instead of
the (albeit correct) word `overflow', to avoid temptation to treat
`underflow' as the opposite notion with zero instead of infinity.
 1.20 24-Oct-2007  reed branches: 1.20.50; 1.20.54;
Add HISTORY: The strtof() and strtold() functions appeared in NetBSD
4.0.
 1.19 15-Mar-2006  wiz branches: 1.19.10;
Use more macros.
 1.18 15-Mar-2006  kleink Add strtof(3) and strtold(3); welcome libc 12.137.
 1.17 19-Apr-2005  wiz Grammar fix.
 1.16 15-Apr-2005  kleink Due to their "inverse" treatment of the fraction's MSb, update NAN
conversion to construct a quiet NaN on hppa, mips, sh3, and sh5 as well.
Also, remove the portion constructing a ROP on vax; this is not required
by the standard, and in its consequences it is not an appropriate
substitute for a qNaN.
 1.15 07-Aug-2003  agc branches: 1.15.6;
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 28-Jan-2002  wiz Punctuation fixes.
 1.11 28-Jan-2002  kleink C99: support INF, INFINITY, NAN and NAN(n-char-sequence-opt) arguments.
 1.10 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.9 21-Mar-2001  kleink Sprinkle some restrict qualifiers.
 1.8 09-Mar-1999  erh branches: 1.8.12;
Add missing .El lines.
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 30-Jan-1998  perry update to lite-2
 1.5 28-Dec-1995  thorpej New-style RCS 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.
 1.3 24-Nov-1993  jtc Remove BUGS section which stated that strtod was unimplemented.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.12.4 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.3 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 28-Jan-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.15.6.2 19-Apr-2005  tron Pull up revision 1.17 (requested by kleink in ticket #163):
Grammar fix.
 1.15.6.1 19-Apr-2005  tron Pull up revision 1.16 (requested by kleink in ticket #163):
Due to their "inverse" treatment of the fraction's MSb, update NAN
conversion to construct a quiet NaN on hppa, mips, sh3, and sh5 as well.
Also, remove the portion constructing a ROP on vax; this is not required
by the standard, and in its consequences it is not an appropriate
substitute for a qNaN.
 1.19.10.1 06-Nov-2007  matt sync with HEAD
 1.20.54.1 18-Jan-2017  skrll Sync with netbsd-5
 1.20.50.1 18-Dec-2016  snj Pull up following revision(s) (requested by riastradh in ticket #1311):
lib/libc/stdlib/strtod.3: revisions 1.21-1.29
lib/libc/stdlib/strtol.3: revision 1.36-1.38
lib/libc/stdlib/strtoul.3: revision 1.36
strtod yields ERANGE for below-subnormal magnitudes, not underflow.
For a floating-point computation, in the language of IEEE 754,
`underflow' means the output was rounded and is too small to be
represented *normally*.
There are many nonzero floating-point numbers to which the exact
output may have been rounded -- namely subnormals. The condition
under which strtod returns ERANGE for small magnitudes is when the
magnitude of the exact result is so small it is rounded to zero, not
even to a subnormal.
While here, use parallel language about large magnitudes instead of
the (albeit correct) word `overflow', to avoid temptation to treat
`underflow' as the opposite notion with zero instead of infinity.
--
Bump date for previous.
--
Fix description of ERANGE cases again.
Do use the technical terms `overflow' and `underflow', because strtod
sets ERANGE precisely to indicate either of these two conditions, and
they are the right keywords that one might be looking for.
Note that strtod may set ERANGE even if it returns noninfinity and
nonzero -- specifically, if the result is subnormal. This part was
wrong before I `fixed' it and remained wrong after I `fixed' it
earlier this year.
--
Add example for strtod.
This illustrates all the cases you might be interested in and asserts
theorems in those cases.
--
Fix infinity detection with isinf(d), not d == HUGE_VAL.
Negative infinity counts as overflow too.
Simplify.
--
EXIT_FAILURE police
--
Distinguish altogether invalid syntax from trailing garbage.
--
Distinguish invalid syntax from trailing garbage cases. Clarify.
--
Simplify error condition case.
Add assertions to reflect its implications.
--
Tidy up the second example too.
--
Update strtoul(3) example to reflect clarifications in strtol(3).
--
Fix phrasing about `out-of-band' and `sentinel value'.
Either an out-of-band channel, or an in-band sentinel value, could
indicate an error, but an out-of-band sentinel value is a silly
proposition.
Noted by uwe@.
--
Use the keywords `underflow' and `overflow' in ERANGE summary.
 1.22.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.51 25-Jan-2006  kleink Drop in gdtoa as a replacement for dtoa, strtod() from stdlib/strtod.c.
 1.50 04-Dec-2005  christos Older gcc does not support #ifdef inside macro expansion.
 1.49 29-Nov-2005  christos WARNS=4
 1.48 24-Apr-2005  christos Revert the previous patch. It is not worth it optimizing the code to avoid
compiler errors because it makes it gratutiously different.
 1.47 24-Apr-2005  christos Simplify the code and avoid a compiler issue with -O6 on sparc64:
Error: Illegal operands: There are only 32 single precision f registers; [0-31]
 1.46 15-Apr-2005  kleink Due to their "inverse" treatment of the fraction's MSb, update NAN
conversion to construct a quiet NaN on hppa, mips, sh3, and sh5 as well.
Also, remove the portion constructing a ROP on vax; this is not required
by the standard, and in its consequences it is not an appropriate
substitute for a qNaN.
 1.45 09-Feb-2005  kleink branches: 1.45.2;
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.44 28-Oct-2004  dsl Use (unsigned char) cast to sanitise arguments to ctype functions.
 1.43 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.42 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.41 06-Jun-2002  fredette Added hppa support (some of it incomplete) to lib/csu, lib/libc,
and lib/libkvm.
 1.40 26-May-2002  wiz Remove #ifdef Bad_float_h and #ifndef __STDC__ parts (unneeded).
 1.39 28-Jan-2002  kleink C99: support INF, INFINITY, NAN and NAN(n-char-sequence-opt) arguments.
 1.38 15-Dec-2001  thorpej Use __sh__ instead of __sh3__.
 1.37 19-Jun-2001  fvdl Add x86_64 to the list of if defined(blah) for endian determination
(surely this can be done in a better way).
 1.36 21-Feb-2001  bjh21 branches: 1.36.2;
Add support for ARM VFP-format doubles, conditional on __VFP_FP__.
 1.35 09-Feb-2001  bjh21 __arm26__ || __arm32__ -> __arm__
Not least because the unified NetBSD/arm compiler probably won't predefine
__arm26__ or __arm32__.
 1.34 09-May-2000  bjh21 Initial commit of arm26 port
 1.33 26-Nov-1999  msaitoh check __sh3__
 1.32 06-Feb-1999  kleink branches: 1.32.6;
Serialize freelist access with a mutex.
 1.31 06-Feb-1999  simonb Changes from Niklas Hallqvist from OpenBSD. Commit message there was:

Make code ANSI/ISO C conformant. Formerly undefined constructs were used
making load/store architectures (like mips&alpha) fail whn compiled with
gcc -O2.

Tested on mips and i386 ok. Can someone with an alpha test this please?
 1.30 16-Nov-1998  christos Since we are forcing unsigned shifts for portability, define Unsigned_shifts
 1.29 15-Nov-1998  christos delint
 1.28 19-Oct-1998  matt More vax -> __vax__ cruft.
 1.27 26-Jul-1998  mycroft const poisoning.
 1.26 03-Feb-1998  perry remove obsolete register declarations
 1.25 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.24 29-Mar-1997  thorpej PowerPC is an IEEE floating point system.
 1.23 13-Oct-1996  christos <machine/endian.h> -> <sys/types.h>
 1.22 20-Jul-1996  jtc The argument to isspace() must be representable as an unsigned char.
This change casts the argument to an unsigned char so that this
function will work with strings with their 8th bit set.
 1.21 16-Feb-1996  mark branches: 1.21.4;
Get the floating point byte and word orders correct for the arm32.
 1.20 28-Dec-1995  thorpej New-style RCS ids.
 1.19 23-Dec-1994  jtc #include <machine/endian.h>.
 1.18 22-Dec-1994  cgd (1) fix up for new compiler predefines
(2) clean up IEEE format defines, so that their names are accurate again.
 1.17 20-Dec-1994  jtc Use "const" qualifier so that tens, tinytens, and bigtens arrays are stored
in the text segment.
 1.16 14-Nov-1994  dean Include code for pmax
 1.15 19-Oct-1994  cgd be a bit more careful with types.
 1.14 22-Jul-1994  jtc branches: 1.14.2;
Updgraded to March 3, 1994 version of dtoa.c from netlib with our local
changes.
 1.13 25-Feb-1994  phil Adding ns32k support.
 1.12 28-Dec-1993  jtc #include <ctype.h> to use the isspace() macro.
 1.11 21-Dec-1993  jtc Fix bug #12, strtod() now uses localeconv() to get locale specific
decimal point character.
 1.10 21-Dec-1993  jtc Use isspace() instead of a switch statement with explicit values when
skipping leading spaces. This is needed for compliant behavior once
localization support is integrated.
 1.9 07-Dec-1993  jtc Restore 4 lines of code that UCB added that got lost when I upgraded to
the latest version of this code. This bug was responsible for printf
formatting errors when values were rounded to 0.
 1.8 03-Dec-1993  briggs Add mc68000 to the list for IEEE_MC68k.
Checks for hp300 and amiga should prob. be removed at some point,
but they do no harm being there.
 1.7 11-Nov-1993  jtc Forgot to change dtoa() to __dtoa() when I updated the code from netlib.
 1.6 10-Nov-1993  jtc Upgraded to Jun 21, 1993 version from research.att.com:
With 32-bit ints, the former could give too small a block for the return
value when, e.g., mode = 2 or 4 and ndigits = 24 (16 for 16-bit ints).
tweak to work with 32-bit ints and 64-bit long
 1.5 19-Oct-1993  deraadt #if defined(hp300) || defined(sparc) || defined(amiga)

The knowledge about floating point format should really be pulled in
from somewhere better.
 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 12-Jul-1993  mycroft Make this work on more than just a 386.
 1.1 09-Jul-1993  cgd branches: 1.1.1;
update for better FP routines, from AT&T & elsewhere
 1.1.1.3 30-Jan-1998  perry import lite-2
 1.1.1.2 05-Jan-1995  jtc Import January 4, 1995 version of dtoa from netlib. No need to merge,
since the only change was the result of my CONST change being adopted
in the master sources.
 1.1.1.1 22-Jul-1994  jtc Import virgin copy of March 3, 1994 version of dtoa from netlib to
provide a good baseline for future updates.
 1.14.2.2 22-Jul-1994  jtc Updgraded to March 3, 1994 version of dtoa.c from netlib with our local
changes.
 1.14.2.1 22-Jul-1994  jtc file strtod.c was added on branch netbsd-1-0 on 1994-07-22 05:08:05 +0000
 1.21.4.1 20-Jul-1996  jtc Pulled up from rev 1.22
 1.32.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.36.2.4 21-Jun-2002  nathanw Catch up to -current.
 1.36.2.3 28-Jan-2002  nathanw Catch up to -current.
 1.36.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.36.2.1 08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.45.2.1 19-Apr-2005  tron Pull up revision 1.46 (requested by kleink in ticket #163):
Due to their "inverse" treatment of the fraction's MSb, update NAN
conversion to construct a quiet NaN on hppa, mips, sh3, and sh5 as well.
Also, remove the portion constructing a ROP on vax; this is not required
by the standard, and in its consequences it is not an appropriate
substitute for a qNaN.
 1.11 24-Jul-2024  kre Improve the man for strtoi() (and consequently strtou())

PR lib/58461 PR lib/58453

Improve the wording so it is clearer exactly what strtoi() is
intended to do in various cases.

While here, add, in the most minimalist way possible, the
strtoi_l(), and so also strtou_l(), functions, which seem to
have been previously undocumented.

Do some linguistic gymnastics so that the conversion of the
page from strtoi(3) -> strtou(3) will not generate "an unitmax_t"
which is incorrect, we need "a unitmax_t" - one of those was
easy to fix in the Makefile sed script, the others would have
been more difficult, so reword instead.
 1.10 10-Feb-2024  andvar branches: 1.10.2;
Fix various typos in comments, log messages and documentation.
 1.9 20-Jan-2024  christos generate strtou.3 from strtoi.3, grammar police
 1.8 20-Jan-2024  christos PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
 1.7 03-Jul-2017  wiz branches: 1.7.8; 1.7.16;
Remove workaround for ancient HTML generation code.
 1.6 13-Nov-2015  christos revert 0b documentation.
 1.5 13-Nov-2015  wiz Remove trailing whitespace.
 1.4 12-Nov-2015  christos Now that our source tree has binary constants, recognize them.
 1.3 11-Jul-2015  wiz Add missing Fc which broke man page on the web. Remove superfluous Pp.
 1.2 03-May-2015  wiz branches: 1.2.2;
Sort ERRORS and SEE ALSO.
 1.1 01-May-2015  christos - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
 1.2.2.2 16-May-2015  snj Pull up following revision(s) (requested by christos in ticket #781):
common/lib/libc/stdlib/strtoi.c: revision 1.2
common/lib/libc/stdlib/strtou.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.113
distrib/sets/lists/tests/mi: revision 1.617
lib/libc/include/namespace.h: revision 1.178
lib/libc/stdlib/Makefile.inc: revision 1.90 via patch
lib/libc/stdlib/strtoi.3: revisions 1.1, 1.2
lib/libc/stdlib/strtol.3: revision 1.32
lib/libc/stdlib/strtou.3: revisions 1.1, 1.2
lib/libc/stdlib/strtoul.3: revisions 1.30, 1.31
tests/lib/libc/stdlib/Makefile: revision 1.25
tests/lib/libc/stdlib/t_strtoi.c: revision 1.1
- new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
--
Sort ERRORS and SEE ALSO.
--
Sort ERRORS and SEE ALSO.
--
Sort SEE ALSO.
 1.2.2.1 03-May-2015  snj file strtoi.3 was added on branch netbsd-7 on 2015-05-16 17:58:46 +0000
 1.7.16.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #792):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)

generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.7.8.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1870):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.10.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 02-Dec-2013  lneto changed lua_Number to int64_t
 1.8 16-Apr-2013  joerg Add strtol_l and friends. Switch _citrus_bcs_strtol to use plain
strtol_l unless in tools mode. Add note to retire the BCS code on the
next libc major bump.
 1.7 10-Sep-2008  joerg branches: 1.7.2; 1.7.6; 1.7.26;
Prepare use of strtoull, strtoumax and strtoimax in tools/compat by
including nbtool_config.h.
 1.6 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.5 18-Dec-2006  christos branches: 1.5.12;
remove bogus (void)&var; From Anon Ymous
 1.4 29-Nov-2005  christos WARNS=4
 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 07-May-2001  kleink branches: 1.2.2;
Add a _DIAGASSERT() case, and remove some cruft.
 1.1 28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.2.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.2.1 07-May-2001  nathanw file strtoimax.c was added on branch nathanw_sa on 2001-10-08 20:21:19 +0000
 1.5.12.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.5.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.26.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.26.1 23-Jun-2013  tls resync from head
 1.7.6.2 10-Sep-2008  joerg Prepare use of strtoull, strtoumax and strtoimax in tools/compat by
including nbtool_config.h.
 1.7.6.1 10-Sep-2008  joerg file strtoimax.c was added on branch christos-time_t on 2008-09-10 18:08:59 +0000
 1.7.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.40 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.39 04-Nov-2016  riastradh Bump date for previous.
 1.38 04-Nov-2016  riastradh Tidy up the second example too.
 1.37 04-Nov-2016  riastradh Simplify error condition case.

Add assertions to reflect its implications.
 1.36 04-Nov-2016  riastradh Distinguish invalid syntax from trailing garbage cases. Clarify.
 1.35 13-Nov-2015  christos branches: 1.35.2;
revert 0b documentation.
 1.34 13-Nov-2015  wiz Remove trailing whitespace.
 1.33 12-Nov-2015  christos Now that our source tree has binary constants, recognize them.
 1.32 01-May-2015  christos - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
 1.31 11-Mar-2015  wiz Use existing month for Dd.
 1.30 10-Mar-2015  christos PR/49640: Kamil Rytarowski: Improve error printing
 1.29 18-Jan-2015  christos cleanups from (Kamil Rytarowski)
 1.28 16-Jan-2015  wiz Remove trailing whitespace.
 1.27 16-Jan-2015  christos strtoi and strtou additions
 1.26 23-Jul-2009  wiz branches: 1.26.24;
Bump date for previous.
 1.25 23-Jul-2009  dholland Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
 1.24 21-May-2009  wiz Markup improvements. No need to mark up numbers as defined values, math
did the definition for us ages ago. Make HTML-ready.
 1.23 20-May-2009  christos mention that these functions return 0 and set errno to ERANGE on invalid base.
 1.22 08-Sep-2003  wiz branches: 1.22.16; 1.22.26; 1.22.38; 1.22.44;
Use St -isoC-9X instead of St -isoC9X, to be in sync with groff.
 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 15-Nov-2002  enami Fix indent in sample code.
 1.18 11-Aug-2002  yamt bring in EXAMPLES from OpenBSD.
 1.17 07-Feb-2002  ross Generate <>& symbolically.
 1.16 15-Jan-2002  wiz Use .Pp instead of empty lines.
 1.15 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.14 28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.13 21-Mar-2001  kleink Sprinkle some restrict qualifiers.
 1.12 16-Mar-2000  enami branches: 1.12.6;
Add missing comma.
 1.11 15-Mar-2000  kleink Need to quote excessively long Nd argument.
 1.10 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 30-Jan-1998  perry update to lite-2
 1.7 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.6 28-Dec-1995  thorpej branches: 1.6.8;
New-style RCS ids.
 1.5 12-Oct-1995  jtc Manpage fixes from Jochen Pohl. Aligns the prototypes in the SYNOPSIS
section with the actual function declarations. See PR #1589 for details.
 1.4 03-Jan-1994  jtc Integrate strtoq() and strtouq() from bsd-sources on uunet.
 1.3 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.8.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.12.6.6 10-Dec-2002  thorpej Sync with HEAD.
 1.12.6.5 13-Aug-2002  nathanw Catch up to -current.
 1.12.6.4 22-Mar-2002  nathanw Catch up to -current.
 1.12.6.3 08-Mar-2002  nathanw Catch up to -current.
 1.12.6.2 28-Jan-2002  nathanw Catch up to -current.
 1.12.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.22.44.1 26-Jul-2009  snj branches: 1.22.44.1.2;
Pull up following revision(s) (requested by dholland in ticket #868):
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
 1.22.44.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.22.38.1 26-Jul-2009  snj Pull up following revision(s) (requested by dholland in ticket #868):
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
 1.22.26.1 18-Aug-2009  bouyer Pull up following revision(s) (requested by dholland in ticket #1341):
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23 via patch
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26 via patch
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
Bump date for previous.
 1.22.16.1 18-Aug-2009  bouyer Pull up following revision(s) (requested by dholland in ticket #1341):
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23 via patch
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26 via patch
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
Bump date for previous.
 1.26.24.3 18-Dec-2016  snj Pull up following revision(s) (requested by riastradh in ticket #1311):
lib/libc/stdlib/strtod.3: revisions 1.21-1.29
lib/libc/stdlib/strtol.3: revision 1.36-1.38
lib/libc/stdlib/strtoul.3: revision 1.36
strtod yields ERANGE for below-subnormal magnitudes, not underflow.
For a floating-point computation, in the language of IEEE 754,
`underflow' means the output was rounded and is too small to be
represented *normally*.
There are many nonzero floating-point numbers to which the exact
output may have been rounded -- namely subnormals. The condition
under which strtod returns ERANGE for small magnitudes is when the
magnitude of the exact result is so small it is rounded to zero, not
even to a subnormal.
While here, use parallel language about large magnitudes instead of
the (albeit correct) word `overflow', to avoid temptation to treat
`underflow' as the opposite notion with zero instead of infinity.
--
Bump date for previous.
--
Fix description of ERANGE cases again.
Do use the technical terms `overflow' and `underflow', because strtod
sets ERANGE precisely to indicate either of these two conditions, and
they are the right keywords that one might be looking for.
Note that strtod may set ERANGE even if it returns noninfinity and
nonzero -- specifically, if the result is subnormal. This part was
wrong before I `fixed' it and remained wrong after I `fixed' it
earlier this year.
--
Add example for strtod.
This illustrates all the cases you might be interested in and asserts
theorems in those cases.
--
Fix infinity detection with isinf(d), not d == HUGE_VAL.
Negative infinity counts as overflow too.
Simplify.
--
EXIT_FAILURE police
--
Distinguish altogether invalid syntax from trailing garbage.
--
Distinguish invalid syntax from trailing garbage cases. Clarify.
--
Simplify error condition case.
Add assertions to reflect its implications.
--
Tidy up the second example too.
--
Update strtoul(3) example to reflect clarifications in strtol(3).
--
Fix phrasing about `out-of-band' and `sentinel value'.
Either an out-of-band channel, or an in-band sentinel value, could
indicate an error, but an out-of-band sentinel value is a silly
proposition.
Noted by uwe@.
--
Use the keywords `underflow' and `overflow' in ERANGE summary.
 1.26.24.2 16-May-2015  snj branches: 1.26.24.2.4;
Pull up following revision(s) (requested by christos in ticket #781):
common/lib/libc/stdlib/strtoi.c: revision 1.2
common/lib/libc/stdlib/strtou.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.113
distrib/sets/lists/tests/mi: revision 1.617
lib/libc/include/namespace.h: revision 1.178
lib/libc/stdlib/Makefile.inc: revision 1.90 via patch
lib/libc/stdlib/strtoi.3: revisions 1.1, 1.2
lib/libc/stdlib/strtol.3: revision 1.32
lib/libc/stdlib/strtou.3: revisions 1.1, 1.2
lib/libc/stdlib/strtoul.3: revisions 1.30, 1.31
tests/lib/libc/stdlib/Makefile: revision 1.25
tests/lib/libc/stdlib/t_strtoi.c: revision 1.1
- new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
--
Sort ERRORS and SEE ALSO.
--
Sort ERRORS and SEE ALSO.
--
Sort SEE ALSO.
 1.26.24.1 22-Apr-2015  snj Pull up following revision(s) (requested by roy in ticket #648):
common/lib/libc/stdlib/_strtoi.h: revisions 1.1, 1.2
common/lib/libc/stdlib/strtoi.c: revision 1.1
common/lib/libc/stdlib/strtou.c: revision 1.1
distrib/sets/lists/base/ad.aarch64: patch
distrib/sets/lists/base/ad.arm: patch
distrib/sets/lists/base/ad.mips: patch
distrib/sets/lists/base/ad.powerpc: patch
distrib/sets/lists/base/md.amd64: patch
distrib/sets/lists/base/md.sparc64: patch
distrib/sets/lists/base/shl.mi: patch
distrib/sets/lists/comp/mi: revision 1.1939
distrib/sets/lists/debug/ad.aarch64: patch
distrib/sets/lists/debug/ad.arm: patch
distrib/sets/lists/debug/ad.mips: patch
distrib/sets/lists/debug/ad.powerpc: patch
distrib/sets/lists/debug/md.amd64: patch
distrib/sets/lists/debug/md.sparc64: patch
distrib/sets/lists/debug/shl.mi: patch
include/inttypes.h: revision 1.11
lib/libc/shlib_version: patch
lib/libc/stdlib/Makefile.inc: revision 1.84
lib/libc/stdlib/strtol.3: revisions 1.27-1.31
lib/libc/stdlib/strtoul.3: revisions 1.26-1.29
sys/lib/libkern/Makefile.libkern: revision 1.37
sys/lib/libkern/libkern.h: revision 1.117
tools/compat/Makefile: revision 1.73
tools/compat/compat_defs.h: revision 1.101
tools/compat/configure.ac: revision 1.83
tools/compat/configure: revision 1.82
tools/compat/nbtool_config.h.in: revision 1.36
add strto{i,u} from Kamil Rytarowski as discussed in tech-userlevel.
--
strtoi and strtou additions
--
strtoi and strtou for the kernel
--
strtoi and strtou additions
--
strtoi and strtou man pages
--
strto{i,u}
--
regen
--
Remove trailing whitespace.
--
match variable names with man page (Kamil Rytarowski)
--
cleanups from (Kamil Rytarowski)
--
add strtoi strtou (Kamil Rytarowski)
--
PR/49640: Kamil Rytarowski: Improve error printing
--
Use existing month for Dd.
 1.26.24.2.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.35.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18 20-Aug-2008  joerg branches: 1.18.6;
Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.17 29-Nov-2005  christos branches: 1.17.20;
WARNS=4
 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 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 15-Nov-1998  christos delint
 1.12 03-Feb-1998  mycroft Nuke `register'.
 1.11 30-Jan-1998  perry update to lite-2
 1.10 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.9 20-Jul-1996  jtc Changing type of "c" to unsigned did not fix the problem --- a signed
char is sign extended before it is assigned to an unsigned int. This
fix, which has been tested with a different testcase, adds explicit
casts to unsigned char before the value of a character is copied.
 1.8 11-Jul-1996  jtc The argument to isfoo() must be representable as an unsigned char, so
type of "c" has been changed to unsigned. This change allows these
functions will work with strings with their 8th bit set.
 1.7 28-Dec-1995  thorpej branches: 1.7.4;
New-style RCS ids.
 1.6 21-Dec-1995  mycroft Rearrange to avoid sign problems with GCC.
 1.5 20-Dec-1995  mycroft Minor cleanup.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 25-Aug-1993  jtc Add cast to silence compiler warning.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.4.2 20-Jul-1996  jtc Pulled up from rev 1.9
 1.7.4.1 11-Jul-1996  jtc Pulled up from rev 1.8
 1.17.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.18.6.2 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.18.6.1 20-Aug-2008  joerg file strtol.c was added on branch christos-time_t on 2008-08-20 12:42:27 +0000
 1.8 08-Oct-2006  thorpej - Move strtoll.c and strtoull.c from libc/stdlib to common/libc/stdlib.
- Add strtoll.c and strtoull.c to libkern.
 1.7 29-Nov-2005  christos WARNS=4
 1.6 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.5 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.4 06-Oct-2002  lukem pull in config.h (et al) for libnbcompat
 1.3 07-May-2001  kleink For consistency add a _DIAGASSERT() case, and remove some cruft.
 1.2 07-Mar-2000  kleink branches: 1.2.6;
Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.2.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.2 19-Jan-2015  wiz Fix date. Sort section. Sort errors. Sort SEE ALSO. Break too long
lines.
 1.1 18-Jan-2015  christos man page for strtonum.3
 1.8 20-Sep-2025  christos toolify.
 1.7 20-Jan-2024  christos PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
 1.6 06-Dec-2018  kamil branches: 1.6.2; 1.6.10;
Correct handling of minval > maxval in strtonum(3)

The original implementation in OpenBSD returns "invalid" and avoids reading
the input string. The replaced behavior was interpreting the input string
ignoring the invalid arguments.
 1.5 04-Jan-2018  kamil branches: 1.5.2; 1.5.4;
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.4 10-Mar-2015  christos The OpenBSD strtonum() only accepts base 10 keywords. (Kamil Rytarowski)
 1.3 05-Feb-2015  christos cast to return type
 1.2 18-Jan-2015  christos cleanups from (Kamil Rytarowski)
 1.1 16-Jan-2015  christos Add strtonum implemented as a wrapper of strtoi.
 1.5.4.1 10-Jun-2019  christos Sync with HEAD
 1.5.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.6.10.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #792):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)

generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.6.2.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1870):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.19 20-Aug-2008  joerg branches: 1.19.6;
Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.18 18-Dec-2006  christos branches: 1.18.12;
remove bogus (void)&var; From Anon Ymous
 1.17 29-Nov-2005  christos WARNS=4
 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 08-Mar-2000  kleink No longer need internal names for strtoq() and strtouq().
 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 17-Aug-1999  mycroft Make some needed weak aliases.
 1.11 15-Nov-1998  christos delint
 1.10 03-Feb-1998  mycroft Nuke `register'.
 1.9 03-Feb-1998  mycroft Deal with GCC warning.
 1.8 30-Jan-1998  perry update to lite-2
 1.7 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.6 20-Jul-1996  jtc branches: 1.6.2;
Changing type of "c" to unsigned did not fix the problem --- a signed
char is sign extended before it is assigned to an unsigned int. This
fix, which has been tested with a different testcase, adds casts to
signed chars which results in proper behavior.
 1.5 11-Jul-1996  jtc The argument to isfoo() must be representable as an unsigned char, so
type of "c" has been changed to unsigned. This change allows these
functions will work with strings with their 8th bit set.
 1.4 21-Dec-1995  mycroft branches: 1.4.4;
Rearrange to avoid sign problems with GCC.
 1.3 20-Dec-1995  mycroft Minor cleanup.
 1.2 04-Jan-1994  mycroft branches: 1.2.4;
Fix two compiler warnings.
 1.1 03-Jan-1994  jtc branches: 1.1.1;
Integrate strtoq() and strtouq() from bsd-sources on uunet.
 1.1.1.1 30-Jan-1998  perry import lite-2
 1.2.4.2 02-May-1995  jtc #include "namespace.h"
 1.2.4.1 17-Feb-1995  jtc Make namespace safe by including "namespace.h" and defining a weak
references. The scanf() family of functions uses strto{,u}q to
convert pointers and quad ints.
 1.4.4.2 20-Jul-1996  jtc Pulled up from rev 1.6
 1.4.4.1 11-Jul-1996  jtc Pulled up from rev 1.5
 1.6.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.18.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.19.6.2 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.19.6.1 20-Aug-2008  joerg file strtoq.c was added on branch christos-time_t on 2008-08-20 12:42:27 +0000
 1.9 20-Jan-2024  christos generate strtou.3 from strtoi.3, grammar police
 1.8 20-Jan-2024  christos PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
 1.7 03-Jul-2017  wiz branches: 1.7.8; 1.7.16;
Remove workaround for ancient HTML generation code.
 1.6 13-Nov-2015  christos revert 0b documentation.
 1.5 13-Nov-2015  wiz Remove trailing whitespace.
 1.4 12-Nov-2015  christos Now that our source tree has binary constants, recognize them.
 1.3 11-Jul-2015  wiz Add missing Fc.
 1.2 03-May-2015  wiz branches: 1.2.2;
Sort ERRORS and SEE ALSO.
 1.1 01-May-2015  christos - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
 1.2.2.2 16-May-2015  snj Pull up following revision(s) (requested by christos in ticket #781):
common/lib/libc/stdlib/strtoi.c: revision 1.2
common/lib/libc/stdlib/strtou.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.113
distrib/sets/lists/tests/mi: revision 1.617
lib/libc/include/namespace.h: revision 1.178
lib/libc/stdlib/Makefile.inc: revision 1.90 via patch
lib/libc/stdlib/strtoi.3: revisions 1.1, 1.2
lib/libc/stdlib/strtol.3: revision 1.32
lib/libc/stdlib/strtou.3: revisions 1.1, 1.2
lib/libc/stdlib/strtoul.3: revisions 1.30, 1.31
tests/lib/libc/stdlib/Makefile: revision 1.25
tests/lib/libc/stdlib/t_strtoi.c: revision 1.1
- new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
--
Sort ERRORS and SEE ALSO.
--
Sort ERRORS and SEE ALSO.
--
Sort SEE ALSO.
 1.2.2.1 03-May-2015  snj file strtou.3 was added on branch netbsd-7 on 2015-05-16 17:58:46 +0000
 1.7.16.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #792):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)

generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.7.8.1 23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1870):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.37 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.36 05-Nov-2016  riastradh Update strtoul(3) example to reflect clarifications in strtol(3).
 1.35 01-May-2016  joerg branches: 1.35.2;
Fix type name. From Abhinav.
 1.34 13-Nov-2015  christos revert 0b documentation.
 1.33 13-Nov-2015  wiz Remove trailing whitespace.
 1.32 12-Nov-2015  christos Now that our source tree has binary constants, recognize them.
 1.31 03-May-2015  wiz Sort SEE ALSO.
 1.30 01-May-2015  christos - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
 1.29 10-Mar-2015  christos PR/49640: Kamil Rytarowski: Improve error printing
 1.28 18-Jan-2015  christos cleanups from (Kamil Rytarowski)
 1.27 16-Jan-2015  wiz Remove trailing whitespace.
 1.26 16-Jan-2015  christos strtoi and strtou additions
 1.25 02-Dec-2009  pooka branches: 1.25.24;
tyop de fix
 1.24 02-Dec-2009  pooka Document that strtouq can return UQUAD_MAX.
 1.23 23-Jul-2009  wiz Bump date for previous.
 1.22 23-Jul-2009  dholland Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
 1.21 21-May-2009  wiz Markup improvements. No need to mark up numbers as defined values, math
did the definition for us ages ago. Make HTML-ready.
 1.20 20-May-2009  christos mention that these functions return 0 and set errno to ERANGE on invalid base.
 1.19 08-Sep-2003  wiz branches: 1.19.16; 1.19.26; 1.19.38; 1.19.44;
Use St -isoC-9X instead of St -isoC9X, to be in sync with groff.
 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 11-Aug-2002  yamt bring in EXAMPLES and a note.
from openbsd.
 1.15 07-Feb-2002  ross Generate <>& symbolically.
 1.14 15-Jan-2002  wiz Use .Pp instead of empty lines.
 1.13 16-Sep-2001  wiz Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.12 28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.11 06-Mar-2000  kleink branches: 1.11.6;
Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.10 19-Nov-1999  enami Don't pass so many args to .Nd macro. It just overflows.
 1.9 05-Feb-1998  perry branches: 1.9.6;
add LIBRARY section to man page
 1.8 30-Jan-1998  perry update to lite-2
 1.7 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.6 28-Dec-1995  thorpej branches: 1.6.8;
New-style RCS ids.
 1.5 03-Jan-1994  jtc Integrate strtoq() and strtouq() from bsd-sources on uunet.
 1.4 29-Nov-1993  jtc Use "Er" for argument to -width in the lists in the ERROR sections so that
formatting is consistant.
 1.3 24-Nov-1993  jtc Strtoul returns a unsigned long.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.8.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.9.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.6.5 13-Aug-2002  nathanw Catch up to -current.
 1.11.6.4 22-Mar-2002  nathanw Catch up to -current.
 1.11.6.3 08-Mar-2002  nathanw Catch up to -current.
 1.11.6.2 28-Jan-2002  nathanw Catch up to -current.
 1.11.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.19.44.1 26-Jul-2009  snj branches: 1.19.44.1.2;
Pull up following revision(s) (requested by dholland in ticket #868):
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
 1.19.44.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.19.38.1 26-Jul-2009  snj Pull up following revision(s) (requested by dholland in ticket #868):
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
 1.19.26.1 18-Aug-2009  bouyer Pull up following revision(s) (requested by dholland in ticket #1341):
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23 via patch
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26 via patch
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
Bump date for previous.
 1.19.16.1 18-Aug-2009  bouyer Pull up following revision(s) (requested by dholland in ticket #1341):
lib/libc/stdlib/strtoul.3: revisions 1.22, 1.23 via patch
lib/libc/stdlib/strtol.3: revisions 1.25, 1.26 via patch
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.
Bump date for previous.
 1.25.24.3 18-Dec-2016  snj Pull up following revision(s) (requested by riastradh in ticket #1311):
lib/libc/stdlib/strtod.3: revisions 1.21-1.29
lib/libc/stdlib/strtol.3: revision 1.36-1.38
lib/libc/stdlib/strtoul.3: revision 1.36
strtod yields ERANGE for below-subnormal magnitudes, not underflow.
For a floating-point computation, in the language of IEEE 754,
`underflow' means the output was rounded and is too small to be
represented *normally*.
There are many nonzero floating-point numbers to which the exact
output may have been rounded -- namely subnormals. The condition
under which strtod returns ERANGE for small magnitudes is when the
magnitude of the exact result is so small it is rounded to zero, not
even to a subnormal.
While here, use parallel language about large magnitudes instead of
the (albeit correct) word `overflow', to avoid temptation to treat
`underflow' as the opposite notion with zero instead of infinity.
--
Bump date for previous.
--
Fix description of ERANGE cases again.
Do use the technical terms `overflow' and `underflow', because strtod
sets ERANGE precisely to indicate either of these two conditions, and
they are the right keywords that one might be looking for.
Note that strtod may set ERANGE even if it returns noninfinity and
nonzero -- specifically, if the result is subnormal. This part was
wrong before I `fixed' it and remained wrong after I `fixed' it
earlier this year.
--
Add example for strtod.
This illustrates all the cases you might be interested in and asserts
theorems in those cases.
--
Fix infinity detection with isinf(d), not d == HUGE_VAL.
Negative infinity counts as overflow too.
Simplify.
--
EXIT_FAILURE police
--
Distinguish altogether invalid syntax from trailing garbage.
--
Distinguish invalid syntax from trailing garbage cases. Clarify.
--
Simplify error condition case.
Add assertions to reflect its implications.
--
Tidy up the second example too.
--
Update strtoul(3) example to reflect clarifications in strtol(3).
--
Fix phrasing about `out-of-band' and `sentinel value'.
Either an out-of-band channel, or an in-band sentinel value, could
indicate an error, but an out-of-band sentinel value is a silly
proposition.
Noted by uwe@.
--
Use the keywords `underflow' and `overflow' in ERANGE summary.
 1.25.24.2 16-May-2015  snj branches: 1.25.24.2.4;
Pull up following revision(s) (requested by christos in ticket #781):
common/lib/libc/stdlib/strtoi.c: revision 1.2
common/lib/libc/stdlib/strtou.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.113
distrib/sets/lists/tests/mi: revision 1.617
lib/libc/include/namespace.h: revision 1.178
lib/libc/stdlib/Makefile.inc: revision 1.90 via patch
lib/libc/stdlib/strtoi.3: revisions 1.1, 1.2
lib/libc/stdlib/strtol.3: revision 1.32
lib/libc/stdlib/strtou.3: revisions 1.1, 1.2
lib/libc/stdlib/strtoul.3: revisions 1.30, 1.31
tests/lib/libc/stdlib/Makefile: revision 1.25
tests/lib/libc/stdlib/t_strtoi.c: revision 1.1
- new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
--
Sort ERRORS and SEE ALSO.
--
Sort ERRORS and SEE ALSO.
--
Sort SEE ALSO.
 1.25.24.1 22-Apr-2015  snj Pull up following revision(s) (requested by roy in ticket #648):
common/lib/libc/stdlib/_strtoi.h: revisions 1.1, 1.2
common/lib/libc/stdlib/strtoi.c: revision 1.1
common/lib/libc/stdlib/strtou.c: revision 1.1
distrib/sets/lists/base/ad.aarch64: patch
distrib/sets/lists/base/ad.arm: patch
distrib/sets/lists/base/ad.mips: patch
distrib/sets/lists/base/ad.powerpc: patch
distrib/sets/lists/base/md.amd64: patch
distrib/sets/lists/base/md.sparc64: patch
distrib/sets/lists/base/shl.mi: patch
distrib/sets/lists/comp/mi: revision 1.1939
distrib/sets/lists/debug/ad.aarch64: patch
distrib/sets/lists/debug/ad.arm: patch
distrib/sets/lists/debug/ad.mips: patch
distrib/sets/lists/debug/ad.powerpc: patch
distrib/sets/lists/debug/md.amd64: patch
distrib/sets/lists/debug/md.sparc64: patch
distrib/sets/lists/debug/shl.mi: patch
include/inttypes.h: revision 1.11
lib/libc/shlib_version: patch
lib/libc/stdlib/Makefile.inc: revision 1.84
lib/libc/stdlib/strtol.3: revisions 1.27-1.31
lib/libc/stdlib/strtoul.3: revisions 1.26-1.29
sys/lib/libkern/Makefile.libkern: revision 1.37
sys/lib/libkern/libkern.h: revision 1.117
tools/compat/Makefile: revision 1.73
tools/compat/compat_defs.h: revision 1.101
tools/compat/configure.ac: revision 1.83
tools/compat/configure: revision 1.82
tools/compat/nbtool_config.h.in: revision 1.36
add strto{i,u} from Kamil Rytarowski as discussed in tech-userlevel.
--
strtoi and strtou additions
--
strtoi and strtou for the kernel
--
strtoi and strtou additions
--
strtoi and strtou man pages
--
strto{i,u}
--
regen
--
Remove trailing whitespace.
--
match variable names with man page (Kamil Rytarowski)
--
cleanups from (Kamil Rytarowski)
--
add strtoi strtou (Kamil Rytarowski)
--
PR/49640: Kamil Rytarowski: Improve error printing
--
Use existing month for Dd.
 1.25.24.2.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.35.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.17 29-Nov-2005  christos WARNS=4
 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 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 15-Nov-1998  christos delint
 1.12 03-Feb-1998  mycroft Nuke `register', deal with GCC warnings.
 1.11 30-Jan-1998  perry update to lite-2
 1.10 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.9 20-Jul-1996  jtc Changing type of "c" to unsigned did not fix the problem --- a signed
char is sign extended before it is assigned to an unsigned int. This
fix, which has been tested with a different testcase, adds explicit
casts to unsigned char before the value of a character is copied.
 1.8 11-Jul-1996  jtc The argument to isfoo() must be representable as an unsigned char, so
type of "c" has been changed to unsigned. This change allows these
functions will work with strings with their 8th bit set.
 1.7 28-Dec-1995  thorpej branches: 1.7.4;
New-style RCS ids.
 1.6 21-Dec-1995  mycroft Rearrange to avoid sign problems with GCC.
 1.5 20-Dec-1995  mycroft Minor cleanup.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 25-Aug-1993  jtc Add cast to silence compiler warning.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.4.2 20-Jul-1996  jtc Pulled up from rev 1.9
 1.7.4.1 11-Jul-1996  jtc Pulled up from rev 1.8
 1.7 08-Oct-2006  thorpej - Move strtoll.c and strtoull.c from libc/stdlib to common/libc/stdlib.
- Add strtoll.c and strtoull.c to libkern.
 1.6 29-Nov-2005  christos WARNS=4
 1.5 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.4 16-May-2000  is Workaround no longer needed, now that the compiler is fixed.
 1.3 02-May-2000  is Add the (void)&acc; hack from strtouq.c to strtoull.c. This works around
an arm32 compiler bug. Change the comment in strtouq.c to reflect the current
usage of the hack.
 1.2 07-Mar-2000  kleink Make lint happy about long long integers. (C99 mode for lint, anyone?)
 1.1 06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.7 22-Apr-2006  thorpej Move strtoumax.c from libc/stdlib to common/libc/stdlib and include it
in libkern. Required for new code coming soon.
 1.6 29-Nov-2005  christos WARNS=4
 1.5 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.4 10-May-2001  mycroft branches: 1.4.2;
Add an underscore for consistency.
 1.3 07-May-2001  kleink Use <stddef.h> rather than <stdio.h> if it's just NULL that's wanted.
 1.2 07-May-2001  lukem need stdio.h for NULL...
 1.1 28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.4.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.4.2.1 10-May-2001  nathanw file strtoumax.c was added on branch nathanw_sa on 2001-10-08 20:21:21 +0000
 1.20 26-Aug-2008  drochner branches: 1.20.6;
fix range of strtouq(), from Henning Petersen per PR lib/39399
 1.19 20-Aug-2008  joerg Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
 1.18 29-Nov-2005  christos branches: 1.18.20;
WARNS=4
 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-May-2000  is Workaround no longer needed, now that the compiler is fixed.
 1.15 02-May-2000  is Add the (void)&acc; hack from strtouq.c to strtoull.c. This works around
an arm32 compiler bug. Change the comment in strtouq.c to reflect the current
usage of the hack.
 1.14 08-Mar-2000  kleink No longer need internal names for strtoq() and strtouq().
 1.13 20-Sep-1999  lukem 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 17-Aug-1999  mycroft Make some needed weak aliases.
 1.10 15-Nov-1998  christos delint
 1.9 03-Feb-1998  mycroft Nuke `register', deal with GCC warnings.
 1.8 30-Jan-1998  perry update to lite-2
 1.7 13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.6 20-Jul-1996  jtc branches: 1.6.2;
Changing type of "c" to unsigned did not fix the problem --- a signed
char is sign extended before it is assigned to an unsigned int. This
fix, which has been tested with a different testcase, adds casts to
signed chars which results in proper behavior.
 1.5 11-Jul-1996  jtc The argument to isfoo() must be representable as an unsigned char, so
type of "c" has been changed to unsigned. This change allows these
functions will work with strings with their 8th bit set.
 1.4 21-Dec-1995  mycroft branches: 1.4.4;
Rearrange to avoid sign problems with GCC.
 1.3 20-Dec-1995  mycroft Minor cleanup.
 1.2 04-Jan-1994  mycroft branches: 1.2.4;
Fix two compiler warnings.
 1.1 03-Jan-1994  jtc branches: 1.1.1;
Integrate strtoq() and strtouq() from bsd-sources on uunet.
 1.1.1.1 30-Jan-1998  perry import lite-2
 1.2.4.2 02-May-1995  jtc #include "namespace.h"
 1.2.4.1 17-Feb-1995  jtc Make namespace safe by including "namespace.h" and defining a weak
references. The scanf() family of functions uses strto{,u}q to
convert pointers and quad ints.
 1.4.4.2 20-Jul-1996  jtc Pulled up from rev 1.6
 1.4.4.1 11-Jul-1996  jtc Pulled up from rev 1.5
 1.6.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.18.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.20.6.2 26-Aug-2008  drochner fix range of strtouq(), from Henning Petersen per PR lib/39399
 1.20.6.1 26-Aug-2008  drochner file strtouq.c was added on branch christos-time_t on 2008-08-26 12:21:25 +0000
 1.17 27-Aug-2008  christos branches: 1.17.6;
system(NULL) should return if the command interpreter is there or not.
Andy Shevchenko
 1.16 02-Aug-2007  wiz branches: 1.16.10; 1.16.12;
Add xref to shquote(3), suggested by joerg. Bump date.
 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 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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.10 06-Apr-1999  tron branches: 1.10.10;
Fix typo noted by NAKAJIMA Yoshihiro in PR lib/7328.
 1.9 05-Feb-1998  perry branches: 1.9.2;
add LIBRARY section to man page
 1.8 30-Jan-1998  perry update to lite-2
 1.7 16-Feb-1996  jtc Fixed bad cross reference: waitpid(3) -> waitpid(2).
 1.6 28-Dec-1995  thorpej New-style RCS ids.
 1.5 01-Nov-1995  pk waitpid is in section 2 (from John Kohl; PR#1710).
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 20-Aug-1993  jtc Upgraded to be 1003.2-92 compliant. The only functional change is
that -1 is returned when the fork fails. Updated implementation to
use int rather than deprecated "union wait". Updated documentation
to describe error / return values.
 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 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.2.1 06-Apr-1999  tron Pull up revision 1.10.
 1.10.10.4 01-Aug-2002  nathanw Catch up to -current.
 1.10.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.10.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.10.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.16.12.2 02-Aug-2007  wiz Add xref to shquote(3), suggested by joerg. Bump date.
 1.16.12.1 02-Aug-2007  wiz file system.3 was added on branch matt-mips64 on 2007-08-02 23:45:11 +0000
 1.16.10.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.17.6.2 27-Aug-2008  christos system(NULL) should return if the command interpreter is there or not.
Andy Shevchenko
 1.17.6.1 27-Aug-2008  christos file system.3 was added on branch christos-time_t on 2008-08-27 06:45:03 +0000
 1.28 14-Mar-2022  riastradh system(3): Simplify initialization of argp.
 1.27 14-Mar-2022  riastradh system(3): Switch from vfork/execve to posix_spawn.

Changes by me:
- Minor style nits.
- Set errno on posix_spawn failure.
- Handle edge cases of SIGINT/SIGQUIT set to SIG_IGN by caller.


Author: Nikita Ronja Gillmann <nikita@NetBSD.org>
Committer: Taylor R Campbell <riastradh@NetBSD.org>
 1.26 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.25 20-Jan-2015  christos Fix non _REENTRANT build.
 1.24 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.23 14-Nov-2010  tron branches: 1.23.6;
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.22 27-Aug-2008  christos branches: 1.22.6;
system(NULL) should return if the command interpreter is there or not.
Andy Shevchenko
 1.21 07-Oct-2006  elad branches: 1.21.18;
Correctly recover signal state if failed trying to set it.

Patch from David A. Holland in #NetBSD-code, thanks!
 1.20 29-Nov-2005  christos WARNS=4
 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 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.17 31-Oct-2001  kleink Inspired by Stevens' APUE and the implementation example in XSH:
* Don't return if wait()ing for the child is interrupted.
* Fix a race condition for the parent's SIG{INT,QUIT} disposition.
* While we're here, convert from using signal(3) to sigaction(2).
 1.16 15-Nov-1998  christos branches: 1.16.10; 1.16.12;
delint
 1.15 26-Sep-1998  christos Adapt to posix signal system calls.
 1.14 30-Jan-1998  perry update to lite-2
 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 Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.11 28-Dec-1995  thorpej branches: 1.11.2;
New-style RCS ids.
 1.10 14-Jun-1995  jtc add explicit return type
 1.9 28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.8 28-Feb-1995  jtc Changed <sys/signal.h> to <signal.h>
 1.7 26-Aug-1993  jtc branches: 1.7.4;
Declare rcsid strings so they are stored in text segment.
 1.6 20-Aug-1993  jtc cast away compiler warning message.
 1.5 20-Aug-1993  jtc Upgraded to be 1003.2-92 compliant. The only functional change is
that -1 is returned when the fork fails. Updated implementation to
use int rather than deprecated "union wait". Updated documentation
to describe error / return values.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 30-Jul-1993  mycroft system.c
 1.2 29-Jul-1993  mycroft Use execve() rather than execl(). This is faster and doesn't use malloc()
(and thus avoids an annoying problem which only seems to manifest itself
in KCL).
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 30-Jan-1998  perry import lite-2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.4.1 02-May-1995  jtc #include "namespace.h"
 1.11.2.1 18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.16.12.1 14-Nov-2001  nathanw Catch up to -current.
 1.16.10.1 09-Dec-2001  he Pull up revision 1.17 (requested by kleink):
Don't return if wait()ing for the child is interrupted; fix a
race condition for the parent's SIG{INT,QUIT} disposition.
 1.21.18.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.22.6.2 27-Aug-2008  christos system(NULL) should return if the command interpreter is there or not.
Andy Shevchenko
 1.22.6.1 27-Aug-2008  christos file system.c was added on branch christos-time_t on 2008-08-27 06:45:03 +0000
 1.23.6.1 30-Oct-2012  yamt sync with head
 1.8 20-Jan-2016  christos Don't return NULL when we are freeing the root node; return a free'd pointer
instead.
 1.7 20-Jan-2016  christos PR/50681: Markiyan Kushnir: Fix memory leak when we delete the root node.
It is questionable if we should return NULL in that case, but what is the
parent of root? The new adjusted root?
 1.6 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.5 18-May-2011  dsl branches: 1.5.4;
Remove __P()
 1.4 19-Mar-2006  christos Coverity CID 2528: Don't delete the node we are about to return.
 1.3 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.2 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.1 22-Feb-1999  christos t{search,find,walk,delete} from OpenBSD via Neil A. Carson
 1.5.4.1 30-Oct-2012  yamt sync with head
 1.7 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.6 18-May-2011  dsl branches: 1.6.4;
Remove __P()
 1.5 23-Mar-2005  kleink Avoid lint warning after previous.
 1.4 22-Mar-2005  kleink * Add restrict qualifiers to tdelete() function arguments.
* Const-poison tfind()'s rootp argument, per SVID Issue 1 and later.
 1.3 20-Sep-1999  lukem branches: 1.3.18;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.2 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.1 22-Feb-1999  christos t{search,find,walk,delete} from OpenBSD via Neil A. Carson
 1.3.18.2 23-Mar-2005  tron Pull up revision 1.5 (requested by kleink in ticket #54):
Avoid lint warning after previous.
 1.3.18.1 23-Mar-2005  tron Pull up revision 1.4 (requested by kleink in ticket #51):
* Add restrict qualifiers to tdelete() function arguments.
* Const-poison tfind()'s rootp argument, per SVID Issue 1 and later.
 1.6.4.1 30-Oct-2012  yamt sync with head
 1.12 30-Apr-2010  jruoho Put the period outside the quotation marks.
 1.11 30-Apr-2010  jruoho Add STANDARDS and CAVEATS. The latter notes the ambiguity of tdelete() when
deleting the root node.
 1.10 11-Apr-2009  joerg Fix markup.
 1.9 07-Dec-2007  simonb branches: 1.9.12; 1.9.16;
Fix twalk()s 3rd argument name so that it matches rest of manpage and
the source code.
 1.8 26-Nov-2006  elad branches: 1.8.8;
PR/34984: Denis Lagno: minor problems with tsearch.3
 1.7 22-Mar-2005  kleink * Add restrict qualifiers to tdelete() function arguments.
* Const-poison tfind()'s rootp argument, per SVID Issue 1 and later.
 1.6 27-Jun-2003  wiz branches: 1.6.6;
Remove superfluous comma.
 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 Drop unnecessary whitespace and .Pp, sort SEE ALSO, sort sections,
and some minor fixes.
 1.1 22-Feb-1999  christos branches: 1.1.12;
t{search,find,walk,delete} from OpenBSD via Neil A. Carson
 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.6.6.1 23-Mar-2005  tron Pull up revision 1.7 (requested by kleink in ticket #51):
* Add restrict qualifiers to tdelete() function arguments.
* Const-poison tfind()'s rootp argument, per SVID Issue 1 and later.
 1.8.8.1 09-Jan-2008  matt sync with HEAD
 1.9.16.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.9.12.1 12-Apr-2009  snj Pull up following revision(s) (requested by joerg in ticket #695):
lib/libc/stdlib/tsearch.3: revision 1.10
Fix markup.
 1.7 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.6 18-May-2011  dsl branches: 1.6.4;
Remove __P()
 1.5 29-Nov-2005  christos WARNS=4
 1.4 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.3 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.2 03-May-1999  christos add a const castaway lint comment.
 1.1 22-Feb-1999  christos t{search,find,walk,delete} from OpenBSD via Neil A. Carson
 1.6.4.1 30-Oct-2012  yamt sync with head
 1.4 20-Mar-2012  matt Remove use of __P
Switch to using C89 definitions.
 1.3 18-May-2011  dsl branches: 1.3.4;
Remove __P()
 1.2 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.1 22-Feb-1999  christos t{search,find,walk,delete} from OpenBSD via Neil A. Carson
 1.3.4.1 17-Apr-2012  yamt sync with head
 1.4 30-Apr-2008  martin branches: 1.4.8;
Convert TNF licenses to new 2 clause variant
 1.3 28-May-2004  wiz branches: 1.3.24;
Uppercase Dt argument; \-1, not -1; sort SEE ALSO; & -> \*[Am].
 1.2 28-May-2004  wiz Drop trailing whitespace.
 1.1 27-May-2004  christos unix/98 pty functions and manual pages.
 1.3.24.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 unlockpt.3 was added on branch christos-time_t on 2008-04-30 13:10:52 +0000
 1.11 20-Jan-2015  christos Fix non _REENTRANT build.
 1.10 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.9 30-Sep-2010  tron Be slightly more careful about freeing memory allocated for environment
variables: only free memory if the current value points to the same
memory area as the allocated block. This will prevent crashes if an
application changes the order of the environment array.

Unfortunately this is still not enough to stop zsh 4.2.* from crashing.
zsh 4.3.* works fine before and after this change.
 1.8 29-Sep-2010  enami Don't put space before close paren.
 1.7 25-Sep-2010  tron Unlock the environment lock if __alocenv() fails.
 1.6 25-Sep-2010  tron Remember memory used by allocated environment variables instead of
using a bitmap. This deals with the case where a variable is first
set via setenv(3) or putenv(3), then overwritten by changing
"environ" directory and afterwards overwritten with setenv(3) again.

This stops "zsh" from crashing under NetBSD-current.

Code reviewed by Christos Zoulas.
 1.5 24-Sep-2010  christos protect the __allocenv call with the mutex; from Enami
 1.4 23-Sep-2010  christos Use a bit array to keep track of malloced environment entries so we can
free them.
 1.3 13-Sep-2005  christos compat core reorg.
 1.2 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.1 07-Apr-2003  kleink 1003.1-2001 has introduced unsetenv() which differs from the current
implementation in not permitting a "name=value" argument.
* Add a conforming __unsetenv13() and do function renaming for
unsetenv(); preserve old symbol with old behavior.
* Make visible setenv() and unsetenv() for 1003.1-2001 feature selection
macros; resolves PR standards/20479.

RSS XML Feed