libcdio  2.1.0
Macros
bytesex.h File Reference

Generic Byte-swapping routines. More...

#include <cdio/types.h>
#include <cdio/bytesex_asm.h>
#include <cdio/logging.h>

Go to the source code of this file.

Macros

#define UINT16_SWAP_LE_BE_C(val)
 
#define UINT32_SWAP_LE_BE_C(val)
 
#define UINT64_SWAP_LE_BE_C(val)
 
#define UINT16_SWAP_LE_BE   UINT16_SWAP_LE_BE_C
 
#define UINT32_SWAP_LE_BE   UINT32_SWAP_LE_BE_C
 
#define UINT64_SWAP_LE_BE   UINT64_SWAP_LE_BE_C
 
#define UINT8_TO_BE(val)   ((uint8_t) (val))
 
#define UINT8_TO_LE(val)   ((uint8_t) (val))
 
#define UINT16_TO_BE(val)   ((uint16_t) UINT16_SWAP_LE_BE(val))
 
#define UINT16_TO_LE(val)   ((uint16_t) (val))
 
#define UINT32_TO_BE(val)   ((uint32_t) UINT32_SWAP_LE_BE(val))
 
#define UINT32_TO_LE(val)   ((uint32_t) (val))
 
#define UINT64_TO_BE(val)   ((uint64_t) UINT64_SWAP_LE_BE(val))
 
#define UINT64_TO_LE(val)   ((uint64_t) (val))
 
#define UINT8_FROM_BE(val)   (UINT8_TO_BE (val))
 
#define UINT8_FROM_LE(val)   (UINT8_TO_LE (val))
 
#define UINT16_FROM_BE(val)   (UINT16_TO_BE (val))
 
#define UINT16_FROM_LE(val)   (UINT16_TO_LE (val))
 
#define UINT32_FROM_BE(val)   (UINT32_TO_BE (val))
 
#define UINT32_FROM_LE(val)   (UINT32_TO_LE (val))
 
#define UINT64_FROM_BE(val)   (UINT64_TO_BE (val))
 
#define UINT64_FROM_LE(val)   (UINT64_TO_LE (val))
 
#define CVT_TO_FUNC(bits)
 
#define uint8_from_be(val)   (uint8_to_be (val))
 
#define uint8_from_le(val)   (uint8_to_le (val))
 
#define uint16_from_be(val)   (uint16_to_be (val))
 
#define uint16_from_le(val)   (uint16_to_le (val))
 
#define uint32_from_be(val)   (uint32_to_be (val))
 
#define uint32_from_le(val)   (uint32_to_le (val))
 
#define uint64_from_be(val)   (uint64_to_be (val))
 
#define uint64_from_le(val)   (uint64_to_le (val))
 
#define to_711(i)   uint8_to_le(i)
 
#define from_711(i)   uint8_from_le(i)
 
#define to_721(i)   uint16_to_le(i)
 
#define from_721(i)   uint16_from_le(i)
 
#define to_722(i)   uint16_to_be(i)
 
#define from_722(i)   uint16_from_be(i)
 
#define to_731(i)   uint32_to_le(i)
 
#define from_731(i)   uint32_from_le(i)
 
#define to_732(i)   uint32_to_be(i)
 
#define from_732(i)   uint32_from_be(i)
 

Detailed Description

Generic Byte-swapping routines.

Note: this header will is slated to get removed and libcdio will use glib.h routines instead.

Macro Definition Documentation

◆ CVT_TO_FUNC

#define CVT_TO_FUNC (   bits)
Value:
static CDIO_INLINE uint ## bits ## _t \
uint ## bits ## _to_be (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_BE (val); } \
static CDIO_INLINE uint ## bits ## _t \
uint ## bits ## _to_le (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_LE (val); } \
#define CDIO_INLINE
Definition: bytesex_asm.h:41

converter function template

◆ from_711

#define from_711 (   i)    uint8_from_le(i)

Convert from ISO 9660 7.1.1 format to uint8_t

◆ from_721

#define from_721 (   i)    uint16_from_le(i)

Convert from ISO 9660 7.2.1 format to uint16_t

◆ from_722

#define from_722 (   i)    uint16_from_be(i)

Convert from ISO 9660 7.2.2 format to uint16_t

◆ from_731

#define from_731 (   i)    uint32_from_le(i)

Convert from ISO 9660 7.3.1 format to uint32_t

◆ from_732

#define from_732 (   i)    uint32_from_be(i)

Convert from ISO 9660 7.3.2 format to uint32_t

◆ to_711

#define to_711 (   i)    uint8_to_le(i)

ISO9660-related field conversion routines Convert from uint8_t to ISO 9660 7.1.1 format

◆ to_721

#define to_721 (   i)    uint16_to_le(i)

Convert from uint16_t to ISO 9669 7.2.1 format

