TOP

Data Types

Mantle is a kind of hardware abstraction layer for the Kestrel-2/EX platform. Because of this, it sits below the natural abstraction layer of most programming languages. For this reason, data types used in specifying Mantle's API are those specified by the RISC-V Instruction Set specifications:

Type Assembly Mnemonic Description
byte byte Signed or unsigned 8-bit quantity (depending on context)
half-word hword Signed or unsigned 16-bit quantity (depending on context)
word word Signed or unsigned 32-bit quantity (depending on context)
double-word dword Signed or unsigned 64-bit quantity (depending on context)

When referring specifically to these types in C, use the stdint.h and stdbool.h headers and the types they define. Other languages, like Forth, might have their own bindings.

Type C Type (signed) C Type (unsigned) Forth Type
byte int8_t uint8_t, bool character
half-word int16_t uint16_t vender-specific
word int32_t uint32_t vender-specific
double-word int64_t, intptr_t uint64_t, uintptr_t cell

Unless you know what you're doing, avoid using char, short, int, and long when working with Mantle interfaces and data structures. These types are logical in nature, intended for writing portable software, in the POSIX sense of the term. Some C compilers say that longs are 32-bits wide, while others say they're 64-bits, for example. If you're interfacing with Mantle, your code is by definition not generally portable.