From c2b73368170743d3cb2388f29e4b0b67c1ac7b29 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 7 May 2014 11:38:22 +0200 Subject: [PATCH] reformat MachineInfo.h --- Extractor/PBFParser.cpp | 2 +- Util/MachineInfo.h | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Extractor/PBFParser.cpp b/Extractor/PBFParser.cpp index f9f87adb4..47a366c9f 100644 --- a/Extractor/PBFParser.cpp +++ b/Extractor/PBFParser.cpp @@ -406,7 +406,7 @@ inline void PBFParser::loadBlock(_ThreadData * threadData) { inline bool PBFParser::readPBFBlobHeader(std::fstream& stream, _ThreadData * threadData) { int size(0); stream.read((char *)&size, sizeof(int)); - size = swapEndian(size); + size = SwapEndian(size); if(stream.eof()) { return false; } diff --git a/Util/MachineInfo.h b/Util/MachineInfo.h index 2000ee5f0..c5cb0522b 100644 --- a/Util/MachineInfo.h +++ b/Util/MachineInfo.h @@ -28,25 +28,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef MACHINE_INFO_H #define MACHINE_INFO_H -enum Endianness { - LittleEndian = 1, - BigEndian = 2 -}; +enum Endianness +{ LittleEndian = 1, + BigEndian = 2 }; -//Function is optimized to a single 'mov eax,1' on GCC, clang and icc using -O3 -inline Endianness getMachineEndianness() { +// Function is optimized to a single 'mov eax,1' on GCC, clang and icc using -O3 +inline Endianness GetMachineEndianness() +{ int i(1); - char *p = (char *) &i; - if (1 == p[0]) { + char *p = (char *)&i; + if (1 == p[0]) + { return LittleEndian; } return BigEndian; } // Reverses Network Byte Order into something usable, compiles down to a bswap-mov combination -inline unsigned swapEndian(unsigned x) { - if(getMachineEndianness() == LittleEndian) - return ( (x>>24) | ((x<<8) & 0x00FF0000) | ((x>>8) & 0x0000FF00) | (x<<24) ); +inline unsigned SwapEndian(unsigned x) +{ + if (GetMachineEndianness() == LittleEndian) + { + return ((x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24)); + } return x; }