Changeset 3bacee1 in mainline for uspace/lib/c
- Timestamp:
- 2018-04-12T16:27:17Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cf22f9
- Parents:
- 76d0981d
- git-author:
- Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
- Location:
- uspace/lib/c
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/arm32/include/libarch/tls.h
r76d0981d r3bacee1 63 63 tls += sizeof(tcb_t) + ARM_TP_OFFSET; 64 64 asm volatile ( 65 66 67 65 "mov r9, %0" 66 : 67 : "r" (tls) 68 68 ); 69 69 } … … 79 79 void *ret; 80 80 asm volatile ( 81 82 : "=r"(ret)81 "mov %0, r9" 82 : "=r" (ret) 83 83 ); 84 84 return (tcb_t *) (ret - ARM_TP_OFFSET - sizeof(tcb_t)); -
uspace/lib/c/arch/ia32/include/libarch/tls.h
r76d0981d r3bacee1 51 51 } 52 52 53 static inline tcb_t * 53 static inline tcb_t *__tcb_get(void) 54 54 { 55 55 void *retval; -
uspace/lib/c/arch/ia64/include/libarch/elf_linux.h
r76d0981d r3bacee1 47 47 { 48 48 /* TODO */ 49 (void) istate; (void) elf_regs; 49 (void) istate; 50 (void) elf_regs; 50 51 } 51 52 -
uspace/lib/c/arch/sparc64/include/libarch/tls.h
r76d0981d r3bacee1 51 51 } 52 52 53 static inline tcb_t * 53 static inline tcb_t *__tcb_get(void) 54 54 { 55 55 void *retval; -
uspace/lib/c/generic/async.c
r76d0981d r3bacee1 943 943 link_t *tmp = timeout_list.head.next; 944 944 while (tmp != &timeout_list.head) { 945 awaiter_t *cur 946 =list_get_instance(tmp, awaiter_t, to_event.link);945 awaiter_t *cur = 946 list_get_instance(tmp, awaiter_t, to_event.link); 947 947 948 948 if (tv_gteq(&cur->to_event.expires, &wd->to_event.expires)) … … 1255 1255 */ 1256 1256 futex_down(&async_futex); 1257 if ((usecs) && (conn->wdata.to_event.occurred) 1258 &&(list_empty(&conn->msg_queue))) {1257 if ((usecs) && (conn->wdata.to_event.occurred) && 1258 (list_empty(&conn->msg_queue))) { 1259 1259 /* If we timed out -> exit */ 1260 1260 futex_up(&async_futex); -
uspace/lib/c/generic/double_to_str.c
r76d0981d r3bacee1 56 56 static bool is_normalized(fp_num_t num) 57 57 { 58 assert(8 *sizeof(num.significand) == significand_width);58 assert(8 * sizeof(num.significand) == significand_width); 59 59 60 60 /* Normalized == most significant bit of the significand is set. */ … … 147 147 /** Returns the interval [low, high] of numbers that convert to binary val. */ 148 148 static void get_normalized_bounds(ieee_double_t val, fp_num_t *high, 149 149 fp_num_t *low, fp_num_t *val_dist) 150 150 { 151 151 /* … … 181 181 182 182 val_dist->significand = 183 183 val_dist->significand << (val_dist->exponent - high->exponent); 184 184 val_dist->exponent = high->exponent; 185 185 } … … 198 198 */ 199 199 static void calc_scaled_bounds(ieee_double_t val, fp_num_t *scaled_upper_bound, 200 200 fp_num_t *bounds_delta, fp_num_t *val_dist, int *scale) 201 201 { 202 202 fp_num_t upper_bound, lower_bound; … … 251 251 /** Rounds the last digit of buf so that it is closest to the converted number.*/ 252 252 static void round_last_digit(uint64_t rest, uint64_t w_dist, uint64_t delta, 253 253 uint64_t digit_val_diff, char *buf, int len) 254 254 { 255 255 /* … … 277 277 bool next_in_val_rng = cur_greater_w && (rest + digit_val_diff < delta); 278 278 /* Rounding down by one would bring buf closer to the processed number. */ 279 bool next_closer = next_in_val_rng 280 &&(rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);279 bool next_closer = next_in_val_rng && 280 (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest); 281 281 282 282 /* Of the shortest strings pick the one that is closest to the actual … … 291 291 cur_greater_w = rest < w_dist; 292 292 next_in_val_rng = cur_greater_w && (rest + digit_val_diff < delta); 293 next_closer = next_in_val_rng 294 &&(rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);293 next_closer = next_in_val_rng && 294 (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest); 295 295 } 296 296 } … … 326 326 */ 327 327 static int gen_dec_digits(fp_num_t scaled_upper, fp_num_t delta, 328 328 fp_num_t val_dist, int scale, char *buf, size_t buf_size, int *dec_exponent) 329 329 { 330 330 /* … … 411 411 /* Of the shortest representations choose the numerically closest. */ 412 412 round_last_digit(remainder, val_dist.significand, delta.significand, 413 413 (uint64_t)div << (-one.exponent), buf, len); 414 414 return len; 415 415 } … … 457 457 /* Of the shortest representations choose the numerically closest one. */ 458 458 round_last_digit(frac_part, val_dist.significand, delta.significand, 459 459 one.significand, buf, len); 460 460 461 461 return len; … … 504 504 */ 505 505 int double_to_short_str(ieee_double_t ieee_val, char *buf, size_t buf_size, 506 506 int *dec_exponent) 507 507 { 508 508 /* The whole computation assumes 64bit significand. */ … … 524 524 525 525 calc_scaled_bounds(ieee_val, &scaled_upper_bound, 526 526 &delta, &val_dist, &scale); 527 527 528 528 int len = gen_dec_digits(scaled_upper_bound, delta, val_dist, scale, 529 529 buf, buf_size, dec_exponent); 530 530 531 531 assert(len <= MAX_DOUBLE_STR_LEN); … … 554 554 */ 555 555 static int gen_fixed_dec_digits(fp_num_t w_scaled, int scale, int signif_d_cnt, 556 556 int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent) 557 557 { 558 558 /* We'll produce at least one digit and a null terminator. */ … … 608 608 int rem_signif_d_cnt = signif_d_cnt; 609 609 int rem_frac_d_cnt = 610 610 (frac_d_cnt >= 0) ? (kappa - scale + frac_d_cnt) : INT_MAX; 611 611 612 612 /* Produce decimal digits for the integral part of w_scaled. */ … … 752 752 */ 753 753 int double_to_fixed_str(ieee_double_t ieee_val, int signif_d_cnt, 754 754 int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent) 755 755 { 756 756 /* The whole computation assumes 64bit significand. */ … … 780 780 /* Produce decimal digits from the scaled number. */ 781 781 int len = gen_fixed_dec_digits(w_scaled, scale, signif_d_cnt, frac_d_cnt, 782 782 buf, buf_size, dec_exponent); 783 783 784 784 assert(len <= MAX_DOUBLE_STR_LEN); -
uspace/lib/c/generic/elf/elf_mod.c
r76d0981d r3bacee1 273 273 // FIXME: This actually won't work, because the text segment is 274 274 // not loaded yet. 275 275 #if 0 276 276 if (elf->info->interp[entry->p_filesz - 1] != '\0') { 277 277 DPRINTF("Unterminated ELF interp string.\n"); … … 279 279 } 280 280 DPRINTF("interpreter: \"%s\"\n", elf->info->interp); 281 281 #endif 282 282 break; 283 283 case PT_DYNAMIC: … … 286 286 (void *)((uint8_t *)entry->p_vaddr + elf->bias); 287 287 DPRINTF("dynamic section found at %p\n", 288 288 (void *)elf->info->dynamic); 289 289 break; 290 290 case 0x70000000: … … 334 334 335 335 DPRINTF("Load segment at addr %p, size 0x%zx\n", (void *) seg_addr, 336 336 entry->p_memsz); 337 337 338 338 if (entry->p_align > 1) { … … 394 394 * need to set the right access mode and ensure SMC coherence. 395 395 */ 396 if ((elf->flags & ELDF_RW) != 0) return EE_OK; 396 if ((elf->flags & ELDF_RW) != 0) 397 return EE_OK; 397 398 398 399 // printf("set area flags to %d\n", flags); -
uspace/lib/c/generic/getopt.c
r76d0981d r3bacee1 132 132 133 133 for (i = 0; i < ncycle; i++) { 134 cstart = panonopt_end +i;134 cstart = panonopt_end + i; 135 135 pos = cstart; 136 136 for (j = 0; j < cyclelen; j++) { … … 181 181 optind, nargv); 182 182 optind -= nonopt_end - nonopt_start; 183 } 184 else if (nonopt_start != -1) { 183 } else if (nonopt_start != -1) { 185 184 /* 186 185 * If we skipped non-options, set optind … … 192 191 return -1; 193 192 } 194 if ((*(place = nargv[optind]) != '-') 195 ||(place[1] == '\0')) { /* found non-option */193 if ((*(place = nargv[optind]) != '-') || 194 (place[1] == '\0')) { /* found non-option */ 196 195 place = EMSG; 197 196 if (IN_ORDER) { … … 289 288 * Parse argc/argv argument vector. 290 289 */ 291 int getopt(int nargc, char * 290 int getopt(int nargc, char *const *nargv, const char *options) 292 291 { 293 292 int retval; … … 305 304 if (nonopt_end != -1) { 306 305 permute_args(nonopt_start, nonopt_end, optind, 307 306 (char **)nargv); 308 307 optind -= nonopt_end - nonopt_start; 309 308 } … … 318 317 * Parse argc/argv argument vector. 319 318 */ 320 int getopt_long(int nargc, char * 319 int getopt_long(int nargc, char *const *nargv, const char *options, 321 320 const struct option *long_options, int *idx) 322 321 { … … 389 388 if (PRINT_ERROR) 390 389 printf(ambig, (int)current_argv_len, 391 390 current_argv); 392 391 optopt = 0; 393 392 return BADCH; 394 393 } 395 394 if (match != -1) { /* option found */ 396 if (long_options[match].has_arg == no_argument397 &&has_equal) {395 if (long_options[match].has_arg == no_argument && 396 has_equal) { 398 397 if (PRINT_ERROR) 399 398 printf(noarg, (int)current_argv_len, 400 399 current_argv); 401 400 /* 402 401 * XXX: GNU sets optopt to val regardless of … … 422 421 } 423 422 } 424 if ((long_options[match].has_arg == required_argument) 425 &&(optarg == NULL)) {423 if ((long_options[match].has_arg == required_argument) && 424 (optarg == NULL)) { 426 425 /* 427 426 * Missing argument; leading ':' -
uspace/lib/c/generic/io/io.c
r76d0981d r3bacee1 388 388 int rc = _fclose_nofree(stream); 389 389 390 if ((stream != &stdin_null) 391 && (stream != &stdout_kio)392 &&(stream != &stderr_kio))390 if ((stream != &stdin_null) && 391 (stream != &stdout_kio) && 392 (stream != &stderr_kio)) 393 393 free(stream); 394 394 -
uspace/lib/c/generic/io/output.c
r76d0981d r3bacee1 89 89 ipc_call_t answer; 90 90 aid_t req = async_send_0(exch, OUTPUT_FRONTBUF_CREATE, &answer); 91 errno_t rc = async_share_out_start(exch, frontbuf, AS_AREA_READ 92 |AS_AREA_WRITE | AS_AREA_CACHEABLE);91 errno_t rc = async_share_out_start(exch, frontbuf, AS_AREA_READ | 92 AS_AREA_WRITE | AS_AREA_CACHEABLE); 93 93 94 94 async_exchange_end(exch); -
uspace/lib/c/generic/tls.c
r76d0981d r3bacee1 154 154 * @return Pointer to TCB structure. 155 155 */ 156 tcb_t * 156 tcb_t *tls_alloc_variant_2(void **data, size_t size) 157 157 { 158 158 tcb_t *tcb; -
uspace/lib/c/include/adt/hash.h
r76d0981d r3bacee1 106 106 * http://burtleburtle.net/bob/c/lookup3.c 107 107 */ 108 seed ^= hash + 0x9e3779b9 109 +((seed << 5) | (seed >> (sizeof(size_t) * 8 - 5)));108 seed ^= hash + 0x9e3779b9 + 109 ((seed << 5) | (seed >> (sizeof(size_t) * 8 - 5))); 110 110 return seed; 111 111 } -
uspace/lib/c/include/io/charfield.h
r76d0981d r3bacee1 91 91 return (a1.val.style == a2.val.style); 92 92 case CHAR_ATTR_INDEX: 93 return (a1.val.index.bgcolor == a2.val.index.bgcolor) 94 && (a1.val.index.fgcolor == a2.val.index.fgcolor)95 &&(a1.val.index.attr == a2.val.index.attr);93 return (a1.val.index.bgcolor == a2.val.index.bgcolor) && 94 (a1.val.index.fgcolor == a2.val.index.fgcolor) && 95 (a1.val.index.attr == a2.val.index.attr); 96 96 case CHAR_ATTR_RGB: 97 return (a1.val.rgb.bgcolor == a2.val.rgb.bgcolor) 98 &&(a1.val.rgb.fgcolor == a2.val.rgb.fgcolor);97 return (a1.val.rgb.bgcolor == a2.val.rgb.bgcolor) && 98 (a1.val.rgb.fgcolor == a2.val.rgb.fgcolor); 99 99 } 100 100 -
uspace/lib/c/test/io/table.c
r76d0981d r3bacee1 34 34 PCUT_TEST_SUITE(table); 35 35 36 PCUT_TEST(smoke) { 36 PCUT_TEST(smoke) 37 { 37 38 table_t *table; 38 39 errno_t rc; -
uspace/lib/c/test/odict.c
r76d0981d r3bacee1 226 226 PCUT_ASSERT_EQUALS(true, odict_empty(&odict)); 227 227 228 v = 1; ep = NULL; 228 v = 1; 229 ep = NULL; 229 230 for (i = 0; i < test_seq_len; i++) { 230 231 e = calloc(1, sizeof(test_entry_t)); -
uspace/lib/c/test/sprintf.c
r76d0981d r3bacee1 48 48 static char buffer[BUFFER_SIZE]; 49 49 50 PCUT_TEST_BEFORE { 50 PCUT_TEST_BEFORE 51 { 51 52 memset(buffer, 0, BUFFER_SIZE); 52 53 } -
uspace/lib/c/test/str.c
r76d0981d r3bacee1 44 44 static char buffer[BUFFER_SIZE]; 45 45 46 PCUT_TEST_BEFORE { 46 PCUT_TEST_BEFORE 47 { 47 48 memset(buffer, 0, BUFFER_SIZE); 48 49 } 49 50 50 51 51 PCUT_TEST(rtrim) { 52 PCUT_TEST(rtrim) 53 { 52 54 SET_BUFFER("foobar"); 53 55 str_rtrim(buffer, ' '); … … 67 69 } 68 70 69 PCUT_TEST(ltrim) { 71 PCUT_TEST(ltrim) 72 { 70 73 SET_BUFFER("foobar"); 71 74 str_ltrim(buffer, ' ');
Note:
See TracChangeset
for help on using the changeset viewer.