Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
Signed-off-by: guo-shaoge <shaoge1994@163.com>
  • Loading branch information
guo-shaoge committed Oct 27, 2021
1 parent 6c0532d commit fafe934
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions libs/libcommon/src/getMemoryAmount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#if defined(WIN32) || defined(_WIN32)
#include <Windows.h>
#else
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/types.h>
#include <unistd.h>
#if defined(BSD)
#include <sys/sysctl.h>
#endif
Expand All @@ -32,15 +32,15 @@ uint64_t getMemoryAmount()
/* New 64-bit MEMORYSTATUSEX isn't available. Use old 32.bit */
MEMORYSTATUS status;
status.dwLength = sizeof(status);
GlobalMemoryStatus( &status );
GlobalMemoryStatus(&status);
return status.dwTotalPhys;

#elif defined(WIN32) || defined(_WIN32)
/* Windows. ------------------------------------------------- */
/* Use new 64-bit MEMORYSTATUSEX, not old 32-bit MEMORYSTATUS */
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx( &status );
GlobalMemoryStatusEx(&status);
return status.ullTotalPhys;

#else
Expand All @@ -57,24 +57,25 @@ uint64_t getMemoryAmount()
#endif
uint64_t size = 0; /* 64-bit */
size_t len = sizeof(size);
if ( sysctl( mib, 2, &size, &len, NULL, 0 ) == 0 ) {
if (sysctl(mib, 2, &size, &len, NULL, 0) == 0)
{
return size;
}
return 0; /* Failed? */

#elif defined(_SC_AIX_REALMEM)
/* AIX. ----------------------------------------------------- */
return sysconf( _SC_AIX_REALMEM ) * 1024;
return sysconf(_SC_AIX_REALMEM) * 1024;

#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
/* FreeBSD, Linux, OpenBSD, and Solaris. -------------------- */
return static_cast<uint64_t>(sysconf( _SC_PHYS_PAGES ))
* static_cast<uint64_t>(sysconf( _SC_PAGESIZE ));
return static_cast<uint64_t>(sysconf(_SC_PHYS_PAGES))
* static_cast<uint64_t>(sysconf(_SC_PAGESIZE));

#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE)
/* Legacy. -------------------------------------------------- */
return (uint64_t)sysconf( _SC_PHYS_PAGES )
* (uint64_t)sysconf( _SC_PAGE_SIZE );
return (uint64_t)sysconf(_SC_PHYS_PAGES)
* (uint64_t)sysconf(_SC_PAGE_SIZE);

#elif defined(CTL_HW) && (defined(HW_PHYSMEM) || defined(HW_REALMEM))
/* DragonFly BSD, FreeBSD, NetBSD, OpenBSD, and OSX. -------- */
Expand All @@ -86,8 +87,9 @@ uint64_t getMemoryAmount()
mib[1] = HW_PHYSMEM; /* Others. ------------------ */
#endif
unsigned int size = 0; /* 32-bit */
size_t len = sizeof( size );
if ( sysctl( mib, 2, &size, &len, NULL, 0 ) == 0 ) {
size_t len = sizeof(size);
if (sysctl(mib, 2, &size, &len, NULL, 0) == 0)
{
return size;
}
return 0; /* Failed? */
Expand Down

0 comments on commit fafe934

Please sign in to comment.