Skip to content

Commit cc0f4d1

Browse files
committed
hwloc/distances.h: add/improve doc about return values
Refs #578 Signed-off-by: Brice Goglin <[email protected]>
1 parent dbcbce3 commit cc0f4d1

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

include/hwloc/distances.h

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2010-2022 Inria. All rights reserved.
2+
* Copyright © 2010-2023 Inria. All rights reserved.
33
* See COPYING in top-level directory.
44
*/
55

@@ -131,6 +131,8 @@ enum hwloc_distances_kind_e {
131131
*
132132
* Each distance matrix returned in the \p distances array should be released
133133
* by the caller using hwloc_distances_release().
134+
*
135+
* \return 0 on success, -1 on error.
134136
*/
135137
HWLOC_DECLSPEC int
136138
hwloc_distances_get(hwloc_topology_t topology,
@@ -140,6 +142,8 @@ hwloc_distances_get(hwloc_topology_t topology,
140142
/** \brief Retrieve distance matrices for object at a specific depth in the topology.
141143
*
142144
* Identical to hwloc_distances_get() with the additional \p depth filter.
145+
*
146+
* \return 0 on success, -1 on error.
143147
*/
144148
HWLOC_DECLSPEC int
145149
hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth,
@@ -149,6 +153,8 @@ hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth,
149153
/** \brief Retrieve distance matrices for object of a specific type.
150154
*
151155
* Identical to hwloc_distances_get() with the additional \p type filter.
156+
*
157+
* \return 0 on success, -1 on error.
152158
*/
153159
HWLOC_DECLSPEC int
154160
hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type,
@@ -162,6 +168,8 @@ hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type,
162168
* The name of the most common structure is "NUMALatency".
163169
* Others include "XGMIBandwidth", "XGMIHops", "XeLinkBandwidth",
164170
* and "NVLinkBandwidth".
171+
*
172+
* \return 0 on success, -1 on error.
165173
*/
166174
HWLOC_DECLSPEC int
167175
hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name,
@@ -171,7 +179,12 @@ hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name,
171179
/** \brief Get a description of what a distances structure contains.
172180
*
173181
* For instance "NUMALatency" for hardware-provided NUMA distances (ACPI SLIT),
174-
* or NULL if unknown.
182+
* or \c NULL if unknown.
183+
*
184+
* \return the constant string with the name of the distance structure.
185+
*
186+
* \note The returned name should not be freed by the caller,
187+
* it belongs to the hwloc library.
175188
*/
176189
HWLOC_DECLSPEC const char *
177190
hwloc_distances_get_name(hwloc_topology_t topology, struct hwloc_distances_s *distances);
@@ -252,6 +265,8 @@ enum hwloc_distances_transform_e {
252265
*
253266
* \p flags must be \c 0 for now.
254267
*
268+
* \return 0 on success, -1 on error for instance if flags are invalid.
269+
*
255270
* \note Objects in distances array \p objs may be directly modified
256271
* in place without using hwloc_distances_transform().
257272
* One may use hwloc_get_obj_with_same_locality() to easily convert
@@ -272,6 +287,7 @@ HWLOC_DECLSPEC int hwloc_distances_transform(hwloc_topology_t topology, struct h
272287

273288
/** \brief Find the index of an object in a distances structure.
274289
*
290+
* \return the index of the object in the distances structure if any.
275291
* \return -1 if object \p obj is not involved in structure \p distances.
276292
*/
277293
static __hwloc_inline int
@@ -289,6 +305,7 @@ hwloc_distances_obj_index(struct hwloc_distances_s *distances, hwloc_obj_t obj)
289305
* The distance from \p obj1 to \p obj2 is stored in the value pointed by
290306
* \p value1to2 and reciprocally.
291307
*
308+
* \return 0 on success.
292309
* \return -1 if object \p obj1 or \p obj2 is not involved in structure \p distances.
293310
*/
294311
static __hwloc_inline int
@@ -374,8 +391,8 @@ hwloc_distances_add_create(hwloc_topology_t topology,
374391
*
375392
* \p flags must be \c 0 for now.
376393
*
377-
* \return \c 0 on success.
378-
* \return \c -1 on error.
394+
* \return 0 on success.
395+
* \return -1 on error.
379396
*/
380397
HWLOC_DECLSPEC int hwloc_distances_add_values(hwloc_topology_t topology,
381398
hwloc_distances_add_handle_t handle,
@@ -411,8 +428,8 @@ enum hwloc_distances_add_flag_e {
411428
*
412429
* On error, the temporary distances structure and its content are destroyed.
413430
*
414-
* \return \c 0 on success.
415-
* \return \c -1 on error.
431+
* \return 0 on success.
432+
* \return -1 on error.
416433
*/
417434
HWLOC_DECLSPEC int hwloc_distances_add_commit(hwloc_topology_t topology,
418435
hwloc_distances_add_handle_t handle,
@@ -433,18 +450,24 @@ HWLOC_DECLSPEC int hwloc_distances_add_commit(hwloc_topology_t topology,
433450
*
434451
* If these distances were used to group objects, these additional
435452
* Group objects are not removed from the topology.
453+
*
454+
* \return 0 on success, -1 on error.
436455
*/
437456
HWLOC_DECLSPEC int hwloc_distances_remove(hwloc_topology_t topology);
438457

439458
/** \brief Remove distance matrices for objects at a specific depth in the topology.
440459
*
441460
* Identical to hwloc_distances_remove() but only applies to one level of the topology.
461+
*
462+
* \return 0 on success, -1 on error.
442463
*/
443464
HWLOC_DECLSPEC int hwloc_distances_remove_by_depth(hwloc_topology_t topology, int depth);
444465

445466
/** \brief Remove distance matrices for objects of a specific type in the topology.
446467
*
447468
* Identical to hwloc_distances_remove() but only applies to one level of the topology.
469+
*
470+
* \return 0 on success, -1 on error.
448471
*/
449472
static __hwloc_inline int
450473
hwloc_distances_remove_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
@@ -458,6 +481,8 @@ hwloc_distances_remove_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
458481
/** \brief Release and remove the given distance matrice from the topology.
459482
*
460483
* This function includes a call to hwloc_distances_release().
484+
*
485+
* \return 0 on success, -1 on error.
461486
*/
462487
HWLOC_DECLSPEC int hwloc_distances_release_remove(hwloc_topology_t topology, struct hwloc_distances_s *distances);
463488

0 commit comments

Comments
 (0)