mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add multi-Emerge thread support
This commit is contained in:
parent
76217939e0
commit
5ec5b1cbd6
8 changed files with 160 additions and 64 deletions
|
@ -131,6 +131,29 @@ void signal_handler_init(void)
|
|||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Multithreading support
|
||||
*/
|
||||
int getNumberOfProcessors() {
|
||||
#if defined(_SC_NPROCESSORS_ONLN)
|
||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#elif defined(__FreeBSD__) || defined(__APPLE__)
|
||||
unsigned int len, count;
|
||||
len = sizeof(count);
|
||||
return sysctlbyname("hw.ncpu", &count, &len, NULL, 0);
|
||||
#elif defined(_GNU_SOURCE)
|
||||
return get_nprocs();
|
||||
#elif defined(_WIN32)
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
return sysinfo.dwNumberOfProcessors;
|
||||
#elif defined(PTW32_VERSION) || defined(__hpux)
|
||||
return pthread_num_processors_np();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Path mangler
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue