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