libnds
Loading...
Searching...
No Matches
Macros | Typedefs
ndstypes.h File Reference

Custom types employed by libnds. More...

#include <stdbool.h>
#include <stdint.h>

Macros

#define ALIGN(m)   __attribute__((aligned (m)))
 Aligns a struct (and other types) to "m".
 
#define ARM_CODE   __attribute__((target("arm")))
 Used to tell the compiler to compile a function as ARM code.
 
#define BIT(n)   (1u << (n))
 Returns a number with the nth bit set.
 
#define COMPILER_MEMORY_BARRIER()   asm volatile("" ::: "memory")
 Helper that prevents the compiler from reordering memory accesses.
 
#define DTCM_BSS   __attribute__((section(".sbss")))
 Used to place uninitialized data in DTCM.
 
#define DTCM_DATA   __attribute__((section(".dtcm")))
 Used to place initialized data in DTCM.
 
#define ITCM_CODE   __attribute__((section(".itcm.text"), long_call))
 Used to place a function in ITCM.
 
#define PACKED   __attribute__ ((packed))
 Packs a struct so it won't include padding bytes.
 
#define THUMB_CODE   __attribute__((target("thumb")))
 Used to tell the compiler to compile a function as Thumb code (default)
 
#define TWL_BSS   __attribute__((section(".twl_bss")))
 Used to place uninitialized data in DSi RAM.
 
#define TWL_CODE   __attribute__((section(".twl.text")))
 Used to place a function in DSi RAM.
 
#define TWL_DATA   __attribute__((section(".twl.data")))
 Used to place initialized data in DSi RAM.
 
#define WARN_UNUSED_RESULT   __attribute__((warn_unused_result))
 Makes the compiler output a warning if the return value of a function is ignored.
 

Typedefs

typedef int16_t s16
 16 bit signed integer.
 
typedef int32_t s32
 32 bit signed integer.
 
typedef int64_t s64
 64 bit signed integer.
 
typedef int8_t s8
 8 bit signed integer.
 
typedef uint16_t u16
 16 bit unsigned integer.
 
typedef uint32_t u32
 32 bit unsigned integer.
 
typedef uint64_t u64
 64 bit unsigned integer.
 
typedef uint8_t u8
 8 bit unsigned integer.
 
typedef volatile int16_t vint16
 16 bit volatile signed integer.
 
typedef volatile int32_t vint32
 32 bit volatile signed integer.
 
typedef volatile int64_t vint64
 64 bit volatile signed integer.
 
typedef volatile int8_t vint8
 8 bit volatile signed integer.
 
typedef void(* VoidFn) (void)
 Function pointer that takes no arguments and doesn't return anything.
 
typedef volatile s16 vs16
 16 bit volatile signed integer.
 
typedef volatile s32 vs32
 32 bit volatile signed integer.
 
typedef volatile s64 vs64
 64 bit volatile signed integer.
 
typedef volatile s8 vs8
 8 bit volatile signed integer.
 
typedef volatile u16 vu16
 16 bit volatile unsigned integer.
 
typedef volatile u32 vu32
 32 bit volatile unsigned integer.
 
typedef volatile u64 vu64
 64 bit volatile unsigned integer.
 
typedef volatile u8 vu8
 8 bit volatile unsigned integer.
 
typedef volatile uint16_t vuint16
 16 bit volatile unsigned integer.
 
typedef volatile uint32_t vuint32
 32 bit volatile unsigned integer.
 
typedef volatile uint64_t vuint64
 64 bit volatile unsigned integer.
 
typedef volatile uint8_t vuint8
 8 bit volatile unsigned integer.
 

Detailed Description

Custom types employed by libnds.

Macro Definition Documentation

◆ COMPILER_MEMORY_BARRIER

#define COMPILER_MEMORY_BARRIER ( )    asm volatile("" ::: "memory")

Helper that prevents the compiler from reordering memory accesses.

Accesses to pointers marked as "volatile" aren't reordered, but accesses to non-volatile pointers can be reordered. Sometimes, this reordering can cause issues. For example, if you want to setup VRAM as LCD to write to it, but the compiler decides to set it to LCD after writing data to it. It can also happen if the compiler sets VRAM to texture mode or extended palette mode before it has finished writing data to it.

This barrier makes sure that all the accesses before it happen before all accesses after it.

Note that this doesn't compile to any instruction, it's just an indication for the compiler.