Changeset 3bacee1 in mainline for uspace/lib/c/generic
- Timestamp:
- 2018-04-12T16:27:17Z (8 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/generic
- Files:
-
- 7 edited
-
async.c (modified) (2 diffs)
-
double_to_str.c (modified) (16 diffs)
-
elf/elf_mod.c (modified) (5 diffs)
-
getopt.c (modified) (8 diffs)
-
io/io.c (modified) (1 diff)
-
io/output.c (modified) (1 diff)
-
tls.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
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 fp_num_t *low, fp_num_t *val_dist)149 fp_num_t *low, fp_num_t *val_dist) 150 150 { 151 151 /* … … 181 181 182 182 val_dist->significand = 183 val_dist->significand << (val_dist->exponent - high->exponent);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 fp_num_t *bounds_delta, fp_num_t *val_dist, int *scale)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 uint64_t digit_val_diff, char *buf, int len)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 fp_num_t val_dist, int scale, char *buf, size_t buf_size, int *dec_exponent)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 (uint64_t)div << (-one.exponent), buf, len);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 one.significand, buf, len);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 int *dec_exponent)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 &delta, &val_dist, &scale);526 &delta, &val_dist, &scale); 527 527 528 528 int len = gen_dec_digits(scaled_upper_bound, delta, val_dist, scale, 529 buf, buf_size, dec_exponent);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 int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)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 (frac_d_cnt >= 0) ? (kappa - scale + frac_d_cnt) : INT_MAX;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 int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)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 buf, buf_size, dec_exponent);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 #if 0275 #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 #endif281 #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 (void *)elf->info->dynamic);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 entry->p_memsz);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 * const *nargv, const char *options)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 (char **)nargv);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 * const *nargv, const char *options,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 current_argv);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 current_argv);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 * tls_alloc_variant_2(void **data, size_t size)156 tcb_t *tls_alloc_variant_2(void **data, size_t size) 157 157 { 158 158 tcb_t *tcb;
Note:
See TracChangeset
for help on using the changeset viewer.
