History log of /openbsd-current/include/stdlib.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.77 01-Mar-2024 millert

Add mkdtemps(3), like mkdtemp(3) but with a suffix.
OK deraadt@ tb@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.76 10-May-2019 otto

Inroduce malloc_conceal() and calloc_conceal(). Similar to their
counterparts but return memory in pages marked MAP_CONCEAL and on
free() freezero() is actually called.


Revision tags: OPENBSD_6_5_BASE
# 1.75 21-Nov-2018 otto

Introducing malloc_usable_size() was a mistake. While some other
libs have it, it is a function that is considered harmful, so:

Delete malloc_usable_size(). It is a function that blurs the line
between malloc managed memory and application managed memory and
exposes some of the internal workings of malloc. If an application
relies on that, it is likely to break using another implementation
of malloc. If you want usable size x, just allocate x bytes. ok
deraadt@ and other devs


# 1.74 18-Nov-2018 otto

Implement malloc_usable_size(); ok millert@ deraadt@ and jmc@ for the man page


# 1.73 05-Nov-2018 otto

Implement C11's aligned_alloc(3). ok guenther@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.72 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.71 11-May-2017 tom

arc4random_buf should be bounded buffer, not bounded string

ok millert@


# 1.70 10-May-2017 millert

Add bounded attribute to freezero(). OK tom@


# 1.69 10-Apr-2017 otto

Introducing freezero(3) a version of free that guarantees the process
no longer has access to the content of a memmory object. It does
this by either clearing (if the object memory remains cached) or
by calling munmap(2). ok millert@, deraadt@, guenther@


Revision tags: OPENBSD_6_1_BASE
# 1.68 06-Mar-2017 otto

Introducing recallocarray(3), a blend of calloc(3) and reallocarray(3)
with the added feature that released memory is cleared. Much input from various
developers. ok deraadt@ tom@


# 1.67 20-Sep-2016 fcambus

Remove duplicated includes in stdlib.h and termios.h

OK guenther@


# 1.66 09-Sep-2016 millert

Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11. OK deraadt@ guenther@ kettenis@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.65 14-Jul-2015 millert

The first argument to devname(3) should be dev_t, not int.
The man page was already correct.


Revision tags: OPENBSD_5_7_BASE
# 1.64 08-Feb-2015 tedu

add restrict to strtol like functions. ok guenther


# 1.63 15-Jan-2015 tedu

we don't have an alloca() symbol anywhere in libc, don't prototype it.
instead, #define to __builtin_alloca. if that doesn't work, you're hosed.
from an old discussion about the perils of alloca. (don't use alloca!)


# 1.62 08-Dec-2014 deraadt

Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode. If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).

Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.

Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert


# 1.61 08-Dec-2014 tedu

header changes for recent libc changes:
add siphash
delete setkey, encrypt, cfree


# 1.60 31-Aug-2014 guenther

Add additional userland interfaces for setting close-on-exec on fds
when creating them: mkostemp(), mkostemps(), the 'e' mode letter for
fopen(), freopen(), fdopen(), and popen(). The close-on-exec flag will
be cleared by the action created by posix_spawn_file_actions_adddup2().

Also, add support for the C11 'x' mode letter for fopen() and freopen(),
setting O_EXCL when possibly creating files.

Note: this requires kernel support for pipe2() and dup3()!

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.59 09-Jul-2014 beck

Clean up after arc4random u_int32_t uint32_t change
ok jsing@


# 1.58 22-Apr-2014 tedu

change mallocarray to reallocarray. useful in a few more situations.
malloc can, as always, be emulated via realloc(NULL).
ok deraadt


# 1.57 21-Apr-2014 deraadt

Introducing: void *mallocarray(size_t nmemb, size_t size);
Like calloc(), except without the cleared-memory gaurantee
ok beck guenther, discussed for more than a year...


Revision tags: OPENBSD_5_5_BASE
# 1.56 28-Dec-2013 martynas

Annotate a few more bounded functions: realpath(3) needs a buffer
of size at least PATH_MAX. pread(2), pwrite(2) and readlinkat(2)
also take the buffer and the bound. OK theo.


# 1.55 13-Dec-2013 millert

Fix typo; 200809 not 20080 for __POSIX_VISIBLE. Noticed by jca@


# 1.54 22-Nov-2013 millert

The getopt() prototype and externs don't belong in stdlib.h. Berkeley
moved them to unistd.h to match POSIX in 1995 but we never did.
The exception to this is getsubopt() which POSIX says should be in
stdlib.h. The non-standard suboptarg extern remains in the BSD-only
section of stdlib.h. Neither getsubopt() nor suboptarg belong in
unistd.h or getopt.h. They were only there to allow us to protect
all the getopt() bits from being multiply defined. OK guenther@


# 1.53 21-Oct-2013 deraadt

Remove arc4random_stir() and arc4random_addrandom(), which none should
be using directly. Well, a few rare people cloned it upstream and it
will take a bit of time for them to learn.
ok various


Revision tags: OPENBSD_5_4_BASE
# 1.52 31-May-2013 ajacoutot

Add getprogname() and setprogname() to ease slackers^porters' work.
Man page adapted from FreeBSD and NetBSD.

Bump libc minor now (there will be more upcoming changes).

input from tedu@
get it in deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.51 03-Dec-2012 millert

Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),
grantpt() and unlockpt() using /dev/ptm. Man pages from FreeBSD.
OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@


Revision tags: OPENBSD_5_2_BASE
# 1.50 01-Jun-2012 guenther

Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),
and valloc() are not in the current version, while posix_memalign() mkstemp(),
and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'.

ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.49 03-Jul-2011 jsg

As pointed out by Richard Guenther our definition
of NULL was incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

ok miod@


# 1.48 06-Apr-2011 miod

Define NULL as a void * instead of a long integer, as required by Single Unix.
Kernel and bootblocks still use the old 0L value until all the NULL abuses
in the code are fixed.


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.47 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.46 03-Jun-2009 millert

Make putenv(), setenv() and unsetenv() standards compliant. The
standard explicitly disallows passing setenv a name with a '=' in
it but historic BSD behavior is to allow this but to ignore the '='
and anything after it.


Revision tags: OPENBSD_4_5_BASE
# 1.45 07-Sep-2008 martynas

