summaryrefslogtreecommitdiffstats
path: root/include/stdlib.h
AgeCommit message (Collapse)AuthorFilesLines
2019-05-10Inroduce malloc_conceal() and calloc_conceal(). Similar to theirotto1-1/+3
counterparts but return memory in pages marked MAP_CONCEAL and on free() freezero() is actually called.
2018-11-21Introducing malloc_usable_size() was a mistake. While some otherotto1-2/+1
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
2018-11-18Implement malloc_usable_size(); ok millert@ deraadt@ and jmc@ for the man pageotto1-1/+2
2018-11-05Implement C11's aligned_alloc(3). ok guenther@otto1-1/+6
2017-09-05New POSIX xlocale implementation written from scratch.schwarze1-4/+3
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.
2017-05-11arc4random_buf should be bounded buffer, not bounded stringtom1-2/+2
ok millert@
2017-05-10Add bounded attribute to freezero(). OK tom@millert1-2/+3
2017-04-10Introducing freezero(3) a version of free that guarantees the processotto1-1/+2
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@
2017-03-06Introducing recallocarray(3), a blend of calloc(3) and reallocarray(3)otto1-1/+2
with the added feature that released memory is cleared. Much input from various developers. ok deraadt@ tom@
2016-09-20Remove duplicated includes in stdlib.h and termios.hfcambus1-3/+1
OK guenther@
2016-09-09Move the 10 (!) defintions of NULL to their own mini header file andmillert1-12/+2
update the NULL definition for C++11. OK deraadt@ guenther@ kettenis@
2015-07-14The first argument to devname(3) should be dev_t, not int.millert1-2/+2
The man page was already correct.
2015-02-08add restrict to strtol like functions. ok guenthertedu1-10/+10
2015-01-15we don't have an alloca() symbol anywhere in libc, don't prototype it.tedu1-2/+2
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!)
2014-12-08Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()deraadt1-1/+6
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
2014-12-08header changes for recent libc changes:tedu1-5/+1
add siphash delete setkey, encrypt, cfree
2014-08-31Add additional userland interfaces for setting close-on-exec on fdsguenther1-1/+9
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@
2014-07-09Clean up after arc4random u_int32_t uint32_t changebeck1-3/+3
ok jsing@
2014-04-22change mallocarray to reallocarray. useful in a few more situations.tedu1-2/+2
malloc can, as always, be emulated via realloc(NULL). ok deraadt
2014-04-21Introducing: void *mallocarray(size_t nmemb, size_t size);deraadt1-1/+4
Like calloc(), except without the cleared-memory gaurantee ok beck guenther, discussed for more than a year...
2013-12-28Annotate a few more bounded functions: realpath(3) needs a buffermartynas1-2/+3
of size at least PATH_MAX. pread(2), pwrite(2) and readlinkat(2) also take the buffer and the bound. OK theo.
2013-12-13Fix typo; 200809 not 20080 for __POSIX_VISIBLE. Noticed by jca@millert1-2/+2
2013-11-22The getopt() prototype and externs don't belong in stdlib.h. Berkeleymillert1-8/+5
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@
2013-10-21Remove arc4random_stir() and arc4random_addrandom(), which none shouldderaadt1-4/+1
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
2013-05-31Add getprogname() and setprogname() to ease slackers^porters' work.ajacoutot1-1/+5
Man page adapted from FreeBSD and NetBSD. Bump libc minor now (there will be more upcoming changes). input from tedu@ get it in deraadt@
2012-12-03Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),millert1-1/+9
grantpt() and unlockpt() using /dev/ptm. Man pages from FreeBSD. OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@
2012-06-01Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),guenther1-14/+37
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@
2011-07-03As pointed out by Richard Guenther our definitionjsg1-1/+3
of NULL was incorrect for c++ compilers that aren't gcc (or pretend to be gcc like clang). ok miod@
2011-04-06Define NULL as a void * instead of a long integer, as required by Single Unix.miod1-2/+2
Kernel and bootblocks still use the old 0L value until all the NULL abuses in the code are fixed.
2010-05-18add posix_madvise, posix_memalign, strndup, and strnlen. mostly fromtedu1-1/+2
brad and millert, with hints from guenther, jmc, and otto I think. ok previous.
2009-06-03Make putenv(), setenv() and unsetenv() standards compliant. Themillert1-3/+3
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.
2008-09-07- replace dtoa w/ David's gdtoa, version 2008-03-15martynas1-1/+3
- 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
2008-06-24remove recalloc; sloppy me; ok deraadt@otto1-2/+1
2008-06-20Remove obsolete (and erroneous) #if statement that caused all compilersragge1-6/+2
except for gcc to get the wrong prototype. Ok millert@
2008-06-13Add strtof() to libc, some ports seem to like it. Currently it's a simplelandry1-1/+2
call to strtod() with bounding check. Discussed with pyr@ and otto@ ok otto@ deraadt@
2008-03-16diff from djm@ committed at his request:otto1-1/+5
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@
2007-09-03add recaloc(3)millert1-1/+2
2006-09-17add lldiv prototype; ok deraadt@djm1-1/+3
2006-03-31after we changed mode_t to be an int, the devname() man page wasderaadt1-2/+2
updated but the function itself never was; ok millert
2006-01-13Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax()millert1-2/+9
2006-01-06Adapt things to use __type_t instead of _BSD_TYPE_T_millert1-11/+9
Add new sys/_types.h header Include machine/_types.h or sys/_types.h where applicable
2005-12-13First step in include files overhaul. Use __FOO_VISIBLE (as definedmillert1-45/+78
in sys/cdefs.h) instead of _FOO_SOURCE. Also fix several namespace pollution issues, including the byte order defines. OK deraadt@
2005-05-27mktemp(3) et al. go in stdlib.h, not unistd.h. While there be moremillert1-1/+5
explicit about mktemp(3) in the man page.
2005-05-11major abi changes:espie1-2/+3
* 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
2004-08-03Update strtonum() protormillert1-3/+3
2004-05-03strtonum prototypetedu1-1/+3
2004-05-03Add _Exit(3) as per C99. Discussed with espie@ some time ago.millert1-1/+2
2004-01-21Prototype llabs(3). Forgotten commit gathering bit rot in my tree...millert1-1/+3
2003-08-01add __bounded__ attributes for userland headers; enabled with -Wboundedavsm1-3/+5
ok deraadt@
2003-06-26backout the __bounded__ attributes for a while; requested by deraadt@avsm1-5/+3