|
int | abs (int i) |
|
long | labs (long i) |
|
long long | llabs (long long i) |
|
int | atoi (const char *s) |
|
long | atol (const char *s) |
|
div_t | div (int numer, int denom) |
|
ldiv_t | ldiv (long numer, long denom) |
|
lldiv_t | lldiv (long long numer, long long denom) |
|
long long | atoll (const char *nptr) |
|
long | strtol (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
long long | strtoll (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
unsigned long | strtoul (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
unsigned long long | strtoull (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
signed char | _strtosc (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
unsigned char | _strtouc (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
int | _strtoi (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
unsigned int | _strtoui (const char *__restrict__ nptr, char **__restrict endptr, int base) |
|
int | rand (void) |
|
void | srand (unsigned seed) |
|
void * | aligned_alloc (size_t alignment, size_t size) |
|
void * | calloc (size_t nmemb, size_t size) |
|
void | free (void *ptr) |
|
void * | malloc (size_t size) |
|
void * | realloc (void *ptr, size_t size) |
|
_Noreturn void | abort (void) |
|
int | atexit (void(*func)(void)) |
|
int | at_quick_exit (void(*func)(void)) |
|
_Noreturn void | exit (int status) |
|
char * | getenv (const char *name) |
|
_Noreturn void | quick_exit (int status) |
|
int | system (const char *string) |
|
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 *)) |
|
Simple malloc/free implementation.
Note: if your program does not need to use the heap, then do not call any of these functions. The entire heap implementation is only allocated in your program if you actually call the allocation functions.
The heap segment is placed directly after BSS in your program. The heap can utilize any of the memory between the base heap address and the top of the software-defined stack.
Typical memory map, for a target that loads programs into RAM:
┌─────────────────────────────────┐
│Reserved or otherwise unavailable│
0xFFFF┌────────────────────────────┐ ┌──│ memory. Ex: ROM or I/O │ │ │◀─┘ └─────────────────────────────────┘ │ │ ├────────────────────────────┤◀┐ │ │ │ │ ┌───────────────────────────────────────┐ │ Stack │ │ │ │Stack base. As stack usage grows, more│ │ │ │ └──│memory below this address is utilized. │ │ ▼ │ └───────────────────────────────────────┘ │ │ ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│◀─┐ ┌────────────────────────────────────────┐ │ │ │ │Actual lower limit for stack depends on │ │ │ │ │how much stack space your code actually │ │ │ └──│needs. Generally it can't be determined│ │ │ │ ahead of time. │ │ │ └────────────────────────────────────────┘ ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│◀┐ │ │ │ │ │ │ │ │ │ │ │ │ ┌───────────────────────────────────────┐ │ │ │ │Heap limit. You can set this from │ │ ▲ │ └──│within your program. │ │ Heap │ │ └───────────────────────────────────────┘ │ │ │ ├────────────────────────────┤◀┐ │ │ │ ┌───────────────────────────────────────┐ │ Your program is loaded │ │ │ Heap base pointer. It's location │ │ here. │ │ │depends on how big your program is and │ │ │ └──│how much memory it allocated in global │ ├────────────────────────────┤ │ and static variables. │ │ │ └───────────────────────────────────────┘ │ Reserved lower memory: │ │ zero-page, │ │ hardware stack, etc. │ │ │ │ │ 0x0000└────────────────────────────┘