- replace dtoa w/ David's gdtoa, version 2008-03-15
- provide proper dtoa locks
- use the real strtof implementation
- add strtold, __hdtoa, __hldtoa
- add %a/%A support
- don't lose precision in printf, don't round to double anymore
- implement extended-precision versions of libc functions: fpclassify,
isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is
fixed
- separate vax versions of strtof, and __hdtoa
- add complex math support. added functions: cacos, casin, catan,
ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp,
clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf,
casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf,
ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf,
cimagf, conjf, cprojf, crealf
- add fdim, fmax, fmin
- add log2. (adapted implementation e_log.c. could be more acruate
& faster, but it's good enough for now)
- remove wrappers & cruft in libm, supposed to work-around mistakes
in SVID, etc.; use ieee versions. fixes issues in python 2.6 for
djm@
- make _digittoint static
- proper definitions for i386, and amd64 in ieee.h
- sh, powerpc don't really have extended-precision
- add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h
for LDBL_*
- merge lead to frac for m{6,8}k, for gdtoa to work properly
- add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa
to use
- add EXT_IMPLICIT_NBIT definition, which indicates implicit
normalization bit
- add regression tests for libc: fpclassify and printf
- arith.h & gd_qnan.h definitions
- update ieee.h: hppa doesn't have quad-precision, hppa64 does
- add missing prototypes to gdtoaimp
- on 64-bit platforms make sure gdtoa doesn't use a long when it
really wants an int
- etc., what i may have forgotten...
- bump libm major, due to removed&changed symbols
- no libc bump, since this is riding on djm's libc major crank from
a day ago

discussed with / requested by / testing theo, sthen@, djm@, jsg@,
merdely@, jsing@, tedu@, brad@, jakemsr@, and others.
looks good to millert@
parts of the diff ok kettenis@

this commit does not include:
- man page changes


Revision tags: OPENBSD_4_4_BASE
# 1.44 24-Jun-2008 otto

remove recalloc; sloppy me; ok deraadt@


# 1.43 20-Jun-2008 ragge

Remove obsolete (and erroneous) #if statement that caused all compilers
except for gcc to get the wrong prototype. Ok millert@


# 1.42 13-Jun-2008 landry

Add strtof() to libc, some ports seem to like it. Currently it's a simple
call to strtod() with bounding check.
Discussed with pyr@ and otto@

ok otto@ deraadt@


# 1.41 16-Mar-2008 otto

diff from djm@ committed at his request:

introduce two new APIs for requesting strong random numbers:

arc4random_buf() - fill an arbitrary memory range with random numbers

arc4random_uniform() - return a uniformly distributed random number
below
a specified upper bound, avoiding the bias that comes from a naive
"arc4random() % upper_bound" construction.

these mirror similarly-named functions in the kernel;
lots of discussion deraadt@ mcbride@


Revision tags: OPENBSD_4_3_BASE
# 1.40 03-Sep-2007 millert

add recaloc(3)


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.39 17-Sep-2006 djm

add lldiv prototype; ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.38 31-Mar-2006 deraadt

after we changed mode_t to be an int, the devname() man page was
updated but the function itself never was; ok millert


Revision tags: OPENBSD_3_9_BASE
# 1.37 13-Jan-2006 millert

Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()


# 1.36 06-Jan-2006 millert

Adapt things to use __type_t instead of _BSD_TYPE_T_
Add new sys/_types.h header
Include machine/_types.h or sys/_types.h where applicable


# 1.35 13-Dec-2005 millert

First step in include files overhaul. Use __FOO_VISIBLE (as defined
in sys/cdefs.h) instead of _FOO_SOURCE. Also fix several namespace
pollution issues, including the byte order defines. OK deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.34 27-May-2005 millert

mktemp(3) et al. go in stdlib.h, not unistd.h. While there be more
explicit about mktemp(3) in the man page.


# 1.33 11-May-2005 espie

major abi changes:

* introduce the mbstate_t typedef.
impacts gnu libiconv, which has already been taken care of.

* Prepare for mb stuff to really exist, replace macro MB_CUR_MAX with
an external variable __mb_cur_max (impacts libX11 and various ports).

* use mbstate in all the mb <-> wchar functions with state.
* add a stub iswctype function allowing some ports to compile.

bash and gdiff are missing wcscoll, and need to be told there's no i18n
until this is fixed.

Discussed and matthieu, otto, millert, kettenis, deraadt.

Major libc bump


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.32 03-Aug-2004 millert

Update strtonum() protor


# 1.31 03-May-2004 tedu

strtonum prototype


# 1.30 03-May-2004 millert

Add _Exit(3) as per C99. Discussed with espie@ some time ago.


Revision tags: OPENBSD_3_5_BASE
# 1.29 21-Jan-2004 millert

Prototype llabs(3). Forgotten commit gathering bit rot in my tree...


Revision tags: OPENBSD_3_4_BASE
# 1.28 01-Aug-2003 avsm

add __bounded__ attributes for userland headers; enabled with -Wbounded
ok deraadt@


# 1.27 26-Jun-2003 avsm

backout the __bounded__ attributes for a while; requested by deraadt@


# 1.26 26-Jun-2003 avsm

Mark various standard library functions with the __bounded__ attribute.
You must have an up-to-date gcc for this!
deraadt@ ok


# 1.25 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.24 03-Dec-2002 millert

GNU-like getopt_long() from NetBSD with changes by me to support
getopt_long_only(). At some point this should replace the BSD
getopt(3) but we are not there yet.

While I am here add protection from the multiple getopt() definitions
due to conflicting standards.


# 1.23 02-Dec-2002 millert

Add ecvt(), fcvt() and gcvt() for standard compliance and legacy code.


# 1.22 02-Dec-2002 millert

Add prototype for atoll(3). I must have forgotten to commit this bit
when I committed atoll(3).


# 1.21 25-Oct-2002 millert

NULL is now 0L so it is the same size as a pointer.
OK mickey@ and discussed with deraadt@


Revision tags: OPENBSD_3_2_BASE
# 1.20 29-Jun-2002 millert

Replace strtou?q() with the more standard strtou?ll(), using weak
aliases to fake up strtou?q(). espie@ OK.


Revision tags: OPENBSD_3_1_BASE
# 1.19 20-Feb-2002 millert

Revert local changes that snuck in to the last commit.


# 1.18 20-Feb-2002 millert

Some user header files may define an abs macro which will cause a
syntax error if the #define happens before stdlib.h is included.
If abs is #defined, #undef and issue a warning. This is similar
to what Tru64 UNIX does and is effectively the same as what happens
on Solaris (though on Solaris the real abs() is a macro).


# 1.17 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 04-Nov-2001 krw

Ghostscript port refused to build with 'printf' in the
__attribute__ statement. Using '__printf__' makes it happy.

ok millert@ miod@


# 1.14 01-Nov-2001 miod

Mention printf-like attributes for setproctitle().
millert@ espie@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.13 18-Jun-2001 millert

Add new cgetusedb() function to toggle reading of .db files in getcap(3).
Needed for cap_mkdb to really DRT when given several input files or
an output file with a different name from the input file.
cvs: ----------------------------------------------------------------------


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.12 03-Apr-2000 millert

Add srandomdev() from FreeBSD for use by sendmail and others.


# 1.11 27-Nov-1999 espie

In ANSI C++, wchar_t is a builtin. gcc 2.95.1 handles that correctly.
Redefining it as a typedef is an error, as it prevents overloading
on e.g., int/wchar_t separately.


Revision tags: OPENBSD_2_6_BASE
# 1.10 11-Jun-1999 espie

Define NULL to be __null for C++: better quality of implementation.
__null is a magic constant of integral type that converts to a null pointer
as should be, but warns for ambiguity when used to resolved an overload
between an integral type and a pointer type.


Revision tags: OPENBSD_2_5_BASE
# 1.9 25-Feb-1999 millert

constify getcap(3). This fixes a warning in libcurses and doesn't
really change the API since those parameters that was been constified
really are not modified by getcap(3) routines.


# 1.8 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 07-Feb-1998 millert

More XPG4.2 --
setstate takes a const parameter
don't ever spew to stderr, just return NULL


# 1.6 06-Feb-1998 deraadt

size_t n in initstate(); XPG


# 1.5 09-Dec-1997 deraadt

for XPG, do not use special typedef types


Revision tags: OPENBSD_2_2_BASE
# 1.4 21-Sep-1997 niklas

Well, as we are heading for a release people are encouraged to rebuild their
entire trees for testing anyway, I might as well do this intrusive touching
of include files now. Added openBSD tags.


Revision tags: OPENBSD_2_1_BASE
# 1.3 28-Dec-1996 dm

arc4random() number generator, for use with things like RPC xid's.


Revision tags: OPENBSD_2_0_BASE
# 1.2 30-Dec-1995 deraadt

abort() and exit() need __dead tags in stdlib.h; mike.long@analog.com;
netbsd pr#1845


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.76 10-May-2019 otto

Inroduce malloc_conceal() and calloc_conceal(). Similar to their
counterparts but return memory in pages marked MAP_CONCEAL and on
free() freezero() is actually called.


Revision tags: OPENBSD_6_5_BASE
# 1.75 21-Nov-2018 otto

Introducing malloc_usable_size() was a mistake. While some other
libs have it, it is a function that is considered harmful, so:

Delete malloc_usable_size(). It is a function that blurs the line
between malloc managed memory and application managed memory and
exposes some of the internal workings of malloc. If an application
relies on that, it is likely to break using another implementation
of malloc. If you want usable size x, just allocate x bytes. ok
deraadt@ and other devs


# 1.74 18-Nov-2018 otto

Implement malloc_usable_size(); ok millert@ deraadt@ and jmc@ for the man page


# 1.73 05-Nov-2018 otto

Implement C11's aligned_alloc(3). ok guenther@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.72 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.71 11-May-2017 tom

arc4random_buf should be bounded buffer, not bounded string

ok millert@


# 1.70 10-May-2017 millert

Add bounded attribute to freezero(). OK tom@


# 1.69 10-Apr-2017 otto

Introducing freezero(3) a version of free that guarantees the process
no longer has access to the content of a memmory object. It does
this by either clearing (if the object memory remains cached) or
by calling munmap(2). ok millert@, deraadt@, guenther@


Revision tags: OPENBSD_6_1_BASE
# 1.68 06-Mar-2017 otto

Introducing recallocarray(3), a blend of calloc(3) and reallocarray(3)
with the added feature that released memory is cleared. Much input from various
developers. ok deraadt@ tom@


# 1.67 20-Sep-2016 fcambus

Remove duplicated includes in stdlib.h and termios.h

OK guenther@


# 1.66 09-Sep-2016 millert

Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11. OK deraadt@ guenther@ kettenis@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.65 14-Jul-2015 millert

The first argument to devname(3) should be dev_t, not int.
The man page was already correct.


Revision tags: OPENBSD_5_7_BASE
# 1.64 08-Feb-2015 tedu

add restrict to strtol like functions. ok guenther


# 1.63 15-Jan-2015 tedu

we don't have an alloca() symbol anywhere in libc, don't prototype it.
instead, #define to __builtin_alloca. if that doesn't work, you're hosed.
from an old discussion about the perils of alloca. (don't use alloca!)


# 1.62 08-Dec-2014 deraadt

Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode. If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).

Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.

Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert


# 1.61 08-Dec-2014 tedu

header changes for recent libc changes:
add siphash
delete setkey, encrypt, cfree


# 1.60 31-Aug-2014 guenther

Add additional userland interfaces for setting close-on-exec on fds
when creating them: mkostemp(), mkostemps(), the 'e' mode letter for
fopen(), freopen(), fdopen(), and popen(). The close-on-exec flag will
be cleared by the action created by posix_spawn_file_actions_adddup2().

Also, add support for the C11 'x' mode letter for fopen() and freopen(),
setting O_EXCL when possibly creating files.

Note: this requires kernel support for pipe2() and dup3()!

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.59 09-Jul-2014 beck

Clean up after arc4random u_int32_t uint32_t change
ok jsing@


# 1.58 22-Apr-2014 tedu

change mallocarray to reallocarray. useful in a few more situations.
malloc can, as always, be emulated via realloc(NULL).
ok deraadt


# 1.57 21-Apr-2014 deraadt

Introducing: void *mallocarray(size_t nmemb, size_t size);
Like calloc(), except without the cleared-memory gaurantee
ok beck guenther, discussed for more than a year...


Revision tags: OPENBSD_5_5_BASE
# 1.56 28-Dec-2013 martynas

Annotate a few more bounded functions: realpath(3) needs a buffer
of size at least PATH_MAX. pread(2), pwrite(2) and readlinkat(2)
also take the buffer and the bound. OK theo.


# 1.55 13-Dec-2013 millert

Fix typo; 200809 not 20080 for __POSIX_VISIBLE. Noticed by jca@


# 1.54 22-Nov-2013 millert

The getopt() prototype and externs don't belong in stdlib.h. Berkeley
moved them to unistd.h to match POSIX in 1995 but we never did.
The exception to this is getsubopt() which POSIX says should be in
stdlib.h. The non-standard suboptarg extern remains in the BSD-only
section of stdlib.h. Neither getsubopt() nor suboptarg belong in
unistd.h or getopt.h. They were only there to allow us to protect
all the getopt() bits from being multiply defined. OK guenther@


# 1.53 21-Oct-2013 deraadt

Remove arc4random_stir() and arc4random_addrandom(), which none should
be using directly. Well, a few rare people cloned it upstream and it
will take a bit of time for them to learn.
ok various


Revision tags: OPENBSD_5_4_BASE
# 1.52 31-May-2013 ajacoutot

Add getprogname() and setprogname() to ease slackers^porters' work.
Man page adapted from FreeBSD and NetBSD.

Bump libc minor now (there will be more upcoming changes).

input from tedu@
get it in deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.51 03-Dec-2012 millert

Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),
grantpt() and unlockpt() using /dev/ptm. Man pages from FreeBSD.
OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@


