# HG changeset patch # User Matti Hamalainen # Date 1375725229 -10800 # Node ID bef14a3387a1921ea31c55efd908329427c41352 # Parent 06ab31de6d14b72b4193bd7f29aa3ec81fd4bfb9 Add missing files. diff -r 06ab31de6d14 -r bef14a3387a1 src/mendian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/mendian.h Mon Aug 05 20:53:49 2013 +0300 @@ -0,0 +1,48 @@ +#ifndef MENDIAN_H +#define MENDIAN_H 1 + +#include "mtypes.h" + +/* Endianess swapping macros + */ +#define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ + (Uint16) ((Uint16) (value) >> 8) | \ + (Uint16) ((Uint16) (value) << 8)) ) + + +#define DM_SWAP_32_LE_BE(value) ((Uint32) ( \ + (((Uint32) (value) & (Uint32) 0x000000ffU) << 24) | \ + (((Uint32) (value) & (Uint32) 0x0000ff00U) << 8) | \ + (((Uint32) (value) & (Uint32) 0x00ff0000U) >> 8) | \ + (((Uint32) (value) & (Uint32) 0xff000000U) >> 24))) + + +/* Macros that swap only when needed ... + */ +#if (BYTEORDER == BIG_ENDIAN) +# define DM_LE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) +# define DM_LE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) +# define DM_NATIVE_TO_LE16(value) DM_SWAP_16_LE_BE(value) +# define DM_NATIVE_TO_LE32(value) DM_SWAP_32_LE_BE(value) + +# define DM_BE16_TO_NATIVE(value) ((Uint16) (value)) +# define DM_BE32_TO_NATIVE(value) ((Uint32) (value)) +# define DM_NATIVE_TO_BE16(value) ((Uint16) (value)) +# define DM_NATIVE_TO_BE32(value) ((Uint32) (value)) + +#elif (BYTEORDER == LIL_ENDIAN) + +# define DM_LE16_TO_NATIVE(value) ((Uint16) (value)) +# define DM_LE32_TO_NATIVE(value) ((Uint32) (value)) +# define DM_NATIVE_TO_LE16(value) ((Uint16) (value)) +# define DM_NATIVE_TO_LE32(value) ((Uint32) (value)) + +# define DM_BE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) +# define DM_BE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) +# define DM_NATIVE_TO_BE16(value) DM_SWAP_16_LE_BE(value) +# define DM_NATIVE_TO_BE32(value) DM_SWAP_32_LE_BE(value) + +#endif + + +#endif diff -r 06ab31de6d14 -r bef14a3387a1 src/mtypes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/mtypes.h Mon Aug 05 20:53:49 2013 +0300 @@ -0,0 +1,25 @@ +#ifndef MTYPES_H +#define MTYPES_H 1 + + +typedef unsigned char Uint8; +typedef unsigned short Uint16; +typedef unsigned int Uint32; + + +/* Define a boolean type + */ +#if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) +typedef enum { FALSE = 0, TRUE = 1 } BOOL; +#endif + +#ifndef BOOL +# ifdef bool +# define BOOL bool +# else +# define BOOL int +# endif +#endif + + +#endif