summaryrefslogtreecommitdiffstats
path: root/include/stdlib.h
Commit message (Collapse)AuthorAgeFilesLines
* For C++, expose long long types and functions (lldiv_t, llabs, lldiv,dim2016-03-231-1/+1
| | | | | | | etc) in stdlib.h. These will be needed for newer versions of libc++, which uses them for defining overloaded versions of abs() and div(). MFC after: 1 week
* Make use of GCC alloc_align attributepfg2015-05-151-2/+3
| | | | | | | | | | This lets the compiler know about the alignment of pointers returned by aligned_alloc(3), posix_memalign(3). and contigmalloc(9) Currently this is only supported in recent gcc but we are ready to use it if clang implements it. Relnotes: yes
* No need for result_use_check attribute in reallocf(3).pfg2015-05-011-1/+1
|
* Move reallocarray definition to the _BSD_VISIBLE blockbapt2015-05-011-3/+2
| | | | | | Add the required __alloc_size attributes Requested by: pfg
* Import reallocarray(3) from OpenBSDbapt2015-05-011-0/+3
| | | | | | | | | Add a manpage for it, assign the copyright to the OpenBSD project on it since it is mostly copy/paste from OpenBSD manpage. style(9) fixes Differential Revision: https://reviews.freebsd.org/D2420 Reviewed by: kib
* Make use of gcc attributes in some standard include headers.pfg2015-04-061-6/+8
| | | | | | | | | | | | | | | | | | | The `nonnull' attribute specifies that some function parameters should be non-null pointers. This is very useful as it helps the compiler generate warnings on suspicious code and can also enable some small optimizations. Also start using 'alloc_size' attribute in the allocator functions. This is an initial step to better integrate our libc with the compiler: these attributes are fully supported by clang and they are also useful for the static analyzer. Note that due to some bogus internal procedure in the way gcc ports are built they may require updating if they were built before r280801. Relnotes: yes Hinted by: Android's bionic libc Differential Revision: https://reviews.freebsd.org/D2107
* Clean sparse spaces.pfg2015-03-251-2/+2
|
* Add bsearch_b to the libc map and the stdlib header.pfg2014-09-011-7/+7
| | | | | | | | | | | | bsearch_b is the Apple blocks enabled version of bsearch(3). This was added to libc in Revision 264042 but the commit missed the declaration required to make use of it. While here move some other block-related functions to the BSD_VISIBLE block as these are non-standard. Phabric: D638 Reviewed by: theraven, wollman
* Add support for some block functions that come from OS X. These aretheraven2014-04-021-0/+13
| | | | | | | intended to build with any C compiler. Reviewed by: pfg MFC after: 3 weeks
* Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4tijl2014-04-011-1/+1
| | | | | | -fms-extensions. MFC after: 2 weeks
* Add mkostemp() and mkostemps().jilles2013-08-091-0/+2
| | | | | These are like mkstemp() and mkstemps() but allow passing open(2) flags like O_CLOEXEC.
* stdlib.h: Add correct POSIX version for POSIX extensions to C.jilles2013-07-051-6/+8
|
* 1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,ache2013-07-031-1/+1
| | | | | | | | | | | | | | | | but ACM formula we use have internal state (and return value) in the [1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached because it is off by one, zero is not reached too. Correct both RAND_MAX and rand(3) return value, shifting last one to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new RAND_MAX)] range. 2) Add a checks for not overflowing on too big seeds. It may happens on the machines, where sizeof(unsigned int) > 32 bits. Reviewed by: bde [1] MFC after: 2 weeks
* Import jemalloc 9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa (dev branch,jasone2012-04-171-4/+3
| | | | | | | | prior to 3.0.0 release) as contrib/jemalloc, and integrate it into libc. The code being imported by this commit diverged from lib/libc/stdlib/malloc.c in March 2010, which means that a portion of the jemalloc 1.0.0 ChangeLog entries are relevant, as are the entries for all subsequent releases.
* Correctly expose xlocale functions if people include the headers in the wrongtheraven2012-03-281-0/+3
| | | | | | order (as some ports apparently do). Approved by: dim (mentor)
* Expose some C11 stuff that is also C++11 stuff in C++11 mode.theraven2012-03-141-1/+1
| | | | Approved by: dim (mentor)
* Add aligned_alloc(3).ed2012-01-091-0/+1
| | | | | | | | | The C11 folks reinvented the wheel by introducing an aligned version of malloc(3) called aligned_alloc(3), instead of posix_memalign(3). Instead of returning the allocation by reference, it returns the address, just like malloc(3). Reviewed by: jasone@
* Fix spelling of C11 and sort functions by name.ed2012-01-081-2/+2
|
* Improve C11 bits in <stdlib.h>:ed2011-12-261-5/+5
| | | | | | | - Add missing semicolon to quick_exit(), - Remove `func' parameter name from at_quick_exit(), - Fix indentation. - Compare against 2011 value.
* Replace __const by const in all non-contributed source code.ed2011-12-131-1/+1
| | | | | | As C1X is close to being released, there is no need to wrap around a feature that is already part of C90. Most of these files already use `const' in different placed as well.
* As per das@'s suggestion, s/__noreturn/_Noreturn/, since the latter is antheraven2011-12-071-4/+4
| | | | | | | | identifier reserved for the implementation in C99 and earlier so there is no sensible reason for introducing yet another reserved identifier when we could just use the one C1x uses. Approved by: brooks (mentor)
* Implement quick_exit() / at_quick_exit() from C++11 / C1x. Also add atheraven2011-12-071-3/+11
| | | | | | | | | | | | | | | | __noreturn macro and modify the other exiting functions to use it. The __noreturn macro, unlike __dead2, must be used BEFORE the function. This is in line with the C and C++ specifications that place _Noreturn (c1x) and [[noreturn]] (C++11) in front of the functions. As with __dead2, this macro falls back to using the GCC attribute. Unfortunately, clang currently sets the same value for the C version macro in C99 and C1x modes, so these functions are hidden by default. At some point before 10.0, I need to go through the headers and clean up the C1x / C++11 visibility. Reviewed by: brooks (mentor)
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds atheraven2011-11-201-2/+3
| | | | | | | | | | | | load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor)
* Move realpath(3) prototype to a POSIX section.kib2010-04-211-1/+1
| | | | | Noted by: bde MFC after: 2 weeks
* Slightly modernize realpath(3).kib2010-04-201-1/+1
| | | | | | | | | | | SUSv4 requires that implementation returns EINVAL if supplied path is NULL, and ENOENT if path is empty string [1]. Bring prototype in conformance with SUSv4, adding restrict keywords. Allow the resolved path buffer pointer be NULL, in which case realpath(3) allocates storage with malloc(). PR: kern/121897 [1] MFC after: 2 weeks
* Remove the Berkeley clause 3's.imp2010-02-161-5/+1
| | | | Add a few $FreeBSD$
* Namespace: abort2() is a BSD extension.das2009-03-141-1/+1
|
* r189349 removed mktemp() from the XSI namespace whendas2009-03-141-1/+1
| | | | | | | __XOPEN_SOURCE >= 700, since mktemp() was withdrawn from the standard. However, __XSI_VISIBLE is set to 700 in the default BSD envrionment, where mktemp() should still exist; hence, check for this.
* - Add getsubopt and mkdtemp to the POSIX.1-2008 namespace.das2009-03-041-6/+13
| | | | | - Add mkstemp to the POSIX.1-2008 and BSD namespaces. - Remove mktemp from the XSI namespace.
* Add two new routines: fdevname() and fdevname_r().ed2009-02-111-0/+2
| | | | | | | | | | | | | | A more elegant way of obtaining a name of a character device by its file descriptor on FreeBSD, is to use the FIODGNAME ioctl. Because a valid file descriptor implies a file descriptor is visible in /dev, it will always resolve a valid device name. I'm adding a more friendly wrapper for this ioctl, called fdevname(). It is a lot easier to use than devname() and also has better error handling. When a device name cannot be resolved, it will just return NULL instead of a generated device name that makes no sense. Discussed with: kib
* Add a function attribute called `__malloc_like', which informs gccdas2009-01-311-2/+2
| | | | | | | | | | | | | | that the annotated function returns a pointer that doesn't alias any extant pointer. This results in a 50%+ speedup in microbenchmarks such as the following: char *cp = malloc(1), *buf = malloc(BUF); for (i = 0; i < BUF; i++) buf[i] = *cp; In real programs, your mileage will vary. Note that gcc already performs this optimization automatically for any function called `malloc', `calloc', `strdup', or `strndup' unless -fno-builtins is used.
* Add arc4random_uniform()ache2008-07-221-0/+2
| | | | Obtained from: OpenBSD
* Add arc4random_buf.ache2008-07-211-1/+2
| | | | Style: remove arg names from arc4random_addrandom.
* Significantly reduce the memory leak as noted in BUGS section forscf2007-07-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | setenv(3) by tracking the size of the memory allocated instead of using strlen() on the current value. Convert all calls to POSIX from historic BSD API: - unsetenv returns an int. - putenv takes a char * instead of const char *. - putenv no longer makes a copy of the input string. - errno is set appropriately for POSIX. Exceptions involve bad environ variable and internal initialization code. These both set errno to EFAULT. Several patches to base utilities to handle the POSIX changes from Andrey Chernov's previous commit. A few I re-wrote to use setenv() instead of putenv(). New regression module for tools/regression/environ to test these functions. It also can be used to test the performance. Bump __FreeBSD_version to 700050 due to API change. PR: kern/99826 Approved by: wes Approved by: re (kensmith)
* Back out all POSIXified *env() changes.ache2007-05-011-2/+2
| | | | | | | | | Not because I admit they are technically wrong and not because of bug reports (I receive nothing). But because I surprisingly meets so strong opposition and resistance so lost any desire to continue that. Anyone who interested in POSIX can dig out what changes and how through cvs diffs.
* Fix unsetenv and putenv prototypes to conform Open Group specs Issue 6ache2007-04-301-2/+2
| | | | (also IEEE Std 1003.1-2001)
* Import of OpenBSD's strtonum(3) which is a nicer version of strtoll(3)andre2006-03-141-0/+2
| | | | | | | | providing proper error checking and other improvements. Obtained from: OpenBSD Requested by: flz (to port Open[BGP|OSPF]D) MFC after: 3 days
* Expose the posix_memalign() prototype, now that the function is implementedjasone2006-01-121-1/+1
| | | | by libc.
* Add a64l(), l64a(), and l64a_r() XSI extentions. These functions converttrhodes2005-12-241-2/+3
| | | | | | | | between a 32-bit integer and a radix-64 ASCII string. The l64a_r() function is a NetBSD addition. PR: 51209 (based on submission, but very different) Reviewed by: bde, ru
* Add abort2() prototypephk2005-12-231-0/+1
|
* Fix the prototypes for devname() and devname_r(), the first two argumentstefanf2005-09-121-2/+2
| | | | | types are supposed to be dev_t and mode_t (prefixed with __ due to namespace reasons).
* Implement rpmatch(), a semi-standard interface (as found on AIX, Tru64,tjr2005-01-091-0/+1
| | | | | | GNU) for determining whether a string is an affirmative or negative response to a question according to the current locale. This is done by matching the response against nl_langinfo(3) items YESEXPR and NOEXPR.
* POSIX clearly states that getsubopt() should be declared in <stdlib.h>,ache2004-02-231-3/+2
| | | | not in <unistd.h>
* Change the definition of NULL on ia64 (for LP64 compilations) frommarcel2003-12-071-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | an int constant to a long constant. This change improves consistency in the following two ways: 1. The first 8 arguments are always passed in registers on ia64, which by virtue of the generated code implicitly widens ints to longs and allows the use of an 32-bit integral type for 64-bit arguments. Subsequent arguments are passed onto the memory stack, which does not exhibit the same behaviour and consequently do not allow this. In practice this means that variadic functions taking pointers and given NULL (without cast) work as long as the NULL is passed in one of the first 8 arguments. A SIGSEGV is more likely the result if such would be done for stack-based arguments. This is due to the fact that the upper 4 bytes remain undefined. 2. All 64-bit platforms that FreeBSD supports, with the obvious exception of ia64, allow 32-bit integral types (specifically NULL) when 64-bit pointers are expected in variadic functions by way of how the compiler generates code. As such, code that works correctly (whether rightfully so or not) on any platform other than ia64, may fail on ia64. To more easily allow tweaking of the definition of NULL, this commit removes the 12 definitions in the various headers and puts it in a new header that can be included whenever NULL is to be made visible. This commit fixes GNOME, emacs, xemacs and a whole bunch of ports that I don't particularly care about at this time...
* Push the alloca #error warning farther down to play nicer with some out ofobrien2003-06-251-2/+0
| | | | | | tree local translator. Requested by: jmallett
* Fix a mismerge.obrien2003-06-251-1/+1
|
* Don't blindly provide alloca() for all compilers -- it is too implementationobrien2003-06-251-4/+5
| | | | | | dependent. Instead provide one for GCC & Intel's GCC copy and one for lint. Anyone using any other translator tool needs to look closely at how that tool can handle alloca.
* Remove argument names from a function declaration.dwmalone2003-06-221-1/+1
| | | | Reviewed by: phk
* Add devname_r(3) which takes a buffer as argument.phk2003-06-201-0/+1
|
* Use __builtin_alloca() on compilers that have it. Keep the prototype fordes2003-06-151-1/+17
| | | | the benefit of lint and non-{GNU,Intel} compilers.
OpenPOWER on IntegriCloud