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
bfaf23bf
Commit
bfaf23bf
authored
Apr 16, 2013
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include: Use gcc atomic builtins to implement interlocked inlines on non-i386.
parent
1ce059d6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
96 deletions
+59
-96
winbase.h
include/winbase.h
+59
-96
No files found.
include/winbase.h
View file @
bfaf23bf
...
...
@@ -2501,146 +2501,109 @@ static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest
WINBASEAPI
LONGLONG
WINAPI
InterlockedCompareExchange64
(
LONGLONG
volatile
*
,
LONGLONG
,
LONGLONG
);
#el
se
/* __i386__ */
#el
if defined(_MSC_VER)
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedCompareExchange)
#endif
#pragma intrinsic(_InterlockedCompareExchangePointer)
#pragma intrinsic(_InterlockedCompareExchange64)
#pragma intrinsic(_InterlockedExchange)
#pragma intrinsic(_InterlockedExchangePointer)
#pragma intrinsic(_InterlockedExchangeAdd)
#pragma intrinsic(_InterlockedIncrement)
#pragma intrinsic(_InterlockedDecrement)
static
FORCEINLINE
LONG
WINAPI
InterlockedCompareExchange
(
LONG
volatile
*
dest
,
LONG
xchg
,
LONG
compare
)
{
#if defined(__x86_64__) && defined(__GNUC__)
LONG
ret
;
__asm__
__volatile__
(
"lock; cmpxchgl %2,(%1)"
:
"=a"
(
ret
)
:
"r"
(
dest
),
"r"
(
xchg
),
"0"
(
compare
)
:
"memory"
);
return
ret
;
#elif defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedCompareExchange
(
dest
,
xchg
,
compare
);
#else
extern
int
interlocked_cmpxchg
(
int
*
dest
,
int
xchg
,
int
compare
);
return
interlocked_cmpxchg
(
(
int
*
)
dest
,
xchg
,
compare
);
#endif
}
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedCompareExchangePointer)
#endif
static
FORCEINLINE
PVOID
WINAPI
InterlockedCompareExchangePointer
(
PVOID
volatile
*
dest
,
PVOID
xchg
,
PVOID
compare
)
{
#if defined(__x86_64__) && defined(__GNUC__)
PVOID
ret
;
__asm__
__volatile__
(
"lock; cmpxchgq %2,(%1)"
:
"=a"
(
ret
)
:
"r"
(
dest
),
"r"
(
xchg
),
"0"
(
compare
)
:
"memory"
);
return
ret
;
#elif defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedCompareExchangePointer
(
dest
,
xchg
,
compare
);
#else
extern
void
*
interlocked_cmpxchg_ptr
(
void
**
dest
,
void
*
xchg
,
void
*
compare
);
return
interlocked_cmpxchg_ptr
(
(
void
**
)
dest
,
xchg
,
compare
);
#endif
}
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedCompareExchange64)
#endif
static
FORCEINLINE
LONGLONG
WINAPI
InterlockedCompareExchange64
(
LONGLONG
volatile
*
dest
,
LONGLONG
xchg
,
LONGLONG
compare
)
{
#if defined(__x86_64__) && defined(__GNUC__)
LONGLONG
ret
;
__asm__
__volatile__
(
"lock; cmpxchgq %2,(%1)"
:
"=a"
(
ret
)
:
"r"
(
dest
),
"r"
(
xchg
),
"0"
(
compare
)
:
"memory"
);
return
ret
;
#elif defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedCompareExchange64
(
dest
,
xchg
,
compare
);
#else
extern
__int64
interlocked_cmpxchg64
(
__int64
*
dest
,
__int64
xchg
,
__int64
compare
);
return
interlocked_cmpxchg64
(
(
__int64
*
)
dest
,
xchg
,
compare
);
#endif
}
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedExchange)
#endif
static
FORCEINLINE
LONG
WINAPI
InterlockedExchange
(
LONG
volatile
*
dest
,
LONG
val
)
{
#if defined(__x86_64__) && defined(__GNUC__)
LONG
ret
;
__asm__
__volatile__
(
"lock; xchgl %0,(%1)"
:
"=r"
(
ret
)
:
"r"
(
dest
),
"0"
(
val
)
:
"memory"
);
return
ret
;
#elif defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedExchange
(
dest
,
val
);
#else
extern
int
interlocked_xchg
(
int
*
dest
,
int
val
);
return
interlocked_xchg
(
(
int
*
)
dest
,
val
);
#endif
}
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedExchangePointer)
#endif
static
FORCEINLINE
PVOID
WINAPI
InterlockedExchangePointer
(
PVOID
volatile
*
dest
,
PVOID
val
)
{
#if defined(__x86_64__) && defined(__GNUC__)
PVOID
ret
;
__asm__
__volatile__
(
"lock; xchgq %0,(%1)"
:
"=r"
(
ret
)
:
"r"
(
dest
),
"0"
(
val
)
:
"memory"
);
return
ret
;
#elif defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedExchangePointer
(
dest
,
val
);
#else
extern
void
*
interlocked_xchg_ptr
(
void
**
dest
,
void
*
val
);
return
interlocked_xchg_ptr
(
(
void
**
)
dest
,
val
);
#endif
}
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedExchangeAdd)
#endif
static
FORCEINLINE
LONG
WINAPI
InterlockedExchangeAdd
(
LONG
volatile
*
dest
,
LONG
incr
)
{
#if defined(__x86_64__) && defined(__GNUC__)
LONG
ret
;
__asm__
__volatile__
(
"lock; xaddl %0,(%1)"
:
"=r"
(
ret
)
:
"r"
(
dest
),
"0"
(
incr
)
:
"memory"
);
return
ret
;
#elif defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedExchangeAdd
(
dest
,
incr
);
#else
extern
int
interlocked_xchg_add
(
int
*
dest
,
int
incr
);
return
interlocked_xchg_add
(
(
int
*
)
dest
,
incr
);
#endif
}
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedIncrement)
#endif
static
FORCEINLINE
LONG
WINAPI
InterlockedIncrement
(
LONG
volatile
*
dest
)
{
#if defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedIncrement
(
dest
);
}
static
FORCEINLINE
LONG
WINAPI
InterlockedDecrement
(
LONG
volatile
*
dest
)
{
return
_InterlockedDecrement
(
dest
);
}
#elif defined(__GNUC__)
static
FORCEINLINE
LONG
WINAPI
InterlockedCompareExchange
(
LONG
volatile
*
dest
,
LONG
xchg
,
LONG
compare
)
{
return
__sync_val_compare_and_swap
(
dest
,
compare
,
xchg
);
}
static
FORCEINLINE
PVOID
WINAPI
InterlockedCompareExchangePointer
(
PVOID
volatile
*
dest
,
PVOID
xchg
,
PVOID
compare
)
{
return
__sync_val_compare_and_swap
(
dest
,
compare
,
xchg
);
}
static
FORCEINLINE
LONGLONG
WINAPI
InterlockedCompareExchange64
(
LONGLONG
volatile
*
dest
,
LONGLONG
xchg
,
LONGLONG
compare
)
{
return
__sync_val_compare_and_swap
(
dest
,
compare
,
xchg
);
}
static
FORCEINLINE
LONG
WINAPI
InterlockedExchange
(
LONG
volatile
*
dest
,
LONG
val
)
{
LONG
ret
;
#ifdef __x86_64__
__asm__
__volatile__
(
"lock; xchgl %0,(%1)"
:
"=r"
(
ret
)
:
"r"
(
dest
),
"0"
(
val
)
:
"memory"
);
#else
return
InterlockedExchangeAdd
(
dest
,
1
)
+
1
;
do
ret
=
*
dest
;
while
(
!
__sync_bool_compare_and_swap
(
dest
,
ret
,
val
))
;
#endif
return
ret
;
}
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedDecrement)
static
FORCEINLINE
PVOID
WINAPI
InterlockedExchangePointer
(
PVOID
volatile
*
dest
,
PVOID
val
)
{
PVOID
ret
;
#ifdef __x86_64__
__asm__
__volatile__
(
"lock; xchgq %0,(%1)"
:
"=r"
(
ret
)
:
"r"
(
dest
),
"0"
(
val
)
:
"memory"
);
#else
do
ret
=
*
dest
;
while
(
!
__sync_bool_compare_and_swap
(
dest
,
ret
,
val
));
#endif
return
ret
;
}
static
FORCEINLINE
LONG
WINAPI
InterlockedExchangeAdd
(
LONG
volatile
*
dest
,
LONG
incr
)
{
return
__sync_fetch_and_add
(
dest
,
incr
);
}
static
FORCEINLINE
LONG
WINAPI
InterlockedIncrement
(
LONG
volatile
*
dest
)
{
return
__sync_add_and_fetch
(
dest
,
1
);
}
static
FORCEINLINE
LONG
WINAPI
InterlockedDecrement
(
LONG
volatile
*
dest
)
{
#if defined(__x86_64__) && defined(_MSC_VER)
return
_InterlockedDecrement
(
dest
);
#else
return
InterlockedExchangeAdd
(
dest
,
-
1
)
-
1
;
#endif
return
__sync_add_and_fetch
(
dest
,
-
1
);
}
#endif
/* __i386__ */
...
...
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