PatchworkOS
Loading...
Searching...
No Matches
stdlib.h
Go to the documentation of this file.
1#ifndef _STDLIB_H
2#define _STDLIB_H 1
3
4#if defined(__cplusplus)
5extern "C"
6{
7#endif
8
9#include "_internal/NULL.h"
10#include "_internal/config.h"
11#include "_internal/size_t.h"
12
13_PUBLIC char* lltoa(long long number, char* str, int base);
14#define ltoa(number, str, base) lltoa(number, str, base)
15#define itoa(number, str, base) lltoa(number, str, base)
16
17_PUBLIC char* ulltoa(unsigned long long number, char* str, int base);
18#define ultoa(number, str, base) lltoa(number, str, base)
19#define uitoa(number, str, base) lltoa(number, str, base)
20
21_PUBLIC double atof(const char* nptr);
22_PUBLIC double strtod(const char* _RESTRICT nptr, char** _RESTRICT endptr);
23_PUBLIC float strtof(const char* _RESTRICT nptr, char** _RESTRICT endptr);
24_PUBLIC long double strtold(const char* _RESTRICT nptr, char** _RESTRICT endptr);
25
26_PUBLIC long long int strtoll(const char* _RESTRICT nptr, char** _RESTRICT endptr, int base);
27#define strtol(nptr, endptr, base) ((long int)strtoll(nptr, endptr, base))
28
29_PUBLIC unsigned long int strtoul(const char* _RESTRICT nptr, char** _RESTRICT endptr, int base);
30_PUBLIC unsigned long long int strtoull(const char* _RESTRICT nptr, char** _RESTRICT endptr, int base);
31
32_PUBLIC long long int atoll(const char* nptr);
33#define atol(nptr) ((long)atoll(nptr))
34#define atoi(nptr) ((int)atoll(nptr))
35
36#define RAND_MAX 32767
37
38_PUBLIC int rand(void);
39_PUBLIC void srand(unsigned int seed);
40
41_PUBLIC void* malloc(size_t size);
42_PUBLIC void* calloc(size_t nmemb, size_t size);
43_PUBLIC void free(void* ptr);
44_PUBLIC void* realloc(void* ptr, size_t size);
45
46#define EXIT_SUCCESS 0
47#define EXIT_FAILURE -1
48
49_PUBLIC _NORETURN void abort(void);
50
51_PUBLIC int at_quick_exit(void (*func)(void));
52
53_PUBLIC int atexit(void (*func)(void));
54
55_PUBLIC _NORETURN void exit(int status);
56
57_PUBLIC _NORETURN void quick_exit(int status);
58
59_PUBLIC _NORETURN void _Exit(int status);
60
61_PUBLIC char* getenv(const char* name);
62
63_PUBLIC int system(const char* string);
64
65_PUBLIC void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
66 int (*compar)(const void*, const void*));
67
68_PUBLIC void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
69
70_PUBLIC int abs(int j);
71_PUBLIC long int labs(long int j);
72_PUBLIC long long int llabs(long long int j);
73
74typedef struct
75{
76 int quot;
77 int rem;
78} div_t;
79
80typedef struct
81{
82 long int quot;
83 long int rem;
84} ldiv_t;
85
86typedef struct
87{
88 long long int quot;
89 long long int rem;
90} lldiv_t;
91
92_PUBLIC div_t div(int numer, int denom);
93_PUBLIC ldiv_t ldiv(long int numer, long int denom);
94_PUBLIC lldiv_t lldiv(long long int numer, long long int denom);
95
96int system(const char* command);
97
98#if _USE_ANNEX_K == 1
99
100#include "_internal/errno_t.h"
101#include "_internal/rsize_t.h"
102
103typedef void (*constraint_handler_t)(const char* _RESTRICT msg, void* _RESTRICT ptr, errno_t err);
104
105_PUBLIC constraint_handler_t set_constraint_handler_s(constraint_handler_t handler);
106
107_PUBLIC void abort_handler_s(const char* _RESTRICT msg, void* _RESTRICT ptr, errno_t err);
108
109_PUBLIC void ignore_handler_s(const char* _RESTRICT msg, void* _RESTRICT ptr, errno_t err);
110
111_PUBLIC errno_t getenv_s(size_t* _RESTRICT len, char* _RESTRICT value, rsize_t maxsize, const char* _RESTRICT name);
112
113_PUBLIC void* bsearch_s(const void* key, const void* base, rsize_t nmemb, rsize_t size,
114 int (*compar)(const void* k, const void* y, void* context), void* context);
115
116_PUBLIC errno_t qsort_s(void* base, rsize_t nmemb, rsize_t size,
117 int (*compar)(const void* x, const void* y, void* context), void* context);
118
119#endif
120
121#if defined(__cplusplus)
122}
123#endif
124
125#endif
void abort_handler_s(const char *_RESTRICT msg, void *_RESTRICT ptr, errno_t err)
int errno_t
Definition errno_t.h:4
static atomic_uint64_t seed
Definition rand.c:11
#define _PUBLIC
Definition config.h:41
#define _NORETURN
Definition config.h:28
#define _RESTRICT
Definition config.h:17
int64_t x
Definition main.c:152
int64_t y
Definition main.c:153
__SIZE_TYPE__ rsize_t
Definition rsize_t.h:4
constraint_handler_t set_constraint_handler_s(constraint_handler_t handler)
_PUBLIC div_t div(int numer, int denom)
Definition div.c:3
_PUBLIC ldiv_t ldiv(long int numer, long int denom)
_PUBLIC _NORETURN void exit(int status)
Definition exit.c:7
_PUBLIC void srand(unsigned int seed)
_PUBLIC int rand(void)
Definition rand.c:5
_PUBLIC int abs(int j)
Definition abs.c:3
_PUBLIC long long int strtoll(const char *_RESTRICT nptr, char **_RESTRICT endptr, int base)
_PUBLIC int atexit(void(*func)(void))
_PUBLIC lldiv_t lldiv(long long int numer, long long int denom)
_PUBLIC void * realloc(void *ptr, size_t size)
Definition realloc.c:13
_PUBLIC void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
Definition qsort.c:47
_PUBLIC long int labs(long int j)
Definition labs.c:3
_PUBLIC char * ulltoa(unsigned long long number, char *str, int base)
Definition ulltoa.c:5
_PUBLIC int at_quick_exit(void(*func)(void))
_PUBLIC void * bsearch(const void *key, const void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
_PUBLIC float strtof(const char *_RESTRICT nptr, char **_RESTRICT endptr)
_PUBLIC int system(const char *string)
Definition system.c:6
_PUBLIC _NORETURN void _Exit(int status)
_PUBLIC long double strtold(const char *_RESTRICT nptr, char **_RESTRICT endptr)
_PUBLIC unsigned long int strtoul(const char *_RESTRICT nptr, char **_RESTRICT endptr, int base)
_PUBLIC char * lltoa(long long number, char *str, int base)
_PUBLIC long long int atoll(const char *nptr)
Definition atoll.c:8
_PUBLIC char * getenv(const char *name)
_PUBLIC long long int llabs(long long int j)
Definition llabs.c:3
_PUBLIC void * calloc(size_t nmemb, size_t size)
Definition calloc.c:6
_PUBLIC void * malloc(size_t size)
Definition malloc.c:5
_PUBLIC _NORETURN void abort(void)
Definition abort.c:7
_PUBLIC _NORETURN void quick_exit(int status)
_PUBLIC void free(void *ptr)
Definition free.c:11
_PUBLIC double strtod(const char *_RESTRICT nptr, char **_RESTRICT endptr)
_PUBLIC unsigned long long int strtoull(const char *_RESTRICT nptr, char **_RESTRICT endptr, int base)
_PUBLIC double atof(const char *nptr)
Definition atof.c:7
Definition stdlib.h:75
int quot
Definition stdlib.h:76
int rem
Definition stdlib.h:77
long int rem
Definition stdlib.h:83
long int quot
Definition stdlib.h:82
long long int quot
Definition stdlib.h:88
long long int rem
Definition stdlib.h:89