Revision tags: OPENBSD_5_2_BASE
# 1.50 01-Jun-2012 guenther

Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),
and valloc() are not in the current version, while posix_memalign() mkstemp(),
and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'.

ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.49 03-Jul-2011 jsg

As pointed out by Richard Guenther our definition
of NULL was incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

ok miod@


# 1.48 06-Apr-2011 miod

Define NULL as a void * instead of a long integer, as required by Single Unix.
Kernel and bootblocks still use the old 0L value until all the NULL abuses
in the code are fixed.


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.47 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.46 03-Jun-2009 millert

Make putenv(), setenv() and unsetenv() standards compliant. The
standard explicitly disallows passing setenv a name with a '=' in
it but historic BSD behavior is to allow this but to ignore the '='
and anything after it.


Revision tags: OPENBSD_4_5_BASE
# 1.45 07-Sep-2008 martynas

- replace dtoa w/ David's gdtoa, version 2008-03-15
- provide proper dtoa locks
- use the real strtof implementation
- add strtold, __hdtoa, __hldtoa
- add %a/%A support
- don't lose precision in printf, don't round to double anymore
- implement extended-precision versions of libc functions: fpclassify,
isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is
fixed
- separate vax versions of strtof, and __hdtoa
- add complex math support. added functions: cacos, casin, catan,
ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp,
clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf,
casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf,
ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf,
cimagf, conjf, cprojf, crealf
- add fdim, fmax, fmin
- add log2. (adapted implementation e_log.c. could be more acruate
& faster, but it's good enough for now)
- remove wrappers & cruft in libm, supposed to work-around mistakes
in SVID, etc.; use ieee versions. fixes issues in python 2.6 for
djm@
- make _digittoint static
- proper definitions for i386, and amd64 in ieee.h
- sh, powerpc don't really have extended-precision
- add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h
for LDBL_*
- merge lead to frac for m{6,8}k, for gdtoa to work properly
- add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa
to use
- add EXT_IMPLICIT_NBIT definition, which indicates implicit
normalization bit
- add regression tests for libc: fpclassify and printf
- arith.h & gd_qnan.h definitions
- update ieee.h: hppa doesn't have quad-precision, hppa64 does
- add missing prototypes to gdtoaimp
- on 64-bit platforms make sure gdtoa doesn't use a long when it
really wants an int
- etc., what i may have forgotten...
- bump libm major, due to removed&changed symbols
- no libc bump, since this is riding on djm's libc major crank from
a day ago

discussed with / requested by / testing theo, sthen@, djm@, jsg@,
merdely@, jsing@, tedu@, brad@, jakemsr@, and others.
looks good to millert@
parts of the diff ok kettenis@

this commit does not include:
- man page changes


Revision tags: OPENBSD_4_4_BASE
# 1.44 24-Jun-2008 otto

remove recalloc; sloppy me; ok deraadt@


# 1.43 20-Jun-2008 ragge

Remove obsolete (and erroneous) #if statement that caused all compilers
except for gcc to get the wrong prototype. Ok millert@


# 1.42 13-Jun-2008 landry

Add strtof() to libc, some ports seem to like it. Currently it's a simple
call to strtod() with bounding check.
Discussed with pyr@ and otto@

ok otto@ deraadt@


# 1.41 16-Mar-2008 otto

diff from djm@ committed at his request:

introduce two new APIs for requesting strong random numbers:

arc4random_buf() - fill an arbitrary memory range with random numbers

arc4random_uniform() - return a uniformly distributed random number
below
a specified upper bound, avoiding the bias that comes from a naive
"arc4random() % upper_bound" construction.

these mirror similarly-named functions in the kernel;
lots of discussion deraadt@ mcbride@


Revision tags: OPENBSD_4_3_BASE
# 1.40 03-Sep-2007 millert

add recaloc(3)


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.39 17-Sep-2006 djm

add lldiv prototype; ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.38 31-Mar-2006 deraadt

after we changed mode_t to be an int, the devname() man page was
updated but the function itself never was; ok millert


Revision tags: OPENBSD_3_9_BASE
# 1.37 13-Jan-2006 millert

Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()


# 1.36 06-Jan-2006 millert

Adapt things to use __type_t instead of _BSD_TYPE_T_
Add new sys/_types.h header
Include machine/_types.h or sys/_types.h where applicable


# 1.35 13-Dec-2005 millert

First step in include files overhaul. Use __FOO_VISIBLE (as defined
in sys/cdefs.h) instead of _FOO_SOURCE. Also fix several namespace
pollution issues, including the byte order defines. OK deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.34 27-May-2005 millert

mktemp(3) et al. go in stdlib.h, not unistd.h. While there be more
explicit about mktemp(3) in the man page.


# 1.33 11-May-2005 espie

major abi changes:

* introduce the mbstate_t typedef.
impacts gnu libiconv, which has already been taken care of.

* Prepare for mb stuff to really exist, replace macro MB_CUR_MAX with
an external variable __mb_cur_max (impacts libX11 and various ports).

* use mbstate in all the mb <-> wchar functions with state.
* add a stub iswctype function allowing some ports to compile.

bash and gdiff are missing wcscoll, and need to be told there's no i18n
until this is fixed.

Discussed and matthieu, otto, millert, kettenis, deraadt.

Major libc bump


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.32 03-Aug-2004 millert

Update strtonum() protor


# 1.31 03-May-2004 tedu

strtonum prototype


# 1.30 03-May-2004 millert

Add _Exit(3) as per C99. Discussed with espie@ some time ago.


Revision tags: OPENBSD_3_5_BASE
# 1.29 21-Jan-2004 millert

Prototype llabs(3). Forgotten commit gathering bit rot in my tree...


Revision tags: OPENBSD_3_4_BASE
# 1.28 01-Aug-2003 avsm

add __bounded__ attributes for userland headers; enabled with -Wbounded
ok deraadt@


# 1.27 26-Jun-2003 avsm

backout the __bounded__ attributes for a while; requested by deraadt@


# 1.26 26-Jun-2003 avsm

Mark various standard library functions with the __bounded__ attribute.
You must have an up-to-date gcc for this!
deraadt@ ok


# 1.25 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.24 03-Dec-2002 millert

GNU-like getopt_long() from NetBSD with changes by me to support
getopt_long_only(). At some point this should replace the BSD
getopt(3) but we are not there yet.

While I am here add protection from the multiple getopt() definitions
due to conflicting standards.


# 1.23 02-Dec-2002 millert

Add ecvt(), fcvt() and gcvt() for standard compliance and legacy code.


# 1.22 02-Dec-2002 millert

Add prototype for atoll(3). I must have forgotten to commit this bit
when I committed atoll(3).


# 1.21 25-Oct-2002 millert

NULL is now 0L so it is the same size as a pointer.
OK mickey@ and discussed with deraadt@


Revision tags: OPENBSD_3_2_BASE
# 1.20 29-Jun-2002 millert

Replace strtou?q() with the more standard strtou?ll(), using weak
aliases to fake up strtou?q(). espie@ OK.


Revision tags: OPENBSD_3_1_BASE
# 1.19 20-Feb-2002 millert

Revert local changes that snuck in to the last commit.


# 1.18 20-Feb-2002 millert

Some user header files may define an abs macro which will cause a
syntax error if the #define happens before stdlib.h is included.
If abs is #defined, #undef and issue a warning. This is similar
to what Tru64 UNIX does and is effectively the same as what happens
on Solaris (though on Solaris the real abs() is a macro).


# 1.17 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 04-Nov-2001 krw

Ghostscript port refused to build with 'printf' in the
__attribute__ statement. Using '__printf__' makes it happy.

ok millert@ miod@


# 1.14 01-Nov-2001 miod

Mention printf-like attributes for setproctitle().
millert@ espie@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.13 18-Jun-2001 millert

Add new cgetusedb() function to toggle reading of .db files in getcap(3).
Needed for cap_mkdb to really DRT when given several input files or
an output file with a different name from the input file.
cvs: ----------------------------------------------------------------------


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.12 03-Apr-2000 millert

Add srandomdev() from FreeBSD for use by sendmail and others.


# 1.11 27-Nov-1999 espie

In ANSI C++, wchar_t is a builtin. gcc 2.95.1 handles that correctly.
Redefining it as a typedef is an error, as it prevents overloading
on e.g., int/wchar_t separately.


Revision tags: OPENBSD_2_6_BASE
# 1.10 11-Jun-1999 espie

Define NULL to be __null for C++: better quality of implementation.
__null is a magic constant of integral type that converts to a null pointer
as should be, but warns for ambiguity when used to resolved an overload
between an integral type and a pointer type.


Revision tags: OPENBSD_2_5_BASE
# 1.9 25-Feb-1999 millert

constify getcap(3). This fixes a warning in libcurses and doesn't
really change the API since those parameters that was been constified
really are not modified by getcap(3) routines.


# 1.8 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 07-Feb-1998 millert

More XPG4.2 --
setstate takes a const parameter
don't ever spew to stderr, just return NULL


# 1.6 06-Feb-1998 deraadt

size_t n in initstate(); XPG


# 1.5 09-Dec-1997 deraadt

for XPG, do not use special typedef types


Revision tags: OPENBSD_2_2_BASE
# 1.4 21-Sep-1997 niklas

Well, as we are heading for a release people are encouraged to rebuild their
entire trees for testing anyway, I might as well do this intrusive touching
of include files now. Added openBSD tags.


Revision tags: OPENBSD_2_1_BASE
# 1.3 28-Dec-1996 dm

arc4random() number generator, for use with things like RPC xid's.


Revision tags: OPENBSD_2_0_BASE
# 1.2 30-Dec-1995 deraadt

abort() and exit() need __dead tags in stdlib.h; mike.long@analog.com;
netbsd pr#1845


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.75 21-Nov-2018 otto

Introducing malloc_usable_size() was a mistake. While some other
libs have it, it is a function that is considered harmful, so:

Delete malloc_usable_size(). It is a function that blurs the line
between malloc managed memory and application managed memory and
exposes some of the internal workings of malloc. If an application
relies on that, it is likely to break using another implementation
of malloc. If you want usable size x, just allocate x bytes. ok
deraadt@ and other devs


# 1.74 18-Nov-2018 otto

Implement malloc_usable_size(); ok millert@ deraadt@ and jmc@ for the man page


# 1.73 05-Nov-2018 otto

Implement C11's aligned_alloc(3). ok guenther@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.72 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.71 11-May-2017 tom

arc4random_buf should be bounded buffer, not bounded string

ok millert@


# 1.70 10-May-2017 millert

Add bounded attribute to freezero(). OK tom@


# 1.69 10-Apr-2017 otto

Introducing freezero(3) a version of free that guarantees the process
no longer has access to the content of a memmory object. It does
this by either clearing (if the object memory remains cached) or
by calling munmap(2). ok millert@, deraadt@, guenther@


Revision tags: OPENBSD_6_1_BASE
# 1.68 06-Mar-2017 otto

Introducing recallocarray(3), a blend of calloc(3) and reallocarray(3)
with the added feature that released memory is cleared. Much input from various
developers. ok deraadt@ tom@


# 1.67 20-Sep-2016 fcambus

Remove duplicated includes in stdlib.h and termios.h

OK guenther@


# 1.66 09-Sep-2016 millert

Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11. OK deraadt@ guenther@ kettenis@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.65 14-Jul-2015 millert

The first argument to devname(3) should be dev_t, not int.
The man page was already correct.


Revision tags: OPENBSD_5_7_BASE
# 1.64 08-Feb-2015 tedu

add restrict to strtol like functions. ok guenther


# 1.63 15-Jan-2015 tedu

we don't have an alloca() symbol anywhere in libc, don't prototype it.
instead, #define to __builtin_alloca. if that doesn't work, you're hosed.
from an old discussion about the perils of alloca. (don't use alloca!)


# 1.62 08-Dec-2014 deraadt

Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode. If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).

Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.

Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert


# 1.61 08-Dec-2014 tedu

header changes for recent libc changes:
add siphash
delete setkey, encrypt, cfree


# 1.60 31-Aug-2014 guenther

Add additional userland interfaces for setting close-on-exec on fds
when creating them: mkostemp(), mkostemps(), the 'e' mode letter for
fopen(), freopen(), fdopen(), and popen(). The close-on-exec flag will
be cleared by the action created by posix_spawn_file_actions_adddup2().

Also, add support for the C11 'x' mode letter for fopen() and freopen(),
setting O_EXCL when possibly creating files.

Note: this requires kernel support for pipe2() and dup3()!

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.59 09-Jul-2014 beck

Clean up after arc4random u_int32_t uint32_t change
ok jsing@


# 1.58 22-Apr-2014 tedu

change mallocarray to reallocarray. useful in a few more situations.
malloc can, as always, be emulated via realloc(NULL).
ok deraadt


# 1.57 21-Apr-2014 deraadt

Introducing: void *mallocarray(size_t nmemb, size_t size);
Like calloc(), except without the cleared-memory gaurantee
ok beck guenther, discussed for more than a year...


Revision tags: OPENBSD_5_5_BASE
# 1.56 28-Dec-2013 martynas

Annotate a few more bounded functions: realpath(3) needs a buffer
of size at least PATH_MAX. pread(2), pwrite(2) and readlinkat(2)
also take the buffer and the bound. OK theo.


# 1.55 13-Dec-2013 millert

Fix typo; 200809 not 20080 for __POSIX_VISIBLE. Noticed by jca@


# 1.54 22-Nov-2013 millert

The getopt() prototype and externs don't belong in stdlib.h. Berkeley
moved them to unistd.h to match POSIX in 1995 but we never did.
The exception to this is getsubopt() which POSIX says should be in
stdlib.h. The non-standard suboptarg extern remains in the BSD-only
section of stdlib.h. Neither getsubopt() nor suboptarg belong in
unistd.h or getopt.h. They were only there to allow us to protect
all the getopt() bits from being multiply defined. OK guenther@


# 1.53 21-Oct-2013 deraadt

Remove arc4random_stir() and arc4random_addrandom(), which none should
be using directly. Well, a few rare people cloned it upstream and it
will take a bit of time for them to learn.
ok various


Revision tags: OPENBSD_5_4_BASE
# 1.52 31-May-2013 ajacoutot

Add getprogname() and setprogname() to ease slackers^porters' work.
Man page adapted from FreeBSD and NetBSD.

Bump libc minor now (there will be more upcoming changes).

input from tedu@
get it in deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.51 03-Dec-2012 millert

Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),
grantpt() and unlockpt() using /dev/ptm. Man pages from FreeBSD.
OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@


