ITAEndianness.h 2.4 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1
/*
2 3 4 5
 * ----------------------------------------------------------------
 *
 *		ITA core libs
 *		(c) Copyright Institute of Technical Acoustics (ITA)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
6
 *		RWTH Aachen University, Germany, 2015-2020
7 8 9 10 11 12 13 14 15 16 17
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */
Jonas Stienen's avatar
Jonas Stienen committed
18 19 20 21 22 23 24

#ifndef INCLUDE_WATCHER_ITA_ENDIANNESS
#define INCLUDE_WATCHER_ITA_ENDIANNESS

// ITABase
#include <ITABaseDefinitions.h>

js908001's avatar
js908001 committed
25 26
#include <stddef.h>

Jonas Stienen's avatar
Jonas Stienen committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
//! Literals for Endianness
enum ITA_BASE_API
{
	ITA_LITTLE_ENDIAN = 0,
	ITA_BIG_ENDIAN = 1
};

int ITA_BASE_API GetEndianness();

/**
 * Byte-Swapping functions, swaping order of bytes to convert between endianness
 */

//! Byte-order swap for 2-Byte (16-Bit) fields
void ITA_BASE_API byteswap_2byte(void* src, size_t count);

//! Byte-order swap for 4-Byte (32-Bit) fields
void ITA_BASE_API byteswap_4byte(void* src, size_t count);

//! Byte-order swap for 8-Byte (64-Bit) fields
void ITA_BASE_API byteswap_8byte(void* src, size_t count);

//! Byte-order swap for 16-Byte (128-Bit) fields
void ITA_BASE_API byteswap_16byte(void* src, size_t count);

/**
 * Endianness-Converter
 */

//! Little endian -> System endianness for 2-Byte (16-Bit) fields
ITA_BASE_API extern void(*le2se_2byte)(void* src, size_t count);

//! Little endian -> System endianness for 4-Byte (32-Bit) fields
ITA_BASE_API extern void(*le2se_4byte)(void* src, size_t count);

//! Little endian -> System endianness for 8-Byte (64-Bit) fields
ITA_BASE_API extern void(*le2se_8byte)(void* src, size_t count);

//! Little endian -> System endianness for 16-Byte (128-Bit) fields
ITA_BASE_API extern void(*le2se_16byte)(void* src, size_t count);

//! Big endian -> System endianness for 2-Byte (16-Bit) fields
ITA_BASE_API extern void(*be2se_2byte)(void* src, size_t count);

//! Big endian -> System endianness f�r 4-Byte (32-Bit) fields
ITA_BASE_API extern void(*be2se_4byte)(void* src, size_t count);

//! Big endian -> System endianness f�r 8-Byte (64-Bit) fields
ITA_BASE_API extern void(*be2se_8byte)(void* src, size_t count);

//! Big endian -> System endianness f�r 16-Byte (128-Bit) fields
ITA_BASE_API extern void(*be2se_16byte)(void* src, size_t count);

#endif // INCLUDE_WATCHER_ITA_ENDIANNESS