Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
192fcc5b
Commit
192fcc5b
authored
15 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
libport: Added an interlocked_cmpxchg128 function for 64-bit.
parent
a60f3273
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/wine/port.h
+20
-0
20 additions, 0 deletions
include/wine/port.h
libs/port/interlocked.c
+17
-6
17 additions, 6 deletions
libs/port/interlocked.c
with
37 additions
and
6 deletions
include/wine/port.h
+
20
−
0
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__ */
...
...
This diff is collapsed.
Click to expand it.
libs/port/interlocked.c
+
17
−
6
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment