CHAILink SDK  Version 1.3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PlatformSerializationMacro.h
Go to the documentation of this file.
1 //*********************************************************
2 // File: PlatformSerializationMacro.h
3 // Project: CopperLan Types, serialization MACRO for basic types
4 // For Client & Server
5 // Version: 1.0
6 // Release Date: 2011/10/11
7 //*********************************************************
8 // Important :
9 // - Nestwork order is Little Endian
10 // - Following alignements for data types can be assumed:
11 // 16 bit words are 2 bytes aligned
12 // 32 bit words are 4 bytes aligned
13 // 64 bit words are 4 bytes aligned
14 // - Macro should increment pointer by the corresponding type size
15 //
16 // This is a Template File and sample implementation tagets
17 // x86 32 & 64 bits processor
18 
19 #ifndef _PLATFORMSERIALIZATIONMACRO_H
20 #define _PLATFORMSERIALIZATIONMACRO_H
21 
23 //#define CP_PROCESSOR_IS_BIGENDIAN
24 
25 #define SERIALIZE_UINT64(d, s) *((CPUINT64*) (d)) = (CPUINT64) (s), d += 8
26 #define SERIALIZE_UINT32(d, s) *((CPUINT32*) (d)) = (CPUINT32) (s), d += 4
27 #define SERIALIZE_UINT16(d, s) *((CPUINT16*) (d)) = (CPUINT16) (s), d += 2
28 #define SERIALIZE_UINT8(d, s) *((CPUINT8*) (d)) = (CPUINT8) (s), d += 1
29 
30 #define DESERIALIZE_UINT64(d, s) (d) = *((CPUINT64*) (s)), s += 8
31 #define DESERIALIZE_UINT32(d, s) (d) = *((CPUINT32*) (s)), s += 4
32 #define DESERIALIZE_UINT16(d, s) (d) = *((CPUINT16*) (s)), s += 2
33 #define DESERIALIZE_UINT8(d, s) (d) = *((CPUINT8*) (s)), s += 1
34 
35 #endif // _PLATFORMSERIALIZATIONMACRO_H