Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
9c077c0d
Commit
9c077c0d
authored
Nov 29, 2013
by
Felix Abecassis
Committed by
Jean-Baptiste Kempf
Nov 30, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement atomic operations for MSVC using the Interlocked API.
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
8cc8898b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
include/vlc_atomic.h
include/vlc_atomic.h
+80
-0
No files found.
include/vlc_atomic.h
View file @
9c077c0d
...
...
@@ -302,6 +302,86 @@ typedef uintmax_t atomic_uintmax_t;
# define atomic_flag_clear_explicit(object,order) \
atomic_flag_clear(object)
# elif defined (_MSC_VER)
/*** Use the Interlocked API. ***/
/* Define macros in order to dispatch to the correct function depending on the type.
Several ranges are need because some operations are not implemented for all types. */
# define atomic_type_dispatch_32_64(operation, object, ...) \
(sizeof(*object) == 4 ? operation(object, __VA_ARGS__) : \
sizeof(*object) == 8 ? operation##64(object, __VA_ARGS__) : \
(abort(), 0))
# define atomic_type_dispatch_16_64(operation, object, ...) \
(sizeof(*object) == 2 ? operation##16(object, __VA_ARGS__) : \
atomic_type_dispatch_32_64(operation, object, __VA_ARGS__))
# define atomic_type_dispatch_8_64(operation, object, ...) \
(sizeof(*object) == 1 ? operation##8(object, __VA_ARGS__) : \
atomic_type_dispatch_16_64(operation, object, __VA_ARGS__))
# define atomic_store(object,desired) \
atomic_type_dispatch_8_64(InterlockedExchange, object, desired)
# define atomic_store_explicit(object,desired,order) \
atomic_store(object, desired)
# define atomic_load(object) \
atomic_type_dispatch_16_64(InterlockedCompareExchange, object, 0, 0)
# define atomic_load_explicit(object,order) \
atomic_load(object)
# define atomic_exchange(object,desired) \
atomic_type_dispatch_8_64(InterlockedExchange, object, desired)
# define atomic_exchange_explicit(object,desired,order) \
atomic_exchange(object, desired)
# define atomic_compare_exchange_strong(object,expected,desired) \
atomic_type_dispatch_16_64(InterlockedCompareExchange, object, expected, desired) == expected
# define atomic_compare_exchange_strong_explicit(object,expected,desired,order) \
atomic_compare_exchange_strong(object, expected, desired)
# define atomic_compare_exchange_weak(object,expected,desired) \
atomic_compare_exchange_strong(object, expected, desired)
# define atomic_compare_exchange_weak_explicit(object,expected,desired,order) \
atomic_compare_exchange_weak(object, expected, desired)
# define atomic_fetch_add(object,operand) \
atomic_type_dispatch_32_64(InterlockedExchangeAdd, object, operand)
# define atomic_fetch_add_explicit(object,operand,order) \
atomic_fetch_add(object, operand)
# define atomic_fetch_sub(object,operand) \
atomic_type_dispatch_32_64(InterlockedExchangeAdd, object, -operand)
# define atomic_fetch_sub_explicit(object,operand,order) \
atomic_fetch_sub(object, operand)
# define atomic_fetch_or(object,operand) \
atomic_type_dispatch_8_64(InterlockedOr, object, operand)
# define atomic_fetch_or_explicit(object,operand,order) \
atomic_fetch_or(object, operand)
# define atomic_fetch_xor(object,operand) \
atomic_type_dispatch_8_64(InterlockedXor, object, operand)
# define atomic_fetch_xor_explicit(object,operand,order) \
atomic_fetch_sub(object, operand)
# define atomic_fetch_and(object,operand) \
atomic_type_dispatch_8_64(InterlockedAnd, object, operand)
# define atomic_fetch_and_explicit(object,operand,order) \
atomic_fetch_and(object, operand)
# define atomic_flag_test_and_set(object) \
atomic_exchange(object, true)
# define atomic_flag_test_and_set_explicit(object,order) \
atomic_flag_test_and_set(object)
# define atomic_flag_clear(object) \
atomic_store(object, false)
# define atomic_flag_clear_explicit(object,order) \
atomic_flag_clear(object)
# else
# error FIXME: implement atomic operations for this compiler.
# 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