88#include "private/autogen/config.h"
99#include "hwloc.h"
1010
11+ #ifdef HWLOC_WIN_SYS
12+ #include <windows.h>
13+ #endif
14+
1115struct hwloc_distrib_level {
1216 hwloc_obj_type_t type ; // level type.
1317 unsigned depth ; // level depth.
@@ -29,48 +33,61 @@ struct hwloc_distrib_iterator{
2933static size_t * range (const size_t n ){
3034 size_t * r = malloc (n * sizeof (* r ));
3135
32- if (r == NULL ) return NULL ;
33- for (size_t i = 0 ; i < n ; i ++ ){ r [i ] = i ; }
36+ if (r == NULL )
37+ return NULL ;
38+ for (size_t i = 0 ; i < n ; i ++ )
39+ r [i ] = i ;
3440 return r ;
3541}
3642
3743static size_t * reversed_range (const size_t n ){
3844 size_t * r = malloc (n * sizeof (* r ));
3945
40- if (r == NULL ) return NULL ;
46+ if (r == NULL )
47+ return NULL ;
4148 for (size_t i = 0 ; i < n ; i ++ ){ r [i ] = n - i - 1 ; }
4249 return r ;
4350}
4451
4552static size_t * shuffled_range (const size_t n ){
4653 size_t i , * index , * ret , val ;
4754
48- if ((index = range (n )) == NULL ) return NULL ;
49- if ((ret = malloc (n * sizeof (* ret ))) == NULL ) { free (index ); return NULL ; }
55+ if ((index = range (n )) == NULL )
56+ return NULL ;
57+
58+ ret = malloc (n * sizeof (* ret ));
59+ if (ret == NULL ) {
60+ free (index );
61+ return NULL ;
62+ }
5063
5164 srand (time (NULL ));
5265 for (i = n ;i > 0 ;i -- ){
5366 val = rand ()%(i );
5467 ret [i - 1 ] = index [val ];
5568 index [val ] = index [i - 1 ];
56- }
57- free (index );
58- return ret ;
69+ }
70+ free (index );
71+ return ret ;
5972}
6073
6174static int hwloc_distrib_level_cmp_depth (const void * la , const void * lb ){
6275 const struct hwloc_distrib_level * a = (struct hwloc_distrib_level * )la ;
6376 const struct hwloc_distrib_level * b = (struct hwloc_distrib_level * )lb ;
64- if (a -> depth > b -> depth ) { return 1 ; }
65- if (a -> depth < b -> depth ) { return -1 ; }
77+ if (a -> depth > b -> depth )
78+ return 1 ;
79+ if (a -> depth < b -> depth )
80+ return -1 ;
6681 return 0 ;
6782}
6883
6984static int hwloc_distrib_level_cmp_user_index (const void * la , const void * lb ){
7085 const struct hwloc_distrib_level * a = (struct hwloc_distrib_level * )la ;
7186 const struct hwloc_distrib_level * b = (struct hwloc_distrib_level * )lb ;
72- if (a -> user_index > b -> user_index ) { return 1 ; }
73- if (a -> user_index < b -> user_index ) { return -1 ; }
87+ if (a -> user_index > b -> user_index )
88+ return 1 ;
89+ if (a -> user_index < b -> user_index )
90+ return -1 ;
7491 return 0 ;
7592}
7693
@@ -172,7 +189,8 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
172189
173190 struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
174191 sizeof (* it -> levels ) * n_roots );
175- if (it == NULL ) return NULL ;
192+ if (it == NULL )
193+ return NULL ;
176194
177195 it -> roots = roots ;
178196 it -> n_roots = n_roots ;
@@ -203,7 +221,8 @@ hwloc_distrib_iterator_round_robin(hwloc_topology_t topology,
203221 struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
204222 sizeof (hwloc_obj_t ) +
205223 sizeof (struct hwloc_distrib_level * ));
206- if (it == NULL ) return NULL ;
224+ if (it == NULL )
225+ return NULL ;
207226
208227 it -> roots = (hwloc_obj_t * ) ((char * )it + sizeof (* it ));
209228 * it -> roots = root ;
@@ -255,7 +274,8 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
255274 struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
256275 sizeof (hwloc_obj_t ) +
257276 sizeof (struct hwloc_distrib_level * ));
258- if (it == NULL ) return NULL ;
277+ if (it == NULL )
278+ return NULL ;
259279
260280 it -> roots = (hwloc_obj_t * ) ((char * )it + sizeof (* it ));
261281 * it -> roots = root ;
0 commit comments