XenevaOS
Loading...
Searching...
No Matches
Macros
alignment.h File Reference

Utility code for dealing with unaligned memory accesses. More...

#include <stdint.h>
#include <string.h>
#include <stdlib.h>
Include dependency graph for alignment.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MBEDTLS_BYTE_0(x)   ((uint8_t) ((x) & 0xff))
 
#define MBEDTLS_BYTE_1(x)   ((uint8_t) (((x) >> 8) & 0xff))
 
#define MBEDTLS_BYTE_2(x)   ((uint8_t) (((x) >> 16) & 0xff))
 
#define MBEDTLS_BYTE_3(x)   ((uint8_t) (((x) >> 24) & 0xff))
 
#define MBEDTLS_BYTE_4(x)   ((uint8_t) (((x) >> 32) & 0xff))
 
#define MBEDTLS_BYTE_5(x)   ((uint8_t) (((x) >> 40) & 0xff))
 
#define MBEDTLS_BYTE_6(x)   ((uint8_t) (((x) >> 48) & 0xff))
 
#define MBEDTLS_BYTE_7(x)   ((uint8_t) (((x) >> 56) & 0xff))
 
#define MBEDTLS_BSWAP16   mbedtls_bswap16
 
#define MBEDTLS_BSWAP32   mbedtls_bswap32
 
#define MBEDTLS_BSWAP64   mbedtls_bswap64
 
#define MBEDTLS_IS_BIG_ENDIAN   (*((unsigned char *) (&mbedtls_byte_order_detector)) == 0x01)
 
#define MBEDTLS_GET_UINT32_BE(data, offset)
 
#define MBEDTLS_PUT_UINT32_BE(n, data, offset)
 
#define MBEDTLS_GET_UINT32_LE(data, offset)
 
#define MBEDTLS_PUT_UINT32_LE(n, data, offset)
 
#define MBEDTLS_GET_UINT16_LE(data, offset)
 
#define MBEDTLS_PUT_UINT16_LE(n, data, offset)
 
#define MBEDTLS_GET_UINT16_BE(data, offset)
 
#define MBEDTLS_PUT_UINT16_BE(n, data, offset)
 
#define MBEDTLS_GET_UINT24_BE(data, offset)
 
#define MBEDTLS_PUT_UINT24_BE(n, data, offset)
 
#define MBEDTLS_GET_UINT24_LE(data, offset)
 
#define MBEDTLS_PUT_UINT24_LE(n, data, offset)
 
#define MBEDTLS_GET_UINT64_BE(data, offset)
 
#define MBEDTLS_PUT_UINT64_BE(n, data, offset)
 
#define MBEDTLS_GET_UINT64_LE(data, offset)
 
#define MBEDTLS_PUT_UINT64_LE(n, data, offset)
 

Detailed Description

Utility code for dealing with unaligned memory accesses.

Macro Definition Documentation

◆ MBEDTLS_BSWAP16

#define MBEDTLS_BSWAP16   mbedtls_bswap16

◆ MBEDTLS_BSWAP32

#define MBEDTLS_BSWAP32   mbedtls_bswap32

◆ MBEDTLS_BSWAP64

#define MBEDTLS_BSWAP64   mbedtls_bswap64

◆ MBEDTLS_BYTE_0

#define MBEDTLS_BYTE_0 (   x)    ((uint8_t) ((x) & 0xff))

Byte Reading Macros

Given a multi-byte integer x, MBEDTLS_BYTE_n retrieves the n-th byte from x, where byte 0 is the least significant byte.

◆ MBEDTLS_BYTE_1

#define MBEDTLS_BYTE_1 (   x)    ((uint8_t) (((x) >> 8) & 0xff))

◆ MBEDTLS_BYTE_2

#define MBEDTLS_BYTE_2 (   x)    ((uint8_t) (((x) >> 16) & 0xff))

◆ MBEDTLS_BYTE_3

#define MBEDTLS_BYTE_3 (   x)    ((uint8_t) (((x) >> 24) & 0xff))

◆ MBEDTLS_BYTE_4

#define MBEDTLS_BYTE_4 (   x)    ((uint8_t) (((x) >> 32) & 0xff))

◆ MBEDTLS_BYTE_5

#define MBEDTLS_BYTE_5 (   x)    ((uint8_t) (((x) >> 40) & 0xff))

◆ MBEDTLS_BYTE_6

#define MBEDTLS_BYTE_6 (   x)    ((uint8_t) (((x) >> 48) & 0xff))

◆ MBEDTLS_BYTE_7

#define MBEDTLS_BYTE_7 (   x)    ((uint8_t) (((x) >> 56) & 0xff))

◆ MBEDTLS_GET_UINT16_BE

#define MBEDTLS_GET_UINT16_BE (   data,
  offset 
)
Value:
? mbedtls_get_unaligned_uint16((data) + (offset)) \
: MBEDTLS_BSWAP16(mbedtls_get_unaligned_uint16((data) + (offset))) \
)
#define MBEDTLS_IS_BIG_ENDIAN
Definition alignment.h:390
#define MBEDTLS_BSWAP16
Definition alignment.h:350
size_t size_t offset
Definition drm_bridge.h:1299
void * data
Definition kthread.h:30

