Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
261 giacomo 1
#ifndef __ENDIAN_H__
2
#define __ENDIAN_H__
3
 
4
/******************************************************************************
5
  FUNCTION: SwapEndian
6
  PURPOSE: Swap the byte order of a structure
7
  EXAMPLE: float F=123.456;; SWAP_FLOAT(F);
8
******************************************************************************/
9
 
10
#define SWAP_SHORT(Var)  Var = *(short*)         SwapEndian((void*)&Var, sizeof(short))
11
#define SWAP_USHORT(Var) Var = *(unsigned short*)SwapEndian((void*)&Var, sizeof(short))
12
#define SWAP_LONG(Var)   Var = *(long*)          SwapEndian((void*)&Var, sizeof(long))
13
#define SWAP_ULONG(Var)  Var = *(unsigned long*) SwapEndian((void*)&Var, sizeof(long))
14
#define SWAP_FLOAT(Var)  Var = *(float*)         SwapEndian((void*)&Var, sizeof(float))
15
#define SWAP_DOUBLE(Var) Var = *(double*)        SwapEndian((void*)&Var, sizeof(double))
16
 
17
void *SwapEndian(void* Addr, const int Nb);
18
 
19
#endif
20