MySQL 5.6.14 Source Code Document
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
my_getncpus.c
1
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
2
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16
/* get the number of (online) CPUs */
17
18
#include "mysys_priv.h"
19
#ifdef HAVE_UNISTD_H
20
#include <unistd.h>
21
#endif
22
23
static
int
ncpus=0;
24
25
int
my_getncpus()
26
{
27
if
(!ncpus)
28
{
29
#ifdef _SC_NPROCESSORS_ONLN
30
ncpus= sysconf(_SC_NPROCESSORS_ONLN);
31
#elif defined(__WIN__)
32
SYSTEM_INFO sysinfo;
33
34
/*
35
* We are not calling GetNativeSystemInfo here because (1) we
36
* don't believe that they return different values for number
37
* of processors and (2) if WOW64 limits processors for Win32
38
* then we don't want to try to override that.
39
*/
40
GetSystemInfo(&sysinfo);
41
42
ncpus= sysinfo.dwNumberOfProcessors;
43
#else
44
/* unknown so play safe: assume SMP and forbid uniprocessor build */
45
ncpus= 2;
46
#endif
47
}
48
return
ncpus;
49
}
mysys
my_getncpus.c
Generated on Sat Nov 9 2013 01:25:09 for MySQL 5.6.14 Source Code Document by
1.8.1.2