diff options
author | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
---|---|---|
committer | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
commit | c63f340d90800895f007de64b7d2d14624263331 (patch) | |
tree | 2c0849fa597dd6da831c8707b6f2603403778d7b /user/include/stdlib.h |
Created student weenix repository
Diffstat (limited to 'user/include/stdlib.h')
-rw-r--r-- | user/include/stdlib.h | 60 |
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); |