Get the unsigned 16 bits integer corresponding to two bytes in big-endian order (MSB first).

Parameters
dataBase address of the memory to get the two bytes from.
offsetOffset from data of the first and most significant byte of the two bytes to build the 16 bits unsigned integer from.

◆ MBEDTLS_GET_UINT16_LE

#define MBEDTLS_GET_UINT16_LE (   data,
  offset 
)
Value:
? MBEDTLS_BSWAP16(mbedtls_get_unaligned_uint16((data) + (offset))) \
: mbedtls_get_unaligned_uint16((data) + (offset)) \
)

Get the unsigned 16 bits integer corresponding to two bytes in little-endian order (LSB first).

Parameters
dataBase address of the memory to get the two bytes from.
offsetOffset from data of the first and least significant byte of the two bytes to build the 16 bits unsigned integer from.

◆ MBEDTLS_GET_UINT24_BE

#define MBEDTLS_GET_UINT24_BE (   data,
  offset 
)
Value:
( \
((uint32_t) (data)[(offset)] << 16) \
| ((uint32_t) (data)[(offset) + 1] << 8) \
| ((uint32_t) (data)[(offset) + 2]) \
)
unsigned int uint32_t
Definition acefiex.h:163

Get the unsigned 24 bits integer corresponding to three bytes in big-endian order (MSB first).

Parameters
dataBase address of the memory to get the three bytes from.
offsetOffset from data of the first and most significant byte of the three bytes to build the 24 bits unsigned integer from.

◆ MBEDTLS_GET_UINT24_LE

#define MBEDTLS_GET_UINT24_LE (   data,
  offset 
)
Value:
( \
((uint32_t) (data)[(offset)]) \
| ((uint32_t) (data)[(offset) + 1] << 8) \
| ((uint32_t) (data)[(offset) + 2] << 16) \
)

Get the unsigned 24 bits integer corresponding to three bytes in little-endian order (LSB first).

Parameters
dataBase address of the memory to get the three bytes from.
offsetOffset from data of the first and least significant byte of the three bytes to build the 24 bits unsigned integer from.

◆ MBEDTLS_GET_UINT32_BE

#define MBEDTLS_GET_UINT32_BE (   data,
  offset 
)
Value:
? mbedtls_get_unaligned_uint32((data) + (offset)) \
: MBEDTLS_BSWAP32(mbedtls_get_unaligned_uint32((data) + (offset))) \
)
#define MBEDTLS_BSWAP32
Definition alignment.h:362

Get the unsigned 32 bits integer corresponding to four bytes in big-endian order (MSB first).

Parameters
dataBase address of the memory to get the four bytes from.
offsetOffset from data of the first and most significant byte of the four bytes to build the 32 bits unsigned integer from.

◆ MBEDTLS_GET_UINT32_LE

#define MBEDTLS_GET_UINT32_LE (   data,
  offset 
)
Value:
? MBEDTLS_BSWAP32(mbedtls_get_unaligned_uint32((data) + (offset))) \
: mbedtls_get_unaligned_uint32((data) + (offset)) \
)

Get the unsigned 32 bits integer corresponding to four bytes in little-endian order (LSB first).

Parameters
dataBase address of the memory to get the four bytes from.
offsetOffset from data of the first and least significant byte of the four bytes to build the 32 bits unsigned integer from.

◆ MBEDTLS_GET_UINT64_BE

#define MBEDTLS_GET_UINT64_BE (   data,
  offset 
)
Value:
? mbedtls_get_unaligned_uint64((data) + (offset)) \
: MBEDTLS_BSWAP64(mbedtls_get_unaligned_uint64((data) + (offset))) \
)
#define MBEDTLS_BSWAP64
Definition alignment.h:378

Get the unsigned 64 bits integer corresponding to eight bytes in big-endian order (MSB first).

Parameters
dataBase address of the memory to get the eight bytes from.
offsetOffset from data of the first and most significant byte of the eight bytes to build the 64 bits unsigned integer from.

◆ MBEDTLS_GET_UINT64_LE

#define MBEDTLS_GET_UINT64_LE (   data,
  offset 
)
Value:
? MBEDTLS_BSWAP64(mbedtls_get_unaligned_uint64((data) + (offset))) \
: mbedtls_get_unaligned_uint64((data) + (offset)) \
)

Get the unsigned 64 bits integer corresponding to eight bytes in little-endian order (LSB first).

Parameters
dataBase address of the memory to get the eight bytes from.
offsetOffset from data of the first and least significant byte of the eight bytes to build the 64 bits unsigned integer from.

◆ MBEDTLS_IS_BIG_ENDIAN

#define MBEDTLS_IS_BIG_ENDIAN   (*((unsigned char *) (&mbedtls_byte_order_detector)) == 0x01)

◆ MBEDTLS_PUT_UINT16_BE

