diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-11 11:03:24 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-12 07:44:36 +0100 |
commit | 0c431303cc7f0e91c70e06126353072e9a9bdb05 (patch) | |
tree | 2f08e6704668b961f81baa2e554b2e1b1ead2459 /cpukit/libcsupport/include | |
parent | score: Remove unused _States_Is_*() (diff) | |
download | rtems-0c431303cc7f0e91c70e06126353072e9a9bdb05.tar.bz2 |
Add rtems_assoc_32_to_string()
Diffstat (limited to 'cpukit/libcsupport/include')
-rw-r--r-- | cpukit/libcsupport/include/rtems/assoc.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/cpukit/libcsupport/include/rtems/assoc.h b/cpukit/libcsupport/include/rtems/assoc.h index c4933159e0..9f65ba60a4 100644 --- a/cpukit/libcsupport/include/rtems/assoc.h +++ b/cpukit/libcsupport/include/rtems/assoc.h @@ -16,7 +16,8 @@ */ /**@{*/ -#include <stdint.h> /* uint32_t */ +#include <stddef.h> +#include <stdint.h> #ifdef __cplusplus extern "C" { @@ -150,6 +151,36 @@ const char *rtems_assoc_name_bad( ); #endif +typedef struct { + uint32_t bits; + const char *name; +} rtems_assoc_32_pair; + +/** + * @brief Converts the specified value into a text representation. + * + * @param[in] value The value to convert. + * @param[in] buffer The buffer for the text representation. + * @param[in] buffer_size The buffer size in characters. + * @param[in] pairs Names for particular bits. + * @param[in] pair_count Count of pairs. + * @param[in] separator Separator between individual names. + * @param[in] fallback Fallback value in case no bits contained in the pairs + * are set in the value. + * + * @retval The length of the text representation. May be greater than the + * buffer size if truncation occurred. + */ +size_t rtems_assoc_32_to_string( + uint32_t value, + char *buffer, + size_t buffer_size, + const rtems_assoc_32_pair *pairs, + size_t pair_count, + const char *separator, + const char *fallback +); + #ifdef __cplusplus } #endif |