Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
192fcc5b
Commit
192fcc5b
authored
Sep 01, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libport: Added an interlocked_cmpxchg128 function for 64-bit.
parent
a60f3273
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
port.h
include/wine/port.h
+20
-0
interlocked.c
libs/port/interlocked.c
+17
-6
No files found.
include/wine/port.h
View file @
192fcc5b
...
...
@@ -412,6 +412,22 @@ extern inline int interlocked_xchg_add( int *dest, int incr )
return
ret
;
}
#ifdef __x86_64__
extern
inline
unsigned
char
interlocked_cmpxchg128
(
__int64
*
dest
,
__int64
xchg_high
,
__int64
xchg_low
,
__int64
*
compare
);
extern
inline
unsigned
char
interlocked_cmpxchg128
(
__int64
*
dest
,
__int64
xchg_high
,
__int64
xchg_low
,
__int64
*
compare
)
{
unsigned
char
ret
;
__asm__
__volatile__
(
"lock cmpxchg16b %0; setz %b2"
:
"=m"
(
dest
[
0
]),
"=m"
(
dest
[
1
]),
"=r"
(
ret
),
"=a"
(
compare
[
0
]),
"=d"
(
compare
[
1
])
:
"m"
(
dest
[
0
]),
"m"
(
dest
[
1
]),
"3"
(
compare
[
0
]),
"4"
(
compare
[
1
]),
"c"
(
xchg_high
),
"b"
(
xchg_low
)
);
return
ret
;
}
#endif
#else
/* __GNUC__ */
extern
int
interlocked_cmpxchg
(
int
*
dest
,
int
xchg
,
int
compare
);
...
...
@@ -420,6 +436,10 @@ extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compa
extern
int
interlocked_xchg
(
int
*
dest
,
int
val
);
extern
void
*
interlocked_xchg_ptr
(
void
**
dest
,
void
*
val
);
extern
int
interlocked_xchg_add
(
int
*
dest
,
int
incr
);
#ifdef _WIN64
extern
unsigned
char
interlocked_cmpxchg128
(
__int64
*
dest
,
__int64
xchg_high
,
__int64
xchg_low
,
__int64
*
compare
);
#endif
#endif
/* __GNUC__ */
...
...
libs/port/interlocked.c
View file @
192fcc5b
...
...
@@ -139,8 +139,6 @@ __declspec(naked) int interlocked_xchg_add( int *dest, int incr )
#elif defined(__x86_64__)
#ifdef __GNUC__
__ASM_GLOBAL_FUNC
(
interlocked_cmpxchg
,
"mov %edx, %eax
\n\t
"
"lock cmpxchgl %esi,(%rdi)
\n\t
"
...
...
@@ -165,10 +163,23 @@ __ASM_GLOBAL_FUNC(interlocked_xchg_add,
"mov %esi, %eax
\n\t
"
"lock xaddl %eax, (%rdi)
\n\t
"
"ret"
)
#else
# error You must implement the interlocked* functions for your compiler
#endif
__ASM_GLOBAL_FUNC
(
interlocked_cmpxchg128
,
"push %rbx
\n\t
"
".cfi_adjust_cfa_offset 8
\n\t
"
".cfi_rel_offset %rbx,0
\n\t
"
"mov %rcx,%r8
\n\t
"
/* compare */
"mov %rdx,%rbx
\n\t
"
/* xchg_low */
"mov %rsi,%rcx
\n\t
"
/* xchg_high */
"mov 0(%r8),%rax
\n\t
"
"mov 8(%r8),%rdx
\n\t
"
"lock cmpxchg16b (%rdi)
\n\t
"
"mov %rax,0(%r8)
\n\t
"
"mov %rdx,8(%r8)
\n\t
"
"setz %al
\n\t
"
"pop %rbx
\n\t
"
".cfi_adjust_cfa_offset -8
\n\t
"
".cfi_same_value %rbx
\n\t
"
"ret"
)
#elif defined(__powerpc__)
void
*
interlocked_cmpxchg_ptr
(
void
**
dest
,
void
*
xchg
,
void
*
compare
)
...
...
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