1
1
/*
2
2
* Copyright © 2009 CNRS
3
- * Copyright © 2009-2017 Inria. All rights reserved.
3
+ * Copyright © 2009-2023 Inria. All rights reserved.
4
4
* Copyright © 2009-2010, 2012 Université Bordeaux
5
5
* See COPYING in top-level directory.
6
6
*/
@@ -50,6 +50,8 @@ extern "C" {
50
50
* This function may be used before calling set_mempolicy, mbind, migrate_pages
51
51
* or any other function that takes an array of unsigned long and a maximal
52
52
* node number as input parameter.
53
+ *
54
+ * \return 0.
53
55
*/
54
56
static __hwloc_inline int
55
57
hwloc_cpuset_to_linux_libnuma_ulongs (hwloc_topology_t topology , hwloc_const_cpuset_t cpuset ,
@@ -84,6 +86,8 @@ hwloc_cpuset_to_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_const_cpus
84
86
* This function may be used before calling set_mempolicy, mbind, migrate_pages
85
87
* or any other function that takes an array of unsigned long and a maximal
86
88
* node number as input parameter.
89
+ *
90
+ * \return 0.
87
91
*/
88
92
static __hwloc_inline int
89
93
hwloc_nodeset_to_linux_libnuma_ulongs (hwloc_topology_t topology , hwloc_const_nodeset_t nodeset ,
@@ -119,6 +123,9 @@ hwloc_nodeset_to_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_const_nod
119
123
* This function may be used after calling get_mempolicy or any other function
120
124
* that takes an array of unsigned long as output parameter (and possibly
121
125
* a maximal node number as input parameter).
126
+ *
127
+ * \return 0 on success.
128
+ * \return -1 on error, for instance if failing an internal reallocation.
122
129
*/
123
130
static __hwloc_inline int
124
131
hwloc_cpuset_from_linux_libnuma_ulongs (hwloc_topology_t topology , hwloc_cpuset_t cpuset ,
@@ -130,7 +137,8 @@ hwloc_cpuset_from_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_cpuset_t
130
137
while ((node = hwloc_get_next_obj_by_depth (topology , depth , node )) != NULL )
131
138
if (node -> os_index < maxnode
132
139
&& (mask [node -> os_index /sizeof (* mask )/8 ] & (1UL << (node -> os_index % (sizeof (* mask )* 8 )))))
133
- hwloc_bitmap_or (cpuset , cpuset , node -> cpuset );
140
+ if (hwloc_bitmap_or (cpuset , cpuset , node -> cpuset ) < 0 )
141
+ return -1 ;
134
142
return 0 ;
135
143
}
136
144
@@ -142,6 +150,9 @@ hwloc_cpuset_from_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_cpuset_t
142
150
* This function may be used after calling get_mempolicy or any other function
143
151
* that takes an array of unsigned long as output parameter (and possibly
144
152
* a maximal node number as input parameter).
153
+ *
154
+ * \return 0 on success.
155
+ * \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
145
156
*/
146
157
static __hwloc_inline int
147
158
hwloc_nodeset_from_linux_libnuma_ulongs (hwloc_topology_t topology , hwloc_nodeset_t nodeset ,
@@ -153,7 +164,8 @@ hwloc_nodeset_from_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_nodeset
153
164
while ((node = hwloc_get_next_obj_by_depth (topology , depth , node )) != NULL )
154
165
if (node -> os_index < maxnode
155
166
&& (mask [node -> os_index /sizeof (* mask )/8 ] & (1UL << (node -> os_index % (sizeof (* mask )* 8 )))))
156
- hwloc_bitmap_set (nodeset , node -> os_index );
167
+ if (hwloc_bitmap_set (nodeset , node -> os_index ) < 0 )
168
+ return -1 ;
157
169
return 0 ;
158
170
}
159
171
@@ -184,7 +196,7 @@ hwloc_nodeset_from_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_nodeset
184
196
* This function may be used before calling many numa_ functions
185
197
* that use a struct bitmask as an input parameter.
186
198
*
187
- * \return newly allocated struct bitmask.
199
+ * \return newly allocated struct bitmask, or \c NULL on error .
188
200
*/
189
201
static __hwloc_inline struct bitmask *
190
202
hwloc_cpuset_to_linux_libnuma_bitmask (hwloc_topology_t topology , hwloc_const_cpuset_t cpuset ) __hwloc_attribute_malloc ;
@@ -209,7 +221,7 @@ hwloc_cpuset_to_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_const_cpu
209
221
* This function may be used before calling many numa_ functions
210
222
* that use a struct bitmask as an input parameter.
211
223
*
212
- * \return newly allocated struct bitmask.
224
+ * \return newly allocated struct bitmask, or \c NULL on error .
213
225
*/
214
226
static __hwloc_inline struct bitmask *
215
227
hwloc_nodeset_to_linux_libnuma_bitmask (hwloc_topology_t topology , hwloc_const_nodeset_t nodeset ) __hwloc_attribute_malloc ;
@@ -231,6 +243,9 @@ hwloc_nodeset_to_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_const_no
231
243
*
232
244
* This function may be used after calling many numa_ functions
233
245
* that use a struct bitmask as an output parameter.
246
+ *
247
+ * \return 0 on success.
248
+ * \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
234
249
*/
235
250
static __hwloc_inline int
236
251
hwloc_cpuset_from_linux_libnuma_bitmask (hwloc_topology_t topology , hwloc_cpuset_t cpuset ,
@@ -241,14 +256,18 @@ hwloc_cpuset_from_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_cpuset_
241
256
hwloc_bitmap_zero (cpuset );
242
257
while ((node = hwloc_get_next_obj_by_depth (topology , depth , node )) != NULL )
243
258
if (numa_bitmask_isbitset (bitmask , node -> os_index ))
244
- hwloc_bitmap_or (cpuset , cpuset , node -> cpuset );
259
+ if (hwloc_bitmap_or (cpuset , cpuset , node -> cpuset ) < 0 )
260
+ return -1 ;
245
261
return 0 ;
246
262
}
247
263
248
264
/** \brief Convert libnuma bitmask \p bitmask into hwloc NUMA node set \p nodeset
249
265
*
250
266
* This function may be used after calling many numa_ functions
251
267
* that use a struct bitmask as an output parameter.
268
+ *
269
+ * \return 0 on success.
270
+ * \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
252
271
*/
253
272
static __hwloc_inline int
254
273
hwloc_nodeset_from_linux_libnuma_bitmask (hwloc_topology_t topology , hwloc_nodeset_t nodeset ,
@@ -259,7 +278,8 @@ hwloc_nodeset_from_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_nodese
259
278
hwloc_bitmap_zero (nodeset );
260
279
while ((node = hwloc_get_next_obj_by_depth (topology , depth , node )) != NULL )
261
280
if (numa_bitmask_isbitset (bitmask , node -> os_index ))
262
- hwloc_bitmap_set (nodeset , node -> os_index );
281
+ if (hwloc_bitmap_set (nodeset , node -> os_index ) < 0 )
282
+ return -1 ;
263
283
return 0 ;
264
284
}
265
285
0 commit comments