Haka: include/haka/types.h File Reference

Haka

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Typedefs
types.h File Reference
`#include <haka/config.h>`
`#include <byteswap.h>`

Go to the source code of this file.

## Macros
#define | true 1
#define | false 0
#define | SWAP(type, x) SWAP_##type(x)
#define | SWAP_TO_LE(type, x) (x)
#define | SWAP_FROM_LE(type, x) (x)
#define | SWAP_TO_BE(type, x) SWAP(type, (x))
#define | SWAP_FROM_BE(type, x) SWAP(type, (x))
#define | GET_BIT(v, i) ((((v) & (1 << (i))) != 0))
#define | SET_BIT(v, i, x) ((x) ? ((v) | (1 << (i))) : ((v) & ~(1 << (i))))
#define | GET_BITS(v, i, j) (((v) & GET_BITS_MASK(i, j)) >> (i))
#define | SET_BITS(v, i, j, x) (((v) & ~(GET_BITS_MASK(i, j))) | (((x) << (i)) & GET_BITS_MASK(i, j)))

## Typedefs
typedef unsigned char | bool
typedef char | int8
typedef HAKA_16BIT_TYPE | int16
typedef HAKA_32BIT_TYPE | int32
typedef HAKA_64BIT_TYPE | int64
typedef unsigned char | uint8
typedef unsigned HAKA_16BIT_TYPE | uint16
typedef unsigned HAKA_32BIT_TYPE | uint32
typedef unsigned HAKA_64BIT_TYPE | uint64

## Detailed Description

Basic types used all along Haka.

## Macro Definition Documentation

#define false 0

Boolean value `false`.

#define GET_BIT | ( |  | v,
|  |  | i
| ) |  | ((((v) & (1 << (i))) != 0))

Get the bit `i` from an integer `v`.

#define GET_BITS | ( |  | v,
|  |  | i,
|  |  | j
| ) |  | (((v) & GET_BITS_MASK(i, j)) >> (i))

Get the bits in range [`i` ; `j`] from an integer `v`.

#define SET_BIT | ( |  | v,
|  |  | i,
|  |  | x
| ) |  | ((x) ? ((v) | (1 << (i))) : ((v) & ~(1 << (i))))

Set the bit `i` from an integer `v` to `x`.

#define SET_BITS | ( |  | v,
|  |  | i,
|  |  | j,
|  |  | x
| ) |  | (((v) & ~(GET_BITS_MASK(i, j))) | (((x) << (i)) & GET_BITS_MASK(i, j)))

Set the bits in range [`i` ; `j`] from an integer `v` to `x`.

#define SWAP | ( |  | type,
|  |  | x
| ) |  | SWAP_##type(x)

Byte swapping utility macro.

Parameters

  type | C type (int32, uint64...)
  x | Value to swap.

#define SWAP_FROM_BE | ( |  | type,
|  |  | x
| ) |  | SWAP(type, (x))

Byte swapping utility macro. Swap from big endian to local machine endian.

Parameters

  type | C type (int32, uint64...)
  x | Value to swap.

#define SWAP_FROM_LE | ( |  | type,
|  |  | x
| ) |  | (x)

Byte swapping utility macro. Swap from little endian to local machine endian.

Parameters

  type | C type (int32, uint64...)
  x | Value to swap.

#define SWAP_TO_BE | ( |  | type,
|  |  | x
| ) |  | SWAP(type, (x))

Byte swapping utility macro. Swap from local machine endian to big endian.

Parameters

  type | C type (int32, uint64...)
  x | Value to swap.

#define SWAP_TO_LE | ( |  | type,
|  |  | x
| ) |  | (x)

Byte swapping utility macro. Swap from local machine endian to little endian.

Parameters

  type | C type (int32, uint64...)
  x | Value to swap.

#define true 1

Boolean value `true`.

## Typedef Documentation

typedef unsigned char bool

Boolean. Its value can be `true` or `false`.

typedef HAKA_16BIT_TYPE int16

Signed 2 byte integer type.

typedef HAKA_32BIT_TYPE int32

Signed 4 byte integer type.

typedef HAKA_64BIT_TYPE int64

Signed 8 byte integer type.

typedef char int8

Signed 1 byte integer type.

typedef unsigned HAKA_16BIT_TYPE uint16

Unsigned 2 byte integer type.

typedef unsigned HAKA_32BIT_TYPE uint32

Unsigned 4 byte integer type.

typedef unsigned HAKA_64BIT_TYPE uint64

Unsigned 8 byte integer type.

typedef unsigned char uint8

Unsigned 1 byte integer type.