llvm-mos-sdk
Classes | Macros | Functions
stdlib.h File Reference
#include <stddef.h>
Include dependency graph for stdlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  div_t
 
struct  ldiv_t
 
struct  lldiv_t
 

Macros

#define EXIT_SUCCESS   0
 
#define EXIT_FAILURE   1
 
#define RAND_MAX   32767
 
#define MB_CUR_MAX   ((size_t)1)
 

Functions

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 *))
 

Macro Definition Documentation

◆ EXIT_FAILURE

#define EXIT_FAILURE   1

◆ EXIT_SUCCESS

#define EXIT_SUCCESS   0

◆ MB_CUR_MAX

#define MB_CUR_MAX   ((size_t)1)

◆ RAND_MAX

#define RAND_MAX   32767

Function Documentation

◆ _strtoi()

int _strtoi ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ _strtosc()

signed char _strtosc ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ _strtouc()

unsigned char _strtouc ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ _strtoui()

unsigned int _strtoui ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ abort()

_Noreturn void abort ( void  )

◆ abs()

int abs ( int  i)

◆ aligned_alloc()

void* aligned_alloc ( size_t  alignment,
size_t  size 
)

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└────────────────────────────┘

◆ at_quick_exit()

int at_quick_exit ( void(*)(void)  func)

◆ atexit()

int atexit ( void(*)(void)  func)

◆ atoi()

int atoi ( const char *  s)

◆ atol()

long atol ( const char *  s)

◆ atoll()

long long atoll ( const char *  nptr)

◆ bsearch()

void* bsearch ( const void *  key,
const void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)

◆ calloc()

void* calloc ( size_t  nmemb,
size_t  size 
)

◆ div()

div_t div ( int  numer,
int  denom 
)

◆ exit()

_Noreturn void exit ( int  status)

◆ free()

void free ( void *  ptr)

◆ getenv()

char* getenv ( const char *  name)

◆ labs()

long labs ( long  i)

◆ ldiv()

ldiv_t ldiv ( long  numer,
long  denom 
)

◆ llabs()

long long llabs ( long long  i)

◆ lldiv()

lldiv_t lldiv ( long long  numer,
long long  denom 
)

◆ malloc()

void* malloc ( size_t  size)

◆ qsort()

void qsort ( void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)

◆ quick_exit()

_Noreturn void quick_exit ( int  status)

◆ rand()

int rand ( void  )

◆ realloc()

void* realloc ( void *  ptr,
size_t  size 
)

◆ srand()

void srand ( unsigned  seed)

◆ strtol()

long strtol ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ strtoll()

long long strtoll ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ strtoul()

unsigned long strtoul ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ strtoull()

unsigned long long strtoull ( const char *__restrict__  nptr,
char **__restrict  endptr,
int  base 
)

◆ system()

int system ( const char *  string)