fix some obscure header type size/alignment issues
[musl] / include / stdlib.h
index c1d93e7..0bcc9f4 100644 (file)
@@ -5,12 +5,9 @@
 extern "C" {
 #endif
 
-#undef NULL
-#ifdef __cplusplus
-#define NULL 0
-#else
-#define NULL ((void*)0)
-#endif
+#include <features.h>
+
+#define NULL 0L
 
 #define __NEED_size_t
 #define __NEED_wchar_t
@@ -22,14 +19,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,13 +35,14 @@ void *malloc (size_t);
 void *calloc (size_t, size_t);
 void *realloc (void *, size_t);
 void free (void *);
+void *aligned_alloc(size_t alignment, size_t size);
 
-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));
-void quick_exit (int);
+_Noreturn void quick_exit (int);
 
 char *getenv (const char *);
 
@@ -66,10 +64,10 @@ 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
@@ -83,21 +81,21 @@ size_t wcstombs (char *, const wchar_t *, size_t);
  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  || defined(_BSD_SOURCE)
 
-#ifndef WEXITSTATUS
+#define WNOHANG    1
+#define WUNTRACED  2
+
 #define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
 #define WTERMSIG(s) ((s) & 0x7f)
 #define WSTOPSIG(s) WEXITSTATUS(s)
-#define WCOREDUMP(s) ((s) & 0x80)
 #define WIFEXITED(s) (!WTERMSIG(s))
 #define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
 #define WIFSIGNALED(s) (((signed char) (((s) & 0x7f) + 1) >> 1) > 0)
-#define WIFCONTINUED(s) ((s) == 0xffff)
-#endif
 
 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 *);
@@ -107,7 +105,7 @@ int rand_r (unsigned *);
 
 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  || defined(_BSD_SOURCE)
-char *realpath (const char *, char *);
+char *realpath (const char *__restrict, char *__restrict);
 long int random (void);
 void srandom (unsigned int);
 char *initstate (unsigned int, char *, size_t);
@@ -137,8 +135,12 @@ void lcong48 (unsigned short [7]);
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 #include <alloca.h>
 char *mktemp (char *);
+int mkstemps (char *, int);
+int mkostemps (char *, int, int);
 void *valloc (size_t);
 void *memalign(size_t, size_t);
+#define WCOREDUMP(s) ((s) & 0x80)
+#define WIFCONTINUED(s) ((s) == 0xffff)
 #endif
 
 #ifdef _GNU_SOURCE
@@ -151,6 +153,11 @@ char *gcvt(double, int, char *);
 
 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
 #define mkstemp64 mkstemp
+#define mkostemp64 mkostemp
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define mkstemps64 mkstemps
+#define mkostemps64 mkostemps
+#endif
 #endif
 
 #ifdef __cplusplus