-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystem.cpp
More file actions
38 lines (35 loc) · 762 Bytes
/
System.cpp
File metadata and controls
38 lines (35 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// https://bitbucket.org/wolfpld/etcpak
// Bartosz Taudul <wolf.pld@gmail.com>
#ifdef _WIN32
# include <windows.h>
#else
# include <pthread.h>
# include <unistd.h>
#endif
#include "System.hpp"
int System::CPUCores()
{
static int cores = 0;
if (cores == 0)
{
#ifdef _WIN32
SYSTEM_INFO info;
GetSystemInfo(&info);
cores = (int)info.dwNumberOfProcessors;
#else
# ifndef _SC_NPROCESSORS_ONLN
# ifdef _SC_NPROC_ONLN
# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
# elif defined _SC_CRAY_NCPU
# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
# endif
# endif
cores = (int)(long)sysconf( _SC_NPROCESSORS_ONLN );
#endif
if (cores <= 0)
{
cores = 1;
}
}
return cores;
}