1ac1d04b43d023b776c40fbfb7ab0df38bb3374b
[libcds.git] / cds / os / osx / topology.h
1 //$$CDS-header$$
2
3 #ifndef CDSLIB_OS_OSX_TOPOLOGY_H
4 #define CDSLIB_OS_OSX_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/os/details/fake_topology.h>
11
12 namespace cds { namespace OS {
13     /// Linux-specific wrappers
14     CDS_CXX11_INLINE_NAMESPACE namespace OS_X {
15
16         /// System topology
17         /**
18             The implementation assumes that processor IDs are in numerical order
19             from 0 to N - 1, where N - count of processor in the system
20         */
21         struct topology: public OS::details::fake_topology
22         {
23         private:
24             //@cond
25             typedef OS::details::fake_topology  base_class;
26             static unsigned int     s_nProcessorCount;
27             //@endcond
28         public:
29
30             /// Logical processor count for the system
31             static unsigned int processor_count()
32             {
33                 return s_nProcessorCount;
34             }
35
36             /// Get current processor number
37             static unsigned int current_processor()
38             {
39                 return base_class::current_processor();
40             }
41
42             /// Synonym for \ref current_processor
43             static unsigned int native_current_processor()
44             {
45                 return current_processor();
46             }
47
48             //@cond
49             static void init();
50             static void fini();
51             //@endcond
52         };
53     }   // namespace OS_X
54
55 #ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT
56     using OS_X::topology;
57 #endif
58 }}  // namespace cds::OS
59
60 #endif  // #ifndef CDSLIB_OS_OSX_TOPOLOGY_H