1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Code refactor: rewrite TxUtil::getNumberofProcessors()

This commit is contained in:
Sergey Lipskiy 2017-11-04 19:10:20 +07:00
parent fb6d945953
commit 28051387e9
2 changed files with 4 additions and 33 deletions

View File

@ -21,6 +21,7 @@
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <thread>
#include "TxUtil.h"
#include "TxDbg.h"
#include <zlib.h>
@ -490,41 +491,11 @@ findmax0:
return 1;
}
int
TxUtil::getNumberofProcessors()
uint32 TxUtil::getNumberofProcessors()
{
int numcore = 1;
#ifndef OS_ANDROID
try {
#if defined (OS_WINDOWS)
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
numcore = sysinfo.dwNumberOfProcessors;
#elif defined (OS_MAC_OS_X)
int nm[2];
size_t len = 4;
uint32_t count;
nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
sysctl(nm, 2, &count, &len, nullptr, 0);
if (count < 1) {
nm[1] = HW_NCPU;
sysctl(nm, 2, &count, &len, nullptr, 0);
if (count < 1) { count = 1; }
}
numcore = count;
#elif defined (OS_LINUX)
numcore = sysconf(_SC_NPROCESSORS_ONLN);
#endif
} catch (...) {
DBG_INFO(80, wst("Error: number of processor detection failed!\n"));
}
uint32 numcore = std::thread::hardware_concurrency();
if (numcore > MAX_NUMCORE) numcore = MAX_NUMCORE;
#endif // OS_ANDROID
DBG_INFO(80, wst("Number of processors : %d\n"), numcore);
return numcore;
}

View File

@ -50,7 +50,7 @@ public:
#endif
static uint32 checksum(uint8 *src, int width, int height, int size, int rowStride);
static uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette);
static int getNumberofProcessors();
static uint32 getNumberofProcessors();
};
class TxMemBuf