Revision tags: OPENBSD_5_2_BASE
# 1.50 01-Jun-2012 guenther

Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),
and valloc() are not in the current version, while posix_memalign() mkstemp(),
and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'.

ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.49 03-Jul-2011 jsg

As pointed out by Richard Guenther our definition
of NULL was incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

ok miod@


# 1.48 06-Apr-2011 miod

Define NULL as a void * instead of a long integer, as required by Single Unix.
Kernel and bootblocks still use the old 0L value until all the NULL abuses
in the code are fixed.


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.47 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.46 03-Jun-2009 millert

Make putenv(), setenv() and unsetenv() standards compliant. The
standard explicitly disallows passing setenv a name with a '=' in
it but historic BSD behavior is to allow this but to ignore the '='
and anything after it.


Revision tags: OPENBSD_4_5_BASE
# 1.45 07-Sep-2008 martynas

- replace dtoa w/ David's gdtoa, version 2008-03-15
- provide proper dtoa locks
- use the real strtof implementation
- add strtold, __hdtoa, __hldtoa
- add %a/%A support
- don't lose precision in printf, don't round to double anymore
- implement extended-precision versions of libc functions: fpclassify,
isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is
fixed
- separate vax versions of strtof, and __hdtoa
- add complex math support. added functions: cacos, casin, catan,
ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp,
clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf,
casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf,
ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf,
cimagf, conjf, cprojf, crealf
- add fdim, fmax, fmin
- add log2. (adapted implementation e_log.c. could be more acruate
& faster, but it's good enough for now)
- remove wrappers & cruft in libm, supposed to work-around mistakes
in SVID, etc.; use ieee versions. fixes issues in python 2.6 for
djm@
- make _digittoint static
- proper definitions for i386, and amd64 in ieee.h
- sh, powerpc don't really have extended-precision
- add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h
for LDBL_*
- merge lead to frac for m{6,8}k, for gdtoa to work properly
- add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa
to use
- add EXT_IMPLICIT_NBIT definition, which indicates implicit
normalization bit
- add regression tests for libc: fpclassify and printf
- arith.h & gd_qnan.h definitions
- update ieee.h: hppa doesn't have quad-precision, hppa64 does
- add missing prototypes to gdtoaimp
- on 64-bit platforms make sure gdtoa doesn't use a long when it
really wants an int
- etc., what i may have forgotten...
- bump libm major, due to removed&changed symbols
- no libc bump, since this is riding on djm's libc major crank from
a day ago

discussed with / requested by / testing theo, sthen@, djm@, jsg@,
merdely@, jsing@, tedu@, brad@, jakemsr@, and others.
looks good to millert@
parts of the diff ok kettenis@

this commit does not include:
- man page changes


Revision tags: OPENBSD_4_4_BASE
# 1.44 24-Jun-2008 otto

remove recalloc; sloppy me; ok deraadt@


# 1.43 20-Jun-2008 ragge

Remove obsolete (and erroneous) #if statement that caused all compilers
except for gcc to get the wrong prototype. Ok millert@


# 1.42 13-Jun-2008 landry

Add strtof() to libc, some ports seem to like it. Currently it's a simple
call to strtod() with bounding check.
Discussed with pyr@ and otto@

ok otto@ deraadt@


# 1.41 16-Mar-2008 otto

diff from djm@ committed at his request:

introduce two new APIs for requesting strong random numbers:

arc4random_buf() - fill an arbitrary memory range with random numbers

arc4random_uniform() - return a uniformly distributed random number
below
a specified upper bound, avoiding the bias that comes from a naive
"arc4random() % upper_bound" construction.

these mirror similarly-named functions in the kernel;
lots of discussion deraadt@ mcbride@


Revision tags: OPENBSD_4_3_BASE
# 1.40 03-Sep-2007 millert

add recaloc(3)


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.39 17-Sep-2006 djm

add lldiv prototype; ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.38 31-Mar-2006 deraadt

after we changed mode_t to be an int, the devname() man page was
updated but the function itself never was; ok millert


Revision tags: OPENBSD_3_9_BASE
# 1.37 13-Jan-2006 millert

Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()


# 1.36 06-Jan-2006 millert

Adapt things to use __type_t instead of _BSD_TYPE_T_
Add new sys/_types.h header
Include machine/_types.h or sys/_types.h where applicable


# 1.35 13-Dec-2005 millert

First step in include files overhaul. Use __FOO_VISIBLE (as defined
in sys/cdefs.h) instead of _FOO_SOURCE. Also fix several namespace
pollution issues, including the byte order defines. OK deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.34 27-May-2005 millert

mktemp(3) et al. go in stdlib.h, not unistd.h. While there be more
explicit about mktemp(3) in the man page.


# 1.33 11-May-2005 espie

major abi changes:

* introduce the mbstate_t typedef.
impacts gnu libiconv, which has already been taken care of.

* Prepare for mb stuff to really exist, replace macro MB_CUR_MAX with
an external variable __mb_cur_max (impacts libX11 and various ports).

* use mbstate in all the mb <-> wchar functions with state.
* add a stub iswctype function allowing some ports to compile.

bash and gdiff are missing wcscoll, and need to be told there's no i18n
until this is fixed.

Discussed and matthieu, otto, millert, kettenis, deraadt.

Major libc bump


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.32 03-Aug-2004 millert

Update strtonum() protor


# 1.31 03-May-2004 tedu

strtonum prototype


# 1.30 03-May-2004 millert

Add _Exit(3) as per C99. Discussed with espie@ some time ago.


Revision tags: OPENBSD_3_5_BASE
# 1.29 21-Jan-2004 millert

Prototype llabs(3). Forgotten commit gathering bit rot in my tree...


Revision tags: OPENBSD_3_4_BASE
# 1.28 01-Aug-2003 avsm

add __bounded__ attributes for userland headers; enabled with -Wbounded
ok deraadt@


# 1.27 26-Jun-2003 avsm

backout the __bounded__ attributes for a while; requested by deraadt@


# 1.26 26-Jun-2003 avsm

Mark various standard library functions with the __bounded__ attribute.
You must have an up-to-date gcc for this!
deraadt@ ok


# 1.25 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.24 03-Dec-2002 millert

GNU-like getopt_long() from NetBSD with changes by me to support
getopt_long_only(). At some point this should replace the BSD
getopt(3) but we are not there yet.

While I am here add protection from the multiple getopt() definitions
due to conflicting standards.


# 1.23 02-Dec-2002 millert

Add ecvt(), fcvt() and gcvt() for standard compliance and legacy code.


# 1.22 02-Dec-2002 millert

Add prototype for atoll(3). I must have forgotten to commit this bit
when I committed atoll(3).


# 1.21 25-Oct-2002 millert

NULL is now 0L so it is the same size as a pointer.
OK mickey@ and discussed with deraadt@


Revision tags: OPENBSD_3_2_BASE
# 1.20 29-Jun-2002 millert

Replace strtou?q() with the more standard strtou?ll(), using weak
aliases to fake up strtou?q(). espie@ OK.


Revision tags: OPENBSD_3_1_BASE
# 1.19 20-Feb-2002 millert

Revert local changes that snuck in to the last commit.


# 1.18 20-Feb-2002 millert

Some user header files may define an abs macro which will cause a
syntax error if the #define happens before stdlib.h is included.
If abs is #defined, #undef and issue a warning. This is similar
to what Tru64 UNIX does and is effectively the same as what happens
on Solaris (though on Solaris the real abs() is a macro).


# 1.17 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 04-Nov-2001 krw

Ghostscript port refused to build with 'printf' in the
__attribute__ statement. Using '__printf__' makes it happy.

ok millert@ miod@


# 1.14 01-Nov-2001 miod

Mention printf-like attributes for setproctitle().
millert@ espie@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.13 18-Jun-2001 millert

Add new cgetusedb() function to toggle reading of .db files in getcap(3).
Needed for cap_mkdb to really DRT when given several input files or
an output file with a different name from the input file.
cvs: ----------------------------------------------------------------------


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.12 03-Apr-2000 millert

Add srandomdev() from FreeBSD for use by sendmail and others.


# 1.11 27-Nov-1999 espie

In ANSI C++, wchar_t is a builtin. gcc 2.95.1 handles that correctly.
Redefining it as a typedef is an error, as it prevents overloading
on e.g., int/wchar_t separately.


Revision tags: OPENBSD_2_6_BASE
# 1.10 11-Jun-1999 espie

Define NULL to be __null for C++: better quality of implementation.
__null is a magic constant of integral type that converts to a null pointer
as should be, but warns for ambiguity when used to resolved an overload
between an integral type and a pointer type.


Revision tags: OPENBSD_2_5_BASE
# 1.9 25-Feb-1999 millert

constify getcap(3). This fixes a warning in libcurses and doesn't
really change the API since those parameters that was been constified
really are not modified by getcap(3) routines.


# 1.8 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 07-Feb-1998 millert

More XPG4.2 --
setstate takes a const parameter
don't ever spew to stderr, just return NULL


# 1.6 06-Feb-1998 deraadt

size_t n in initstate(); XPG


# 1.5 09-Dec-1997 deraadt

for XPG, do not use special typedef types


Revision tags: OPENBSD_2_2_BASE
# 1.4 21-Sep-1997 niklas

Well, as we are heading for a release people are encouraged to rebuild their
entire trees for testing anyway, I might as well do this intrusive touching
of include files now. Added openBSD tags.


Revision tags: OPENBSD_2_1_BASE
# 1.3 28-Dec-1996 dm

arc4random() number generator, for use with things like RPC xid's.


Revision tags: OPENBSD_2_0_BASE
# 1.2 30-Dec-1995 deraadt

abort() and exit() need __dead tags in stdlib.h; mike.long@analog.com;
netbsd pr#1845


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.74 18-Nov-2018 otto

Implement malloc_usable_size(); ok millert@ deraadt@ and jmc@ for the man page


# 1.73 05-Nov-2018 otto

Implement C11's aligned_alloc(3). ok guenther@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.72 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.71 11-May-2017 tom

arc4random_buf should be bounded buffer, not bounded string

ok millert@


# 1.70 10-May-2017 millert

Add bounded attribute to freezero(). OK tom@


# 1.69 10-Apr-2017 otto

Introducing freezero(3) a version of free that guarantees the process
no longer has access to the content of a memmory object. It does
this by either clearing (if the object memory remains cached) or
by calling munmap(2). ok millert@, deraadt@, guenther@


Revision tags: OPENBSD_6_1_BASE
# 1.68 06-Mar-2017 otto

Introducing recallocarray(3), a blend of calloc(3) and reallocarray(3)
with the added feature that released memory is cleared. Much input from various
developers. ok deraadt@ tom@


# 1.67 20-Sep-2016 fcambus

Remove duplicated includes in stdlib.h and termios.h

OK guenther@


# 1.66 09-Sep-2016 millert

Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11. OK deraadt@ guenther@ kettenis@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.65 14-Jul-2015 millert

The first argument to devname(3) should be dev_t, not int.
The man page was already correct.


Revision tags: OPENBSD_5_7_BASE
# 1.64 08-Feb-2015 tedu

add restrict to strtol like functions. ok guenther


# 1.63 15-Jan-2015 tedu

we don't have an alloca() symbol anywhere in libc, don't prototype it.
instead, #define to __builtin_alloca. if that doesn't work, you're hosed.
from an old discussion about the perils of alloca. (don't use alloca!)


# 1.62 08-Dec-2014 deraadt

Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode. If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).

Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.

Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert


# 1.61 08-Dec-2014 tedu

header changes for recent libc changes:
add siphash
delete setkey, encrypt, cfree


# 1.60 31-Aug-2014 guenther

Add additional userland interfaces for setting close-on-exec on fds
when creating them: mkostemp(), mkostemps(), the 'e' mode letter for
fopen(), freopen(), fdopen(), and popen(). The close-on-exec flag will
be cleared by the action created by posix_spawn_file_actions_adddup2().

Also, add support for the C11 'x' mode letter for fopen() and freopen(),
setting O_EXCL when possibly creating files.

Note: this requires kernel support for pipe2() and dup3()!

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.59 09-Jul-2014 beck

Clean up after arc4random u_int32_t uint32_t change
ok jsing@


# 1.58 22-Apr-2014 tedu

change mallocarray to reallocarray. useful in a few more situations.
malloc can, as always, be emulated via realloc(NULL).
ok deraadt


# 1.57 21-Apr-2014 deraadt

Introducing: void *mallocarray(size_t nmemb, size_t size);
Like calloc(), except without the cleared-memory gaurantee
ok beck guenther, discussed for more than a year...


Revision tags: OPENBSD_5_5_BASE
# 1.56 28-Dec-2013 martynas

Annotate a few more bounded functions: realpath(3) needs a buffer
of size at least PATH_MAX. pread(2), pwrite(2) and readlinkat(2)
also take the buffer and the bound. OK theo.


# 1.55 13-Dec-2013 millert

Fix typo; 200809 not 20080 for __POSIX_VISIBLE. Noticed by jca@


# 1.54 22-Nov-2013 millert

The getopt() prototype and externs don't belong in stdlib.h. Berkeley
moved them to unistd.h to match POSIX in 1995 but we never did.
The exception to this is getsubopt() which POSIX says should be in
stdlib.h. The non-standard suboptarg extern remains in the BSD-only
section of stdlib.h. Neither getsubopt() nor suboptarg belong in
unistd.h or getopt.h. They were only there to allow us to protect
all the getopt() bits from being multiply defined. OK guenther@


# 1.53 21-Oct-2013 deraadt

Remove arc4random_stir() and arc4random_addrandom(), which none should
be using directly. Well, a few rare people cloned it upstream and it
will take a bit of time for them to learn.
ok various


Revision tags: OPENBSD_5_4_BASE
# 1.52 31-May-2013 ajacoutot

Add getprogname() and setprogname() to ease slackers^porters' work.
Man page adapted from FreeBSD and NetBSD.

Bump libc minor now (there will be more upcoming changes).

input from tedu@
get it in deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.51 03-Dec-2012 millert

Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),
grantpt() and unlockpt() using /dev/ptm. Man pages from FreeBSD.
OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@


