aboutsummaryrefslogtreecommitdiff
path: root/include/odp
diff options
context:
space:
mode:
authorOla Liljedahl <ola.liljedahl@linaro.org>2015-02-04 22:07:23 +0100
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-02-05 16:19:55 +0300
commit9208c4039548cf38c3b204094c1781b7e71f9ce3 (patch)
tree4f944b3029f1096e919381a7392f584cc448cfcd /include/odp
parent73d8c49472a866f761a2d6615d309ff4c129655d (diff)
api: odp_cpumask.h: odp_cpumask_to_str() return chars written or error
Add define ODP_CPUMASK_STR_SIZE for minimum output buffer size for odp_cpumask_to_str(). odp_cpumask_to_str() takes output buffer size as input and returns number of chars written (on success), <0 on failure. Updated the implementation. Updated all usages in example and test programs. Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org> Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'include/odp')
-rw-r--r--include/odp/api/cpumask.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/include/odp/api/cpumask.h b/include/odp/api/cpumask.h
index a78d83ccb..7d782c700 100644
--- a/include/odp/api/cpumask.h
+++ b/include/odp/api/cpumask.h
@@ -18,12 +18,20 @@
extern "C" {
#endif
+#include <sys/types.h>
+#include <odp/config.h>
+
/** @addtogroup odp_scheduler
* CPU mask operations.
* @{
*/
- /**
+/**
+ * @def ODP_CPUMASK_STR_SIZE
+ * Minimum size of output buffer for odp_cpumask_to_str()
+ */
+
+/**
* Add CPU mask bits from a string
*
* @param mask CPU mask to modify
@@ -33,13 +41,16 @@ extern "C" {
void odp_cpumask_from_str(odp_cpumask_t *mask, const char *str);
/**
- * Write CPU mask as a string of hexadecimal digits
+ * Format CPU mask as a string of hexadecimal digits
+ *
+ * @param mask CPU mask to format
+ * @param[out] str Output buffer (use ODP_CPUMASK_STR_SIZE)
+ * @param size Size of output buffer
*
- * @param mask CPU mask
- * @param str String for output
- * @param len Size of string length (incl. ending zero)
+ * @return number of characters written (including terminating null char)
+ * @retval <0 on failure (buffer too small)
*/
-void odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int len);
+ssize_t odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, ssize_t size);
/**
* Clear entire CPU mask