diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-01-03 02:19:57 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-01-03 02:19:57 +0800 |
| commit | 210025560c80b48af4875af199f183ad709e3bf0 (patch) | |
| tree | eb11aeb7b641187f207e3b572c5184cf3526b463 /include/ulib/stdlib.h | |
| parent | bde87490d61135dcaa94d9b1489ff6c39876d169 (diff) | |
| parent | 10614e04929a6d109a5e90524e446b637aaf0c13 (diff) | |
| download | lume-210025560c80b48af4875af199f183ad709e3bf0.tar.gz lume-210025560c80b48af4875af199f183ad709e3bf0.tar.xz | |
Merge pull request #4 from Richard-Qin-001/dev/shell
Rebuilt the system's underlying structure; it is now stable enough to merge.
The system now supports a read-only file system and has a simple shell implemented.
Diffstat (limited to 'include/ulib/stdlib.h')
| -rw-r--r-- | include/ulib/stdlib.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/include/ulib/stdlib.h b/include/ulib/stdlib.h new file mode 100644 index 0000000..7dc325e --- /dev/null +++ b/include/ulib/stdlib.h @@ -0,0 +1,95 @@ +#ifndef _STDLIB_H +#define _STDLIB_H + +#include "ulib/types.h" +#include "ulib/limits.h" +#include "ulib/errno.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define ERANGE 34 /* Math result not representable */ +#define ENOMEM 12 /* Out of memory */ + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 +#define RAND_MAX 32767 +#define MB_CUR_MAX 1 + +typedef struct +{ + int quot; + int rem; +} div_t; +typedef struct +{ + long quot; + long rem; +} ldiv_t; +typedef struct +{ + long long quot; + long long rem; +} lldiv_t; + +typedef int (*__compar_fn_t)(const void *, const void *); + +/* Memory Management */ +void *malloc(size_t size); +void free(void *ptr); +void *calloc(size_t nmemb, size_t size); +void *realloc(void *ptr, size_t size); + +/* Process Control */ +int exit(int status); +void abort(void); +int atexit(void (*function)(void)); +char *getenv(const char *name); +int system(const char *command); + +/* String Conversion */ +int atoi(const char *nptr); +long atol(const char *nptr); +long long atoll(const char *nptr); +double atof(const char *nptr); + +long strtol(const char *nptr, char **endptr, int base); +unsigned long strtoul(const char *nptr, char **endptr, int base); +long long strtoll(const char *nptr, char **endptr, int base); +unsigned long long strtoull(const char *nptr, char **endptr, int base); + +double strtod(const char *nptr, char **endptr); +float strtof(const char *nptr, char **endptr); + +/* Search & Sort*/ +void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); +void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); + +/* Math & Mics */ +int abs(int j); +long labs(long j); +long long llabs(long long j); +div_t div(int numer, int denom); +ldiv_t ldiv(long numer, long denom); +lldiv_t lldiv(long long numer, long long denom); + +int rand(void); +void srand(unsigned int seed); + +int mblen(const char *s, size_t n); +int mbtowc(wchar_t *pwc, const char *s, size_t n); +int wctomb(char *s, wchar_t wchar); +size_t mbstowcs(wchar_t *dest, const char *src, size_t n); +size_t wcstombs(char *dest, const wchar_t *src, size_t n); + +#ifdef __cplusplus +} +#endif + +#endif /* _STDLIB_H */
\ No newline at end of file |
