mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-27 01:26:30 +00:00
Merge with develop
This commit is contained in:
parent
a6694d122b
commit
7de5594966
4 changed files with 38 additions and 141 deletions
|
@ -38,6 +38,10 @@
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(NL_CPU_INTEL) && defined(NL_COMP_GCC)
|
||||||
|
#include "x86intrin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "string_common.h"
|
#include "string_common.h"
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
|
@ -65,20 +69,8 @@ namespace NLMISC
|
||||||
|
|
||||||
inline uint64 rdtsc()
|
inline uint64 rdtsc()
|
||||||
{
|
{
|
||||||
uint64 ticks;
|
// __rdtsc() is defined under all platforms
|
||||||
# ifdef NL_OS_WINDOWS
|
return uint64(__rdtsc());
|
||||||
# ifdef NL_NO_ASM
|
|
||||||
ticks = uint64(__rdtsc());
|
|
||||||
# else
|
|
||||||
// We should use the intrinsic code now. ticks = uint64(__rdtsc());
|
|
||||||
__asm rdtsc
|
|
||||||
__asm mov DWORD PTR [ticks], eax
|
|
||||||
__asm mov DWORD PTR [ticks + 4], edx
|
|
||||||
# endif // NL_NO_ASM
|
|
||||||
# else
|
|
||||||
__asm__ volatile(".byte 0x0f, 0x31" : "=a" (ticks.low), "=d" (ticks.high));
|
|
||||||
# endif // NL_OS_WINDOWS
|
|
||||||
return ticks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NL_CPU_INTEL
|
#endif // NL_CPU_INTEL
|
||||||
|
|
|
@ -72,9 +72,9 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool isNT();
|
static bool isNT();
|
||||||
|
|
||||||
/** Returns the space left on the hard drive that contains the filename
|
/** Returns the space left on the hard drive that contains the filename in bytes
|
||||||
*/
|
*/
|
||||||
static std::string availableHDSpace (const std::string &filename);
|
static uint64 availableHDSpace (const std::string &filename);
|
||||||
|
|
||||||
/** Returns all the physical memory available on the computer (in bytes)
|
/** Returns all the physical memory available on the computer (in bytes)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,6 +34,11 @@
|
||||||
# include <cpuid.h>
|
# include <cpuid.h>
|
||||||
# define nlcpuid(regs, idx) __cpuid(idx, regs[0], regs[1], regs[2], regs[3])
|
# define nlcpuid(regs, idx) __cpuid(idx, regs[0], regs[1], regs[2], regs[3])
|
||||||
# endif // NL_CPU_INTEL
|
# endif // NL_CPU_INTEL
|
||||||
|
# ifdef NL_OS_MAC
|
||||||
|
# include <sys/mount.h>
|
||||||
|
# else
|
||||||
|
# include <sys/vfs.h>
|
||||||
|
# endif
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
|
|
||||||
#include "nel/misc/system_info.h"
|
#include "nel/misc/system_info.h"
|
||||||
|
@ -950,19 +955,8 @@ static bool DetectSSE()
|
||||||
// check OS support for SSE
|
// check OS support for SSE
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
#ifdef NL_NO_ASM
|
|
||||||
unsigned int tmp = _mm_getcsr();
|
unsigned int tmp = _mm_getcsr();
|
||||||
nlunreferenced(tmp);
|
nlunreferenced(tmp);
|
||||||
#else
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
xorps xmm0, xmm0 // Streaming SIMD Extension
|
|
||||||
}
|
|
||||||
#endif // NL_NO_ASM
|
|
||||||
#elif NL_OS_UNIX
|
|
||||||
__asm__ __volatile__ ("xorps %xmm0, %xmm0;");
|
|
||||||
#endif // NL_OS_UNIX
|
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -984,74 +978,10 @@ bool CSystemInfo::_HaveSSE = DetectSSE ();
|
||||||
bool CSystemInfo::hasCPUID ()
|
bool CSystemInfo::hasCPUID ()
|
||||||
{
|
{
|
||||||
#ifdef NL_CPU_INTEL
|
#ifdef NL_CPU_INTEL
|
||||||
uint32 result = 0;
|
uint32 result = 0;
|
||||||
#ifdef NL_OS_WINDOWS
|
sint32 CPUInfo[4] = {-1};
|
||||||
#ifdef NL_NO_ASM
|
nlcpuid(CPUInfo, 0);
|
||||||
sint32 CPUInfo[4] = {-1};
|
if (CPUInfo[3] != -1) result = 1;
|
||||||
nlcpuid(CPUInfo, 0);
|
|
||||||
if (CPUInfo[3] != -1) result = 1;
|
|
||||||
#else
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
pushad
|
|
||||||
pushfd
|
|
||||||
// If ID bit of EFLAGS can change, then cpuid is available
|
|
||||||
pushfd
|
|
||||||
pop eax // Get EFLAG
|
|
||||||
mov ecx,eax
|
|
||||||
xor eax,0x200000 // Flip ID bit
|
|
||||||
push eax
|
|
||||||
popfd // Write EFLAGS
|
|
||||||
pushfd
|
|
||||||
pop eax // read back EFLAG
|
|
||||||
xor eax,ecx
|
|
||||||
je noCpuid // no flip -> no CPUID instr.
|
|
||||||
|
|
||||||
popfd // restore state
|
|
||||||
popad
|
|
||||||
mov result, 1
|
|
||||||
jmp CPUIDPresent
|
|
||||||
|
|
||||||
noCpuid:
|
|
||||||
popfd // restore state
|
|
||||||
popad
|
|
||||||
mov result, 0
|
|
||||||
CPUIDPresent:
|
|
||||||
}
|
|
||||||
#endif // NL_NO_ASM
|
|
||||||
#elif NL_OS_UNIX // NL_OS_WINDOWS
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
/* Save Register */
|
|
||||||
"pushl %%ebp;"
|
|
||||||
"pushl %%ebx;"
|
|
||||||
"pushl %%edx;"
|
|
||||||
|
|
||||||
/* Check if this CPU supports cpuid */
|
|
||||||
"pushf;"
|
|
||||||
"pushf;"
|
|
||||||
"popl %%eax;"
|
|
||||||
"movl %%eax, %%ebx;"
|
|
||||||
"xorl $(1 << 21), %%eax;" // CPUID bit
|
|
||||||
"pushl %%eax;"
|
|
||||||
"popf;"
|
|
||||||
"pushf;"
|
|
||||||
"popl %%eax;"
|
|
||||||
"popf;" // Restore flags
|
|
||||||
"xorl %%ebx, %%eax;"
|
|
||||||
"jz NoCPUID;"
|
|
||||||
"movl $1, %0;"
|
|
||||||
"jmp CPUID;"
|
|
||||||
|
|
||||||
"NoCPUID:;"
|
|
||||||
"movl $0, %0;"
|
|
||||||
"CPUID:;"
|
|
||||||
"popl %%edx;"
|
|
||||||
"popl %%ebx;"
|
|
||||||
"popl %%ebp;"
|
|
||||||
|
|
||||||
:"=a"(result)
|
|
||||||
);
|
|
||||||
#endif // NL_OS_UNIX
|
|
||||||
return result == 1;
|
return result == 1;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
|
@ -1062,7 +992,7 @@ bool CSystemInfo::hasCPUID ()
|
||||||
uint32 CSystemInfo::getCPUID()
|
uint32 CSystemInfo::getCPUID()
|
||||||
{
|
{
|
||||||
#ifdef NL_CPU_INTEL
|
#ifdef NL_CPU_INTEL
|
||||||
if(hasCPUID())
|
if (hasCPUID())
|
||||||
{
|
{
|
||||||
uint32 result = 0;
|
uint32 result = 0;
|
||||||
sint32 CPUInfo[4];
|
sint32 CPUInfo[4];
|
||||||
|
@ -1118,49 +1048,24 @@ bool CSystemInfo::isNT()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
string CSystemInfo::availableHDSpace (const string &filename)
|
uint64 CSystemInfo::availableHDSpace (const string &filename)
|
||||||
{
|
{
|
||||||
|
std::string path = CFile::getPath(filename);
|
||||||
|
|
||||||
#ifdef NL_OS_UNIX
|
#ifdef NL_OS_UNIX
|
||||||
string cmd = "df ";
|
struct stat stst;
|
||||||
if(filename.empty())
|
struct statfs stfs;
|
||||||
cmd += ".";
|
|
||||||
else
|
|
||||||
cmd += filename;
|
|
||||||
cmd += " >/tmp/nelhdfs";
|
|
||||||
sint error = system (cmd.c_str());
|
|
||||||
if (error)
|
|
||||||
nlwarning("'%s' failed with error code %d", cmd.c_str(), error);
|
|
||||||
|
|
||||||
int fd = open("/tmp/nelhdfs", O_RDONLY);
|
if (::stat(path.c_str(), &stst) == -1) return 0;
|
||||||
if (fd == -1)
|
if (::statfs(c_str(), &stfs) == -1) return 0;
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char buffer[4096+1];
|
|
||||||
int len = read(fd, buffer, sizeof(buffer)-1);
|
|
||||||
close(fd);
|
|
||||||
buffer[len] = '\0';
|
|
||||||
|
|
||||||
vector<string> splitted;
|
return (uint64)(stfs.f_bavail * stst.st_blksize);
|
||||||
explode(string(buffer), string("\n"), splitted, true);
|
|
||||||
|
|
||||||
if(splitted.size() < 2)
|
|
||||||
return "NoInfo";
|
|
||||||
|
|
||||||
vector<string> sline;
|
|
||||||
explode(splitted[1], string(" "), sline, true);
|
|
||||||
|
|
||||||
if(sline.size() < 5)
|
|
||||||
return splitted[1];
|
|
||||||
|
|
||||||
string space = sline[3] + "000";
|
|
||||||
return bytesToHumanReadable(space);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
nlunreferenced(filename);
|
ULARGE_INTEGER freeSpace = {0};
|
||||||
return "NoInfo";
|
BOOL bRes = ::GetDiskFreeSpaceExA(path.c_str(), &freeSpace, NULL, NULL);
|
||||||
|
if (!bRes) return 0;
|
||||||
|
|
||||||
|
return (uint64)freeSpace.QuadPart;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
#Platform specifics
|
#Platform specifics
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/src )
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/src)
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common )
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common)
|
||||||
|
|
||||||
SET(RZ_SERVER_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/server/src)
|
SET(RZ_SERVER_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/server/src)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(common)
|
ADD_SUBDIRECTORY(common)
|
||||||
|
ADD_SUBDIRECTORY(tools)
|
||||||
|
|
||||||
IF(WITH_RYZOM_CLIENT)
|
IF(WITH_RYZOM_CLIENT)
|
||||||
IF(NOT WITH_GUI)
|
IF(NOT WITH_GUI)
|
||||||
MESSAGE( FATAL_ERROR "The client cannot be built without the NeL GUI Library (WITH_GUI)")
|
MESSAGE( FATAL_ERROR "The client cannot be built without the NeL GUI Library (WITH_GUI)")
|
||||||
ENDIF(NOT WITH_GUI)
|
ENDIF()
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(client)
|
ADD_SUBDIRECTORY(client)
|
||||||
ELSEIF(WITH_RYZOM_TOOLS)
|
ELSEIF(WITH_RYZOM_TOOLS)
|
||||||
# Need clientsheets lib for sheets packer tool
|
# Need clientsheets lib for sheets packer tool
|
||||||
ADD_SUBDIRECTORY(client)
|
ADD_SUBDIRECTORY(client)
|
||||||
ENDIF(WITH_RYZOM_CLIENT)
|
ENDIF()
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(tools)
|
|
||||||
|
|
||||||
IF(WITH_RYZOM_SERVER OR WITH_RYZOM_TOOLS)
|
IF(WITH_RYZOM_SERVER OR WITH_RYZOM_TOOLS)
|
||||||
# Need servershare for build packed collision tool
|
# Need servershare for build packed collision tool
|
||||||
# Need aishare for build wmap tool
|
# Need aishare for build wmap tool
|
||||||
FIND_PACKAGE(MySQL REQUIRED)
|
FIND_PACKAGE(MySQL REQUIRED)
|
||||||
ADD_SUBDIRECTORY(server)
|
ADD_SUBDIRECTORY(server)
|
||||||
ENDIF(WITH_RYZOM_SERVER OR WITH_RYZOM_TOOLS)
|
ENDIF()
|
||||||
|
|
Loading…
Reference in a new issue