Removed mingw-gcc warnings
[libcds.git] / cds / os / win / topology.h
1 //$$CDS-header$$
2
3 #ifndef CDSLIB_OS_WIN_TOPOLOGY_H
4 #define CDSLIB_OS_WIN_TOPOLOGY_H
5
6 #ifndef CDSLIB_OS_TOPOLOGY_H
7 #   error "<cds/os/topology.h> must be included instead"
8 #endif
9
10 #include <cds/details/defs.h>
11 #ifndef NOMINMAX
12 #   define NOMINMAX
13 #endif
14 #include <windows.h>
15
16 namespace cds { namespace OS {
17
18     /// Windows-specific wrappers
19     CDS_CXX11_INLINE_NAMESPACE namespace Win32 {
20
21         /// System topology
22         /**
23             The implementation assumes that:
24                 \li the system has no more than 64 logical processors;
25                 \li processor IDs are in numerical order from 0 to N - 1, where N - count of processor in the system
26         */
27         struct CDS_EXPORT_API topology
28         {
29 #   if _WIN32_WINNT >= 0x0601       // >= Windows 7
30             static unsigned int    processor_count()
31             {
32                 return ::GetActiveProcessorCount( ALL_PROCESSOR_GROUPS );
33             }
34 #   else    // < Windows 7
35             /// Logical processor count for the system
36             static unsigned int processor_count();
37 #   endif
38
39 #   if _WIN32_WINNT >= 0x0600   // >= Windows Vista
40             static unsigned int current_processor()
41             {
42                 return ::GetCurrentProcessorNumber();
43             }
44 #   else    // < Windows Vista
45             /// Get current processor number
46             static unsigned int current_processor();
47 #   endif
48
49             /// Synonym for \ref current_processor
50             static unsigned int native_current_processor()
51             {
52                 return current_processor();
53             }
54
55             //@cond
56             static void init()
57             {}
58             static void fini()
59             {}
60             //@endcond
61         };
62
63     }   // namespace Win32
64
65 #ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT
66     using Win32::topology;
67 #endif
68 }}  // namespace cds::OS
69
70
71
72 #endif  // #ifndef CDSLIB_OS_WIN_TOPOLOGY_H