Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
6df25e80
Commit
6df25e80
authored
Nov 14, 1998
by
Rein Klazes
Committed by
Alexandre Julliard
Nov 14, 1998
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added implementations for InterlockedExchangeAdd() and
InterlockedCompareExchange().
parent
7b06d984
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
3 deletions
+72
-3
kernel32.spec
relay32/kernel32.spec
+2
-2
thread.c
win32/thread.c
+70
-1
No files found.
relay32/kernel32.spec
View file @
6df25e80
...
...
@@ -893,8 +893,8 @@ init MAIN_KernelInit
875 stdcall GetFileAttributesExW(wstr long ptr) GetFileAttributesEx32W
876 stub GetProcessPriorityBoost
877 stub GetThreadPriorityBoost
878 st
ub
InterlockedCompareExchange
879 st
ub
InterlockedExchangeAdd
878 st
dcall InterlockedCompareExchange (ptr long long)
InterlockedCompareExchange
879 st
dcall InterlockedExchangeAdd (ptr long )
InterlockedExchangeAdd
880 stdcall IsProcessorFeaturePresent(long) IsProcessorFeaturePresent
881 stub OpenWaitableTimerA
882 stub OpenWaitableTimerW
...
...
win32/thread.c
View file @
6df25e80
...
...
@@ -7,7 +7,7 @@
#include <unistd.h>
#include <string.h>
#include "win
dows
.h"
#include "win
nt
.h"
#include "winbase.h"
#include "winerror.h"
#include "debug.h"
...
...
@@ -131,3 +131,72 @@ LONG WINAPI InterlockedExchange(
return
ret
;
#endif
}
/************************************************************************
* InterlockedCompareExchange [KERNEL32.879]
*
* Atomically compares Destination and Comperand, and if found equal exchanges
* the value of Destination with Exchange
*
* RETURNS
* Prior value of value pointed to by Destination
*/
PVOID
WINAPI
InterlockedCompareExchange
(
PVOID
*
Destination
,
/* Address of 32-bit value to exchange */
PVOID
Exchange
,
/* change value, 32 bits */
PVOID
Comperand
/* value to compare, 32 bits */
)
{
#if defined(__i386__)&&defined(__GNUC__)
PVOID
ret
;
__asm__
(
/* lock for SMP systems */
"lock
\n\t
"
"cmpxchgl %2,(%1)"
:
"=r"
(
ret
)
:
"r"
(
Destination
),
"r"
(
Exchange
),
"0"
(
Comperand
)
:
"memory"
);
return
ret
;
#else
PVOID
ret
;
/* StopAllThreadsAndProcesses() */
ret
=*
Destination
;
if
(
*
Destination
==
Comperand
)
*
Destination
=
Exchange
;
/* ResumeAllThreadsAndProcesses() */
return
ret
;
#endif
}
/************************************************************************
* InterlockedExchangeAdd [KERNEL32.880]
*
* Atomically adds Increment to Addend and returns the previous value of
* Addend
*
* RETURNS
* Prior value of value pointed to by cwAddendTarget
*/
LONG
WINAPI
InterlockedExchangeAdd
(
PLONG
Addend
,
/* Address of 32-bit value to exchange */
LONG
Increment
/* Value to add */
)
{
#if defined(__i386__)&&defined(__GNUC__)
LONG
ret
;
__asm__
(
/* lock for SMP systems */
"lock
\n\t
"
"xaddl %0,(%1)"
:
"=r"
(
ret
)
:
"r"
(
Addend
),
"0"
(
Increment
)
:
"memory"
);
return
ret
;
#else
LONG
ret
;
/* StopAllThreadsAndProcesses() */
ret
=
*
Addend
;
*
Addend
+=
Increment
;
/* ResumeAllThreadsAndProcesses() */
return
ret
;
#endif
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment