Changeset 331 for EcnlProtoTool/trunk/tcc-0.9.27/lib/libtcc1.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/tcc-0.9.27
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/tcc-0.9.27/lib/libtcc1.c
r321 r331 104 104 union float_long { 105 105 float f; 106 longl;106 unsigned int l; 107 107 }; 108 108 109 109 /* XXX: we don't support several builtin supports for now */ 110 #if ndef __x86_64__110 #if !defined __x86_64__ && !defined __arm__ 111 111 112 112 /* XXX: use gcc/tcc intrinsic ? */ 113 #if defined (__i386__)113 #if defined __i386__ 114 114 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ 115 115 __asm__ ("subl %5,%1\n\tsbbl %3,%0" \ … … 479 479 } 480 480 481 #if defined(__i386__)482 /* FPU control word for rounding to nearest mode */483 unsigned short __tcc_fpu_control = 0x137f;484 /* FPU control word for round to zero mode for int conversion */485 unsigned short __tcc_int_fpu_control = 0x137f | 0x0c00;486 #endif487 488 481 #endif /* !__x86_64__ */ 489 482 … … 558 551 } 559 552 553 long long __fixsfdi (float a1) 554 { 555 long long ret; int s; 556 ret = __fixunssfdi((s = a1 >= 0) ? a1 : -a1); 557 return s ? ret : -ret; 558 } 559 560 560 unsigned long long __fixunsdfdi (double a1) 561 561 { … … 583 583 } 584 584 585 long long __fixdfdi (double a1) 586 { 587 long long ret; int s; 588 ret = __fixunsdfdi((s = a1 >= 0) ? a1 : -a1); 589 return s ? ret : -ret; 590 } 591 592 #ifndef __arm__ 585 593 unsigned long long __fixunsxfdi (long double a1) 586 594 { … … 606 614 } 607 615 608 #if defined(__x86_64__) && !defined(_WIN64) 609 610 /* helper functions for stdarg.h */ 611 612 #include <stdlib.h> 613 #ifndef __TINYC__ 614 /* gives "incompatible types for redefinition of __va_arg" below */ 615 #include <stdio.h> 616 #endif 617 618 enum __va_arg_type { 619 __va_gen_reg, __va_float_reg, __va_stack 620 }; 621 622 /* GCC compatible definition of va_list. */ 623 struct __va_list_struct { 624 unsigned int gp_offset; 625 unsigned int fp_offset; 626 union { 627 unsigned int overflow_offset; 628 char *overflow_arg_area; 629 }; 630 char *reg_save_area; 631 }; 632 633 void *__va_start(void *fp) 634 { 635 struct __va_list_struct *ap = 636 (struct __va_list_struct *)malloc(sizeof(struct __va_list_struct)); 637 *ap = *(struct __va_list_struct *)((char *)fp - 16); 638 ap->overflow_arg_area = (char *)fp + ap->overflow_offset; 639 ap->reg_save_area = (char *)fp - 176 - 16; 640 return ap; 641 } 642 643 void *__va_arg(struct __va_list_struct *ap, 644 enum __va_arg_type arg_type, 645 int size) 646 { 647 size = (size + 7) & ~7; 648 switch (arg_type) { 649 case __va_gen_reg: 650 if (ap->gp_offset < 48) { 651 ap->gp_offset += 8; 652 return ap->reg_save_area + ap->gp_offset - 8; 653 } 654 size = 8; 655 goto use_overflow_area; 656 657 case __va_float_reg: 658 if (ap->fp_offset < 128 + 48) { 659 ap->fp_offset += 16; 660 return ap->reg_save_area + ap->fp_offset - 16; 661 } 662 size = 8; 663 goto use_overflow_area; 664 665 case __va_stack: 666 use_overflow_area: 667 ap->overflow_arg_area += size; 668 return ap->overflow_arg_area - size; 669 670 default: 671 #ifndef __TINYC__ 672 fprintf(stderr, "unknown ABI type for __va_arg\n"); 673 #endif 674 abort(); 675 } 676 } 677 678 void *__va_copy(struct __va_list_struct *src) 679 { 680 struct __va_list_struct *dest = 681 (struct __va_list_struct *)malloc(sizeof(struct __va_list_struct)); 682 *dest = *src; 683 return dest; 684 } 685 686 void __va_end(struct __va_list_struct *ap) 687 { 688 free(ap); 689 } 690 691 #endif /* __x86_64__ */ 616 long long __fixxfdi (long double a1) 617 { 618 long long ret; int s; 619 ret = __fixunsxfdi((s = a1 >= 0) ? a1 : -a1); 620 return s ? ret : -ret; 621 } 622 #endif /* !ARM */
Note:
See TracChangeset
for help on using the changeset viewer.