]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.0.1/test/src/abstraction_cpu_count.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.0.1 / test / src / abstraction_cpu_count.c
1 #include "internal.h"\r
2 \r
3 \r
4 \r
5 \r
6 \r
7 /****************************************************************************/\r
8 #if (defined _WIN32 && defined _MSC_VER && !defined WIN_KERNEL_BUILD)\r
9 \r
10   /* TRD : any Windows (user-mode) on any CPU with the Microsoft C compiler\r
11 \r
12            _WIN32             indicates 64-bit or 32-bit Windows\r
13            _MSC_VER           indicates Microsoft C compiler\r
14            !WIN_KERNEL_BUILD  indicates Windows user-mode\r
15   */\r
16 \r
17   unsigned int abstraction_cpu_count()\r
18   {\r
19     SYSTEM_INFO\r
20       si;\r
21 \r
22     GetNativeSystemInfo( &si );\r
23 \r
24     return( (unsigned int) si.dwNumberOfProcessors );\r
25   }\r
26 \r
27 #endif\r
28 \r
29 \r
30 \r
31 \r
32 \r
33 /****************************************************************************/\r
34 #if (defined _WIN32 && defined _MSC_VER && defined WIN_KERNEL_BUILD)\r
35 \r
36   /* TRD : any Windows on any CPU with the Microsoft C compiler\r
37 \r
38            _WIN32            indicates 64-bit or 32-bit Windows\r
39            _MSC_VER          indicates Microsoft C compiler\r
40            WIN_KERNEL_BUILD  indicates Windows kernel\r
41   */\r
42 \r
43   unsigned int abstraction_cpu_count()\r
44   {\r
45     unsigned int\r
46       active_processor_count;\r
47 \r
48     active_processor_count = KeQueryActiveProcessorCount( NULL );\r
49 \r
50     return( active_processor_count );\r
51   }\r
52 \r
53 #endif\r
54 \r
55 \r
56 \r
57 \r
58 \r
59 /****************************************************************************/\r
60 #if (defined __linux__ && __GNUC__)\r
61 \r
62   /* TRD : Linux on any CPU with GCC\r
63 \r
64            this function I believe is Linux specific and varies by UNIX flavour\r
65 \r
66            __linux__  indicates Linux\r
67            __GNUC__   indicates GCC\r
68   */\r
69 \r
70   unsigned int abstraction_cpu_count()\r
71   {\r
72     long int\r
73       cpu_count;\r
74 \r
75     cpu_count = sysconf( _SC_NPROCESSORS_ONLN );\r
76 \r
77     return( (unsigned int) cpu_count );\r
78   }\r
79 \r
80 #endif\r
81 \r