libc/newlib/libc/include/stdlib.h

298 lines
11 KiB
C
Raw Normal View History

2000-02-17 20:39:52 +01:00
/*
* stdlib.h
*
* Definitions for common types, variables, and functions.
*/
#ifndef _STDLIB_H_
#define _STDLIB_H_
2009-04-16 Ken Werner <ken.werner@de.ibm.com> * libm/libm.texinfo: Add long double function support chapter. * libc/include/machine/ieeefp.h: Add _LDBL_EQ_DBL define. * libc/include/stdlib.h: Include <machine/ieeefp.h>. (strtold, wcstold): Declare. * libc/stdlib/strtold.c: New File. * libc/stdlib/wcstold.c: Likewise. * libc/configure.in: Add long double check. * libc/configure: Regenerate. * libc/stdlib/Makefile.am: Add strtold.c and wcstold.c. * libc/stdlib/Makefile.in: Regenerate. * libc/include/math.h (atanl, cosl, sinl, tanl, tanhl): Declare. (frexpl, modfl, ceill, fabsl, floorl, log1pl, expm1l, acosl): Ditto. (asinl, atan2l, coshl, sinhl, expl, ldexpl, logl, log10l, powl): Ditto. (sqrtl, fmodl, hypotl, copysignl, nanl, ilogbl, asinhl, cbrt): Ditto. (nextafterl, rintl, scalbnl, exp2l, scalblnl, tgammal): Ditto. (nearbyintl, lrintl, llrintl, roundl, lroundl, llround): Ditto. (llroundl, truncl, remquol, fdiml, fmaxl, fminl, fmal, acoshl): Ditto. (atanhl, remainderl, lgammal, erfl, erfcl): Ditto. * libm/common/atanl.c: New File. * libm/common/cosl.c: Likewise. * libm/common/sinl.c: Likewise. * libm/common/modfl.c: Likewise. * libm/common/frexpl.c: Likewise. * libm/common/tanhl.c: Likewise. * libm/common/tanl.c: Likewise. * libm/common/expm1l.c: Likewise. * libm/common/log1pl.c: Likewise. * libm/common/ceill.c: Likewise. * libm/common/fabsl.c: Likewise. * libm/common/floorl.c: Likewise. * libm/common/acosl.c: Likewise. * libm/common/asinl.c: Likewise. * libm/common/atan2l.c: Likewise. * libm/common/coshl.c: Likewise. * libm/common/expl.c: Likewise. * libm/common/fmodl.c: Likewise. * libm/common/hypotl.c: Likewise. * libm/common/ldexpl.c: Likewise. * libm/common/log10l.c: Likewise. * libm/common/logl.c: Likewise. * libm/common/powl.c: Likewise. * libm/common/sqrtl.c: Likewise. * libm/common/copysignl.c: Likewise. * libm/common/ilogbl.c: Likewise. * libm/common/nanl.c: Likewise. * libm/common/cbrtl.c: Likewise. * libm/common/asinhl.c: Likewise. * libm/common/nextafterl.c: Likewise. * libm/common/rintl.c: Likewise. * libm/common/scalbnl.c: Likewise. * libm/common/exp2l.c: Likewise. * libm/common/fdiml.c: Likewise. * libm/common/fmal.c: Likewise. * libm/common/fmaxl.c: Likewise. * libm/common/fminl.c: Likewise. * libm/common/lrintl.c: Likewise. * libm/common/lroundl.c: Likewise. * libm/common/nearbyintl.c: Likewise. * libm/common/remquol.c: Likewise. * libm/common/roundl.c: Likewise. * libm/common/scalblnl.c: Likewise. * libm/common/truncl.c: Likewise. * libm/common/acoshl.c: Likewise. * libm/common/atanhl.c: Likewise. * libm/common/erfcl.c: Likewise. * libm/common/erfl.c: Likewise. * libm/common/lgammal.c: Likewise. * libm/common/remainderl.c: Likewise. * libm/common/tgammal.c: Likewise. * libm/common/sinhl.c: Likewise. * libm/common/llroundl.c: Likewise. * libm/configure.in: Add long double check. * libm/configure: Regenerate. * libm/common/Makefile.am: Add new files. * libm/common/Makefile.in: Regenerate.
2009-04-16 20:24:35 +02:00
#include <machine/ieeefp.h>
2000-02-17 20:39:52 +01:00
#include "_ansi.h"
#define __need_size_t
#define __need_wchar_t
#define __need_NULL
2000-02-17 20:39:52 +01:00
#include <stddef.h>
#include <sys/reent.h>
#include <sys/cdefs.h>
#include <machine/stdlib.h>
#ifndef __STRICT_ANSI__
#include <alloca.h>
#endif
#ifdef __CYGWIN__
#include <cygwin/stdlib.h>
#endif
_BEGIN_STD_C
2000-02-17 20:39:52 +01:00
typedef struct
{
int quot; /* quotient */
int rem; /* remainder */
} div_t;
typedef struct
{
long quot; /* quotient */
long rem; /* remainder */
} ldiv_t;
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
typedef struct
{
long long int quot; /* quotient */
long long int rem; /* remainder */
} lldiv_t;
#endif
#ifndef __compar_fn_t_defined
#define __compar_fn_t_defined
typedef int (*__compar_fn_t) (const _PTR, const _PTR);
#endif
2000-02-17 20:39:52 +01:00
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
#define RAND_MAX __RAND_MAX
2000-02-17 20:39:52 +01:00
Extend locale support to maintain wide char values of native strings if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/include/langinfo.h (enum __nl_item): New type. Define all native values accessible through nl_langinfo. Define previously existing POSIX-compatible values as macros as well. * libc/include/stdlib.h (__mb_cur_max): Drop declaration. (__locale_mb_cur_max): Declare. (MB_CUR_MAX): Re-define calling __locale_mb_cur_max. * libc/locale/Makefile.am (ELIX_SOURCES): Add lctype.c. * libc/locale/Makefile.in: Regenerate. * libc/locale/lctype.c: New file to define and load LC_CTYPE category. * libc/locale/lctype.h: New file, matching header. * libc/locale/lmessages.c (_C_messages_locale): Add default values for wide char members. (__messages_load_locale): Add _C_messages_locale in call to __set_lc_messages_from_win. * libc/locale/lmessages.h (struct lc_messages_T): Add wide char members. * libc/locale/lmonetary.c (_C_monetary_locale): Add default values for wide char members. (__monetary_load_locale): Add _C_monetary_locale in call to __set_lc_monetary_from_win. * libc/locale/lmonetary.h (struct lc_monetary_T): Add wide char members. Add numerical values for international currency formatting per POSIX-1.2008, if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/locale/lnumeric.c (_C_numeric_locale): Add default values for wide char members. (__numeric_load_locale): Add _C_numeric_locale in call to __set_lc_numeric_from_win. * libc/locale/lnumeric.h (struct lc_numeric_T): Add wide char members. * libc/locale/locale.c (loadlocale): Return doing nothing if category locale didn't change. Convert category if chain to switch statement. Call __ctype_load_locale in LC_CTYPE case. (__locale_charset): Add (but disable for now) returning codeset from __get_current_ctype_locale. (__locale_mb_cur_max): Add (but disable for now) returning mb_cur_max from __get_current_ctype_locale. (__locale_msgcharset): Add returning codeset from __get_current_messages_locale. (_localeconv_r): Accommodate int_XXX values. * libc/locale/nl_langinfo.c (nl_ext): New array to define what is to be returned for non-POSIX values. (nl_Langinfo): Return correct codeset for each locale category. Return extended values if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/locale/timelocal.c (_C_time_locale): Add default values for wide char members. (__time_load_locale): Add _C_time_locale in call to __set_lc_time_from_win. * libc/locale/timelocal.h (struct lc_time_T): Add wide char members. * libc/stdio/vfwprintf.c (_VFWPRINTF_R): Use wide char decimal point and thousands_sep if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/time/strftime.c: Rework to accommodate availability of wide char strings in LC_TIME category if __HAVE_LOCALE_INFO_EXTENDED__ is defined.
2010-04-28 11:59:37 +02:00
int _EXFUN(__locale_mb_cur_max,(_VOID));
2000-02-17 20:39:52 +01:00
Extend locale support to maintain wide char values of native strings if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/include/langinfo.h (enum __nl_item): New type. Define all native values accessible through nl_langinfo. Define previously existing POSIX-compatible values as macros as well. * libc/include/stdlib.h (__mb_cur_max): Drop declaration. (__locale_mb_cur_max): Declare. (MB_CUR_MAX): Re-define calling __locale_mb_cur_max. * libc/locale/Makefile.am (ELIX_SOURCES): Add lctype.c. * libc/locale/Makefile.in: Regenerate. * libc/locale/lctype.c: New file to define and load LC_CTYPE category. * libc/locale/lctype.h: New file, matching header. * libc/locale/lmessages.c (_C_messages_locale): Add default values for wide char members. (__messages_load_locale): Add _C_messages_locale in call to __set_lc_messages_from_win. * libc/locale/lmessages.h (struct lc_messages_T): Add wide char members. * libc/locale/lmonetary.c (_C_monetary_locale): Add default values for wide char members. (__monetary_load_locale): Add _C_monetary_locale in call to __set_lc_monetary_from_win. * libc/locale/lmonetary.h (struct lc_monetary_T): Add wide char members. Add numerical values for international currency formatting per POSIX-1.2008, if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/locale/lnumeric.c (_C_numeric_locale): Add default values for wide char members. (__numeric_load_locale): Add _C_numeric_locale in call to __set_lc_numeric_from_win. * libc/locale/lnumeric.h (struct lc_numeric_T): Add wide char members. * libc/locale/locale.c (loadlocale): Return doing nothing if category locale didn't change. Convert category if chain to switch statement. Call __ctype_load_locale in LC_CTYPE case. (__locale_charset): Add (but disable for now) returning codeset from __get_current_ctype_locale. (__locale_mb_cur_max): Add (but disable for now) returning mb_cur_max from __get_current_ctype_locale. (__locale_msgcharset): Add returning codeset from __get_current_messages_locale. (_localeconv_r): Accommodate int_XXX values. * libc/locale/nl_langinfo.c (nl_ext): New array to define what is to be returned for non-POSIX values. (nl_Langinfo): Return correct codeset for each locale category. Return extended values if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/locale/timelocal.c (_C_time_locale): Add default values for wide char members. (__time_load_locale): Add _C_time_locale in call to __set_lc_time_from_win. * libc/locale/timelocal.h (struct lc_time_T): Add wide char members. * libc/stdio/vfwprintf.c (_VFWPRINTF_R): Use wide char decimal point and thousands_sep if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/time/strftime.c: Rework to accommodate availability of wide char strings in LC_TIME category if __HAVE_LOCALE_INFO_EXTENDED__ is defined.
2010-04-28 11:59:37 +02:00
#define MB_CUR_MAX __locale_mb_cur_max()
2000-02-17 20:39:52 +01:00
headers: properly decorate attributes Found by: find -name '*.h' |xargs grep -i 'attribute.*(([a-z]' For an example of the type of bugs this causes, try compiling this valid C11 program (it's valid because 'noreturn' is reserved for use in the user namespace unless you include <stdnoreturn.h>): $ cat foo.c #define noreturn __attribute__((noreturn)) #include <stdlib.h> $ gcc -c -o foo.o -Wall foo.c In file included from /usr/include/stdlib.h:11:0, from foo.c:2: foo.c:1:18: error: expected ')' before '__attribute__' #define noreturn __attribute__((noreturn)) ^ /usr/include/stdlib.h:66:28: error: expected ',' or ';' before ')' token _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); ^ * libc/machine/spu/spu_timer_internal.h: Decorate attribute names with __, for namespace safety. * libc/machine/xscale/machine/profile.h: Likewise. * libc/include/stdlib.h: Likewise. * libc/include/_ansi.h: Likewise. * libc/include/sys/unistd.h: Likewise. * libc/sys/linux/linuxthreads/libc-symbols.h: Likewise. * libc/sys/linux/linuxthreads/internals.h: Likewise. * libc/sys/linux/machine/i386/weakalias.h: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.h: Likewise. * libc/sys/linux/machine/i386/dl-machine.h: Likewise. * libc/sys/linux/libc-symbols.h: Likewise. * libc/sys/linux/iconv/gconv_charset.h: Likewise. * libc/sys/linux/include/resolv.h: Likewise. * libc/sys/linux/sys/unistd.h: Likewise. * libc/sys/linux/dl/atomicity.h: Likewise. * libc/sys/linux/dl/dynamic-link.h: Likewise. * libc/sys/linux/dl/ldsodefs.h: Likewise.
2014-08-01 17:44:51 +02:00
_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((__noreturn__)));
2000-02-17 20:39:52 +01:00
int _EXFUN(abs,(int));
int _EXFUN(atexit,(_VOID (*__func)(_VOID)));
double _EXFUN(atof,(const char *__nptr));
#ifndef __STRICT_ANSI__
float _EXFUN(atoff,(const char *__nptr));
#endif
int _EXFUN(atoi,(const char *__nptr));
int _EXFUN(_atoi_r,(struct _reent *, const char *__nptr));
2000-02-17 20:39:52 +01:00
long _EXFUN(atol,(const char *__nptr));
long _EXFUN(_atol_r,(struct _reent *, const char *__nptr));
2000-02-17 20:39:52 +01:00
_PTR _EXFUN(bsearch,(const _PTR __key,
const _PTR __base,
size_t __nmemb,
size_t __size,
__compar_fn_t _compar));
_PTR _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size));
2000-02-17 20:39:52 +01:00
div_t _EXFUN(div,(int __numer, int __denom));
headers: properly decorate attributes Found by: find -name '*.h' |xargs grep -i 'attribute.*(([a-z]' For an example of the type of bugs this causes, try compiling this valid C11 program (it's valid because 'noreturn' is reserved for use in the user namespace unless you include <stdnoreturn.h>): $ cat foo.c #define noreturn __attribute__((noreturn)) #include <stdlib.h> $ gcc -c -o foo.o -Wall foo.c In file included from /usr/include/stdlib.h:11:0, from foo.c:2: foo.c:1:18: error: expected ')' before '__attribute__' #define noreturn __attribute__((noreturn)) ^ /usr/include/stdlib.h:66:28: error: expected ',' or ';' before ')' token _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); ^ * libc/machine/spu/spu_timer_internal.h: Decorate attribute names with __, for namespace safety. * libc/machine/xscale/machine/profile.h: Likewise. * libc/include/stdlib.h: Likewise. * libc/include/_ansi.h: Likewise. * libc/include/sys/unistd.h: Likewise. * libc/sys/linux/linuxthreads/libc-symbols.h: Likewise. * libc/sys/linux/linuxthreads/internals.h: Likewise. * libc/sys/linux/machine/i386/weakalias.h: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.h: Likewise. * libc/sys/linux/machine/i386/dl-machine.h: Likewise. * libc/sys/linux/libc-symbols.h: Likewise. * libc/sys/linux/iconv/gconv_charset.h: Likewise. * libc/sys/linux/include/resolv.h: Likewise. * libc/sys/linux/sys/unistd.h: Likewise. * libc/sys/linux/dl/atomicity.h: Likewise. * libc/sys/linux/dl/dynamic-link.h: Likewise. * libc/sys/linux/dl/ldsodefs.h: Likewise.
2014-08-01 17:44:51 +02:00
_VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((__noreturn__)));
_VOID _EXFUN_NOTHROW(free,(_PTR));
2000-02-17 20:39:52 +01:00
char * _EXFUN(getenv,(const char *__string));
char * _EXFUN(_getenv_r,(struct _reent *, const char *__string));
char * _EXFUN(_findenv,(_CONST char *, int *));
char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *));
#ifndef __STRICT_ANSI__
extern char *suboptarg; /* getsubopt(3) external variable */
int _EXFUN(getsubopt,(char **, char * const *, char **));
#endif
2000-02-17 20:39:52 +01:00
long _EXFUN(labs,(long));
ldiv_t _EXFUN(ldiv,(long __numer, long __denom));
_PTR _EXFUN_NOTHROW(malloc,(size_t __size));
2000-02-17 20:39:52 +01:00
int _EXFUN(mblen,(const char *, size_t));
* libc/include/langinfo.h: New file. * libc/include/wchar.h: Likewise. * libc/include/sys/syslimits.h: Likewise. * libc/locale/fix_grouping.c: Likewise. * libc/locale/ldpart.c: Likewise. * libc/locale/ldpart.h: Likewise. * libc/locale/lmessages.c: Likewise. * libc/locale/lmessages.h: Likewise. * libc/locale/lmonetary.c: Likewise. * libc/locale/lmonetary.h: Likewise. * libc/locale/lnumeric.c: Likewise. * libc/locale/lnumeric.h: Likewise. * libc/locale/nl_langinfo.3: Likewise. * libc/locale/nl_langinfo.c: Likewise. * libc/locale/timelocal.c: Likewise. * libc/locale/timelocal.h: Likewise. * libc/stdlib/btowc.c: Likewise. * libc/stdlib/mbrlen.c: Likewise. * libc/stdlib/mbrtowc.c: Likewise. * libc/stdlib/mbsinit.c: Likewise. * libc/stdlib/mbsrtowcs.c: Likewise. * libc/stdlib/wcrtomb.c: Likewise. * libc/stdlib/wcsrtombs.c: Likewise. * libc/stdlib/wctob.c: Likewise. * libc/sys/linux/prof-freq.c: Likewise. * libc/sys/linux/profile.c: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.c: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.h: Likewise. * libc/include/stdlib.h: Change re-entrant functions to take mbstate_t pointers. * libc/include/sys/_types.h: Define _mbstate_t. * libc/include/sys/config.h (MB_LEN_MAX): New macro. * libc/include/sys/errno.h (EILSEQ): New error code. * libc/include/sys/reent.h: Include wchar.h. Change reentrant structure to use mbstate_t. * libc/locale/Makefile.am (LIB_SOURCES): Add new files. * libc/machine/powerpc/vfprintf.c: Use mbstate_t. * libc/machine/powerpc/vfscanf.c: Likewise. * libc/stdio/getdelim.c: Reallocate buffer only when necessary. * libc/stdio/vfprintf.c: Likewise. * libc/stdio/vfscanf.c: Likewise. * libc/stdlib/Makefile.am (LIB_SOURCES): Add new files. * libc/stdlib/mblen.c: Use mbstate_t. * libc/stdlib/mblen_r.c: Likewise. * libc/stdlib/mbstowcs.c: Likewise. * libc/stdlib/mbstowcs_r.c: Likewise. * libc/stdlib/mbtowc.c: Likewise. * libc/stdlib/mbtowc_r.c: Likewise. * libc/stdlib/wcstombs.c: Likewise. * libc/stdlib/wcstombs_r.c: Likewise. * libc/stdlib/wctomb_r.c: Likewise. * libc/sys/linux/Makefile.am (LIB_SOURCES): Add prof-freq.c and profile.c. * libc/sys/linux/machine/i386/Makefile.am (LIB_SOURCES): Add dl-procinfo.c. * libc/sys/linux/sys/errno.h (EILSEQ): New error code. * libc/sys/linux/sys/types.h (off_t): Define type. * testsuite/newlib.locale/UTF-8.c: Change locale name from UTF-8 to C-UTF-8. * testsuite/newlib.locale/UTF-8.exp: Likewise.
2002-08-23 03:56:05 +02:00
int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *));
int _EXFUN(mbtowc,(wchar_t *__restrict, const char *__restrict, size_t));
int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *));
2000-02-17 20:39:52 +01:00
int _EXFUN(wctomb,(char *, wchar_t));
* libc/include/langinfo.h: New file. * libc/include/wchar.h: Likewise. * libc/include/sys/syslimits.h: Likewise. * libc/locale/fix_grouping.c: Likewise. * libc/locale/ldpart.c: Likewise. * libc/locale/ldpart.h: Likewise. * libc/locale/lmessages.c: Likewise. * libc/locale/lmessages.h: Likewise. * libc/locale/lmonetary.c: Likewise. * libc/locale/lmonetary.h: Likewise. * libc/locale/lnumeric.c: Likewise. * libc/locale/lnumeric.h: Likewise. * libc/locale/nl_langinfo.3: Likewise. * libc/locale/nl_langinfo.c: Likewise. * libc/locale/timelocal.c: Likewise. * libc/locale/timelocal.h: Likewise. * libc/stdlib/btowc.c: Likewise. * libc/stdlib/mbrlen.c: Likewise. * libc/stdlib/mbrtowc.c: Likewise. * libc/stdlib/mbsinit.c: Likewise. * libc/stdlib/mbsrtowcs.c: Likewise. * libc/stdlib/wcrtomb.c: Likewise. * libc/stdlib/wcsrtombs.c: Likewise. * libc/stdlib/wctob.c: Likewise. * libc/sys/linux/prof-freq.c: Likewise. * libc/sys/linux/profile.c: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.c: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.h: Likewise. * libc/include/stdlib.h: Change re-entrant functions to take mbstate_t pointers. * libc/include/sys/_types.h: Define _mbstate_t. * libc/include/sys/config.h (MB_LEN_MAX): New macro. * libc/include/sys/errno.h (EILSEQ): New error code. * libc/include/sys/reent.h: Include wchar.h. Change reentrant structure to use mbstate_t. * libc/locale/Makefile.am (LIB_SOURCES): Add new files. * libc/machine/powerpc/vfprintf.c: Use mbstate_t. * libc/machine/powerpc/vfscanf.c: Likewise. * libc/stdio/getdelim.c: Reallocate buffer only when necessary. * libc/stdio/vfprintf.c: Likewise. * libc/stdio/vfscanf.c: Likewise. * libc/stdlib/Makefile.am (LIB_SOURCES): Add new files. * libc/stdlib/mblen.c: Use mbstate_t. * libc/stdlib/mblen_r.c: Likewise. * libc/stdlib/mbstowcs.c: Likewise. * libc/stdlib/mbstowcs_r.c: Likewise. * libc/stdlib/mbtowc.c: Likewise. * libc/stdlib/mbtowc_r.c: Likewise. * libc/stdlib/wcstombs.c: Likewise. * libc/stdlib/wcstombs_r.c: Likewise. * libc/stdlib/wctomb_r.c: Likewise. * libc/sys/linux/Makefile.am (LIB_SOURCES): Add prof-freq.c and profile.c. * libc/sys/linux/machine/i386/Makefile.am (LIB_SOURCES): Add dl-procinfo.c. * libc/sys/linux/sys/errno.h (EILSEQ): New error code. * libc/sys/linux/sys/types.h (off_t): Define type. * testsuite/newlib.locale/UTF-8.c: Change locale name from UTF-8 to C-UTF-8. * testsuite/newlib.locale/UTF-8.exp: Likewise.
2002-08-23 03:56:05 +02:00
int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *));
size_t _EXFUN(mbstowcs,(wchar_t *__restrict, const char *__restrict, size_t));
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *));
size_t _EXFUN(wcstombs,(char *__restrict, const wchar_t *__restrict, size_t));
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *__restrict, const wchar_t *__restrict, size_t, _mbstate_t *));
#ifndef __STRICT_ANSI__
#ifndef _REENT_ONLY
char * _EXFUN(mkdtemp,(char *));
int _EXFUN(mkostemp,(char *, int));
int _EXFUN(mkostemps,(char *, int, int));
int _EXFUN(mkstemp,(char *));
int _EXFUN(mkstemps,(char *, int));
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
#endif
char * _EXFUN(_mkdtemp_r, (struct _reent *, char *));
int _EXFUN(_mkostemp_r, (struct _reent *, char *, int));
int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int));
int _EXFUN(_mkstemp_r, (struct _reent *, char *));
int _EXFUN(_mkstemps_r, (struct _reent *, char *, int));
char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
#endif
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
2000-02-17 20:39:52 +01:00
int _EXFUN(rand,(_VOID));
_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
#ifndef __STRICT_ANSI__
_PTR _EXFUN(reallocf,(_PTR __r, size_t __size));
char * _EXFUN(realpath, (const char *__restrict path, char *__restrict resolved_path));
int _EXFUN(rpmatch, (const char *response));
#endif
2000-02-17 20:39:52 +01:00
_VOID _EXFUN(srand,(unsigned __seed));
double _EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR));
double _EXFUN(_strtod_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR));
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
float _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR));
#endif
2000-02-17 20:39:52 +01:00
#ifndef __STRICT_ANSI__
/* the following strtodf interface is deprecated...use strtof instead */
# ifndef strtodf
# define strtodf strtof
# endif
2000-02-17 20:39:52 +01:00
#endif
long _EXFUN(strtol,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
long _EXFUN(_strtol_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base));
unsigned long _EXFUN(strtoul,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base));
2000-02-17 20:39:52 +01:00
int _EXFUN(system,(const char *__string));
#ifndef __STRICT_ANSI__
long _EXFUN(a64l,(const char *__input));
char * _EXFUN(l64a,(long __input));
char * _EXFUN(_l64a_r,(struct _reent *,long __input));
int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
#endif /* ! __STRICT_ANSI__ */
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
headers: properly decorate attributes Found by: find -name '*.h' |xargs grep -i 'attribute.*(([a-z]' For an example of the type of bugs this causes, try compiling this valid C11 program (it's valid because 'noreturn' is reserved for use in the user namespace unless you include <stdnoreturn.h>): $ cat foo.c #define noreturn __attribute__((noreturn)) #include <stdlib.h> $ gcc -c -o foo.o -Wall foo.c In file included from /usr/include/stdlib.h:11:0, from foo.c:2: foo.c:1:18: error: expected ')' before '__attribute__' #define noreturn __attribute__((noreturn)) ^ /usr/include/stdlib.h:66:28: error: expected ',' or ';' before ')' token _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); ^ * libc/machine/spu/spu_timer_internal.h: Decorate attribute names with __, for namespace safety. * libc/machine/xscale/machine/profile.h: Likewise. * libc/include/stdlib.h: Likewise. * libc/include/_ansi.h: Likewise. * libc/include/sys/unistd.h: Likewise. * libc/sys/linux/linuxthreads/libc-symbols.h: Likewise. * libc/sys/linux/linuxthreads/internals.h: Likewise. * libc/sys/linux/machine/i386/weakalias.h: Likewise. * libc/sys/linux/machine/i386/dl-procinfo.h: Likewise. * libc/sys/linux/machine/i386/dl-machine.h: Likewise. * libc/sys/linux/libc-symbols.h: Likewise. * libc/sys/linux/iconv/gconv_charset.h: Likewise. * libc/sys/linux/include/resolv.h: Likewise. * libc/sys/linux/sys/unistd.h: Likewise. * libc/sys/linux/dl/atomicity.h: Likewise. * libc/sys/linux/dl/dynamic-link.h: Likewise. * libc/sys/linux/dl/ldsodefs.h: Likewise.
2014-08-01 17:44:51 +02:00
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((__noreturn__)));
#endif
#ifndef __STRICT_ANSI__
int _EXFUN(putenv,(char *__string));
int _EXFUN(_putenv_r,(struct _reent *, char *__string));
_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));
2000-02-17 20:39:52 +01:00
int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite));
int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite));
char * _EXFUN(gcvt,(double,int,char *));
char * _EXFUN(gcvtf,(float,int,char *));
char * _EXFUN(fcvt,(double,int,int *,int *));
char * _EXFUN(fcvtf,(float,int,int *,int *));
char * _EXFUN(ecvt,(double,int,int *,int *));
char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(ecvtf,(float,int,int *,int *));
char * _EXFUN(dtoa,(double, int, int, int *, int*, char**));
#endif
char * _EXFUN(__itoa,(int, char *, int));
char * _EXFUN(__utoa,(unsigned, char *, int));
#ifndef __STRICT_ANSI__
char * _EXFUN(itoa,(int, char *, int));
char * _EXFUN(utoa,(unsigned, char *, int));
2000-02-17 20:39:52 +01:00
int _EXFUN(rand_r,(unsigned *__seed));
double _EXFUN(drand48,(_VOID));
double _EXFUN(_drand48_r,(struct _reent *));
double _EXFUN(erand48,(unsigned short [3]));
double _EXFUN(_erand48_r,(struct _reent *, unsigned short [3]));
long _EXFUN(jrand48,(unsigned short [3]));
long _EXFUN(_jrand48_r,(struct _reent *, unsigned short [3]));
_VOID _EXFUN(lcong48,(unsigned short [7]));
_VOID _EXFUN(_lcong48_r,(struct _reent *, unsigned short [7]));
long _EXFUN(lrand48,(_VOID));
long _EXFUN(_lrand48_r,(struct _reent *));
long _EXFUN(mrand48,(_VOID));
long _EXFUN(_mrand48_r,(struct _reent *));
long _EXFUN(nrand48,(unsigned short [3]));
long _EXFUN(_nrand48_r,(struct _reent *, unsigned short [3]));
unsigned short *
_EXFUN(seed48,(unsigned short [3]));
unsigned short *
_EXFUN(_seed48_r,(struct _reent *, unsigned short [3]));
_VOID _EXFUN(srand48,(long));
_VOID _EXFUN(_srand48_r,(struct _reent *, long));
#endif /* ! __STRICT_ANSI__ */
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
long long _EXFUN(atoll,(const char *__nptr));
#endif
#ifndef __STRICT_ANSI__
long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr));
#endif /* ! __STRICT_ANSI__ */
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
long long _EXFUN(llabs,(long long));
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
#ifndef __STRICT_ANSI__
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif /* ! __STRICT_ANSI__ */
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
#ifndef __STRICT_ANSI__
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#ifndef __CYGWIN__
_VOID _EXFUN(cfree,(_PTR));
int _EXFUN(unsetenv,(const char *__string));
int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
2000-02-17 20:39:52 +01:00
#endif
#ifdef __rtems__
int _EXFUN(posix_memalign,(void **, size_t, size_t));
#endif
2000-02-17 20:39:52 +01:00
#endif /* ! __STRICT_ANSI__ */
char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**));
#ifndef __CYGWIN__
_PTR _EXFUN_NOTHROW(_malloc_r,(struct _reent *, size_t));
_PTR _EXFUN_NOTHROW(_calloc_r,(struct _reent *, size_t, size_t));
_VOID _EXFUN_NOTHROW(_free_r,(struct _reent *, _PTR));
_PTR _EXFUN_NOTHROW(_realloc_r,(struct _reent *, _PTR, size_t));
2000-02-17 20:39:52 +01:00
_VOID _EXFUN(_mstats_r,(struct _reent *, char *));
#endif
2000-02-17 20:39:52 +01:00
int _EXFUN(_system_r,(struct _reent *, const char *));
_VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
/* There are two common qsort_r variants. If you request
_BSD_SOURCE, you get the BSD version; otherwise you get the GNU
version. We want that #undef qsort_r will still let you
invoke the underlying function, but that requires gcc support. */
#ifdef _BSD_SOURCE
# ifdef __GNUC__
_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR)))
__asm__ (__ASMNAME ("__bsd_qsort_r"));
# else
_VOID _EXFUN(__bsd_qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR)));
# define qsort_r __bsd_qsort_r
# endif
#elif __GNU_VISIBLE
_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, int (*_compar)(const _PTR, const _PTR, _PTR), _PTR __thunk));
#endif
/* On platforms where long double equals double. */
#ifdef _HAVE_LONG_DOUBLE
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
extern long double strtold (const char *__restrict, char **__restrict);
#endif
#endif /* _HAVE_LONG_DOUBLE */
2009-04-16 Ken Werner <ken.werner@de.ibm.com> * libm/libm.texinfo: Add long double function support chapter. * libc/include/machine/ieeefp.h: Add _LDBL_EQ_DBL define. * libc/include/stdlib.h: Include <machine/ieeefp.h>. (strtold, wcstold): Declare. * libc/stdlib/strtold.c: New File. * libc/stdlib/wcstold.c: Likewise. * libc/configure.in: Add long double check. * libc/configure: Regenerate. * libc/stdlib/Makefile.am: Add strtold.c and wcstold.c. * libc/stdlib/Makefile.in: Regenerate. * libc/include/math.h (atanl, cosl, sinl, tanl, tanhl): Declare. (frexpl, modfl, ceill, fabsl, floorl, log1pl, expm1l, acosl): Ditto. (asinl, atan2l, coshl, sinhl, expl, ldexpl, logl, log10l, powl): Ditto. (sqrtl, fmodl, hypotl, copysignl, nanl, ilogbl, asinhl, cbrt): Ditto. (nextafterl, rintl, scalbnl, exp2l, scalblnl, tgammal): Ditto. (nearbyintl, lrintl, llrintl, roundl, lroundl, llround): Ditto. (llroundl, truncl, remquol, fdiml, fmaxl, fminl, fmal, acoshl): Ditto. (atanhl, remainderl, lgammal, erfl, erfcl): Ditto. * libm/common/atanl.c: New File. * libm/common/cosl.c: Likewise. * libm/common/sinl.c: Likewise. * libm/common/modfl.c: Likewise. * libm/common/frexpl.c: Likewise. * libm/common/tanhl.c: Likewise. * libm/common/tanl.c: Likewise. * libm/common/expm1l.c: Likewise. * libm/common/log1pl.c: Likewise. * libm/common/ceill.c: Likewise. * libm/common/fabsl.c: Likewise. * libm/common/floorl.c: Likewise. * libm/common/acosl.c: Likewise. * libm/common/asinl.c: Likewise. * libm/common/atan2l.c: Likewise. * libm/common/coshl.c: Likewise. * libm/common/expl.c: Likewise. * libm/common/fmodl.c: Likewise. * libm/common/hypotl.c: Likewise. * libm/common/ldexpl.c: Likewise. * libm/common/log10l.c: Likewise. * libm/common/logl.c: Likewise. * libm/common/powl.c: Likewise. * libm/common/sqrtl.c: Likewise. * libm/common/copysignl.c: Likewise. * libm/common/ilogbl.c: Likewise. * libm/common/nanl.c: Likewise. * libm/common/cbrtl.c: Likewise. * libm/common/asinhl.c: Likewise. * libm/common/nextafterl.c: Likewise. * libm/common/rintl.c: Likewise. * libm/common/scalbnl.c: Likewise. * libm/common/exp2l.c: Likewise. * libm/common/fdiml.c: Likewise. * libm/common/fmal.c: Likewise. * libm/common/fmaxl.c: Likewise. * libm/common/fminl.c: Likewise. * libm/common/lrintl.c: Likewise. * libm/common/lroundl.c: Likewise. * libm/common/nearbyintl.c: Likewise. * libm/common/remquol.c: Likewise. * libm/common/roundl.c: Likewise. * libm/common/scalblnl.c: Likewise. * libm/common/truncl.c: Likewise. * libm/common/acoshl.c: Likewise. * libm/common/atanhl.c: Likewise. * libm/common/erfcl.c: Likewise. * libm/common/erfl.c: Likewise. * libm/common/lgammal.c: Likewise. * libm/common/remainderl.c: Likewise. * libm/common/tgammal.c: Likewise. * libm/common/sinhl.c: Likewise. * libm/common/llroundl.c: Likewise. * libm/configure.in: Add long double check. * libm/configure: Regenerate. * libm/common/Makefile.am: Add new files. * libm/common/Makefile.in: Regenerate.
2009-04-16 20:24:35 +02:00
/*
* If we're in a mode greater than C99, expose C11 functions.
*/
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
__alloc_size(2);
int at_quick_exit(void (*)(void));
_Noreturn void
quick_exit(int);
#endif /* __ISO_C_VISIBLE >= 2011 */
_END_STD_C
2000-02-17 20:39:52 +01:00
#endif /* _STDLIB_H_ */