@@ -108,8 +108,6 @@ static void hwloc__darwin_cpukinds_add_cpu(struct hwloc_darwin_cpukinds *kinds,
108
108
#define kIOMainPortDefault kIOMasterPortDefault
109
109
#endif
110
110
111
- #define DT_PLANE "IODeviceTree"
112
-
113
111
static int hwloc__darwin_look_iokit_cpukinds (struct hwloc_darwin_cpukinds * kinds ,
114
112
int * matched_perflevels )
115
113
{
@@ -118,16 +116,19 @@ static int hwloc__darwin_look_iokit_cpukinds(struct hwloc_darwin_cpukinds *kinds
118
116
io_registry_entry_t cpus_child ;
119
117
kern_return_t kret ;
120
118
unsigned i ;
119
+ #define DT_PLANE "IODeviceTree"
120
+ io_string_t cpu_plane_string = DT_PLANE ":/cpus" ;
121
+ io_name_t dt_plane_name = DT_PLANE ;
121
122
122
- hwloc_debug ("\nLooking at cpukinds under " DT_PLANE ":/cpus ...\n" );
123
+ hwloc_debug ("\nLooking at cpukinds under %s\n" , ( const char * ) cpu_plane_string );
123
124
124
- cpus_root = IORegistryEntryFromPath (kIOMainPortDefault , DT_PLANE ":/cpus" );
125
+ cpus_root = IORegistryEntryFromPath (kIOMainPortDefault , cpu_plane_string );
125
126
if (!cpus_root ) {
126
- fprintf (stderr , "hwloc/darwin/cpukinds: failed to find " DT_PLANE ":/cpus \n" );
127
+ fprintf (stderr , "hwloc/darwin/cpukinds: failed to find %s \n" , ( const char * ) cpu_plane_string );
127
128
return -1 ;
128
129
}
129
130
130
- kret = IORegistryEntryGetChildIterator (cpus_root , DT_PLANE , & cpus_iter );
131
+ kret = IORegistryEntryGetChildIterator (cpus_root , dt_plane_name , & cpus_iter );
131
132
if (kret != KERN_SUCCESS ) {
132
133
if (HWLOC_SHOW_ALL_ERRORS ())
133
134
fprintf (stderr , "hwloc/darwin/cpukinds: failed to create iterator\n" );
@@ -145,7 +146,7 @@ static int hwloc__darwin_look_iokit_cpukinds(struct hwloc_darwin_cpukinds *kinds
145
146
{
146
147
/* get the name */
147
148
io_name_t name ;
148
- kret = IORegistryEntryGetNameInPlane (cpus_child , DT_PLANE , name );
149
+ kret = IORegistryEntryGetNameInPlane (cpus_child , dt_plane_name , name );
149
150
if (kret != KERN_SUCCESS ) {
150
151
hwloc_debug ("failed to find cpu name\n" );
151
152
} else {
@@ -155,7 +156,7 @@ static int hwloc__darwin_look_iokit_cpukinds(struct hwloc_darwin_cpukinds *kinds
155
156
#endif
156
157
157
158
/* get logical-cpu-id */
158
- ref = IORegistryEntrySearchCFProperty (cpus_child , DT_PLANE , CFSTR ("logical-cpu-id" ), kCFAllocatorDefault , kNilOptions );
159
+ ref = IORegistryEntrySearchCFProperty (cpus_child , dt_plane_name , CFSTR ("logical-cpu-id" ), kCFAllocatorDefault , kNilOptions );
159
160
if (!ref ) {
160
161
/* this may happen on old/x86 systems that aren't hybrid, don't warn */
161
162
hwloc_debug ("failed to find logical-cpu-id\n" );
@@ -183,7 +184,7 @@ static int hwloc__darwin_look_iokit_cpukinds(struct hwloc_darwin_cpukinds *kinds
183
184
184
185
#ifdef HWLOC_DEBUG
185
186
/* get logical-cluster-id */
186
- ref = IORegistryEntrySearchCFProperty (cpus_child , DT_PLANE , CFSTR ("logical-cluster-id" ), kCFAllocatorDefault , kNilOptions );
187
+ ref = IORegistryEntrySearchCFProperty (cpus_child , dt_plane_name , CFSTR ("logical-cluster-id" ), kCFAllocatorDefault , kNilOptions );
187
188
if (!ref ) {
188
189
hwloc_debug ("failed to find logical-cluster-id\n" );
189
190
continue ;
@@ -207,7 +208,7 @@ static int hwloc__darwin_look_iokit_cpukinds(struct hwloc_darwin_cpukinds *kinds
207
208
#endif
208
209
209
210
/* get cluster-type */
210
- ref = IORegistryEntrySearchCFProperty (cpus_child , DT_PLANE , CFSTR ("cluster-type" ), kCFAllocatorDefault , kNilOptions );
211
+ ref = IORegistryEntrySearchCFProperty (cpus_child , dt_plane_name , CFSTR ("cluster-type" ), kCFAllocatorDefault , kNilOptions );
211
212
if (!ref ) {
212
213
if (HWLOC_SHOW_ALL_ERRORS ())
213
214
fprintf (stderr , "hwloc/darwin/cpukinds: failed to find cluster-type\n" );
@@ -244,7 +245,7 @@ static int hwloc__darwin_look_iokit_cpukinds(struct hwloc_darwin_cpukinds *kinds
244
245
CFRelease (ref );
245
246
246
247
/* get compatible */
247
- ref = IORegistryEntrySearchCFProperty (cpus_child , DT_PLANE , CFSTR ("compatible" ), kCFAllocatorDefault , kNilOptions );
248
+ ref = IORegistryEntrySearchCFProperty (cpus_child , dt_plane_name , CFSTR ("compatible" ), kCFAllocatorDefault , kNilOptions );
248
249
if (!ref ) {
249
250
if (HWLOC_SHOW_ALL_ERRORS ())
250
251
fprintf (stderr , "hwloc/darwin/cpukinds: failed to find compatible\n" );
0 commit comments