GBDK 2020 Docs  4.1.1
API Documentation for GBDK 2020
stdlib.h File Reference
#include <types.h>

Go to the source code of this file.

Macros

#define __reentrant
 

Functions

void exit (int status) OLDCALL
 
int abs (int i) OLDCALL
 
long labs (long num) OLDCALL
 
int atoi (const char *s)
 
long atol (const char *s)
 
char * itoa (int n, char *s, unsigned char radix) OLDCALL
 
char * uitoa (unsigned int n, char *s, unsigned char radix) OLDCALL
 
char * ltoa (long n, char *s, unsigned char radix) OLDCALL
 
char * ultoa (unsigned long n, char *s, unsigned char radix) OLDCALL
 
void * calloc (size_t nmemb, size_t size)
 
void * malloc (size_t size)
 
void * realloc (void *ptr, size_t size)
 
void free (void *ptr)
 
void * bsearch (const void *key, const void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *) __reentrant)
 
void qsort (void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *) __reentrant)
 

Macro Definition Documentation

◆ __reentrant

#define __reentrant

file stdlib.h 'Standard library' functions, for whatever that means.

Function Documentation

◆ exit()

void exit ( int  status)

Causes normal program termination and the value of status is returned to the parent. All open streams are flushed and closed.

◆ abs()

int abs ( int  i)

Returns the absolute value of int i

Parameters
iInt to obtain absolute value of

If i is negative, returns -i; else returns i.

◆ labs()

long labs ( long  num)

Returns the absolute value of long int num

Parameters
numLong integer to obtain absolute value of

◆ atoi()

int atoi ( const char *  s)

Converts an ASCII string to an int

Parameters
sString to convert to an int

The string may be of the format

[\s]*[+-][\d]+[\D]*
void d
Definition: gb.h:665

i.e. any number of spaces, an optional + or -, then an arbitrary number of digits.

The result is undefined if the number doesnt fit in an int.

Returns: Int value of string

◆ atol()

long atol ( const char *  s)

Converts an ASCII string to a long.

Parameters
sString to convert to an long int
See also
atoi()

Returns: Long int value of string

◆ itoa()

char* itoa ( int  n,
char *  s,
unsigned char  radix 
)

Converts an int into a base 10 ASCII string.

Parameters
nInt to convert to a string
sString to store the converted number
radixNumerical base for converted number, ex: 10 is decimal base (parameter is required but not utilized on Game Boy and Analogue Pocket)

Can be used with set_bkg_based_tiles() for printing if the digit character tiles are not ascii-mapped.

Returns: Pointer to converted string

◆ uitoa()

char* uitoa ( unsigned int  n,
char *  s,
unsigned char  radix 
)

Converts an unsigned int into a base 10 ASCII string.

Parameters
nUnsigned Int to convert to a string
sString to store the converted number
radixNumerical base for converted number, ex: 10 is decimal base (parameter is required but not utilized on Game Boy and Analogue Pocket)

Can be used with set_bkg_based_tiles() for printing if the digit character tiles are not ascii-mapped.

Returns: Pointer to converted string

◆ ltoa()

char* ltoa ( long  n,
char *  s,
unsigned char  radix 
)

Converts a long into a base 10 ASCII string.

Parameters
nLong int to convert to a string
sString to store the converted number
radixNumerical base for converted number, ex: 10 is decimal base (parameter is required but not utilized on Game Boy and Analogue Pocket)

Can be used with set_bkg_based_tiles() for printing if the digit character tiles are not ascii-mapped.

Returns: Pointer to converted string

◆ ultoa()

char* ultoa ( unsigned long  n,
char *  s,
unsigned char  radix 
)

Converts an unsigned long into a base 10 ASCII string.

Parameters
nUnsigned Long Int to convert to a string
sString to store the converted number
radixNumerical base for converted number, ex: 10 is decimal base (parameter is required but not utilized on Game Boy and Analogue Pocket)

Can be used with set_bkg_based_tiles() for printing if the digit character tiles are not ascii-mapped.

Returns: Pointer to converted string

◆ calloc()

void* calloc ( size_t  nmemb,
size_t  size 
)

Memory allocation functions

◆ malloc()

void* malloc ( size_t  size)

◆ realloc()

void* realloc ( void *  ptr,
size_t  size 
)

◆ free()

void free ( void *  ptr)

◆ bsearch()

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

search a sorted array of nmemb items

Parameters
keyPointer to object that is the key for the search
basePointer to first object in the array to search
nmembNumber of elements in the array
sizeSize in bytes of each element in the array
comparFunction used to compare two elements of the array

Returns: Pointer to array entry that matches the search key. If key is not found, NULL is returned.

◆ qsort()

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

Sort an array of nmemb items

Parameters
basePointer to first object in the array to sort
nmembNumber of elements in the array
sizeSize in bytes of each element in the array
comparFunction used to compare and sort two elements of the array