KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Register Macros

Various macros used throughout the codebase More...

Files

file  regfield.h
 Macros to help dealing with register fields.
 

Macros

#define BIT(bit)   (1u << (bit))
 Create a mask with a bit set.
 
#define GENMASK(h, l)   ((0xffffffff << (l)) & (0xffffffff >> (31 - (h))))
 Create a mask with a range of bits set.
 
#define FIELD_GET(var, field)    (((var) & (field)) >> __builtin_ctz(field))
 Extract a field value from a variable.
 
#define FIELD_PREP(field, value)    (((value) << __builtin_ctz(field)) & (field))
 Prepare a field with a given value.
 

Detailed Description

Various macros used throughout the codebase

Macro Definition Documentation

◆ BIT

#define BIT ( bit)    (1u << (bit))

Create a mask with a bit set.

Parameters
bitThe bit to set (from 0 to 31)
Returns
A 32-bit mask with the corresponding bit set

◆ FIELD_GET

#define FIELD_GET ( var,
field )    (((var) & (field)) >> __builtin_ctz(field))

Extract a field value from a variable.

Parameters
varThe 32-bit variable containing the field
fieldA 32-bit mask that corresponds to the field
Returns
The value of the field (shifted)

◆ FIELD_PREP

#define FIELD_PREP ( field,
value )    (((value) << __builtin_ctz(field)) & (field))

Prepare a field with a given value.

Parameters
fieldA 32-bit mask that corresponds to the field
valueThe value to be put in the field

◆ GENMASK

#define GENMASK ( h,
l )   ((0xffffffff << (l)) & (0xffffffff >> (31 - (h))))

Create a mask with a range of bits set.

Parameters
hThe high bit of the range to set, included
lThe low bit of the range to set, included
Returns
A 32-bit mask with the corresponding bits set