◆ to_722

#define to_722 (   i)    uint16_to_be(i)

Convert from uint16_t to ISO 9669 7.2.2 format

◆ to_731

#define to_731 (   i)    uint32_to_le(i)

Convert from uint16_t to ISO 9669 7.3.1 format

◆ to_732

#define to_732 (   i)    uint32_to_be(i)

Convert from uint32_t to ISO 9669 7.3.2 format

◆ UINT16_FROM_BE

#define UINT16_FROM_BE (   val)    (UINT16_TO_BE (val))

◆ uint16_from_be

#define uint16_from_be (   val)    (uint16_to_be (val))

◆ UINT16_FROM_LE

#define UINT16_FROM_LE (   val)    (UINT16_TO_LE (val))

◆ uint16_from_le

#define uint16_from_le (   val)    (uint16_to_le (val))

◆ UINT16_SWAP_LE_BE

#define UINT16_SWAP_LE_BE   UINT16_SWAP_LE_BE_C

◆ UINT16_SWAP_LE_BE_C

#define UINT16_SWAP_LE_BE_C (   val)
Value:
((uint16_t) ( \
(((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) | \
(((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))

16-bit big-endian to little-endian

◆ UINT16_TO_BE

#define UINT16_TO_BE (   val)    ((uint16_t) UINT16_SWAP_LE_BE(val))

◆ UINT16_TO_LE

#define UINT16_TO_LE (   val)    ((uint16_t) (val))

◆ UINT32_FROM_BE

#define UINT32_FROM_BE (   val)    (UINT32_TO_BE (val))

◆ uint32_from_be

#define uint32_from_be (   val)    (uint32_to_be (val))

◆ UINT32_FROM_LE

#define UINT32_FROM_LE (   val)    (UINT32_TO_LE (val))

◆ uint32_from_le

#define uint32_from_le (   val)    (uint32_to_le (val))

◆ UINT32_SWAP_LE_BE

#define UINT32_SWAP_LE_BE   UINT32_SWAP_LE_BE_C

◆ UINT32_SWAP_LE_BE_C

#define UINT32_SWAP_LE_BE_C (   val)
Value:
((uint32_t) ( \
(((uint32_t) (val) & (uint32_t) 0x000000ffU) << 24) | \
(((uint32_t) (val) & (uint32_t) 0x0000ff00U) << 8) | \
(((uint32_t) (val) & (uint32_t) 0x00ff0000U) >> 8) | \
(((uint32_t) (val) & (uint32_t) 0xff000000U) >> 24)))

32-bit big-endian to little-endian

◆ UINT32_TO_BE

#define UINT32_TO_BE (   val)    ((uint32_t) UINT32_SWAP_LE_BE(val))

◆ UINT32_TO_LE

#define UINT32_TO_LE (   val)    ((uint32_t) (val))

◆ UINT64_FROM_BE

#define UINT64_FROM_BE (   val)    (UINT64_TO_BE (val))

◆ uint64_from_be

#define uint64_from_be (   val)    (uint64_to_be (val))

◆ UINT64_FROM_LE

#define UINT64_FROM_LE (   val)    (UINT64_TO_LE (val))

◆ uint64_from_le

#define uint64_from_le (   val)    (uint64_to_le (val))

◆ UINT64_SWAP_LE_BE

#define UINT64_SWAP_LE_BE   UINT64_SWAP_LE_BE_C

◆ UINT64_SWAP_LE_BE_C

#define UINT64_SWAP_LE_BE_C (   val)
Value:
((uint64_t) ( \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000000000ff)) << 56) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x000000000000ff00)) << 40) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x0000000000ff0000)) << 24) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000ff000000)) << 8) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x000000ff00000000)) >> 8) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x0000ff0000000000)) >> 24) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00ff000000000000)) >> 40) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0xff00000000000000)) >> 56)))
#define UINT64_C(c)
Definition: types.h:92

64-bit big-endian to little-endian

◆ UINT64_TO_BE

#define UINT64_TO_BE (   val)    ((uint64_t) UINT64_SWAP_LE_BE(val))

◆ UINT64_TO_LE

#define UINT64_TO_LE (   val)    ((uint64_t) (val))

◆ UINT8_FROM_BE

#define UINT8_FROM_BE (   val)    (UINT8_TO_BE (val))

symmetric conversions

◆ uint8_from_be

#define uint8_from_be (   val)    (uint8_to_be (val))

◆ UINT8_FROM_LE

#define UINT8_FROM_LE (   val)    (UINT8_TO_LE (val))

◆ uint8_from_le

#define uint8_from_le (   val)    (uint8_to_le (val))

◆ UINT8_TO_BE

#define UINT8_TO_BE (   val)    ((uint8_t) (val))

◆ UINT8_TO_LE

#define UINT8_TO_LE (   val)    ((uint8_t) (val))