summaryrefslogtreecommitdiff
path: root/include/stdlib.h
Commit message (Collapse)AuthorAgeFilesLines
* Improve C11 bits in <stdlib.h>:Ed Schouten2011-12-261-5/+5
| | | | | | | | | | - Add missing semicolon to quick_exit(), - Remove `func' parameter name from at_quick_exit(), - Fix indentation. - Compare against 2011 value. Notes: svn path=/head/; revision=228901
* Replace __const by const in all non-contributed source code.Ed Schouten2011-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. Notes: svn path=/head/; revision=228468
* As per das@'s suggestion, s/__noreturn/_Noreturn/, since the latter is anDavid Chisnall2011-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) Notes: svn path=/head/; revision=228330
* Implement quick_exit() / at_quick_exit() from C++11 / C1x. Also add aDavid Chisnall2011-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) Notes: svn path=/head/; revision=228322
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds aDavid Chisnall2011-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) Notes: svn path=/head/; revision=227753
* Move realpath(3) prototype to a POSIX section.Konstantin Belousov2010-04-211-1/+1
| | | | | | | | Noted by: bde MFC after: 2 weeks Notes: svn path=/head/; revision=206997
* Slightly modernize realpath(3).Konstantin Belousov2010-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 Notes: svn path=/head/; revision=206893
* Remove the Berkeley clause 3's.Warner Losh2010-02-161-5/+1
| | | | | | | Add a few $FreeBSD$ Notes: svn path=/head/; revision=203964
* Namespace: abort2() is a BSD extension.David Schultz2009-03-141-1/+1
| | | | Notes: svn path=/head/; revision=189820
* r189349 removed mktemp() from the XSI namespace whenDavid Schultz2009-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. Notes: svn path=/head/; revision=189782
* - Add getsubopt and mkdtemp to the POSIX.1-2008 namespace.David Schultz2009-03-041-6/+13
| | | | | | | | - Add mkstemp to the POSIX.1-2008 and BSD namespaces. - Remove mktemp from the XSI namespace. Notes: svn path=/head/; revision=189349
* Add two new routines: fdevname() and fdevname_r().Ed Schouten2009-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 Notes: svn path=/head/; revision=188497
* Add a function attribute called `__malloc_like', which informs gccDavid Schultz2009-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. Notes: svn path=/head/; revision=187961
* Add arc4random_uniform()Andrey A. Chernov2008-07-221-0/+2
| | | | | | | Obtained from: OpenBSD Notes: svn path=/head/; revision=180689
* Add arc4random_buf.Andrey A. Chernov2008-07-211-1/+2
| | | | | | | Style: remove arg names from arc4random_addrandom. Notes: svn path=/head/; revision=180658
* Significantly reduce the memory leak as noted in BUGS section forSean Farley2007-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) Notes: svn path=/head/; revision=171195
* Back out all POSIXified *env() changes.Andrey A. Chernov2007-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. Notes: svn path=/head/; revision=169177
* Fix unsetenv and putenv prototypes to conform Open Group specs Issue 6Andrey A. Chernov2007-04-301-2/+2
| | | | | | | (also IEEE Std 1003.1-2001) Notes: svn path=/head/; revision=169110
* Import of OpenBSD's strtonum(3) which is a nicer version of strtoll(3)Andre Oppermann2006-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 Notes: svn path=/head/; revision=156707
* Expose the posix_memalign() prototype, now that the function is implementedJason Evans2006-01-121-1/+1
| | | | | | | by libc. Notes: svn path=/head/; revision=154250
* Add a64l(), l64a(), and l64a_r() XSI extentions. These functions convertTom Rhodes2005-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 Notes: svn path=/head/; revision=153707
* Add abort2() prototypePoul-Henning Kamp2005-12-231-0/+1
| | | | Notes: svn path=/head/; revision=153684
* Fix the prototypes for devname() and devname_r(), the first two argumentStefan Farfeleder2005-09-121-2/+2
| | | | | | | | types are supposed to be dev_t and mode_t (prefixed with __ due to namespace reasons). Notes: svn path=/head/; revision=150052
* Implement rpmatch(), a semi-standard interface (as found on AIX, Tru64,Tim J. Robbins2005-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. Notes: svn path=/head/; revision=139922
* POSIX clearly states that getsubopt() should be declared in <stdlib.h>,Andrey A. Chernov2004-02-231-3/+2
| | | | | | | not in <unistd.h> Notes: svn path=/head/; revision=126136
* Change the definition of NULL on ia64 (for LP64 compilations) fromMarcel Moolenaar2003-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... Notes: svn path=/head/; revision=123257
* Push the alloca #error warning farther down to play nicer with some out ofDavid E. O'Brien2003-06-251-2/+0
| | | | | | | | | tree local translator. Requested by: jmallett Notes: svn path=/head/; revision=116833
* Fix a mismerge.David E. O'Brien2003-06-251-1/+1
| | | | Notes: svn path=/head/; revision=116832
* Don't blindly provide alloca() for all compilers -- it is too implementationDavid E. O'Brien2003-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. Notes: svn path=/head/; revision=116831
* Remove argument names from a function declaration.David Malone2003-06-221-1/+1
| | | | | | | Reviewed by: phk Notes: svn path=/head/; revision=116680
* Add devname_r(3) which takes a buffer as argument.Poul-Henning Kamp2003-06-201-0/+1
| | | | Notes: svn path=/head/; revision=116610
* Use __builtin_alloca() on compilers that have it. Keep the prototype forDag-Erling Smørgrav2003-06-151-1/+17
| | | | | | | the benefit of lint and non-{GNU,Intel} compilers. Notes: svn path=/head/; revision=116397
* Replace our ancient dtoa/strtod implementation with the gdtoaDavid Schultz2003-03-121-3/+3
| | | | | | | | | | | | | | | | | | | | | package, a more recent, generalized set of routines. Among the changes: - Declare strtof() and strtold() in stdlib.h. - Add glue to libc to support these routines for all kinds of ``long double''. - Update printf() to reflect the fact that dtoa works slightly differently now. As soon as I see that nothing has blown up, I will kill src/lib/libc/stdlib/strtod.c. Soon printf() will be able to use the new routines to output long doubles without loss of precision, but numerous bugs in the existing code must be addressed first. Reviewed by: bde (briefly), mike (mentor), obrien Notes: svn path=/head/; revision=112163
* Implement POSIX grantpt(3) functionality, and add a pt_chown utility (akinJuli Mallett2003-01-021-4/+4
| | | | | | | | | | | to Solaris, it is in /usr/libexec) to perform the handing over of tty nodes to the user being granted the pty. Submitted by: Ryan Younce <ryany@pobox.com> Reviewed by: security-officer@, standards@, mike@ Notes: svn path=/head/; revision=108574
* Back out the s/int */size_t */ commit.David E. O'Brien2002-12-301-1/+1
| | | | | | | | It makes a difference on 64-bit arches, and no one really wants a 2^64 block size [yet]. Notes: svn path=/head/; revision=108445
* Make the first argument of getbsize a size_t* instead of an int*, as this is ↵Mark Murray2002-10-231-1/+1
| | | | | | | what the quantity actually is. Fix an easy const while I'm here. Notes: svn path=/head/; revision=105797
* Whitespace cleanup (half for fixing missing whitespace before `__restrict'Bruce Evans2002-09-211-20/+21
| | | | | | | | | again). Removed the second pair of banal comments about `quot' and `rem'. Notes: svn path=/head/; revision=103766
* Use new visibility macros. Reorder some disordered declarations. AddGarrett Wollman2002-09-211-52/+104
| | | | | | | | | new 1003.1-2001 declarations, commented out in cases where we do not implement the function. Note that strtoq() and strtouq() are slated for deletion in 6.0. (2 of 5) Notes: svn path=/head/; revision=103728
* Without fixing the namespace issues, add prototypes for the new _Exit()Garrett Wollman2002-09-101-2/+5
| | | | | | | and qsort_r() functions. Fix one other missorted declaration. Notes: svn path=/head/; revision=103164
* Style: One space between "restrict" qualifier and "*".Tim J. Robbins2002-09-061-8/+8
| | | | Notes: svn path=/head/; revision=103012
* Add restrict qualifiers to the arguments of mbstowcs, mbtowc() andTim J. Robbins2002-09-011-3/+3
| | | | | | | wcstombs(). Notes: svn path=/head/; revision=102762
* o Merge <machine/ansi.h> and <machine/types.h> into a new headerMike Barcroft2002-08-211-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | called <machine/_types.h>. o <machine/ansi.h> will continue to live so it can define MD clock macros, which are only MD because of gratuitous differences between architectures. o Change all headers to make use of this. This mainly involves changing: #ifdef _BSD_FOO_T_ typedef _BSD_FOO_T_ foo_t; #undef _BSD_FOO_T_ #endif to: #ifndef _FOO_T_DECLARED typedef __foo_t foo_t; #define _FOO_T_DECLARED #endif Concept by: bde Reviewed by: jake, obrien Notes: svn path=/head/; revision=102227
* - Add the 'restrict' qualifier to the function prototypes andRobert Drehmel2002-08-151-5/+5
| | | | | | | | | | | definitions of the functions that convert strings to numbers and are defined by IEEE Std 1003-1.2001. - Use ANSI-C function definitions for all of the functions mentioned above plus strtouq and strtoq. - Update the prototypes in the manual pages. Notes: svn path=/head/; revision=101912
* Don't define wchar_t if we are a C++ compiler.David E. O'Brien2002-07-091-0/+2
| | | | | | | PR: 31864, 40084 Notes: svn path=/head/; revision=99640
* Convince lint via the standard lint-comment /* LONGLONG */ to notMark Murray2002-07-041-0/+5
| | | | | | | whine about our (valid) "long long" usage. Notes: svn path=/head/; revision=99404
* Const poison.Poul-Henning Kamp2002-05-301-1/+1
| | | | | | | Partially submitted by: wollman Notes: svn path=/head/; revision=97639
* Constify _malloc_options.Poul-Henning Kamp2002-04-241-1/+1
| | | | Notes: svn path=/head/; revision=95377
* Breath deep and take __P out of the system include files.Warner Losh2002-03-231-90/+88
| | | | | | | | | # This appears to not break X11, but I'm having problems compiling the # glide part of the server with or without this patch, so I can't tell # for sure. Notes: svn path=/head/; revision=93032
* const poison just like NetBSD.Warner Losh2002-03-221-7/+7
| | | | Notes: svn path=/head/; revision=92925
* Move user_from_uid to pwd.hWarner Losh2002-02-141-2/+0
| | | | | | | | | | | | | | | | Move group_from_gid to grp.h Remove from stdlib.h Make the prototypes match the code Fix rm and mv to include new files. NetBSD has these defined in those files, and others too that I've not done. Approved by: terminal room kabal Reviewed by: jhb, phk Notes: svn path=/head/; revision=90644