Changeset 2088 for trunk/src


Ignore:
Timestamp:
Dec 16, 1999, 1:22:47 AM (26 years ago)
Author:
sandervl
Message:

Put back old Wine interlocked code + InterlockedExchange fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/interlock.asm

    r2009 r2088  
    1 ; $Id: interlock.asm,v 1.5 1999-12-07 18:19:07 sandervl Exp $
     1; $Id: interlock.asm,v 1.6 1999-12-16 00:22:47 sandervl Exp $
    22
    33;/*
    44; * Interlocked apis
    55; *
    6 ; * IMPORTANT NOTE: THIS CODE WILL NOT RUN ON 386 CPUs,
    7 ; *                 486 IS MINIMUM REQUIREMENT!
    8 ; *
    96; * Copyright 1999 Sander van Leeuwen
    107; * Copyright 1999 Patrick Haller
     8; *
     9; * Based on WINE code: win32\thread.c (990815)
     10; *
     11; * Copyright 1995 Martin von Loewis
     12; * Copyright 1997 Onno Hovers
    1113; *
    1214; * Project Odin Software License can be found in LICENSE.TXT
    1315; *
    1416; */
    15 .486P
     17.586P
    1618               NAME    interlocked
    1719
    1820CODE32         SEGMENT DWORD PUBLIC USE32 'CODE'
    1921
     22       public  _InterlockedIncrement@4
    2023
    21 ;************************************************************************
    2224;*           InterlockedIncrement                       [KERNEL32]      *
    2325;*                                                                      *
     
    2830;*                                                                      *
    2931;* The returned number need not be equal to the result!!!!              *
    30 ;************************************************************************
    3132
    32        public  _InterlockedIncrement@4
    3333_InterlockedIncrement@4 proc near
    34 
    35 ;@@@PH similar to NT4
    36         mov     ecx, [esp+4]
    37         mov     eax, 1
    38         nop
    39         lock    xadd     dword ptr [ecx], eax
    40         inc     eax
    41         retn 4
    42 
    43 ; @@@PH 1999/12/06 old implementation similar to W95
    44 ;var_4   = dword ptr -4
    45 ;arg_0   = dword ptr  4
    46 ;
    47 ;        sub     esp, 4
    48 ;        mov     eax, [esp + 4 + arg_0]
    49 ;   lock inc     dword ptr [eax]
    50 ;        mov     ecx, 0ffffffffh
    51 ;        js      _ic_2
    52 ;        jz      _ic_1
    53 ;        inc     ecx
    54 ;_ic_1:  inc     ecx
    55 ;_ic_2:  mov     [esp + 4 + var_4], ecx
    56 ;        mov     eax, ecx
    57 ;        retn    4
    58 ;
    59 ; @@@PH 1999/12/06 old implementation from WINE
    60 ;               mov     eax, dword ptr [esp+4] ; LPLONG lpAddend
    61 ;       lock    inc dword ptr [eax]
    62 ;               mov     eax, 0
    63 ;               je      @end                  ; not incremented?
    64 ;               jl      @decr
    65 ;               inc     eax                    ; ?
    66 ;               jmp     @end
    67 ;@decr:         dec     eax                    ; ?
    68 ;@end:  ret     4
     34        mov     eax, dword ptr [esp+4] ; LPLONG lpAddend
     35        lock    inc dword ptr [eax]
     36        mov     eax, 0
     37        je      @end                  ; not incremented?
     38        jl      @decr
     39        inc     eax                    ; ?
     40        jmp     @end
     41@decr:  dec     eax                    ; ?
     42@end:   ret     4
    6943_InterlockedIncrement@4 endp
    7044
     45       public  _InterlockedDecrement@4
    7146
    72 ;************************************************************************
    7347;*           InterlockedDecrement                       [KERNEL32]      *
    7448;*                                                                      *
     
    7953;*                                                                      *
    8054;* The returned number need not be equal to the result!!!!              *
    81 ;************************************************************************
    8255
    83        public  _InterlockedDecrement@4
    8456_InterlockedDecrement@4 proc near
    85 
    86 ;@@@PH similar to NT4
    87         mov      ecx, [esp+4]
    88         mov      eax, 0ffffffffh
    89         nop
    90         lock xadd     dword ptr [ecx], eax
    91         dec      eax
    92         retn 4
    93 
    94 
    95 ; @@@PH 1999/12/06 old implementation similar to W95
    96 ;var_4  = dword ptr -4
    97 ;arg_0  = dword ptr  4
    98 ;
    99 ;        sub     esp, 4
    100 ;        mov     eax, dword ptr[esp+4+arg_0]
    101 ;   lock dec     dword ptr [eax]
    102 ;        mov     ecx, 0ffffffffh
    103 ;        js      _id_2
    104 ;        jz      _id_1
    105 ;        inc     ecx
    106 ;_id_1:  inc     ecx
    107 ;_id_2:  mov     dword ptr [esp+4+var_4], ecx
    108 ;        mov     eax, ecx
    109 ;        add     esp, 4
    110 ;        retn    4
    111 
    112 ; @@@PH 1999/12/06 old implementation from WINE
    113 ;               mov     eax, dword ptr [esp+4] ; LPLONG lpAddend
    114 ;       lock    dec dword ptr [eax]
    115 ;               mov     eax, 0
    116 ;               je      @end                   ; not decremented?
    117 ;               jl      @decr
    118 ;               inc     eax                    ; ?
    119 ;               jmp     @end
    120 ;@decr: dec     eax                    ; ?
    121 ;@end:  ret     4
    122 
     57        mov     eax, dword ptr [esp+4] ; LPLONG lpAddend
     58        lock    dec dword ptr [eax]
     59        mov     eax, 0
     60        je      @end                   ; not decremented?
     61        jl      @decr
     62        inc     eax                    ; ?
     63        jmp     @end
     64@decr:  dec     eax                    ; ?
     65@end:   ret     4
    12366_InterlockedDecrement@4 endp
    12467
    12568
    126 ;************************************************************************
    127 ;*         InterlockedExchange                          [KERNEL32.???]  *
    128 ;*                                                                      *
    129 ;* Atomically exchanges a pair of values.                               *
    130 ;*                                                                      *
    131 ;* RETURNS                                                              *
    132 ;*      Prior value of value pointed to by Target                       *
    133 ;************************************************************************
     69       public  _InterlockedExchange@8
     70; *           InterlockedExchange                               [KERNEL32.???]
     71; *
     72; * Atomically exchanges a pair of values.
     73; *
     74; * RETURNS
     75; *     Prior value of value pointed to by Target
    13476
    135        public  _InterlockedExchange@8
    13677_InterlockedExchange@8 proc near
    137 
    138 ;@@@PH similar to NT4
    139         mov     ecx, [esp+4]            ; LPLONG target
    140         mov     edx, [esp+8]            ; LONG value
    141         mov     eax, dword ptr [ecx]
    142 _ie_1:
    143         nop
    144         lock    cmpxchg  dword ptr [ecx], edx
    145         jnz     _ie_1
    146         retn 8
    147 
    148 ; @@@PH 1999/12/06 old implementation similar to W95
    149 ;var_4   = dword ptr -4
    150 ;arg_0   = dword ptr  8
    151 ;arg_4   = dword ptr  0Ch
    152 ;
    153 ;        push    ebp
    154 ;        mov     ebp, esp
    155 ;        sub     esp, 4
    156 ;        mov     eax, dword ptr [ebp+arg_0]
    157 ;        mov     ecx, dword ptr [ebp+arg_4]
    158 ;        xchg    ecx, dword ptr [eax]
    159 ;        mov     dword ptr [ebp+var_4], ecx
    160 ;        mov     eax, ecx
    161 ;        mov     esp, ebp
    162 ;        pop     ebp
    163 ;        retn    8
    164 
    165 ; @@@PH 1999/12/06 old implementation from WINE
    166 ;       push    edx
    167 ;       mov     eax, [esp+12]           ; LONG value
    168 ;       mov     edx,[esp+8]             ; LPLONG target
    169 ;       lock    xchg eax, dword ptr [edx]
    170 ;       pop     edx
    171 ;       ret     8
     78        push    edx                     
     79        mov     eax, [esp+12]           ; LONG value
     80        mov     edx,[esp+8]             ; LPLONG target
     81        lock    xchg eax, dword ptr [edx]
     82        pop     edx
     83        ret     4
    17284_InterlockedExchange@8 endp
    17385
     
    17587
    17688                public _InterlockedCompareExchange@12
    177 ;************************************************************************
    178 ;*           InterlockedCompareExchange         [KERNEL32.879]
    179 ;*
    180 ;* Atomically compares Destination and Comperand, and if found equal exchanges
    181 ;* the value of Destination with Exchange
    182 ;*
    183 ;* RETURNS
    184 ;*      Prior value of value pointed to by Destination
    185 ;*
    186 ;************************************************************************
     89;/************************************************************************
     90; *           InterlockedCompareExchange                [KERNEL32.879]
     91; *
     92; * Atomically compares Destination and Comperand, and if found equal exchanges
     93; * the value of Destination with Exchange
     94; *
     95; * RETURNS
     96; *     Prior value of value pointed to by Destination
     97; */
    18798_InterlockedCompareExchange@12 proc near
     99        push    ebp
     100        mov     ebp, esp
     101        push    edx
     102        push    ebx
    188103
    189 ;@@@PH similar to NT4
    190         mov     ecx, dword ptr [esp + 12]
    191         mov     edx, dword ptr [esp + 8]
    192         mov     eax, dword ptr [esp + 4]
    193 _ice_1:
    194         nop
    195         lock cmpxchg dword ptr [ecx], edx
    196         retn 12
     104        mov     ebx, dword ptr [ebp+8]  ;PVOID *Destination, /* Address of 32-bit value to exchange */
     105        push    dword ptr [ebx]         ;save old *Destination
     106        mov     eax, [ebp+16]           ;PVOID Comperand      /* value to compare, 32 bits */
     107        mov     edx, [ebp+12]           ;PVOID Exchange,      /* change value, 32 bits */
     108        lock    cmpxchg dword ptr [ebx],edx
     109        pop     eax
    197110
    198 
    199 ; @@@PH 1999/12/06 old implementation from WINE
    200 ;       push    ebp
    201 ;       mov     ebp, esp
    202 ;       push    edx
    203 ;       push    ebx
    204 ;
    205 ;       mov     ebx, dword ptr [ebp+8]  ;PVOID *Destination, /* Address of 32-bit value to exchange */
    206 ;       push    dword ptr [ebx]         ;save old *Destination
    207 ;       mov     eax, [ebp+16]           ;PVOID Comperand      /* value to compare, 32 bits */
    208 ;       mov     edx, [ebp+12]           ;PVOID Exchange,      /* change value, 32 bits */
    209 ;       lock    cmpxchg dword ptr [ebx],edx
    210 ;       pop     eax
    211 ;
    212 ;       pop     ebx
    213 ;       pop     edx
    214 ;       pop     ebp
    215 ;       ret     12
     111        pop     ebx
     112        pop     edx
     113        pop     ebp
     114        ret     12
    216115_InterlockedCompareExchange@12 endp
    217116
    218 
    219 ;************************************************************************
    220 ;*           InterlockedExchangeAdd                     [KERNEL32.880]
    221 ;*
    222 ;* Atomically adds Increment to Addend and returns the previous value of
    223 ;* Addend
    224 ;*
    225 ;* RETURNS
    226 ;*      Prior value of value pointed to by cwAddendTarget
    227 ;*
    228 ;************************************************************************
    229117                public _InterlockedExchangeAdd@8
     118; *           InterlockedExchangeAdd                    [KERNEL32.880]
     119; *
     120; * Atomically adds Increment to Addend and returns the previous value of
     121; * Addend
     122; *
     123; * RETURNS
     124; *     Prior value of value pointed to by cwAddendTarget
     125; */
    230126_InterlockedExchangeAdd@8 proc near
    231 
    232 ;@@@PH similar to NT4
    233         mov     ecx, dword ptr [esp + 4]
    234         mov     eax, dword ptr [esp + 8]
    235         nop
    236         lock xadd    dword ptr [ecx], eax
    237         retn    8
    238 
    239 ; @@@PH 1999/12/06 old implementation from WINE
    240 ;
    241 ;       push    edx
    242 ;       mov     eax, dword ptr [esp+12] ;LONG Increment /* Value to add */
    243 ;       mov     edx, dword ptr [esp+8]  ;PLONG Addend, /* Address of 32-bit value to exchange */
    244 ;       lock    xadd dword ptr [edx], eax
    245 ;       pop     edx
    246 ;       ret     8
     127        push    edx
     128        mov     eax, dword ptr [esp+12] ;LONG Increment /* Value to add */
     129        mov     edx, dword ptr [esp+8]  ;PLONG Addend, /* Address of 32-bit value to exchange */
     130        lock    xadd dword ptr [edx], eax
     131        pop     edx
     132        ret     8
    247133_InterlockedExchangeAdd@8 endp
    248134
Note: See TracChangeset for help on using the changeset viewer.