2 * Copyright (c) 2014 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #define WIN32_LEAN_AND_MEAN
24 /* Standard file descriptors. */
25 #define STDIN_FILENO 0 /* Standard input. */
26 #define STDOUT_FILENO 1 /* Standard output. */
27 #define STDERR_FILENO 2 /* Standard error output. */
29 #define _SC_UIO_MAXIOV 2
30 #define _XOPEN_IOV_MAX 16
32 #define _SC_PAGESIZE 0x1
33 #define _SC_NPROCESSORS_ONLN 0x2
34 #define _SC_PHYS_PAGES 0x4
36 __inline int GetNumLogicalProcessors(void)
38 SYSTEM_INFO info_temp;
39 GetSystemInfo(&info_temp);
40 long int n_cores = info_temp.dwNumberOfProcessors;
44 __inline long sysconf(int type)
49 MEMORYSTATUSEX status;
52 case _SC_NPROCESSORS_ONLN:
53 value = GetNumLogicalProcessors();
57 GetSystemInfo(&sys_info);
58 value = sys_info.dwPageSize;
62 status.dwLength = sizeof(status);
63 page_size = sysconf(_SC_PAGESIZE);
64 if (GlobalMemoryStatusEx(&status) && page_size != -1) {
65 value = status.ullTotalPhys / page_size;