Changes in / [4805495:d5a89a3] in mainline
- Location:
- uspace
- Files:
-
- 8 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/df/df.c
r4805495 rd5a89a3 70 70 71 71 /* Parse command-line options */ 72 while ((optres = getopt(argc, argv, " :ubh")) != -1) {72 while ((optres = getopt(argc, argv, "ubh")) != -1) { 73 73 switch (optres) { 74 74 case 'h': … … 78 78 case 'b': 79 79 display_blocks = true; 80 break;81 82 case ':':83 fprintf(stderr, "Option -%c requires an operand\n",84 optopt);85 errflg++;86 80 break; 87 81 -
uspace/lib/c/Makefile
r4805495 rd5a89a3 190 190 TEST_SOURCES = \ 191 191 test/adt/circ_buf.c \ 192 test/adt/odict.c \ 192 193 test/casting.c \ 193 194 test/fibril/timer.c \ … … 197 198 test/io/table.c \ 198 199 test/stdio/scanf.c \ 199 test/odict.c \200 200 test/perf.c \ 201 201 test/perm.c \ … … 205 205 test/stdlib.c \ 206 206 test/str.c \ 207 test/string.c 207 test/string.c \ 208 test/cap.c \ 209 test/gsort.c \ 210 test/ieee_double.c \ 211 test/double_to_str.c \ 212 test/getopt.c \ 213 test/uuid.c \ 214 test/imath.c 208 215 209 216 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/c/generic/cap.c
r4805495 rd5a89a3 160 160 161 161 /* Round the number so that we have at most @c scap_max_sdig significant digits */ 162 sdig = 1 + ilog10_u64(cap->m); /* number of significant digits */ 162 rc = ilog10_u64(cap->m, &sdig); /* number of significant digits */ 163 sdig += 1; 164 assert(rc == EOK); 163 165 if (sdig > scap_max_sdig) { 164 166 /* Number of digits to remove */ -
uspace/lib/c/generic/gsort.c
r4805495 rd5a89a3 33 33 /** 34 34 * @file 35 * @brief Sorting functions.35 * @brief Gnome Sort. 36 36 * 37 * This files contains functions implementing several sorting 38 * algorithms (e.g. quick sort and gnome sort). 37 * This file contains an implementation of gnome sort 39 38 * 40 39 */ … … 80 79 if ((i != 0) && 81 80 (cmp(INDEX(data, i, elem_size), 82 INDEX(data, i - 1, elem_size), arg) == -1)) {81 INDEX(data, i - 1, elem_size), arg) <= -1)) { 83 82 memcpy(slot, INDEX(data, i, elem_size), elem_size); 84 83 memcpy(INDEX(data, i, elem_size), INDEX(data, i - 1, elem_size), -
uspace/lib/c/generic/ieee_double.c
r4805495 rd5a89a3 92 92 if (ret.is_denormal) { 93 93 ret.pos_val.significand = raw_significand; 94 ret.pos_val.exponent = 1 - exponent_bias; 94 if (raw_significand == 0) { 95 ret.pos_val.exponent = -exponent_bias; 96 } else { 97 ret.pos_val.exponent = 1 - exponent_bias; 98 } 99 95 100 ret.is_accuracy_step = false; 96 101 } else { -
uspace/lib/c/generic/imath.c
r4805495 rd5a89a3 50 50 errno_t ipow10_u64(unsigned exp, uint64_t *res) 51 51 { 52 u nsigneda;52 uint64_t a; 53 53 uint64_t r; 54 54 … … 81 81 * 82 82 * @param v Value to compute logarithm from 83 * @param res Place to store result 84 * @return EOK on success 83 85 * @return Logarithm value 84 86 */ 85 unsigned ilog10_u64(uint64_t v)87 errno_t ilog10_u64(uint64_t v, unsigned *res) 86 88 { 89 if (v == 0) 90 return ERANGE; 91 87 92 unsigned b; 88 93 unsigned e; … … 117 122 } 118 123 119 return r; 124 *res = r; 125 return EOK; 120 126 } 121 127 -
uspace/lib/c/generic/string.c
r4805495 rd5a89a3 565 565 } 566 566 567 str cpy(dup, s);567 strncpy(dup, s, sz); 568 568 return dup; 569 569 } -
uspace/lib/c/generic/uuid.c
r4805495 rd5a89a3 39 39 #include <stddef.h> 40 40 #include <str.h> 41 #include <stdio.h> 41 42 42 43 /** Generate UUID. … … 64 65 65 66 /* Version 4 UUID from random or pseudo-random numbers */ 66 uuid->b[ 8] = (uuid->b[8] & ~0xc0) | 0x40;67 uuid->b[ 6] = (uuid->b[6] & 0xf0) | 0x40;68 69 r eturnEOK;67 uuid->b[6] = (uuid->b[6] & 0x4F) | 0x40; 68 uuid->b[8] = (uuid->b[8] & 0xBF) | 0xB0; 69 70 rc = EOK; 70 71 error: 71 72 rndgen_destroy(rndgen); … … 139 140 140 141 rc = str_uint64_t(str + 24, &eptr, 16, false, &node); 141 if (rc != EOK || eptr != str + 36 || *eptr != '\0')142 if (rc != EOK || eptr != str + 36) 142 143 return EINVAL; 143 144 … … 176 177 * @return EOK on success, ENOMEM if out of memory 177 178 */ 178 errno_t uuid_format(uuid_t *uuid, char **rstr) 179 { 180 return ENOTSUP; 179 errno_t uuid_format(uuid_t *uuid, char **rstr, bool uppercase) 180 { 181 size_t size = 37; 182 char *str = malloc(sizeof(char) * size); 183 if (str == NULL) 184 return ENOMEM; 185 186 const char *format = "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"; 187 if (uppercase) 188 format = "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X"; 189 190 int ret = snprintf(str, size, format, uuid->b[0], uuid->b[1], uuid->b[2], uuid->b[3], uuid->b[4], uuid->b[5], uuid->b[6], uuid->b[7], uuid->b[8], uuid->b[9], uuid->b[10], uuid->b[11], uuid->b[12], uuid->b[13], uuid->b[14], uuid->b[15]); 191 192 if (ret != 36) 193 return EINVAL; 194 195 *rstr = str; 196 return EOK; 181 197 } 182 198 -
uspace/lib/c/include/imath.h
r4805495 rd5a89a3 40 40 41 41 extern errno_t ipow10_u64(unsigned, uint64_t *); 42 extern unsigned ilog10_u64(uint64_t);42 extern errno_t ilog10_u64(uint64_t, unsigned *); 43 43 44 44 #endif -
uspace/lib/c/include/uuid.h
r4805495 rd5a89a3 38 38 #include <stdint.h> 39 39 #include <types/uuid.h> 40 #include <stdbool.h> 40 41 41 42 extern errno_t uuid_generate(uuid_t *); … … 43 44 extern void uuid_decode(uint8_t *, uuid_t *); 44 45 extern errno_t uuid_parse(const char *, uuid_t *, const char **); 45 extern errno_t uuid_format(uuid_t *, char ** );46 extern errno_t uuid_format(uuid_t *, char **, bool); 46 47 47 48 #endif -
uspace/lib/c/test/main.c
r4805495 rd5a89a3 48 48 PCUT_IMPORT(string); 49 49 PCUT_IMPORT(table); 50 PCUT_IMPORT(cap); 51 PCUT_IMPORT(gsort); 52 PCUT_IMPORT(ieee_double); 53 PCUT_IMPORT(double_to_str); 54 PCUT_IMPORT(getopt); 55 PCUT_IMPORT(uuid); 56 PCUT_IMPORT(imath); 50 57 51 58 PCUT_MAIN();
Note:
See TracChangeset
for help on using the changeset viewer.