path: root/include/stdlib.h
AgeCommit message (Collapse)AuthorLines
2014-09-10fix places where _BSD_SOURCE failed to yield a superset of _XOPEN_SOURCERich Felker-3/+0
the vast majority of these failures seem to have been oversights at the time _BSD_SOURCE was added, or perhaps shortly afterward. the one which may have had some reason behind it is omission of setpgrp from the _BSD_SOURCE feature profile, since the standard setpgrp interface conflicts with a legacy (pre-POSIX) BSD interface by the same name. however, such omission is not aligned with our general policy in this area (for example, handling of similar _GNU_SOURCE cases) and should not be preserved.
2014-08-08make clearenv available with _BSD_SOURCEClément Vasseur-1/+1
glibc declares clearenv under _BSD_SOURCE, some applications might depend on it being available this way.
2014-02-11fix signed and unsigned comparision in macros in public headersSzabolcs Nagy-1/+1
gcc -Wsign-compare warns about expanded macros that were defined in standard headers (before gcc 4.8) which can make builds fail that use -Werror. changed macros: WIFSIGNALED, __CPU_op_S
2013-11-24restore type of NULL to void * except when used in C++ programsRich Felker-0/+4
unfortunately this eliminates the ability of the compiler to diagnose some dangerous/incorrect usage, but POSIX requires (as an extension to the C language, i.e. CX shaded) that NULL have type void *. plain C allows it to be defined as any null pointer constant. the definition 0L is preserved for C++ rather than reverting to plain 0 to avoid dangerous behavior in non-conforming programs which use NULL as a variadic sentinel. (it's impossible to use (void *)0 for C++ since C++ lacks the proper implicit pointer conversions, and other popular alternatives like the GCC __null extension seem non-conforming to the standard's requirements.)
2013-11-21add legacy getloadavg apiSzabolcs Nagy-0/+1
2013-08-13provide declarations for strtod_l and familyRich Felker-0/+4
these aliases were originally intended to be for ABI compatibility only, but their presence caused regressions in broken gnulib-based software whose configure scripts detect the existing of these functions then use them without declarations, resulting in bogus return values.
2013-08-10fix definitions of WIFSTOPPED and WIFSIGNALED to support up to signal 127Rich Felker-2/+2
mips has signal numbers up to 127 (formerly, up to 128, but the last one never worked right and caused kernel panic when used), so 127 in the "signal number" field of the wait status is insufficient for determining that the process was stopped. in addition, a nonzero value in the upper bits must be present, indicating the signal number which caused the process to be stopped. details on this issue can be seen in the email with message id on the linux-mips mailing list, archived at: and in the associated thread about fixing the mips kernel bug. commit 4a96b948687166da26a6c327e6c6733ad2336c5c fixed the corresponding issue in uClibc, but introduced a multiple-evaluation issue for the WIFSTOPPED macro. for the most part, none of these issues affected pure musl systems, since musl has up until now (incorrectly) defined SIGRTMAX as 64 on all archs, even mips. however, interpreting status of non-musl programs on mips may have caused problems. with this change, the full range of signal numbers can be made available on mips.
2013-02-20add mkostemp, mkstemps, and mkostemps functions and reorganize temp internalsRich Felker-0/+8
based on patch contributed by Anthony G. Basile (blueness) some issues remain with the filename generation algorithm and other small bugs, but this patch has been sitting around long enough that I feel it's best to get it committed and then work out any remaining issues.
2013-01-18use a common definition of NULL as 0L for C and C++Rich Felker-6/+1
the historical mess of having different definitions for C and C++ comes from the historical C definition as (void *)0 and the fact that (void *)0 can't be used in C++ because it does not convert to other pointer types implicitly. however, using plain 0 in C++ exposed bugs in C++ programs that call variadic functions with NULL as an argument and (wrongly; this is UB) expect it to arrive as a null pointer. on 64-bit machines, the high bits end up containing junk. glibc dodges the issue by using a GCC extension __null to define NULL; this is observably non-conforming because a conforming application could observe the definition of NULL via stringizing and see that it is neither an integer constant expression with value zero nor such an expression cast to void. switching to 0L eliminates the issue and provides compatibility with broken applications, since on all musl targets, long and pointers have the same size, representation, and argument-passing convention. we could maintain separate C and C++ definitions of NULL (i.e. just use 0L on C++ and use (void *)0 on C) but after careful analysis, it seems extremely difficult for a C program to even determine whether NULL has integer or pointer type, much less depend in subtle, unintentional ways, on whether it does. C89 seems to have no way to make the distinction. on C99, the fact that (int)(void *)0 is not an integer constant expression, along with subtle VLA/sizeof semantics, can be used to make the distinction, but many compilers are non-conforming and give the wrong result to this test anyway. on C11, _Generic can trivially make the distinction, but it seems unlikely that code targetting C11 would be so backwards in caring which definition of NULL an implementation uses. as such, the simplest path of using the same definition for NULL in both C and C++ was chosen. the #undef directive was also removed so that the compiler can catch and give a warning or error on redefinition if buggy programs have defined their own versions of NULL prior to inclusion of standard headers.
2012-10-21fix issues with wait constants in stdlib.hRich Felker-4/+5
the W* namespace is not reserved, so the nonstandard ones must be moved under extension features. also WNOHANG and WUNTRACED were missing.
2012-09-07default features: make musl usable without feature test macrosRich Felker-12/+1
the old behavior of exposing nothing except plain ISO C can be obtained by defining __STRICT_ANSI__ or using a compiler option (such as -std=c99) that predefines it. the new default featureset is POSIX with XSI plus _BSD_SOURCE. any explicit feature test macros will inhibit the default. installation docs have also been updated to reflect this change.
2012-09-06add _Noreturn function attribute, with fallback for pre-C11 GNUCRich Felker-4/+11
2012-09-06use restrict everywhere it's required by c99 and/or posix 2008Rich Felker-11/+17
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
2012-08-25implement "low hanging fruit" from C11Rich Felker-0/+1
based on Gregor's patch sent to the list. includes: - stdalign.h - removing gets in C11 mode - adding aligned_alloc and adjusting other functions to use it - adding 'x' flag to fopen for exclusive mode
2012-08-25add c11 quick_exit and at_quick_exit functionsRich Felker-0/+2
2012-06-04_GNU_SOURCE is supposed to imply _LARGEFILE64_SOURCERich Felker-1/+1
this is ugly and stupid, but now that the *64 symbol names exist, a lot of broken GNU software detects them in configure, then either breaks during build due to missing off64_t definition, or attempts to compile without function declarations/prototypes. "fixing" it here is easier than telling everyone to add yet another feature test macro to their builds.
2012-05-22support _BSD_SOURCE feature test macroRich Felker-7/+15
patch by Isaac Dunham. matched closely (maybe not exact) to glibc's idea of what _BSD_SOURCE should make visible.
2012-05-04add support for ugly *64 functions with _LARGEFILE64_SOURCERich Felker-0/+3
musl does not support legacy 32-bit-off_t whatsoever. off_t is always 64 bit, and correct programs that use off_t and the standard functions will just work out of the box. (on glibc, they would require -D_FILE_OFFSET_BITS=64 to work.) however, some programs instead define _LARGEFILE64_SOURCE and use alternate versions of all the standard types and functions with "64" appended to their names. we do not want code to actually get linked against these functions (it's ugly and inconsistent), so macros are used instead of prototypes with weak aliases in the library itself. eventually the weak aliases may be added at the library level for the sake of using code that was originally built against glibc, but the macros will still be the desired solution in the headers.
2012-04-09fix alloca issue in stdlib.h tooRich Felker-1/+1
I forgot _GNU_SOURCE also has it declared here...
2012-02-06add deprecated (removed from posix) [efg]cvt() functionsRich Felker-0/+3
these have not been heavily tested, but they should work as described in the old standards. probably broken for non-finite values...
2011-09-11declare alloca in stdlib.h when _GNU_SOURCE is definedRich Felker-0/+1
2011-04-21move wait.h macros out of bits. they do not vary.Rich Felker-1/+8
2011-04-13add ptsname_r (nonstandard) and split ptsname (standard) to separate fileRich Felker-0/+1
this eliminates the ugly static buffer in programs that use ptsname_r.
2011-03-30add some missing prototypes for nonstandard functions (strsep, clearenv)Rich Felker-0/+1
2011-02-15fix the types of some integer constant limits in headersRich Felker-1/+1
2011-02-15fix missing EXIT_* in stdlib.h after header cleanupRich Felker-3/+3
2011-02-14begin namespace-cleanup of standard C headersRich Felker-46/+51
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+129