aboutsummaryrefslogtreecommitdiff
path: root/user/include/stdlib.h
diff options
context:
space:
mode:
Diffstat (limited to 'user/include/stdlib.h')
-rw-r--r--user/include/stdlib.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/user/include/stdlib.h b/user/include/stdlib.h
new file mode 100644
index 0000000..31de474
--- /dev/null
+++ b/user/include/stdlib.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "limits.h"
+#include "sys/types.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+/* Exit */
+__attribute__((noreturn)) void exit(int status);
+
+int atexit(void (*func)(void));
+void _Exit(int status); /* NYI */
+
+/* string to num conversion */
+int atoi(const char *val);
+
+/* --- NYI --- */
+long atol(const char *val);
+
+float atof(const char *val);
+
+#define atoi(val) ((int)strtol(val, NULL, 10))
+#define atol(val) strtol(val, NULL, 10)
+#define atolf(val) strtof(val, NULL)
+
+long strtol(const char *nptr, char **endptr, int base);
+
+long long strtoll(const char *nptr, char **endptr, int base);
+
+double strtod(const char *nptr, char **endptr);
+
+float strtof(const char *nptr, char **endptr);
+
+long double strtold(const char *nptr, char **endptr);
+/* --- END NYI --- */
+
+/* Malloc library */
+void *malloc(size_t size);
+
+void free(void *ptr);
+
+void *realloc(void *ptr, size_t size);
+
+void *calloc(size_t nelem, size_t elsize);
+
+#define RAND_MAX INT_MAX
+
+int rand(void);
+
+void srand(unsigned int seed);