Peka2D_v5  v5.0
utilities.h
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "define.h"
4 #include "structs.h"
5 
6 // ENDIAN ##########################################################################
7 #ifndef _SWAP_ENDIAN
8 #define _SWAP_ENDIAN
9 
10 EXPORT_DLL int IsLittleEndian(void);
11 
12 /******************************************************************************
13  FUNCTION: SwapEndian
14  PURPOSE: Swap the byte order of a structure
15  EXAMPLE: float F=123.456;; SWAP_FLOAT(F);
16 ******************************************************************************/
17 
18 #define SWAP_SHORT(Var) Var = *(short*) SwapEndian((void*)&Var, sizeof(short))
19 #define SWAP_USHORT(Var) Var = *(unsigned short*)SwapEndian((void*)&Var, sizeof(short))
20 #define SWAP_LONG(Var) Var = *(long*) SwapEndian((void*)&Var, sizeof(long))
21 #define SWAP_ULONG(Var) Var = *(unsigned long*) SwapEndian((void*)&Var, sizeof(long))
22 #define SWAP_INT(Var) Var = *(int*) SwapEndian((void*)&Var, sizeof(int))
23 #define SWAP_FLOAT(Var) Var = *(float*) SwapEndian((void*)&Var, sizeof(float))
24 #define SWAP_DOUBLE(Var) Var = *(double*) SwapEndian((void*)&Var, sizeof(double))
25 
26 EXPORT_DLL void *SwapEndian(void* Addr, const int Nb);
27 
28 #endif
29 // ENDIAN ##########################################################################
#define EXPORT_DLL
Definition: define.h:80
EXPORT_DLL int IsLittleEndian(void)
Definition: cuTilities.cu:7
EXPORT_DLL void * SwapEndian(void *Addr, const int Nb)
Definition: cuTilities.cu:17