X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Fstdlib.h;h=475190bfa2c9fee8b2d482fb492f28af35e05a8e;hb=d055e6a45a17673b8dd3ec16e786bb2fe1700dd5;hp=045756bc92b7c76dfdf8d40fbd241ec078ea8e44;hpb=80695b1d1e64a026c473a33965e680444e863e34;p=musl diff --git a/include/stdlib.h b/include/stdlib.h index 045756bc..475190bf 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -5,9 +5,12 @@ extern "C" { #endif -#undef NULL -#ifdef __cplusplus -#define NULL 0 +#include + +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) +#define NULL 0L #else #define NULL ((void*)0) #endif @@ -22,14 +25,14 @@ long atol (const char *); long long atoll (const char *); double atof (const char *); -float strtof (const char *, char **); -double strtod (const char *, char **); -long double strtold (const char *, char **); +float strtof (const char *__restrict, char **__restrict); +double strtod (const char *__restrict, char **__restrict); +long double strtold (const char *__restrict, char **__restrict); -long strtol (const char *, char **, int); -unsigned long strtoul (const char *, char **, int); -long long strtoll (const char *, char **, int); -unsigned long long strtoull (const char *, char **, int); +long strtol (const char *__restrict, char **__restrict, int); +unsigned long strtoul (const char *__restrict, char **__restrict, int); +long long strtoll (const char *__restrict, char **__restrict, int); +unsigned long long strtoull (const char *__restrict, char **__restrict, int); int rand (void); void srand (unsigned); @@ -38,11 +41,14 @@ void *malloc (size_t); void *calloc (size_t, size_t); void *realloc (void *, size_t); void free (void *); +void *aligned_alloc(size_t, size_t); -void abort (void); +_Noreturn void abort (void); int atexit (void (*) (void)); -void exit (int); -void _Exit (int); +_Noreturn void exit (int); +_Noreturn void _Exit (int); +int at_quick_exit (void (*) (void)); +_Noreturn void quick_exit (int); char *getenv (const char *); @@ -64,30 +70,39 @@ ldiv_t ldiv (long, long); lldiv_t lldiv (long long, long long); int mblen (const char *, size_t); -int mbtowc (wchar_t *, const char *, size_t); +int mbtowc (wchar_t *__restrict, const char *__restrict, size_t); int wctomb (char *, wchar_t); -size_t mbstowcs (wchar_t *, const char *, size_t); -size_t wcstombs (char *, const wchar_t *, size_t); +size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t); +size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t); + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 -#define MB_CUR_MAX 4 +size_t __ctype_get_mb_cur_max(void); +#define MB_CUR_MAX (__ctype_get_mb_cur_max()) #define RAND_MAX (0x7fffffff) #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) -#ifndef WEXITSTATUS -#include -#endif +#define WNOHANG 1 +#define WUNTRACED 2 -#define EXIT_FAILURE 1 -#define EXIT_SUCCESS 0 +#define WEXITSTATUS(s) (((s) & 0xff00) >> 8) +#define WTERMSIG(s) ((s) & 0x7f) +#define WSTOPSIG(s) WEXITSTATUS(s) +#define WIFEXITED(s) (!WTERMSIG(s)) +#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001U)>>8) > 0x7f00) +#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) int posix_memalign (void **, size_t, size_t); int setenv (const char *, const char *, int); int unsetenv (const char *); int mkstemp (char *); +int mkostemp (char *, int); char *mkdtemp (char *); int getsubopt (char **, char *const *, char **); int rand_r (unsigned *); @@ -95,20 +110,21 @@ int rand_r (unsigned *); #endif -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +char *realpath (const char *__restrict, char *__restrict); +long int random (void); +void srandom (unsigned int); +char *initstate (unsigned int, char *, size_t); +char *setstate (char *); int putenv (char *); int posix_openpt (int); int grantpt (int); int unlockpt (int); char *ptsname (int); -char *realpath (const char *, char *); char *l64a (long); long a64l (const char *); void setkey (const char *); -long int random (void); -void srandom (unsigned int); -char *initstate (unsigned int, char *, size_t); -char *setstate (char *); double drand48 (void); double erand48 (unsigned short [3]); long int lrand48 (void); @@ -120,12 +136,41 @@ unsigned short *seed48 (unsigned short [3]); void lcong48 (unsigned short [7]); #endif -#if defined(_GNU_SOURCE) +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#include char *mktemp (char *); +int mkstemps (char *, int); +int mkostemps (char *, int, int); void *valloc (size_t); void *memalign(size_t, size_t); +int getloadavg(double *, int); +int clearenv(void); +#define WCOREDUMP(s) ((s) & 0x80) +#define WIFCONTINUED(s) ((s) == 0xffff) +void *reallocarray (void *, size_t, size_t); +void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *); +#endif + +#ifdef _GNU_SOURCE +int ptsname_r(int, char *, size_t); +char *ecvt(double, int, int *, int *); +char *fcvt(double, int, int *, int *); +char *gcvt(double, int, char *); +char *secure_getenv(const char *); +struct __locale_struct; +float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *); +double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *); +long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); #endif +#if defined(_LARGEFILE64_SOURCE) +#define mkstemp64 mkstemp +#define mkostemp64 mkostemp +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define mkstemps64 mkstemps +#define mkostemps64 mkostemps +#endif +#endif #ifdef __cplusplus }