- Timestamp:
- Jun 28, 2014, 4:30:53 AM (11 years ago)
- Location:
- trunk/libc
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/include/386/builtin.h
r3866 r3884 570 570 571 571 572 #ifndef __WATCOMC__ /** @todo port me later. */573 572 /** 574 573 * Atomically compare and exchange a pointer. … … 579 578 * @param pvCur The current value. Only update if *pu32 equals this one. 580 579 */ 580 #ifdef __WATCOMC__ 581 unsigned __atomic_cmpxchgptr(void * volatile *ppv, void *pvNew, void *pvOld); 582 # pragma aux __atomic_cmpxchgptr = \ 583 "lock cmpxchg [edx], ecx" \ 584 "setz al" \ 585 "movzx eax, al" \ 586 parm [edx] [ecx] [eax] value [eax] 587 #else 581 588 static inline unsigned __atomic_cmpxchgptr(void * volatile *ppv, void *pvNew, void *pvOld) 582 589 { 590 # ifdef _MSC_VER 591 uint32_t uOrg = _InterlockedCompareExchange((long volatile *)ppv, (uintptr_t)pvNew, (uintptr_t)pvOld) 592 return uOrg == (uintptr_t)pvOld; 593 # else 583 594 __asm__ __volatile__("lock; cmpxchgl %2, %1\n\t" 584 595 "setz %%al\n\t" … … 589 600 "0" (pvOld)); 590 601 return (uintptr_t)pvOld; 591 } 602 # endif 603 } 604 #endif 592 605 593 606 … … 598 611 * @param iBit The bit to be set. 599 612 */ 613 #ifdef __WATCOMC__ 614 void __bit_set(void volatile *pvBitmap, uint32_t iBit); 615 # pragma aux __bit_set = "bts [eax], edx" parm [eax] [edx] 616 #else 600 617 static inline void __bit_set(void volatile *pvBitmap, uint32_t iBit) 601 618 { 619 # ifdef _MSC_VER 620 _bittestandset((long *)pvBitmap, iBit); 621 # else 602 622 __asm__ __volatile__("btsl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 603 } 623 # endif 624 } 625 #endif 604 626 605 627 /** … … 609 631 * @param iBit The bit to be cleared. 610 632 */ 633 #ifdef __WATCOMC__ 634 void __bit_clear(void volatile *pvBitmap, uint32_t iBit); 635 # pragma aux __bit_clear = "btr [eax], edx" parm [eax] [edx] 636 #else 611 637 static inline void __bit_clear(void volatile *pvBitmap, uint32_t iBit) 612 638 { 639 # ifdef _MSC_VER 640 _bittestandreset((long *)pvBitmap, iBit); 641 # else 613 642 __asm__ __volatile__("btrl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 614 } 643 # endif 644 } 645 #endif 615 646 616 647 /** … … 620 651 * @param iBit The bit to be cleared. 621 652 */ 653 #ifdef __WATCOMC__ 654 void __bit_toggle(void volatile *pvBitmap, uint32_t iBit); 655 # pragma aux __bit_toggle = "btc [eax], edx" parm [eax] [edx] 656 #else 622 657 static inline void __bit_toggle(void volatile *pvBitmap, uint32_t iBit) 623 658 { 659 # ifdef _MSC_VER 660 _bittestandcomplement((long *)pvBitmap, iBit); 661 # else 624 662 __asm__ __volatile__("btcl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 625 } 663 # endif 664 } 665 #endif 626 666 627 667 /** … … 632 672 * @param iBit The bit to be tested. 633 673 */ 674 #ifdef __WATCOMC__ 675 _Bool __bit_test(void volatile *pvBitmap, uint32_t iBit); 676 # pragma aux __bit_toggle = \ 677 "bt [edx], eax" \ 678 "sbb eax, eax" \ 679 "neg eax" \ 680 parm [edx] [eax] value [al] 681 #else 634 682 static inline _Bool __bit_test(void volatile *pvBitmap, uint32_t iBit) 635 683 { 684 # ifdef _MSC_VER 685 return _bittest((long *)pvBitmap, iBit); 686 # else 636 687 union { _Bool f; uint32_t u32; } u; 637 688 638 689 __asm__ __volatile__("btl %2, %1\n\t" 639 "sbbl %0, %0" 690 "sbbl %0, %0\n\t" 691 "neg %0\n\t" 640 692 : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap) 641 693 : "Ir" (iBit)); 642 694 return u.f; 643 } 695 # endif 696 } 697 #endif 698 644 699 645 700 /** … … 650 705 * @param iBit The bit to be tested and set. 651 706 */ 707 #ifdef __WATCOMC__ 708 _Bool __bit_test_and_set(void volatile *pvBitmap, uint32_t iBit); 709 # pragma aux __bit_test_and_set = \ 710 "bts [edx], eax" \ 711 "sbb eax, eax" \ 712 "neg eax" \ 713 parm [edx] [eax] value [al] 714 #else 652 715 static inline _Bool __bit_test_and_set(void volatile *pvBitmap, uint32_t iBit) 653 716 { 717 # ifdef _MSC_VER 718 return _bittestandset((long *)pvBitmap, iBit); 719 # else 654 720 union { _Bool f; uint32_t u32; } u; 655 721 656 722 __asm__ __volatile__("btsl %2, %1\n\t" 657 "sbbl %0, %0" 723 "sbbl %0, %0\n\t" 724 "neg %0\n\t" 658 725 : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap) 659 726 : "Ir" (iBit)); 660 727 return u.f; 661 } 728 # endif 729 } 730 #endif 662 731 663 732 /** … … 668 737 * @param iBit The bit to be tested and cleared. 669 738 */ 739 #ifdef __WATCOMC__ 740 _Bool __bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit); 741 # pragma aux __bit_test_and_clear = \ 742 "btr [edx], eax" \ 743 "sbb eax, eax" \ 744 "neg eax" \ 745 parm [edx] [eax] value [al] 746 #else 670 747 static inline _Bool __bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit) 671 748 { 749 # ifdef _MSC_VER 750 return _bittestandreset((long *)pvBitmap, iBit); 751 # else 672 752 union { _Bool f; uint32_t u32; } u; 673 753 674 754 __asm__ __volatile__("btrl %2, %1\n\t" 675 "sbbl %0, %0" 755 "sbbl %0, %0\n\t" 756 "neg %0\n\t" 676 757 : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap) 677 758 : "Ir" (iBit)); 678 759 return u.f; 679 } 760 #endif 761 } 762 #endif 680 763 681 764 /** … … 686 769 * @param iBit The bit to be tested and toggled. 687 770 */ 771 #ifdef __WATCOMC__ 772 _Bool __bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit); 773 # pragma aux __bit_test_and_toggle = \ 774 "btc [edx], eax" \ 775 "sbb eax, eax" \ 776 "neg eax" \ 777 parm [edx] [eax] value [al] 778 #else 688 779 static inline _Bool __bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit) 689 780 { 781 # ifdef _MSC_VER 782 return _bittestandcomplement((long *)pvBitmap, iBit); 783 # else 690 784 union { _Bool f; uint32_t u32; } u; 691 785 692 786 __asm__ __volatile__("btcl %2, %1\n\t" 693 "sbbl %0, %0" 787 "sbbl %0, %0\n\t" 788 "neg %0\n\t" 694 789 : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap) 695 790 : "Ir" (iBit)); 696 791 return u.f; 697 } 792 # endif 793 } 794 #endif 698 795 699 796 /** … … 703 800 * @param iBit The bit to be set. 704 801 */ 802 #ifdef __WATCOMC__ 803 void __atomic_bit_set(void volatile *pvBitmap, uint32_t iBit); 804 # pragma aux __atomic_bit_set = "bts [eax], edx" parm [eax] [edx] 805 #else 705 806 static inline void __atomic_bit_set(void volatile *pvBitmap, uint32_t iBit) 706 807 { 707 __asm__ __volatile__("btsl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 708 } 808 # ifdef _MSC_VER 809 _interlockedbittestandset((long *)pvBitmap, iBit); 810 # else 811 __asm__ __volatile__("lock; btsl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 812 # endif 813 } 814 #endif 709 815 710 816 /** … … 714 820 * @param iBit The bit to be cleared. 715 821 */ 822 #ifdef __WATCOMC__ 823 void __atomic_bit_clear(void volatile *pvBitmap, uint32_t iBit); 824 # pragma aux __atomic_bit_clear = "lock btr [eax], edx" parm [eax] [edx] 825 #else 716 826 static inline void __atomic_bit_clear(void volatile *pvBitmap, uint32_t iBit) 717 827 { 718 __asm__ __volatile__("btrl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 719 } 828 # ifdef _MSC_VER 829 _interlockedbittestandreset((long *)pvBitmap, iBit); 830 # else 831 __asm__ __volatile__("lock; btrl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 832 # endif 833 } 834 #endif 720 835 721 836 /** … … 725 840 * @param iBit The bit to be cleared. 726 841 */ 842 #ifdef __WATCOMC__ 843 void __atomic_bit_toggle(void volatile *pvBitmap, uint32_t iBit); 844 # pragma aux __atomic_bit_toggle = "lock btc [eax], edx" parm [eax] [edx] 845 #elif defined(_MSC_VER) 846 void __atomic_bit_toggle(void volatile *pvBitmap, uint32_t iBit); 847 #else 727 848 static inline void __atomic_bit_toggle(void volatile *pvBitmap, uint32_t iBit) 728 849 { 729 __asm__ __volatile__("btcl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 730 } 850 __asm__ __volatile__("lock; btcl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory"); 851 } 852 #endif 731 853 732 854 /** … … 737 859 * @param iBit The bit to be tested and set. 738 860 */ 861 #ifdef __WATCOMC__ 862 _Bool __atomic_bit_test_and_set(void volatile *pvBitmap, uint32_t iBit); 863 # pragma aux __atomic_bit_test_and_set = \ 864 "lock bts [edx], eax" \ 865 "sbb eax, eax" \ 866 "neg eax" \ 867 parm [edx] [eax] value [al] 868 #else 739 869 static inline _Bool __atomic_bit_test_and_set(void volatile *pvBitmap, uint32_t iBit) 740 870 { 871 # ifdef _MSC_VER 872 return _interrlockedbittestandset((long *)pvBitmap, iBit); 873 # else 741 874 union { _Bool f; uint32_t u32; } u; 742 875 743 876 __asm__ __volatile__("lock; btsl %2, %1\n\t" 744 "sbbl %0, %0" 877 "sbbl %0, %0\n\t" 878 "neg %0\n\t" 745 879 : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap) 746 880 : "Ir" (iBit)); 747 881 return u.f; 748 } 882 # endif 883 } 884 #endif 749 885 750 886 /** … … 755 891 * @param iBit The bit to be tested and cleared. 756 892 */ 893 #ifdef __WATCOMC__ 894 _Bool __atomic_bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit); 895 # pragma aux __atomic_bit_test_and_clear = \ 896 "lock btr [edx], eax" \ 897 "sbb eax, eax" \ 898 "neg eax" \ 899 parm [edx] [eax] value [al] 900 #else 757 901 static inline _Bool __atomic_bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit) 758 902 { 903 # ifdef _MSC_VER 904 return _interlockedbittestandreset((long *)pvBitmap, iBit); 905 # else 759 906 union { _Bool f; uint32_t u32; } u; 760 907 761 908 __asm__ __volatile__("lock; btrl %2, %1\n\t" 762 "sbbl %0, %0" 909 "sbbl %0, %0\n\t" 910 "neg %0\n\t" 763 911 : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap) 764 912 : "Ir" (iBit)); 765 913 return u.f; 766 } 914 # endif 915 } 916 #endif 767 917 768 918 /** … … 773 923 * @param iBit The bit to be tested and toggled. 774 924 */ 925 #ifdef __WATCOMC__ 926 _Bool __atomic_bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit); 927 # pragma aux __atomic_bit_test_and_toggle = \ 928 "btc [edx], eax" \ 929 "sbb eax, eax" \ 930 "neg eax" \ 931 parm [edx] [eax] value [al] 932 #elif defined(_MSC_VER) 933 _Bool __atomic_bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit); 934 #else 775 935 static inline _Bool __atomic_bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit) 776 936 { … … 778 938 779 939 __asm__ __volatile__("lock; btcl %2, %1\n\t" 780 "sbbl %0, %0" 940 "sbbl %0, %0\n\t" 941 "neg %0\n\t" 781 942 : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap) 782 943 : "Ir" (iBit)); 783 944 return u.f; 784 945 } 946 #endif 785 947 786 948 … … 794 956 * @param cbBitmap Size (in bytes) of the bitmap. Must be a multiple of 8. 795 957 */ 958 #ifndef __GNUC__ 959 int32_t __bit_scan_clear_forward(void volatile *pvBitmap, uint32_t cbBitmap); 960 #else 796 961 static inline int32_t __bit_scan_clear_forward(void volatile *pvBitmap, uint32_t cbBitmap) 797 962 { … … 813 978 return iBit; 814 979 } 815 816 980 #endif 981 982 983 #ifndef __WATCOMC__ /** @todo port me later */ 817 984 #define __ROTATE_FUN(F,I,T) \ 818 985 static __inline__ T F (T value, int shift) \ -
trunk/libc/src/kNIX/os2/386/__libc_back_envInitAsm.asm
r3883 r3884 4 4 ; 5 5 ; @copyright Copyright (C) 2003-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net> 6 ; @licenses MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3 .6 ; @licenses MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture. 7 7 ; 8 8 9 9 10 %include "klibc/ os2/asmdefs.mac"10 %include "klibc/asmdefs.mac" 11 11 12 extern __hmalloc13 extern __org_environ12 extern NAME_FUNC(_hmalloc) 13 extern NAME_DATA(_org_environ) 14 14 extern _STD(environ) 15 15 … … 25 25 ; @remarks Requires lots of stack. 26 26 ; 27 global ___libc_back_envInitAsm 28 ___libc_back_envInitAsm: 29 push ebp 30 mov esp, ebp 27 FUNC_BEGIN_WITH_FRAME __libc_back_envInitAsm 31 28 push edi 29 FUNC_PROLOGUE_END 32 30 33 31 ; … … 60 58 61 59 push ecx 62 call __hmalloc60 call NAME_FUNC(_hmalloc) 63 61 add esp, 4 64 62 or eax, eax 65 63 jz .return_error 66 64 67 mov [ __org_environ], eax65 mov [NAME_DATA(_org_environ)], eax 68 66 mov [_STD(environ)], eax 69 67 … … 81 79 jnz .reverse_copy 82 80 81 FUNC_EPILOGUE 83 82 .return: 84 83 lea esp, [ebp - 4] … … 90 89 mov eax, -1 91 90 jmp .return 91 FUNC_END 92 92 -
trunk/libc/src/kNIX/os2/386/signal16bit.asm
r3861 r3884 1 1 ; $Id$ 2 2 ;; @file 3 ;4 3 ; kNIX - Signals, OS/2 16-bit handler. 5 4 ; 6 ; Copyright (c) 2004-2007 knut st. osmundsen <bird-src-spam@anduin.net> 7 ; 8 ; 9 ; This file is part of InnoTek LIBC. 10 ; 11 ; InnoTek LIBC is free software; you can redistribute it and/or modify 12 ; it under the terms of the GNU Lesser General Public License as published 13 ; by the Free Software Foundation; either version 2 of the License, or 14 ; (at your option) any later version. 15 ; 16 ; InnoTek LIBC is distributed in the hope that it will be useful, 17 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 ; GNU Lesser General Public License for more details. 20 ; 21 ; You should have received a copy of the GNU Lesser General Public License 22 ; along with InnoTek LIBC; if not, write to the Free Software 23 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 ; 5 ; @copyright Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net> 6 ; @licenses MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture. 25 7 ; 26 8 27 %include "klibc/ os2/asmdefs.mac"9 %include "klibc/asmdefs.mac" 28 10 29 11 extern Dos32TIB 30 extern ___libc_back_signalOS2V1Handler32bit 31 12 extern NAME_FUNC(__libc_back_signalOS2V1Handler32bit) 32 13 33 14 segment CODE16 15 34 16 ;; 35 17 ; … … 37 19 ; void FAR PASCAL __libc_back_signalOS2V1Handler16bit(USHORT sig_arg, USHORT sig_num); 38 20 ; 39 global ___libc_back_signalOS2V1Handler16bit40 ___libc_back_signalOS2V1Handler16bit:21 GLOBAL_FUNC __libc_back_signalOS2V1Handler16bit 22 NAME_FUNC(__libc_back_signalOS2V1Handler16bit): 41 23 ; save registers. 42 24 push eax … … 84 66 push eax 85 67 push edx 86 call ___libc_back_signalOS2V1Handler32bitwrt FLAT68 call NAME_FUNC(__libc_back_signalOS2V1Handler32bit) wrt FLAT 87 69 add esp, 8h 88 70 … … 109 91 retf 4 110 92 111 -
trunk/libc/src/kNIX/os2/386/thunk1.asm
r3861 r3884 1 1 ; $Id$ 2 2 ;; @file 3 ; 16-bit thunks.3 ; kNIX - 16-bit thunks. 4 4 ; 5 5 ; @copyright Copyright (c) 1992-1994 by Eberhard Mattes 6 6 ; Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net> 7 ; @licenses MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3 .7 ; @licenses MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture. 8 8 ; 9 9 10 %include "klibc/ os2/asmdefs.mac"10 %include "klibc/asmdefs.mac" 11 11 12 12 … … 31 31 ; Out: EAX Return value (DX:AX) of 16-bit function 32 32 ; 33 global __libc_thunk134 __libc_thunk1:33 GLOBAL_FUNC _libc_thunk1 34 NAME_FUNC(_libc_thunk1): 35 35 %define ARGS (2*4) ; Offset to ARGS relative to ebp 36 36 %define FUN (3*4) ; Offset to FUN relative to ebp -
trunk/libc/src/kNIX/os2/386/unwind.asm
r3883 r3884 1 ; sys/unwind.s (emx+gcc) -- Copyright (c) 1992-1994 by Eberhard Mattes 2 ; Copyright (c) 2014 by Knut St. Osmundsen 1 ; $Id$ 2 ;; @file 3 ; kNIX - 16-bit thunks. 4 ; 5 ; @copyright Copyright (c) 1992-1994 by Eberhard Mattes 6 ; Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net> 7 ; @licenses MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture. 8 ; 3 9 4 %include "klibc/ os2/asmdefs.mac"10 %include "klibc/asmdefs.mac" 5 11 6 12 extern DosUnwindException 7 13 8 14 SEG_BEGIN_CODE 9 ; void __unwind2 (void *xcpt_reg_ptr) 10 global ___unwind2 11 ___unwind2: 15 ;; 16 ; @cproto void __unwind2 (void *xcpt_reg_ptr) 17 ; 18 GLOBAL_FUNC __unwind2 19 NAME_FUNC(__unwind2): 12 20 mov eax, [esp + 4] 13 21 push 0 14 push __unwind2_continue22 push .continue 15 23 push eax 16 24 call DosUnwindException 17 __unwind2_continue:25 .continue: 18 26 lea esp, [esp + 12] 19 27 ret -
trunk/libc/src/libc/process/psignal.c
r3881 r3884 37 37 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL 38 38 #include <InnoTekLIBC/logstrict.h> 39 #include <klibc/backend.h> 39 40 40 41 -
trunk/libc/src/libc/process/tls.c
r3881 r3884 38 38 39 39 #if ULONG_MAX == UINT_MAX 40 41 #define ENTRY_BITS 3242 #define ENTRY_BYTES 443 #define INDEX_SHIFT 544 #define BIT_MASK 0x0000001f40 /* 32 bits */ 41 # define ENTRY_BITS 32 42 # define ENTRY_BYTES 4 43 # define INDEX_SHIFT 5 44 # define BIT_MASK 0x0000001f 45 45 #else 46 47 #define ENTRY_BITS 6448 #define ENTRY_BYTES 849 #define INDEX_SHIFT 650 #define BIT_MASK 0x000000000000003f46 /* 64 bits */ 47 # define ENTRY_BITS 64 48 # define ENTRY_BYTES 8 49 # define INDEX_SHIFT 6 50 # define BIT_MASK 0x000000000000003f 51 51 #endif 52 52
Note:
See TracChangeset
for help on using the changeset viewer.