Revision tags: OPENBSD_5_2_BASE
# 1.50 01-Jun-2012 guenther

Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),
and valloc() are not in the current version, while posix_memalign() mkstemp(),
and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'.

ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.49 03-Jul-2011 jsg

As pointed out by Richard Guenther our definition
of NULL was incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

ok miod@


# 1.48 06-Apr-2011 miod

Define NULL as a void * instead of a long integer, as required by Single Unix.
Kernel and bootblocks still use the old 0L value until all the NULL abuses
in the code are fixed.


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.47 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.46 03-Jun-2009 millert

Make putenv(), setenv() and unsetenv() standards compliant. The
standard explicitly disallows passing setenv a name with a '=' in
it but historic BSD behavior is to allow this but to ignore the '='
and anything after it.


Revision tags: OPENBSD_4_5_BASE
# 1.45 07-Sep-2008 martynas

- replace dtoa w/ David's gdtoa, version 2008-03-15
- provide proper dtoa locks
- use the real strtof implementation
- add strtold, __hdtoa, __hldtoa
- add %a/%A support
- don't lose precision in printf, don't round to double anymore
- implement extended-precision versions of libc functions: fpclassify,
isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is
fixed
- separate vax versions of strtof, and __hdtoa
- add complex math support. added functions: cacos, casin, catan,
ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp,
clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf,
casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf,
ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf,
cimagf, conjf, cprojf, crealf
- add fdim, fmax, fmin
- add log2. (adapted implementation e_log.c. could be more acruate
& faster, but it's good enough for now)
- remove wrappers & cruft in libm, supposed to work-around mistakes
in SVID, etc.; use ieee versions. fixes issues in python 2.6 for
djm@
- make _digittoint static
- proper definitions for i386, and amd64 in ieee.h
- sh, powerpc don't really have extended-precision
- add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h
for LDBL_*
- merge lead to frac for m{6,8}k, for gdtoa to work properly
- add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa
to use
- add EXT_IMPLICIT_NBIT definition, which indicates implicit
normalization bit
- add regression tests for libc: fpclassify and printf
- arith.h & gd_qnan.h definitions
- update ieee.h: hppa doesn't have quad-precision, hppa64 does
- add missing prototypes to gdtoaimp
- on 64-bit platforms make sure gdtoa doesn't use a long when it
really wants an int
- etc., what i may have forgotten...
- bump libm major, due to removed&changed symbols
- no libc bump, since this is riding on djm's libc major crank from
a day ago

discussed with / requested by / testing theo, sthen@, djm@, jsg@,
merdely@, jsing@, tedu@, brad@, jakemsr@, and others.
looks good to millert@
parts of the diff ok kettenis@

this commit does not include:
- man page changes


Revision tags: OPENBSD_4_4_BASE
# 1.44 24-Jun-2008 otto

remove recalloc; sloppy me; ok deraadt@


# 1.43 20-Jun-2008 ragge

Remove obsolete (and erroneous) #if statement that caused all compilers
except for gcc to get the wrong prototype. Ok millert@


# 1.42 13-Jun-2008 landry

Add strtof() to libc, some ports seem to like it. Currently it's a simple
call to strtod() with bounding check.
Discussed with pyr@ and otto@

ok otto@ deraadt@


# 1.41 16-Mar-2008 otto

diff from djm@ committed at his request:

introduce two new APIs for requesting strong random numbers:

arc4random_buf() - fill an arbitrary memory range with random numbers

arc4random_uniform() - return a uniformly distributed random number
below
a specified upper bound, avoiding the bias that comes from a naive
"arc4random() % upper_bound" construction.

these mirror similarly-named functions in the kernel;
lots of discussion deraadt@ mcbride@


Revision tags: OPENBSD_4_3_BASE
# 1.40 03-Sep-2007 millert

add recaloc(3)


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.39 17-Sep-2006 djm

add lldiv prototype; ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.38 31-Mar-2006 deraadt

after we changed mode_t to be an int, the devname() man page was
updated but the function itself never was; ok millert


Revision tags: OPENBSD_3_9_BASE
# 1.37 13-Jan-2006 millert

Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()


# 1.36 06-Jan-2006 millert

Adapt things to use __type_t instead of _BSD_TYPE_T_
Add new sys/_types.h header
Include machine/_types.h or sys/_types.h where applicable


# 1.35 13-Dec-2005 millert

First step in include files overhaul. Use __FOO_VISIBLE (as defined
in sys/cdefs.h) instead of _FOO_SOURCE. Also fix several namespace
pollution issues, including the byte order defines. OK deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.34 27-May-2005 millert

mktemp(3) et al. go in stdlib.h, not unistd.h. While there be more
explicit about mktemp(3) in the man page.


# 1.33 11-May-2005 espie

major abi changes:

* introduce the mbstate_t typedef.
impacts gnu libiconv, which has already been taken care of.

* Prepare for mb stuff to really exist, replace macro MB_CUR_MAX with
an external variable __mb_cur_max (impacts libX11 and various ports).

* use mbstate in all the mb <-> wchar functions with state.
* add a stub iswctype function allowing some ports to compile.

bash and gdiff are missing wcscoll, and need to be told there's no i18n
until this is fixed.

Discussed and matthieu, otto, millert, kettenis, deraadt.

Major libc bump


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.32 03-Aug-2004 millert

Update strtonum() protor


# 1.31 03-May-2004 tedu

strtonum prototype


# 1.30 03-May-2004 millert

Add _Exit(3) as per C99. Discussed with espie@ some time ago.


Revision tags: OPENBSD_3_5_BASE
# 1.29 21-Jan-2004 millert

Prototype llabs(3). Forgotten commit gathering bit rot in my tree...


Revision tags: OPENBSD_3_4_BASE
# 1.28 01-Aug-2003 avsm

add __bounded__ attributes for userland headers; enabled with -Wbounded
ok deraadt@


# 1.27 26-Jun-2003 avsm

backout the __bounded__ attributes for a while; requested by deraadt@


# 1.26 26-Jun-2003 avsm

Mark various standard library functions with the __bounded__ attribute.
You must have an up-to-date gcc for this!
deraadt@ ok


# 1.25 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.24 03-Dec-2002 millert

GNU-like getopt_long() from NetBSD with changes by me to support
getopt_long_only(). At some point this should replace the BSD
getopt(3) but we are not there yet.

While I am here add protection from the multiple getopt() definitions
due to conflicting standards.


# 1.23 02-Dec-2002 millert

Add ecvt(), fcvt() and gcvt() for standard compliance and legacy code.


# 1.22 02-Dec-2002 millert

Add prototype for atoll(3). I must have forgotten to commit this bit
when I committed atoll(3).


# 1.21 25-Oct-2002 millert

NULL is now 0L so it is the same size as a pointer.
OK mickey@ and discussed with deraadt@


Revision tags: OPENBSD_3_2_BASE
# 1.20 29-Jun-2002 millert

Replace strtou?q() with the more standard strtou?ll(), using weak
aliases to fake up strtou?q(). espie@ OK.


Revision tags: OPENBSD_3_1_BASE
# 1.19 20-Feb-2002 millert

Revert local changes that snuck in to the last commit.


# 1.18 20-Feb-2002 millert

Some user header files may define an abs macro which will cause a
syntax error if the #define happens before stdlib.h is included.
If abs is #defined, #undef and issue a warning. This is similar
to what Tru64 UNIX does and is effectively the same as what happens
on Solaris (though on Solaris the real abs() is a macro).


# 1.17 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 04-Nov-2001 krw

Ghostscript port refused to build with 'printf' in the
__attribute__ statement. Using '__printf__' makes it happy.

ok millert@ miod@


# 1.14 01-Nov-2001 miod

Mention printf-like attributes for setproctitle().
millert@ espie@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.13 18-Jun-2001 millert

Add new cgetusedb() function to toggle reading of .db files in getcap(3).
Needed for cap_mkdb to really DRT when given several input files or
an output file with a different name from the input file.
cvs: ----------------------------------------------------------------------


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.12 03-Apr-2000 millert

Add srandomdev() from FreeBSD for use by sendmail and others.


# 1.11 27-Nov-1999 espie

In ANSI C++, wchar_t is a builtin. gcc 2.95.1 handles that correctly.
Redefining it as a typedef is an error, as it prevents overloading
on e.g., int/wchar_t separately.


Revision tags: OPENBSD_2_6_BASE
# 1.10 11-Jun-1999 espie

Define NULL to be __null for C++: better quality of implementation.
__null is a magic constant of integral type that converts to a null pointer
as should be, but warns for ambiguity when used to resolved an overload
between an integral type and a pointer type.


Revision tags: OPENBSD_2_5_BASE
# 1.9 25-Feb-1999 millert

constify getcap(3). This fixes a warning in libcurses and doesn't
really change the API since those parameters that was been constified
really are not modified by getcap(3) routines.


# 1.8 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 07-Feb-1998 millert

More XPG4.2 --
setstate takes a const parameter
don't ever spew to stderr, just return NULL


# 1.6 06-Feb-1998 deraadt

size_t n in initstate(); XPG


# 1.5 09-Dec-1997 deraadt

for XPG, do not use special typedef types


Revision tags: OPENBSD_2_2_BASE
# 1.4 21-Sep-1997 niklas

Well, as we are heading for a release people are encouraged to rebuild their
entire trees for testing anyway, I might as well do this intrusive touching
of include files now. Added openBSD tags.


Revision tags: OPENBSD_2_1_BASE
# 1.3 28-Dec-1996 dm

arc4random() number generator, for use with things like RPC xid's.


Revision tags: OPENBSD_2_0_BASE
# 1.2 30-Dec-1995 deraadt

abort() and exit() need __dead tags in stdlib.h; mike.long@analog.com;
netbsd pr#1845


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.73 05-Nov-2018 otto

Implement C11's aligned_alloc(3). ok guenther@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.72 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.71 11-May-2017 tom

arc4random_buf should be bounded buffer, not bounded string

ok millert@


# 1.70 10-May-2017 millert

Add bounded attribute to freezero(). OK tom@


# 1.69 10-Apr-2017 otto

Introducing freezero(3) a version of free that guarantees the process
no longer has access to the content of a memmory object. It does
this by either clearing (if the object memory remains cached) or
by calling munmap(2). ok millert@, deraadt@, guenther@


Revision tags: OPENBSD_6_1_BASE
# 1.68 06-Mar-2017 otto

Introducing recallocarray(3), a blend of calloc(3) and reallocarray(3)
with the added feature that released memory is cleared. Much input from various
developers. ok deraadt@ tom@


# 1.67 20-Sep-2016 fcambus

Remove duplicated includes in stdlib.h and termios.h

OK guenther@


# 1.66 09-Sep-2016 millert

Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11. OK deraadt@ guenther@ kettenis@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.65 14-Jul-2015 millert

The first argument to devname(3) should be dev_t, not int.
The man page was already correct.


Revision tags: OPENBSD_5_7_BASE
# 1.64 08-Feb-2015 tedu

add restrict to strtol like functions. ok guenther


# 1.63 15-Jan-2015 tedu

we don't have an alloca() symbol anywhere in libc, don't prototype it.
instead, #define to __builtin_alloca. if that doesn't work, you're hosed.
from an old discussion about the perils of alloca. (don't use alloca!)


# 1.62 08-Dec-2014 deraadt

Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode. If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).

Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.

Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert


# 1.61 08-Dec-2014 tedu

header changes for recent libc changes:
add siphash
delete setkey, encrypt, cfree


# 1.60 31-Aug-2014 guenther

Add additional userland interfaces for setting close-on-exec on fds
when creating them: mkostemp(), mkostemps(), the 'e' mode letter for
fopen(), freopen(), fdopen(), and popen(). The close-on-exec flag will
be cleared by the action created by posix_spawn_file_actions_adddup2().

Also, add support for the C11 'x' mode letter for fopen() and freopen(),
setting O_EXCL when possibly creating files.

Note: this requires kernel support for pipe2() and dup3()!

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.59 09-Jul-2014 beck

Clean up after arc4random u_int32_t uint32_t change
ok jsing@


# 1.58 22-Apr-2014 tedu

change mallocarray to reallocarray. useful in a few more situations.
malloc can, as always, be emulated via realloc(NULL).
ok deraadt


# 1.57 21-Apr-2014 deraadt

Introducing: void *mallocarray(size_t nmemb, size_t size);
Like calloc(), except without the cleared-memory gaurantee
ok beck guenther, discussed for more than a year...


Revision tags: OPENBSD_5_5_BASE
# 1.56 28-Dec-2013 martynas

Annotate a few more bounded functions: realpath(3) needs a buffer
of size at least PATH_MAX. pread(2), pwrite(2) and readlinkat(2)
also take the buffer and the bound. OK theo.


# 1.55 13-Dec-2013 millert

Fix typo; 200809 not 20080 for __POSIX_VISIBLE. Noticed by jca@


# 1.54 22-Nov-2013 millert

The getopt() prototype and externs don't belong in stdlib.h. Berkeley
moved them to unistd.h to match POSIX in 1995 but we never did.
The exception to this is getsubopt() which POSIX says should be in
stdlib.h. The non-standard suboptarg extern remains in the BSD-only
section of stdlib.h. Neither getsubopt() nor suboptarg belong in
unistd.h or getopt.h. They were only there to allow us to protect
all the getopt() bits from being multiply defined. OK guenther@


# 1.53 21-Oct-2013 deraadt

Remove arc4random_stir() and arc4random_addrandom(), which none should
be using directly. Well, a few rare people cloned it upstream and it
will take a bit of time for them to learn.
ok various


Revision tags: OPENBSD_5_4_BASE
# 1.52 31-May-2013 ajacoutot

Add getprogname() and setprogname() to ease slackers^porters' work.
Man page adapted from FreeBSD and NetBSD.

Bump libc minor now (there will be more upcoming changes).

input from tedu@
get it in deraadt@


Revision tags: OPENBSD_5_3_BASE
# 1.51 03-Dec-2012 millert

Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),
grantpt() and unlockpt() using /dev/ptm. Man pages from FreeBSD.
OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@


