Changeset 57220 in vbox for trunk/include/iprt
- Timestamp:
- Aug 6, 2015 6:24:59 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm-amd64-x86.h
r56291 r57220 598 598 599 599 /** 600 * Modifies the [RE]FLAGS register. 601 * @returns Original value. 602 * @param fAndEfl Flags to keep (applied first). 603 * @param fOrEfl Flags to be set. 604 */ 605 #if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15 606 DECLASM(RTCCUINTREG) ASMChangeFlags(RTCCUINTREG fAndEfl, RTCCUINTREG fOrEfl); 607 #else 608 DECLINLINE(RTCCUINTREG) ASMChangeFlags(RTCCUINTREG fAndEfl, RTCCUINTREG fOrEfl) 609 { 610 RTCCUINTREG fOldEfl; 611 # if RT_INLINE_ASM_GNU_STYLE 612 # ifdef RT_ARCH_AMD64 613 __asm__ __volatile__("pushfq\n\t" 614 "movq (%%rsp), %0\n\t" 615 "andq %0, %1\n\t" 616 "orq %3, %1\n\t" 617 "mov %1, (%%rsp)\n\t" 618 "popfq\n\t" 619 : "=r" (fOldEfl), 620 "=g" (fAndEfl) 621 : "1" (fAndEfl), 622 "g" (fOrEfl) ); 623 # else 624 __asm__ __volatile__("pushfl\n\t" 625 "movl (%%esp), %0\n\t" 626 "andl %1, (%%esp)\n\t" 627 "orl %2, (%%esp)\n\t" 628 "popfl\n\t" 629 : "=r" (fOldEfl) 630 : "g" (fAndEfl), 631 "g" (fOrEfl) ); 632 # endif 633 # elif RT_INLINE_ASM_USES_INTRIN >= 15 634 fOldEfl = __readeflags(); 635 __writeeflags((fOldEfl & fAndEfl) | fOrEfl); 636 # else 637 __asm 638 { 639 # ifdef RT_ARCH_AMD64 640 mov rdx, [fAndEfl] 641 mov rcx, [fOrEfl] 642 pushfq 643 mov rax, [rsp] 644 and rdx, rax 645 or rdx, rcx 646 mov [rsp], rdx 647 popfq 648 mov [fOldEfl], rax 649 # else 650 mov edx, [fAndEfl] 651 mov ecx, [fOrEfl] 652 pushfd 653 mov eax, [esp] 654 and edx, eax 655 or edx, ecx 656 mov [esp], edx 657 popfd 658 mov [fOldEfl], eax 659 # endif 660 } 661 # endif 662 return fOldEfl; 663 } 664 #endif 665 666 667 /** 668 * Modifies the [RE]FLAGS register by ORing in one or more flags. 669 * @returns Original value. 670 * @param fOrEfl The flags to be set (ORed in). 671 */ 672 #if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15 673 DECLASM(RTCCUINTREG) ASMAddFlags(RTCCUINTREG fOrEfl); 674 #else 675 DECLINLINE(RTCCUINTREG) ASMAddFlags(RTCCUINTREG fOrEfl) 676 { 677 RTCCUINTREG fOldEfl; 678 # if RT_INLINE_ASM_GNU_STYLE 679 # ifdef RT_ARCH_AMD64 680 __asm__ __volatile__("pushfq\n\t" 681 "movq (%%rsp), %0\n\t" 682 "orq %1, (%%rsp)\n\t" 683 "popfq\n\t" 684 : "=r" (fOldEfl) 685 : "g" (fOrEfl) ); 686 # else 687 __asm__ __volatile__("pushfl\n\t" 688 "movl (%%esp), %0\n\t" 689 "orl %1, (%%esp)\n\t" 690 "popfl\n\t" 691 : "=r" (fOldEfl) 692 : "g" (fOrEfl) ); 693 # endif 694 # elif RT_INLINE_ASM_USES_INTRIN >= 15 695 fOldEfl = __readeflags(); 696 __writeeflags(fOldEfl | fOrEfl); 697 # else 698 __asm 699 { 700 # ifdef RT_ARCH_AMD64 701 mov rcx, [fOrEfl] 702 pushfq 703 mov rdx, [rsp] 704 or [rsp], rcx 705 popfq 706 mov [fOldEfl], rax 707 # else 708 mov ecx, [fOrEfl] 709 pushfd 710 mov edx, [esp] 711 or [esp], ecx 712 popfd 713 mov [fOldEfl], eax 714 # endif 715 } 716 # endif 717 return fOldEfl; 718 } 719 #endif 720 721 722 /** 723 * Modifies the [RE]FLAGS register by AND'ing out one or more flags. 724 * @returns Original value. 725 * @param fAndEfl The flags to keep. 726 */ 727 #if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15 728 DECLASM(RTCCUINTREG) ASMClearFlags(RTCCUINTREG fAndEfl); 729 #else 730 DECLINLINE(RTCCUINTREG) ASMClearFlags(RTCCUINTREG fAndEfl) 731 { 732 RTCCUINTREG fOldEfl; 733 # if RT_INLINE_ASM_GNU_STYLE 734 # ifdef RT_ARCH_AMD64 735 __asm__ __volatile__("pushfq\n\t" 736 "movq (%%rsp), %0\n\t" 737 "andq %1, (%%rsp)\n\t" 738 "popfq\n\t" 739 : "=r" (fOldEfl) 740 : "g" (fAndEfl) ); 741 # else 742 __asm__ __volatile__("pushfl\n\t" 743 "movl (%%esp), %0\n\t" 744 "andl %1, (%%esp)\n\t" 745 "popfl\n\t" 746 : "=r" (fOldEfl) 747 : "g" (fAndEfl) ); 748 # endif 749 # elif RT_INLINE_ASM_USES_INTRIN >= 15 750 fOldEfl = __readeflags(); 751 __writeeflags(fOldEfl & fAndEfl); 752 # else 753 __asm 754 { 755 # ifdef RT_ARCH_AMD64 756 mov rdx, [fAndEfl] 757 pushfq 758 mov rdx, [rsp] 759 and [rsp], rdx 760 popfq 761 mov [fOldEfl], rax 762 # else 763 mov edx, [fAndEfl] 764 pushfd 765 mov edx, [esp] 766 and [esp], edx 767 popfd 768 mov [fOldEfl], eax 769 # endif 770 } 771 # endif 772 return fOldEfl; 773 } 774 #endif 775 776 777 /** 600 778 * Gets the content of the CPU timestamp counter register. 601 779 *
Note:
See TracChangeset
for help on using the changeset viewer.