Skip to content

Commit 5142093

Browse files
committed
hwloc/bitmap.h: improve doc about return values
Refs #578 And fix the documentation of hwloc_bitmap_last_unset(). Signed-off-by: Brice Goglin <[email protected]>
1 parent 469b39b commit 5142093

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

include/hwloc/bitmap.h

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2009 CNRS
3-
* Copyright © 2009-2022 Inria. All rights reserved.
3+
* Copyright © 2009-2023 Inria. All rights reserved.
44
* Copyright © 2009-2012 Université Bordeaux
55
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
66
* See COPYING in top-level directory.
@@ -83,7 +83,13 @@ typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
8383
*/
8484
HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc(void) __hwloc_attribute_malloc;
8585

86-
/** \brief Allocate a new full bitmap. */
86+
/** \brief Allocate a new full bitmap.
87+
*
88+
* \returns A valid bitmap or \c NULL.
89+
*
90+
* The bitmap should be freed by a corresponding call to
91+
* hwloc_bitmap_free().
92+
*/
8793
HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc_full(void) __hwloc_attribute_malloc;
8894

8995
/** \brief Free bitmap \p bitmap.
@@ -119,11 +125,13 @@ HWLOC_DECLSPEC int hwloc_bitmap_snprintf(char * __hwloc_restrict buf, size_t buf
119125

120126
/** \brief Stringify a bitmap into a newly allocated string.
121127
*
122-
* \return -1 on error.
128+
* \return 0 on success, -1 on error.
123129
*/
124130
HWLOC_DECLSPEC int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
125131

126132
/** \brief Parse a bitmap string and stores it in bitmap \p bitmap.
133+
*
134+
* \return 0 on success, -1 on error.
127135
*/
128136
HWLOC_DECLSPEC int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
129137

@@ -144,11 +152,13 @@ HWLOC_DECLSPEC int hwloc_bitmap_list_snprintf(char * __hwloc_restrict buf, size_
144152

145153
/** \brief Stringify a bitmap into a newly allocated list string.
146154
*
147-
* \return -1 on error.
155+
* \return 0 on success, -1 on error.
148156
*/
149157
HWLOC_DECLSPEC int hwloc_bitmap_list_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
150158

151159
/** \brief Parse a list string and stores it in bitmap \p bitmap.
160+
*
161+
* \return 0 on success, -1 on error.
152162
*/
153163
HWLOC_DECLSPEC int hwloc_bitmap_list_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
154164

@@ -168,11 +178,13 @@ HWLOC_DECLSPEC int hwloc_bitmap_taskset_snprintf(char * __hwloc_restrict buf, si
168178

169179
/** \brief Stringify a bitmap into a newly allocated taskset-specific string.
170180
*
171-
* \return -1 on error.
181+
* \return 0 on success, -1 on error.
172182
*/
173183
HWLOC_DECLSPEC int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
174184

175185
/** \brief Parse a taskset-specific bitmap string and stores it in bitmap \p bitmap.
186+
*
187+
* \return 0 on success, -1 on error.
176188
*/
177189
HWLOC_DECLSPEC int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
178190

@@ -279,6 +291,7 @@ HWLOC_DECLSPEC int hwloc_bitmap_to_ulongs(hwloc_const_bitmap_t bitmap, unsigned
279291
* When called on the output of hwloc_topology_get_topology_cpuset(),
280292
* the returned number is large enough for all cpusets of the topology.
281293
*
294+
* \return the number of unsigned longs required.
282295
* \return -1 if \p bitmap is infinite.
283296
*/
284297
HWLOC_DECLSPEC int hwloc_bitmap_nr_ulongs(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
@@ -305,50 +318,53 @@ HWLOC_DECLSPEC int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) __hwloc_attr
305318

306319
/** \brief Compute the first index (least significant bit) in bitmap \p bitmap
307320
*
308-
* \return -1 if no index is set in \p bitmap.
321+
* \return the first index set in \p bitmap.
322+
* \return -1 if \p bitmap is empty.
309323
*/
310324
HWLOC_DECLSPEC int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
311325

312326
/** \brief Compute the next index in bitmap \p bitmap which is after index \p prev
313327
*
314-
* If \p prev is -1, the first index is returned.
315-
*
328+
* \return the first index set in \p bitmap if \p prev is \c -1.
329+
* \return the next index set in \p bitmap if \p prev is not \c -1.
316330
* \return -1 if no index with higher index is set in \p bitmap.
317331
*/
318332
HWLOC_DECLSPEC int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure;
319333

320334
/** \brief Compute the last index (most significant bit) in bitmap \p bitmap
321335
*
322-
* \return -1 if no index is set in \p bitmap, or if \p bitmap is infinitely set.
336+
* \return the last index set in \p bitmap.
337+
* \return -1 if \p bitmap is empty, or if \p bitmap is infinitely set.
323338
*/
324339
HWLOC_DECLSPEC int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
325340

326341
/** \brief Compute the "weight" of bitmap \p bitmap (i.e., number of
327342
* indexes that are in the bitmap).
328343
*
329344
* \return the number of indexes that are in the bitmap.
330-
*
331345
* \return -1 if \p bitmap is infinitely set.
332346
*/
333347
HWLOC_DECLSPEC int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
334348

335349
/** \brief Compute the first unset index (least significant bit) in bitmap \p bitmap
336350
*
337-
* \return -1 if no index is unset in \p bitmap.
351+
* \return the first unset index in \p bitmap.
352+
* \return -1 if \p bitmap is full.
338353
*/
339354
HWLOC_DECLSPEC int hwloc_bitmap_first_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
340355

341356
/** \brief Compute the next unset index in bitmap \p bitmap which is after index \p prev
342357
*
343-
* If \p prev is -1, the first unset index is returned.
344-
*
358+
* \return the first index unset in \p bitmap if \p prev is \c -1.
359+
* \return the next index unset in \p bitmap if \p prev is not \c -1.
345360
* \return -1 if no index with higher index is unset in \p bitmap.
346361
*/
347362
HWLOC_DECLSPEC int hwloc_bitmap_next_unset(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure;
348363

349364
/** \brief Compute the last unset index (most significant bit) in bitmap \p bitmap
350365
*
351-
* \return -1 if no index is unset in \p bitmap, or if \p bitmap is infinitely set.
366+
* \return the last index unset in \p bitmap.
367+
* \return -1 if \p bitmap is full, or if \p bitmap is not infinitely set.
352368
*/
353369
HWLOC_DECLSPEC int hwloc_bitmap_last_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
354370

0 commit comments

Comments
 (0)