Revision tags: OPENBSD_5_2_BASE
# 1.50 01-Jun-2012 guenther

Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),
and valloc() are not in the current version, while posix_memalign() mkstemp(),
and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'.

ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.49 03-Jul-2011 jsg

As pointed out by Richard Guenther our definition
of NULL was incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

ok miod@


# 1.48 06-Apr-2011 miod

Define NULL as a void * instead of a long integer, as required by Single Unix.
Kernel and bootblocks still use the old 0L value until all the NULL abuses
in the code are fixed.


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.47 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.46 03-Jun-2009 millert

Make putenv(), setenv() and unsetenv() standards compliant. The
standard explicitly disallows passing setenv a name with a '=' in
it but historic BSD behavior is to allow this but to ignore the '='
and anything after it.


Revision tags: OPENBSD_4_5_BASE
# 1.45 07-Sep-2008 martynas

- replace dtoa w/ David's gdtoa, version 2008-03-15
- provide proper dtoa locks
- use the real strtof implementation
- add strtold, __hdtoa, __hldtoa
- add %a/%A support
- don't lose precision in printf, don't round to double anymore
- implement extended-precision versions of libc functions: fpclassify,
isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is
fixed
- separate vax versions of strtof, and __hdtoa
- add complex math support. added functions: cacos, casin, catan,
ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp,
clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf,
casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf,
ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf,
cimagf, conjf, cprojf, crealf
- add fdim, fmax, fmin
- add log2. (adapted implementation e_log.c. could be more acruate
& faster, but it's good enough for now)
- remove wrappers & cruft in libm, supposed to work-around mistakes
in SVID, etc.; use ieee versions. fixes issues in python 2.6 for
djm@
- make _digittoint static
- proper definitions for i386, and amd64 in ieee.h
- sh, powerpc don't really have extended-precision
- add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h
for LDBL_*
- merge lead to frac for m{6,8}k, for gdtoa to work properly
- add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa
to use
- add EXT_IMPLICIT_NBIT definition, which indicates implicit
normalization bit
- add regression tests for libc: fpclassify and printf
- arith.h & gd_qnan.h definitions
- update ieee.h: hppa doesn't have quad-precision, hppa64 does
- add missing prototypes to gdtoaimp
- on 64-bit platforms make sure gdtoa doesn't use a long when it
really wants an int
- etc., what i may have forgotten...
- bump libm major, due to removed&changed symbols
- no libc bump, since this is riding on djm's libc major crank from
a day ago

discussed with / requested by / testing theo, sthen@, djm@, jsg@,
merdely@, jsing@, tedu@, brad@, jakemsr@, and others.
looks good to millert@
parts of the diff ok kettenis@

this commit does not include:
- man page changes


Revision tags: OPENBSD_4_4_BASE
# 1.44 24-Jun-2008 otto

remove recalloc; sloppy me; ok deraadt@


# 1.43 20-Jun-2008 ragge

Remove obsolete (and erroneous) #if statement that caused all compilers
except for gcc to get the wrong prototype. Ok millert@


# 1.42 13-Jun-2008 landry

Add strtof() to libc, some ports seem to like it. Currently it's a simple
call to strtod() with bounding check.
Discussed with pyr@ and otto@

ok otto@ deraadt@


# 1.41 16-Mar-2008 otto

diff from djm@ committed at his request:

introduce two new APIs for requesting strong random numbers:

arc4random_buf() - fill an arbitrary memory range with random numbers

arc4random_uniform() - return a uniformly distributed random number
below
a specified upper bound, avoiding the bias that comes from a naive
"arc4random() % upper_bound" construction.

these mirror similarly-named functions in the kernel;
lots of discussion deraadt@ mcbride@


Revision tags: OPENBSD_4_3_BASE
# 1.40 03-Sep-2007 millert

add recaloc(3)


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.39 17-Sep-2006 djm

add lldiv prototype; ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.38 31-Mar-2006 deraadt

after we changed mode_t to be an int, the devname() man page was
updated but the function itself never was; ok millert


Revision tags: OPENBSD_3_9_BASE
# 1.37 13-Jan-2006 millert

Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()


# 1.36 06-Jan-2006 millert

Adapt things to use __type_t instead of _BSD_TYPE_T_
Add new sys/_types.h header
Include machine/_types.h or sys/_types.h where applicable


# 1.35 13-Dec-2005 millert

First step in include files overhaul. Use __FOO_VISIBLE (as defined
in sys/cdefs.h) instead of _FOO_SOURCE. Also fix several namespace
pollution issues, including the byte order defines. OK deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.34 27-May-2005 millert

mktemp(3) et al. go in stdlib.h, not unistd.h. While there be more
explicit about mktemp(3) in the man page.


# 1.33 11-May-2005 espie

major abi changes:

* introduce the mbstate_t typedef.
impacts gnu libiconv, which has already been taken care of.

* Prepare for mb stuff to really exist, replace macro MB_CUR_MAX with
an external variable __mb_cur_max (impacts libX11 and various ports).

* use mbstate in all the mb <-> wchar functions with state.
* add a stub iswctype function allowing some ports to compile.

bash and gdiff are missing wcscoll, and need to be told there's no i18n
until this is fixed.

Discussed and matthieu, otto, millert, kettenis, deraadt.

Major libc bump


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.32 03-Aug-2004 millert

Update strtonum() protor


# 1.31 03-May-2004 tedu

strtonum prototype


# 1.30 03-May-2004 millert

Add _Exit(3) as per C99. Discussed with espie@ some time ago.


Revision tags: OPENBSD_3_5_BASE
# 1.29 21-Jan-2004 millert

Prototype llabs(3). Forgotten commit gathering bit rot in my tree...


Revision tags: OPENBSD_3_4_BASE
# 1.28 01-Aug-2003 avsm

add __bounded__ attributes for userland headers; enabled with -Wbounded
ok deraadt@


# 1.27 26-Jun-2003 avsm

backout the __bounded__ attributes for a while; requested by deraadt@


# 1.26 26-Jun-2003 avsm

Mark various standard library functions with the __bounded__ attribute.
You must have an up-to-date gcc for this!
deraadt@ ok


# 1.25 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.24 03-Dec-2002 millert

GNU-like getopt_long() from NetBSD with changes by me to support
getopt_long_only(). At some point this should replace the BSD
getopt(3) but we are not there yet.

While I am here add protection from the multiple getopt() definitions
due to conflicting standards.


# 1.23 02-Dec-2002 millert

Add ecvt(), fcvt() and gcvt() for standard compliance and legacy code.


# 1.22 02-Dec-2002 millert

Add prototype for atoll(3). I must have forgotten to commit this bit
when I committed atoll(3).


# 1.21 25-Oct-2002 millert

NULL is now 0L so it is the same size as a pointer.
OK mickey@ and discussed with deraadt@


Revision tags: OPENBSD_3_2_BASE
# 1.20 29-Jun-2002 millert

Replace strtou?q() with the more standard strtou?ll(), using weak
aliases to fake up strtou?q(). espie@ OK.


Revision tags: OPENBSD_3_1_BASE
# 1.19 20-Feb-2002 millert

Revert local changes that snuck in to the last commit.


# 1.18 20-Feb-2002 millert

Some user header files may define an abs macro which will cause a
syntax error if the #define happens before stdlib.h is included.
If abs is #defined, #undef and issue a warning. This is similar
to what Tru64 UNIX does and is effectively the same as what happens
on Solaris (though on Solaris the real abs() is a macro).


# 1.17 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 04-Nov-2001 krw

Ghostscript port refused to build with 'printf' in the
__attribute__ statement. Using '__printf__' makes it happy.

ok millert@ miod@


# 1.14 01-Nov-2001 miod

Mention printf-like attributes for setproctitle().
millert@ espie@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.13 18-Jun-2001 millert

Add new cgetusedb() function to toggle reading of .db files in getcap(3).
Needed for cap_mkdb to really DRT when given several input files or
an output file with a different name from the input file.
cvs: ----------------------------------------------------------------------


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.12 03-Apr-2000 millert

Add srandomdev() from FreeBSD for use by sendmail and others.


# 1.11 27-Nov-1999 espie

In ANSI C++, wchar_t is a builtin. gcc 2.95.1 handles that correctly.
Redefining it as a typedef is an error, as it prevents overloading
on e.g., int/wchar_t separately.


Revision tags: OPENBSD_2_6_BASE
# 1.10 11-Jun-1999 espie

Define NULL to be __null for C++: better quality of implementation.
__null is a magic constant of integral type that converts to a null pointer
as should be, but warns for ambiguity when used to resolved an overload
between an integral type and a pointer type.


Revision tags: OPENBSD_2_5_BASE
# 1.9 25-Feb-1999 millert

constify getcap(3). This fixes a warning in libcurses and doesn't
really change the API since those parameters that was been constified
really are not modified by getcap(3) routines.


# 1.8 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 07-Feb-1998 millert

More XPG4.2 --
setstate takes a const parameter
don't ever spew to stderr, just return NULL


# 1.6 06-Feb-1998 deraadt

size_t n in initstate(); XPG


# 1.5 09-Dec-1997 deraadt

for XPG, do not use special typedef types


Revision tags: OPENBSD_2_2_BASE
# 1.4 21-Sep-1997 niklas

Well, as we are heading for a release people are encouraged to rebuild their
entire trees for testing anyway, I might as well do this intrusive touching
of include files now. Added openBSD tags.


Revision tags: OPENBSD_2_1_BASE
# 1.3 28-Dec-1996 dm

arc4random() number generator, for use with things like RPC xid's.


Revision tags: OPENBSD_2_0_BASE
# 1.2 30-Dec-1995 deraadt

abort() and exit() need __dead tags in stdlib.h; mike.long@analog.com;
netbsd pr#1845


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision