github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/src/cmd/8l/pass.c (about) 1 // Inferno utils/8l/pass.c 2 // http://code.google.com/p/inferno-os/source/browse/utils/8l/pass.c 3 // 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) 6 // Portions Copyright © 1997-1999 Vita Nuova Limited 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) 8 // Portions Copyright © 2004,2006 Bruce Ellis 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others 11 // Portions Copyright © 2009 The Go Authors. All rights reserved. 12 // 13 // Permission is hereby granted, free of charge, to any person obtaining a copy 14 // of this software and associated documentation files (the "Software"), to deal 15 // in the Software without restriction, including without limitation the rights 16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 // copies of the Software, and to permit persons to whom the Software is 18 // furnished to do so, subject to the following conditions: 19 // 20 // The above copyright notice and this permission notice shall be included in 21 // all copies or substantial portions of the Software. 22 // 23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 // THE SOFTWARE. 30 31 // Code and data passes. 32 33 #include "l.h" 34 #include "../ld/lib.h" 35 #include "../../pkg/runtime/stack.h" 36 37 static void xfol(Prog*, Prog**); 38 39 Prog* 40 brchain(Prog *p) 41 { 42 int i; 43 44 for(i=0; i<20; i++) { 45 if(p == P || p->as != AJMP) 46 return p; 47 p = p->pcond; 48 } 49 return P; 50 } 51 52 void 53 follow(void) 54 { 55 Prog *firstp, *lastp; 56 57 if(debug['v']) 58 Bprint(&bso, "%5.2f follow\n", cputime()); 59 Bflush(&bso); 60 61 for(cursym = textp; cursym != nil; cursym = cursym->next) { 62 firstp = prg(); 63 lastp = firstp; 64 xfol(cursym->text, &lastp); 65 lastp->link = nil; 66 cursym->text = firstp->link; 67 } 68 } 69 70 static int 71 nofollow(int a) 72 { 73 switch(a) { 74 case AJMP: 75 case ARET: 76 case AIRETL: 77 case AIRETW: 78 case AUNDEF: 79 return 1; 80 } 81 return 0; 82 } 83 84 static int 85 pushpop(int a) 86 { 87 switch(a) { 88 case APUSHL: 89 case APUSHFL: 90 case APUSHW: 91 case APUSHFW: 92 case APOPL: 93 case APOPFL: 94 case APOPW: 95 case APOPFW: 96 return 1; 97 } 98 return 0; 99 } 100 101 static void 102 xfol(Prog *p, Prog **last) 103 { 104 Prog *q; 105 int i; 106 enum as a; 107 108 loop: 109 if(p == P) 110 return; 111 if(p->as == AJMP) 112 if((q = p->pcond) != P && q->as != ATEXT) { 113 /* mark instruction as done and continue layout at target of jump */ 114 p->mark = 1; 115 p = q; 116 if(p->mark == 0) 117 goto loop; 118 } 119 if(p->mark) { 120 /* 121 * p goes here, but already used it elsewhere. 122 * copy up to 4 instructions or else branch to other copy. 123 */ 124 for(i=0,q=p; i<4; i++,q=q->link) { 125 if(q == P) 126 break; 127 if(q == *last) 128 break; 129 a = q->as; 130 if(a == ANOP) { 131 i--; 132 continue; 133 } 134 if(nofollow(a) || pushpop(a)) 135 break; // NOTE(rsc): arm does goto copy 136 if(q->pcond == P || q->pcond->mark) 137 continue; 138 if(a == ACALL || a == ALOOP) 139 continue; 140 for(;;) { 141 if(p->as == ANOP) { 142 p = p->link; 143 continue; 144 } 145 q = copyp(p); 146 p = p->link; 147 q->mark = 1; 148 (*last)->link = q; 149 *last = q; 150 if(q->as != a || q->pcond == P || q->pcond->mark) 151 continue; 152 153 q->as = relinv(q->as); 154 p = q->pcond; 155 q->pcond = q->link; 156 q->link = p; 157 xfol(q->link, last); 158 p = q->link; 159 if(p->mark) 160 return; 161 goto loop; 162 } 163 } /* */ 164 q = prg(); 165 q->as = AJMP; 166 q->line = p->line; 167 q->to.type = D_BRANCH; 168 q->to.offset = p->pc; 169 q->pcond = p; 170 p = q; 171 } 172 173 /* emit p */ 174 p->mark = 1; 175 (*last)->link = p; 176 *last = p; 177 a = p->as; 178 179 /* continue loop with what comes after p */ 180 if(nofollow(a)) 181 return; 182 if(p->pcond != P && a != ACALL) { 183 /* 184 * some kind of conditional branch. 185 * recurse to follow one path. 186 * continue loop on the other. 187 */ 188 if((q = brchain(p->pcond)) != P) 189 p->pcond = q; 190 if((q = brchain(p->link)) != P) 191 p->link = q; 192 if(p->from.type == D_CONST) { 193 if(p->from.offset == 1) { 194 /* 195 * expect conditional jump to be taken. 196 * rewrite so that's the fall-through case. 197 */ 198 p->as = relinv(a); 199 q = p->link; 200 p->link = p->pcond; 201 p->pcond = q; 202 } 203 } else { 204 q = p->link; 205 if(q->mark) 206 if(a != ALOOP) { 207 p->as = relinv(a); 208 p->link = p->pcond; 209 p->pcond = q; 210 } 211 } 212 xfol(p->link, last); 213 if(p->pcond->mark) 214 return; 215 p = p->pcond; 216 goto loop; 217 } 218 p = p->link; 219 goto loop; 220 } 221 222 int 223 relinv(int a) 224 { 225 226 switch(a) { 227 case AJEQ: return AJNE; 228 case AJNE: return AJEQ; 229 case AJLE: return AJGT; 230 case AJLS: return AJHI; 231 case AJLT: return AJGE; 232 case AJMI: return AJPL; 233 case AJGE: return AJLT; 234 case AJPL: return AJMI; 235 case AJGT: return AJLE; 236 case AJHI: return AJLS; 237 case AJCS: return AJCC; 238 case AJCC: return AJCS; 239 case AJPS: return AJPC; 240 case AJPC: return AJPS; 241 case AJOS: return AJOC; 242 case AJOC: return AJOS; 243 } 244 diag("unknown relation: %s in %s", anames[a], TNAME); 245 return a; 246 } 247 248 void 249 patch(void) 250 { 251 int32 c; 252 Prog *p, *q; 253 Sym *s; 254 int32 vexit; 255 Sym *plan9_tos; 256 257 if(debug['v']) 258 Bprint(&bso, "%5.2f mkfwd\n", cputime()); 259 Bflush(&bso); 260 mkfwd(); 261 if(debug['v']) 262 Bprint(&bso, "%5.2f patch\n", cputime()); 263 Bflush(&bso); 264 s = lookup("exit", 0); 265 vexit = s->value; 266 267 plan9_tos = S; 268 if(HEADTYPE == Hplan9x32) 269 plan9_tos = lookup("_tos", 0); 270 271 for(cursym = textp; cursym != nil; cursym = cursym->next) { 272 for(p = cursym->text; p != P; p = p->link) { 273 if(HEADTYPE == Hwindows) { 274 // Convert 275 // op n(GS), reg 276 // to 277 // MOVL 0x14(FS), reg 278 // op n(reg), reg 279 // The purpose of this patch is to fix some accesses 280 // to extern register variables (TLS) on Windows, as 281 // a different method is used to access them. 282 if(p->from.type == D_INDIR+D_GS 283 && p->to.type >= D_AX && p->to.type <= D_DI) { 284 q = appendp(p); 285 q->from = p->from; 286 q->from.type = D_INDIR + p->to.type; 287 q->to = p->to; 288 q->as = p->as; 289 p->as = AMOVL; 290 p->from.type = D_INDIR+D_FS; 291 p->from.offset = 0x14; 292 } 293 } 294 if(HEADTYPE == Hlinux) { 295 // Running binaries under Xen requires using 296 // MOVL 0(GS), reg 297 // and then off(reg) instead of saying off(GS) directly 298 // when the offset is negative. 299 // In external mode we just produce a reloc. 300 if(p->from.type == D_INDIR+D_GS && p->from.offset < 0 301 && p->to.type >= D_AX && p->to.type <= D_DI) { 302 if(linkmode != LinkExternal) { 303 q = appendp(p); 304 q->from = p->from; 305 q->from.type = D_INDIR + p->to.type; 306 q->to = p->to; 307 q->as = p->as; 308 p->as = AMOVL; 309 p->from.type = D_INDIR+D_GS; 310 p->from.offset = 0; 311 } else { 312 // Add signals to relocate. 313 p->from.index = D_GS; 314 p->from.scale = 1; 315 } 316 } 317 } 318 if(HEADTYPE == Hplan9x32) { 319 if(p->from.type == D_INDIR+D_GS 320 && p->to.type >= D_AX && p->to.type <= D_DI) { 321 q = appendp(p); 322 q->from = p->from; 323 q->from.type = D_INDIR + p->to.type; 324 q->to = p->to; 325 q->as = p->as; 326 p->as = AMOVL; 327 p->from.type = D_EXTERN; 328 p->from.sym = plan9_tos; 329 p->from.offset = 0; 330 } 331 } 332 if((p->as == ACALL && p->to.type != D_BRANCH) || (p->as == AJMP && p->to.type != D_BRANCH) || (p->as == ARET && p->to.sym != nil)) { 333 s = p->to.sym; 334 if(p->to.type == D_INDIR+D_ADDR) { 335 /* skip check if this is an indirect call (CALL *symbol(SB)) */ 336 continue; 337 } else if(s) { 338 if(debug['c']) 339 Bprint(&bso, "%s calls %s\n", TNAME, s->name); 340 if((s->type&SMASK) != STEXT) { 341 /* diag prints TNAME first */ 342 diag("undefined: %s", s->name); 343 s->type = STEXT; 344 s->value = vexit; 345 continue; // avoid more error messages 346 } 347 if(s->text == nil) 348 continue; 349 p->to.type = D_BRANCH; 350 p->to.offset = s->text->pc; 351 p->pcond = s->text; 352 continue; 353 } 354 } 355 if(p->to.type != D_BRANCH) 356 continue; 357 c = p->to.offset; 358 for(q = cursym->text; q != P;) { 359 if(c == q->pc) 360 break; 361 if(q->forwd != P && c >= q->forwd->pc) 362 q = q->forwd; 363 else 364 q = q->link; 365 } 366 if(q == P) { 367 diag("branch out of range in %s (%#ux)\n%P [%s]", 368 TNAME, c, p, p->to.sym ? p->to.sym->name : "<nil>"); 369 p->to.type = D_NONE; 370 } 371 p->pcond = q; 372 } 373 } 374 375 for(cursym = textp; cursym != nil; cursym = cursym->next) { 376 if(cursym->text == nil || cursym->p != nil) 377 continue; 378 379 for(p = cursym->text; p != P; p = p->link) { 380 p->mark = 0; /* initialization for follow */ 381 if(p->pcond != P) { 382 p->pcond = brloop(p->pcond); 383 if(p->pcond != P) 384 if(p->to.type == D_BRANCH) 385 p->to.offset = p->pcond->pc; 386 } 387 } 388 } 389 } 390 391 Prog* 392 brloop(Prog *p) 393 { 394 int c; 395 Prog *q; 396 397 c = 0; 398 for(q = p; q != P; q = q->pcond) { 399 if(q->as != AJMP) 400 break; 401 c++; 402 if(c >= 5000) 403 return P; 404 } 405 return q; 406 } 407 408 void 409 dostkoff(void) 410 { 411 Prog *p, *q, *q1; 412 int32 autoffset, deltasp; 413 int a, arg; 414 Prog *pmorestack; 415 Sym *symmorestack; 416 Sym *plan9_tos; 417 418 pmorestack = P; 419 symmorestack = lookup("runtime.morestack", 0); 420 421 if(symmorestack->type != STEXT) 422 diag("runtime.morestack not defined"); 423 else { 424 pmorestack = symmorestack->text; 425 symmorestack->text->from.scale |= NOSPLIT; 426 } 427 428 plan9_tos = S; 429 if(HEADTYPE == Hplan9x32) 430 plan9_tos = lookup("_tos", 0); 431 432 for(cursym = textp; cursym != nil; cursym = cursym->next) { 433 if(cursym->text == nil || cursym->text->link == nil) 434 continue; 435 436 p = cursym->text; 437 autoffset = p->to.offset; 438 if(autoffset < 0) 439 autoffset = 0; 440 441 q = P; 442 q1 = P; 443 if(pmorestack != P) 444 if(!(p->from.scale & NOSPLIT)) { 445 p = appendp(p); // load g into CX 446 switch(HEADTYPE) { 447 case Hwindows: 448 p->as = AMOVL; 449 p->from.type = D_INDIR+D_FS; 450 p->from.offset = 0x14; 451 p->to.type = D_CX; 452 453 p = appendp(p); 454 p->as = AMOVL; 455 p->from.type = D_INDIR+D_CX; 456 p->from.offset = 0; 457 p->to.type = D_CX; 458 break; 459 460 case Hlinux: 461 if(linkmode != LinkExternal) { 462 p->as = AMOVL; 463 p->from.type = D_INDIR+D_GS; 464 p->from.offset = 0; 465 p->to.type = D_CX; 466 467 p = appendp(p); 468 p->as = AMOVL; 469 p->from.type = D_INDIR+D_CX; 470 p->from.offset = tlsoffset + 0; 471 p->to.type = D_CX; 472 } else { 473 p->as = AMOVL; 474 p->from.type = D_INDIR+D_GS; 475 p->from.offset = tlsoffset + 0; 476 p->to.type = D_CX; 477 p->from.index = D_GS; 478 p->from.scale = 1; 479 } 480 break; 481 482 case Hplan9x32: 483 p->as = AMOVL; 484 p->from.type = D_EXTERN; 485 p->from.sym = plan9_tos; 486 p->to.type = D_CX; 487 488 p = appendp(p); 489 p->as = AMOVL; 490 p->from.type = D_INDIR+D_CX; 491 p->from.offset = tlsoffset + 0; 492 p->to.type = D_CX; 493 break; 494 495 default: 496 p->as = AMOVL; 497 p->from.type = D_INDIR+D_GS; 498 p->from.offset = tlsoffset + 0; 499 p->to.type = D_CX; 500 } 501 502 if(debug['K']) { 503 // 8l -K means check not only for stack 504 // overflow but stack underflow. 505 // On underflow, INT 3 (breakpoint). 506 // Underflow itself is rare but this also 507 // catches out-of-sync stack guard info. 508 p = appendp(p); 509 p->as = ACMPL; 510 p->from.type = D_INDIR+D_CX; 511 p->from.offset = 4; 512 p->to.type = D_SP; 513 514 p = appendp(p); 515 p->as = AJCC; 516 p->to.type = D_BRANCH; 517 p->to.offset = 4; 518 q1 = p; 519 520 p = appendp(p); 521 p->as = AINT; 522 p->from.type = D_CONST; 523 p->from.offset = 3; 524 525 p = appendp(p); 526 p->as = ANOP; 527 q1->pcond = p; 528 } 529 q1 = P; 530 531 if(autoffset <= StackSmall) { 532 // small stack: SP <= stackguard 533 // CMPL SP, stackguard 534 p = appendp(p); 535 p->as = ACMPL; 536 p->from.type = D_SP; 537 p->to.type = D_INDIR+D_CX; 538 } else if(autoffset <= StackBig) { 539 // large stack: SP-framesize <= stackguard-StackSmall 540 // LEAL -(autoffset-StackSmall)(SP), AX 541 // CMPL AX, stackguard 542 p = appendp(p); 543 p->as = ALEAL; 544 p->from.type = D_INDIR+D_SP; 545 p->from.offset = -(autoffset-StackSmall); 546 p->to.type = D_AX; 547 548 p = appendp(p); 549 p->as = ACMPL; 550 p->from.type = D_AX; 551 p->to.type = D_INDIR+D_CX; 552 } else { 553 // Such a large stack we need to protect against wraparound 554 // if SP is close to zero. 555 // SP-stackguard+StackGuard <= framesize + (StackGuard-StackSmall) 556 // The +StackGuard on both sides is required to keep the left side positive: 557 // SP is allowed to be slightly below stackguard. See stack.h. 558 // 559 // Preemption sets stackguard to StackPreempt, a very large value. 560 // That breaks the math above, so we have to check for that explicitly. 561 // MOVL stackguard, CX 562 // CMPL CX, $StackPreempt 563 // JEQ label-of-call-to-morestack 564 // LEAL StackGuard(SP), AX 565 // SUBL stackguard, AX 566 // CMPL AX, $(autoffset+(StackGuard-StackSmall)) 567 p = appendp(p); 568 p->as = AMOVL; 569 p->from.type = D_INDIR+D_CX; 570 p->from.offset = 0; 571 p->to.type = D_SI; 572 573 p = appendp(p); 574 p->as = ACMPL; 575 p->from.type = D_SI; 576 p->to.type = D_CONST; 577 p->to.offset = (uint32)StackPreempt; 578 579 p = appendp(p); 580 p->as = AJEQ; 581 p->to.type = D_BRANCH; 582 q1 = p; 583 584 p = appendp(p); 585 p->as = ALEAL; 586 p->from.type = D_INDIR+D_SP; 587 p->from.offset = StackGuard; 588 p->to.type = D_AX; 589 590 p = appendp(p); 591 p->as = ASUBL; 592 p->from.type = D_SI; 593 p->from.offset = 0; 594 p->to.type = D_AX; 595 596 p = appendp(p); 597 p->as = ACMPL; 598 p->from.type = D_AX; 599 p->to.type = D_CONST; 600 p->to.offset = autoffset+(StackGuard-StackSmall); 601 } 602 603 // common 604 p = appendp(p); 605 p->as = AJHI; 606 p->to.type = D_BRANCH; 607 p->to.offset = 4; 608 q = p; 609 610 p = appendp(p); // save frame size in DI 611 p->as = AMOVL; 612 p->to.type = D_DI; 613 p->from.type = D_CONST; 614 615 // If we ask for more stack, we'll get a minimum of StackMin bytes. 616 // We need a stack frame large enough to hold the top-of-stack data, 617 // the function arguments+results, our caller's PC, our frame, 618 // a word for the return PC of the next call, and then the StackLimit bytes 619 // that must be available on entry to any function called from a function 620 // that did a stack check. If StackMin is enough, don't ask for a specific 621 // amount: then we can use the custom functions and save a few 622 // instructions. 623 if(StackTop + cursym->text->to.offset2 + PtrSize + autoffset + PtrSize + StackLimit >= StackMin) 624 p->from.offset = (autoffset+7) & ~7LL; 625 626 arg = cursym->text->to.offset2; 627 if(arg == 1) // special marker for known 0 628 arg = 0; 629 if(arg&3) 630 diag("misaligned argument size in stack split"); 631 p = appendp(p); // save arg size in AX 632 p->as = AMOVL; 633 p->to.type = D_AX; 634 p->from.type = D_CONST; 635 p->from.offset = arg; 636 637 p = appendp(p); 638 p->as = ACALL; 639 p->to.type = D_BRANCH; 640 p->pcond = pmorestack; 641 p->to.sym = symmorestack; 642 643 p = appendp(p); 644 p->as = AJMP; 645 p->to.type = D_BRANCH; 646 p->pcond = cursym->text->link; 647 } 648 649 if(q != P) 650 q->pcond = p->link; 651 if(q1 != P) 652 q1->pcond = q->link; 653 654 if(autoffset) { 655 p = appendp(p); 656 p->as = AADJSP; 657 p->from.type = D_CONST; 658 p->from.offset = autoffset; 659 p->spadj = autoffset; 660 if(q != P) 661 q->pcond = p; 662 } else { 663 // zero-byte stack adjustment. 664 // Insert a fake non-zero adjustment so that stkcheck can 665 // recognize the end of the stack-splitting prolog. 666 p = appendp(p); 667 p->as = ANOP; 668 p->spadj = -PtrSize; 669 p = appendp(p); 670 p->as = ANOP; 671 p->spadj = PtrSize; 672 } 673 deltasp = autoffset; 674 675 if(debug['Z'] && autoffset && !(cursym->text->from.scale&NOSPLIT)) { 676 // 8l -Z means zero the stack frame on entry. 677 // This slows down function calls but can help avoid 678 // false positives in garbage collection. 679 p = appendp(p); 680 p->as = AMOVL; 681 p->from.type = D_SP; 682 p->to.type = D_DI; 683 684 p = appendp(p); 685 p->as = AMOVL; 686 p->from.type = D_CONST; 687 p->from.offset = autoffset/4; 688 p->to.type = D_CX; 689 690 p = appendp(p); 691 p->as = AMOVL; 692 p->from.type = D_CONST; 693 p->from.offset = 0; 694 p->to.type = D_AX; 695 696 p = appendp(p); 697 p->as = AREP; 698 699 p = appendp(p); 700 p->as = ASTOSL; 701 } 702 703 for(; p != P; p = p->link) { 704 a = p->from.type; 705 if(a == D_AUTO) 706 p->from.offset += deltasp; 707 if(a == D_PARAM) 708 p->from.offset += deltasp + 4; 709 a = p->to.type; 710 if(a == D_AUTO) 711 p->to.offset += deltasp; 712 if(a == D_PARAM) 713 p->to.offset += deltasp + 4; 714 715 switch(p->as) { 716 default: 717 continue; 718 case APUSHL: 719 case APUSHFL: 720 deltasp += 4; 721 p->spadj = 4; 722 continue; 723 case APUSHW: 724 case APUSHFW: 725 deltasp += 2; 726 p->spadj = 2; 727 continue; 728 case APOPL: 729 case APOPFL: 730 deltasp -= 4; 731 p->spadj = -4; 732 continue; 733 case APOPW: 734 case APOPFW: 735 deltasp -= 2; 736 p->spadj = -2; 737 continue; 738 case ARET: 739 break; 740 } 741 742 if(autoffset != deltasp) 743 diag("unbalanced PUSH/POP"); 744 745 if(autoffset) { 746 p->as = AADJSP; 747 p->from.type = D_CONST; 748 p->from.offset = -autoffset; 749 p->spadj = -autoffset; 750 p = appendp(p); 751 p->as = ARET; 752 // If there are instructions following 753 // this ARET, they come from a branch 754 // with the same stackframe, so undo 755 // the cleanup. 756 p->spadj = +autoffset; 757 } 758 if(p->to.sym) // retjmp 759 p->as = AJMP; 760 } 761 } 762 } 763 764 int32 765 atolwhex(char *s) 766 { 767 int32 n; 768 int f; 769 770 n = 0; 771 f = 0; 772 while(*s == ' ' || *s == '\t') 773 s++; 774 if(*s == '-' || *s == '+') { 775 if(*s++ == '-') 776 f = 1; 777 while(*s == ' ' || *s == '\t') 778 s++; 779 } 780 if(s[0]=='0' && s[1]){ 781 if(s[1]=='x' || s[1]=='X'){ 782 s += 2; 783 for(;;){ 784 if(*s >= '0' && *s <= '9') 785 n = n*16 + *s++ - '0'; 786 else if(*s >= 'a' && *s <= 'f') 787 n = n*16 + *s++ - 'a' + 10; 788 else if(*s >= 'A' && *s <= 'F') 789 n = n*16 + *s++ - 'A' + 10; 790 else 791 break; 792 } 793 } else 794 while(*s >= '0' && *s <= '7') 795 n = n*8 + *s++ - '0'; 796 } else 797 while(*s >= '0' && *s <= '9') 798 n = n*10 + *s++ - '0'; 799 if(f) 800 n = -n; 801 return n; 802 }