#define MBEDTLS_PUT_UINT16_BE (   n,
  data,
  offset 
)
Value:
{ \
{ \
mbedtls_put_unaligned_uint16((data) + (offset), (uint16_t) (n)); \
} \
else \
{ \
mbedtls_put_unaligned_uint16((data) + (offset), MBEDTLS_BSWAP16((uint16_t) (n))); \
} \
}
unsigned short int uint16_t
Definition acefiex.h:162

Put in memory a 16 bits unsigned integer in big-endian order.

Parameters
n16 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 16 bits unsigned integer in.
offsetOffset from data where to put the most significant byte of the 16 bits unsigned integer n.

◆ MBEDTLS_PUT_UINT16_LE

#define MBEDTLS_PUT_UINT16_LE (   n,
  data,
  offset 
)
Value:
{ \
{ \
mbedtls_put_unaligned_uint16((data) + (offset), MBEDTLS_BSWAP16((uint16_t) (n))); \
} \
else \
{ \
mbedtls_put_unaligned_uint16((data) + (offset), (uint16_t) (n)); \
} \
}

Put in memory a 16 bits unsigned integer in little-endian order.

Parameters
n16 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 16 bits unsigned integer in.
offsetOffset from data where to put the least significant byte of the 16 bits unsigned integer n.

◆ MBEDTLS_PUT_UINT24_BE

#define MBEDTLS_PUT_UINT24_BE (   n,
  data,
  offset 
)
Value:
{ \
(data)[(offset)] = MBEDTLS_BYTE_2(n); \
(data)[(offset) + 1] = MBEDTLS_BYTE_1(n); \
(data)[(offset) + 2] = MBEDTLS_BYTE_0(n); \
}
#define MBEDTLS_BYTE_1(x)
Definition alignment.h:269
#define MBEDTLS_BYTE_2(x)
Definition alignment.h:270
#define MBEDTLS_BYTE_0(x)
Definition alignment.h:268

Put in memory a 24 bits unsigned integer in big-endian order.

Parameters
n24 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 24 bits unsigned integer in.
offsetOffset from data where to put the most significant byte of the 24 bits unsigned integer n.

◆ MBEDTLS_PUT_UINT24_LE

#define MBEDTLS_PUT_UINT24_LE (   n,
  data,
  offset 
)
Value:
{ \
(data)[(offset)] = MBEDTLS_BYTE_0(n); \
(data)[(offset) + 1] = MBEDTLS_BYTE_1(n); \
(data)[(offset) + 2] = MBEDTLS_BYTE_2(n); \
}

Put in memory a 24 bits unsigned integer in little-endian order.

Parameters
n24 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 24 bits unsigned integer in.
offsetOffset from data where to put the least significant byte of the 24 bits unsigned integer n.

◆ MBEDTLS_PUT_UINT32_BE

#define MBEDTLS_PUT_UINT32_BE (   n,
  data,
  offset 
)
Value:
{ \
{ \
mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n)); \
} \
else \
{ \
mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
} \
}

Put in memory a 32 bits unsigned integer in big-endian order.

Parameters
n32 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 32 bits unsigned integer in.
offsetOffset from data where to put the most significant byte of the 32 bits unsigned integer n.

◆ MBEDTLS_PUT_UINT32_LE

#define MBEDTLS_PUT_UINT32_LE (   n,
  data,
  offset 
)
Value:
{ \
{ \
mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
} \
else \
{ \
mbedtls_put_unaligned_uint32((data) + (offset), ((uint32_t) (n))); \
} \
}

Put in memory a 32 bits unsigned integer in little-endian order.

Parameters
n32 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 32 bits unsigned integer in.
offsetOffset from data where to put the least significant byte of the 32 bits unsigned integer n.

◆ MBEDTLS_PUT_UINT64_BE

#define MBEDTLS_PUT_UINT64_BE (   n,
  data,
  offset 
)
Value:
{ \
{ \
mbedtls_put_unaligned_uint64((data) + (offset), (uint64_t) (n)); \
} \
else \
{ \
mbedtls_put_unaligned_uint64((data) + (offset), MBEDTLS_BSWAP64((uint64_t) (n))); \
} \
}
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165

Put in memory a 64 bits unsigned integer in big-endian order.

Parameters
n64 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 64 bits unsigned integer in.
offsetOffset from data where to put the most significant byte of the 64 bits unsigned integer n.

◆ MBEDTLS_PUT_UINT64_LE

#define MBEDTLS_PUT_UINT64_LE (   n,
  data,
  offset 
)
Value:
{ \
{ \
mbedtls_put_unaligned_uint64((data) + (offset), MBEDTLS_BSWAP64((uint64_t) (n))); \
} \
else \
{ \
mbedtls_put_unaligned_uint64((data) + (offset), (uint64_t) (n)); \
} \
}

Put in memory a 64 bits unsigned integer in little-endian order.

Parameters
n64 bits unsigned integer to put in memory.
dataBase address of the memory where to put the 64 bits unsigned integer in.
offsetOffset from data where to put the least significant byte of the 64 bits unsigned integer n.