3.1. Types

Basic types used all along Haka.

Defines

true

Boolean value true.

false

Boolean value false.

SWAP(type, x)

Byte swapping utility macro.

Parameters
  • type -

    C type (int32, uint64...)

  • x -

    Value to swap.

SWAP_TO_LE(type, x)

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

Parameters
  • type -

    C type (int32, uint64...)

  • x -

    Value to swap.

SWAP_FROM_LE(type, x)

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

Parameters
  • type -

    C type (int32, uint64...)

  • x -

    Value to swap.

SWAP_TO_BE(type, x)

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

Parameters
  • type -

    C type (int32, uint64...)

  • x -

    Value to swap.

SWAP_FROM_BE(type, x)

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

Parameters
  • type -

    C type (int32, uint64...)

  • x -

    Value to swap.

GET_BIT(v, i)

Get the bit i from an integer v.

SET_BIT(v, i, x)

Set the bit i from an integer v to x.

GET_BITS(v, i, j)

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

SET_BITS(v, i, j, x)

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

Typedefs

typedef unsigned char bool

Boolean. Its value can be true or false.

typedef char int8

Signed 1 byte integer type.

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 unsigned char uint8

Unsigned 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.

3.2. Errors handling

Error handling functions.

Functions

void error(const char * error, ...)

Set error to be reported to the callers. The function follows the printf API and can be used in multi-threaded application. The error can then be retrieved using clear_error() and check_error().

If lua is at the origin of this call, the error will be converted to a lua error.

void const char * errno_error(int err)

Convert the err value to a human readable error message.

The returned string will be erased by the next call to this function. This function is thread-safe.

bool check_error(void)

Check if an error has occurred. This function does not clear error flag.

const char * clear_error(void)

Get the error message and clear the error state.