Changeset 0c43130 in rtems
- Timestamp:
- 01/11/17 10:03:24 (6 years ago)
- Branches:
- 5, master
- Children:
- b7f1fc3b
- Parents:
- fa9f964f
- git-author:
- Sebastian Huber <sebastian.huber@…> (01/11/17 10:03:24)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (01/12/17 06:44:36)
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libcsupport/Makefile.am
rfa9f964f r0c43130 39 39 src/assocptrbyremote.c src/assocremotebylocalbitfield.c \ 40 40 src/assocremotebylocal.c src/assocremotebyname.c 41 ASSOCIATION_C_FILES += src/assoc32tostring.c 41 42 42 43 BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \ -
cpukit/libcsupport/include/rtems/assoc.h
rfa9f964f r0c43130 17 17 /**@{*/ 18 18 19 #include <stdint.h> /* uint32_t */ 19 #include <stddef.h> 20 #include <stdint.h> 20 21 21 22 #ifdef __cplusplus … … 151 152 #endif 152 153 154 typedef struct { 155 uint32_t bits; 156 const char *name; 157 } rtems_assoc_32_pair; 158 159 /** 160 * @brief Converts the specified value into a text representation. 161 * 162 * @param[in] value The value to convert. 163 * @param[in] buffer The buffer for the text representation. 164 * @param[in] buffer_size The buffer size in characters. 165 * @param[in] pairs Names for particular bits. 166 * @param[in] pair_count Count of pairs. 167 * @param[in] separator Separator between individual names. 168 * @param[in] fallback Fallback value in case no bits contained in the pairs 169 * are set in the value. 170 * 171 * @retval The length of the text representation. May be greater than the 172 * buffer size if truncation occurred. 173 */ 174 size_t rtems_assoc_32_to_string( 175 uint32_t value, 176 char *buffer, 177 size_t buffer_size, 178 const rtems_assoc_32_pair *pairs, 179 size_t pair_count, 180 const char *separator, 181 const char *fallback 182 ); 183 153 184 #ifdef __cplusplus 154 185 } -
testsuites/sptests/spassoc01/init.c
rfa9f964f r0c43130 62 62 } 63 63 64 static void test_assoc_32_to_string( void ) 65 { 66 static const rtems_assoc_32_pair pairs[] = { 67 { 1, "A" }, 68 { 2, "LOOOOONG" }, 69 { 4, "C" } 70 }; 71 char buf[4]; 72 size_t len; 73 74 len = rtems_assoc_32_to_string( 75 0, 76 buf, 77 sizeof( buf ), 78 pairs, 79 RTEMS_ARRAY_SIZE( pairs ), 80 ":", 81 "D" 82 ); 83 rtems_test_assert( len == 1 ); 84 rtems_test_assert( strcmp( buf, "D" ) == 0 ); 85 86 len = rtems_assoc_32_to_string( 87 1, 88 buf, 89 sizeof( buf ), 90 pairs, 91 RTEMS_ARRAY_SIZE( pairs ), 92 ":", 93 "D" 94 ); 95 rtems_test_assert( len == 1 ); 96 rtems_test_assert( strcmp( buf, "A" ) == 0 ); 97 98 len = rtems_assoc_32_to_string( 99 5, 100 buf, 101 sizeof( buf ), 102 pairs, 103 RTEMS_ARRAY_SIZE( pairs ), 104 ":", 105 "D" 106 ); 107 rtems_test_assert( len == 3 ); 108 rtems_test_assert( strcmp( buf, "A:C" ) == 0 ); 109 110 len = rtems_assoc_32_to_string( 111 7, 112 buf, 113 sizeof( buf ), 114 pairs, 115 RTEMS_ARRAY_SIZE( pairs ), 116 ":", 117 "D" 118 ); 119 rtems_test_assert( len == 12 ); 120 rtems_test_assert( strcmp( buf, "A:L" ) == 0 ); 121 } 122 64 123 rtems_task Init( 65 124 rtems_task_argument argument … … 218 277 free( name ); 219 278 279 test_assoc_32_to_string(); 280 220 281 TEST_END(); 221 282
Note: See TracChangeset
for help on using the changeset viewer.