From b93d34176f1815bd4acd942dc4830d7d17969096 Mon Sep 17 00:00:00 2001
From: Gitea <gitea@fake.local>
Date: Wed, 16 Dec 2020 17:18:27 -0600
Subject: [PATCH] Added POSIX defuns

---
 include/stdlib.h | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h
index d7879fb..4c07e0a 100755
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -43,12 +43,39 @@ struct lldiv_t {
   long long rem;
 };
 
-__attribute__((__noreturn__))
+#ifdef _POSIX_C_SOURCE
+#include <sys/wait.h>
+#endif
+
 void abort(void);
+int atexit(void (*)(void));
+void exit(int);
+void _Exit(int);
+
+char * getenv(const char *);
+int system(const char *);
+
+void * malloc(size_t);
+void * calloc(size_t, size_t);
+void * realloc(void *, size_t);
+void free(void *);
 
 void srand(unsigned int);
 int rand(void);
 
+double atof(const char *);
+int atoi(const char *);
+long int atol(const char *);
+long long int atoll(const char *);
+
+double strtod(const char * restrict, char ** restrict);
+float strtof(const char * restrict, char ** restrict);
+long double strtold(const char * restrict, char ** restrict);
+long int strtol(const char * restrict, char ** restrict, int);
+long long int strtoll(const char * restrict, char ** restrict, int);
+unsigned long int strtoul(const char * restrict, char ** restrict, int);
+unsigned long long int strtoull(const char * restrict, char ** restrict, int);
+
 struct div_t div(int, int);
 struct ldiv_t ldiv(long, long);
 struct lldiv_t lldiv(long long, long long);
@@ -58,6 +85,14 @@ long labs(long);
 long long llabs(long long);
 
 void * bsearch(const void *, const void *, size_t, size_t,
-	       int (*compar)(const void *, const void *));
+	       int (*)(const void *, const void *));
+void qsort(void *, size_t, size_t, int(*)(const void *, const void *));
+
+int mblen(const char *, size_t);
+int mbtowc(wchar_t * restrict, const char * restrict, size_t);
+int wctomb(char *, wchar_t);
+
+size_t mbstowcs(wchar_t * restrict, const char * restrict, size_t);
+size_t wcstombs(char * restrict, const wchar_t * restrict, size_t);
 
 #endif