Changeset - r21422:5562a7bad682
[Not reviewed]
master
0 1 0
frosch - 11 years ago 2014-04-27 13:21:30
frosch@openttd.org
(svn r26523) -Fix [FS#5992]: OpenBSD compilation (MagisterQuis)
1 file changed with 9 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/os/unix/unix.cpp
Show inline comments
 
@@ -337,15 +337,24 @@ uint GetCPUCoreCount()
 
{
 
	uint count = 1;
 
#ifdef HAS_SYSCTL
 
	int ncpu = 0;
 
	size_t len = sizeof(ncpu);
 

	
 
#ifdef OPENBSD
 
	int name[2];
 
	name[0] = CTL_HW;
 
	name[1] = HW_NCPU;
 
	if (sysctl(name, 2, &ncpu, &len, NULL, 0) < 0) {
 
	        ncpu = 0;
 
	}
 
#else
 
	if (sysctlbyname("hw.availcpu", &ncpu, &len, NULL, 0) < 0) {
 
		sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0);
 
	}
 
#endif /* #ifdef OPENBSD */
 

	
 
	if (ncpu > 0) count = ncpu;
 
#elif defined(_SC_NPROCESSORS_ONLN)
 
	long res = sysconf(_SC_NPROCESSORS_ONLN);
 
	if (res > 0) count = res;
 
#endif
0 comments (0 inline, 0 general)