diff options
author | Marc Alff <marc.alff@sun.com> | 2009-11-17 17:11:32 -0700 |
---|---|---|
committer | Marc Alff <marc.alff@sun.com> | 2009-11-17 17:11:32 -0700 |
commit | 382ae222902919f37ae749acada48ee05e3704e6 (patch) | |
tree | 4b3f59fa13833492f961ebb9857d1149467a9db8 /mysys/my_getncpus.c | |
parent | 7d59878096611f3869aef17fe2658d6beffd7823 (diff) | |
download | mariadb-git-382ae222902919f37ae749acada48ee05e3704e6.tar.gz |
WL#2595 kernel-independent atomic operations
Backport from 6.0.14 to 5.6.0
Original code from Sergei Golubchik
Diffstat (limited to 'mysys/my_getncpus.c')
-rw-r--r-- | mysys/my_getncpus.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c index 82e87dee2e4..5be961e3bc9 100644 --- a/mysys/my_getncpus.c +++ b/mysys/my_getncpus.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (C) 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,24 +16,34 @@ /* get the number of (online) CPUs */ #include "mysys_priv.h" +#ifdef HAVE_UNISTD_H #include <unistd.h> +#endif static int ncpus=0; -#ifdef _SC_NPROCESSORS_ONLN int my_getncpus() { if (!ncpus) + { +#ifdef _SC_NPROCESSORS_ONLN ncpus= sysconf(_SC_NPROCESSORS_ONLN); - return ncpus; -} - +#elif defined(__WIN__) + SYSTEM_INFO sysinfo; + + /* + * We are not calling GetNativeSystemInfo here because (1) we + * don't believe that they return different values for number + * of processors and (2) if WOW64 limits processors for Win32 + * then we don't want to try to override that. + */ + GetSystemInfo(&sysinfo); + + ncpus= sysinfo.dwNumberOfProcessors; #else -/* unknown */ -int my_getncpus() -{ - return 2; -} - +/* unknown so play safe: assume SMP and forbid uniprocessor build */ + ncpus= 2; #endif - + } + return ncpus; +} |