Splitting monolithic extraction code into compile units

This commit is contained in:
Dennis Luxen 2013-01-02 00:33:14 +01:00
parent 9379d2462e
commit 12a35c1214
2 changed files with 26 additions and 3 deletions

View File

@ -30,8 +30,29 @@ extern "C" {
#include <windows.h> #include <windows.h>
#endif #endif
/* Returns the physical memory size in kilobytes */ enum Endianness {
unsigned GetPhysicalmemory(void){ LittleEndian = 1,
BigEndian = 2
};
//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])
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) );
return x;
}
// Returns the physical memory size in kilobytes
inline unsigned GetPhysicalmemory(void){
#if defined(SUN5) || defined(__linux__) #if defined(SUN5) || defined(__linux__)
return (sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE)); return (sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE));
@ -61,4 +82,5 @@ unsigned GetPhysicalmemory(void){
#endif #endif
} }
#endif #endif // MACHINE_INFO_H

View File

@ -32,6 +32,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "Util/BaseConfiguration.h" #include "Util/BaseConfiguration.h"
#include "Util/InputFileUtil.h" #include "Util/InputFileUtil.h"
#include "Util/MachineInfo.h" #include "Util/MachineInfo.h"
#include "Util/OpenMPWrapper.h"
#include "Util/StringUtil.h" #include "Util/StringUtil.h"
typedef BaseConfiguration ExtractorConfiguration; typedef BaseConfiguration ExtractorConfiguration;