Alchemy
1.0
A framework to robustly process network messages and structured data
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
Pb
detail
endianess.h
Go to the documentation of this file.
1
/// @file Pb/detail/endianess.h
2
/// Defines the endianess of the local platform.
3
///
4
/// The MIT License(MIT)
5
/// @copyright 2015 Paul M Watt
6
// ****************************************************************************
7
#ifndef ENDIANESS_H_INCLUDED
8
#define ENDIANESS_H_INCLUDED
9
10
// Determine Processor *********************************************************
11
#define ALCHEMY_CPU_ARM 1
12
#define ALCHEMY_CPU_X86 2
13
// Definition to make comparisons simpler.
14
// This value can increase as more l-endian CPUs are added.
15
#define ALCHEMY_CPU_BIG_ENDIAN 3
16
17
// Determine the processor type based on compiler flags. This code has been
18
// adapted from the POSH portable framework from: http://www.poshlib.org
19
// New definitions will be required for CPUs that are not defined here.
20
#if defined ARM || defined __arm__ || defined _ARM
21
# define ALCHEMY_CPU ALCHEMY_CPU_ARM
22
# define ALCHEMY_CPU_STRING "ARM"
23
#endif
24
25
#if defined __X86__ || defined __i386__ || defined i386 || defined _M_IX86 || defined __386__ || defined __x86_64__ || defined _M_X64
26
# define ALCHEMY_CPU ALCHEMY_CPU_X86
27
# define ALCHEMY_CPU_STRING "Intel 386+"
28
#endif
29
30
#ifndef ALCHEMY_CPU
31
# error ALCHEMY_CPU not defined. Please add definition
32
#endif
33
34
// Determine Support for 64-bit ************************************************
35
36
37
38
// Determine Endianess *********************************************************
39
#define ALCHEMY_BIG_ENDIAN 1
40
#define ALCHEMY_LITTLE_ENDIAN 2
41
// Attempt to infer endianess by comparing the processor type and/or OS.
42
// Some processors are bi-endian, such as MIPS, this may cause trouble in the future.
43
#if (ALCHEMY_CPU < ALCHEMY_CPU_BIG_ENDIAN) || defined(_WIN32)
44
# define ALCHEMY_ENDIANESS ALCHEMY_LITTLE_ENDIAN
45
# define ORDER_DCBA
46
#else
47
# define ALCHEMY_ENDIANESS ALCHEMY_BIG_ENDIAN
48
#endif
49
50
51
// Constants ******************************************************************
52
/// This set contains constant definitions for each type of endian processor
53
/// supported by these conversion functions.
54
///
55
#ifdef __cplusplus
56
enum
Endianess
57
{
58
k_big_endian
= ALCHEMY_BIG_ENDIAN,
///< Indicates Big-Endian byte-order
59
k_little_endian
= ALCHEMY_LITTLE_ENDIAN
///< Indicates Little-Endian byte-order
60
};
61
62
#else
63
# define k_big_endian ALCHEMY_BIG_ENDIAN
64
# define k_little_endian ALCHEMY_LITTLE_ENDIAN
65
66
#endif
67
68
#endif
Generated on Sat May 9 2015 21:25:05 for Alchemy by
1.8.3.1