From c63f340d90800895f007de64b7d2d14624263331 Mon Sep 17 00:00:00 2001 From: nthnluu Date: Sun, 28 Jan 2024 21:20:27 -0500 Subject: Created student weenix repository --- user/include/stdlib.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 user/include/stdlib.h (limited to 'user/include/stdlib.h') 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); -- cgit v1.2.3-70-g09d2