Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
450
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
876bb0e0
Commit
876bb0e0
authored
4 years ago
by
Hugo Beauzée-Luyssen
Browse files
Options
Downloads
Patches
Plain Diff
vlc_atomic.h: Allow inclusion when building C++
parent
5a6b9d32
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/vlc_atomic.h
+12
-7
12 additions, 7 deletions
include/vlc_atomic.h
with
12 additions
and
7 deletions
include/vlc_atomic.h
+
12
−
7
View file @
876bb0e0
...
...
@@ -18,10 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef __cplusplus
# error Not implemented in C++.
#endif
#ifndef VLC_ATOMIC_H
# define VLC_ATOMIC_H
...
...
@@ -31,7 +27,14 @@
*/
# include <assert.h>
#ifndef __cplusplus
# include <stdatomic.h>
#else
# include <atomic>
using
std
::
atomic_uintptr_t
;
using
std
::
memory_order_relaxed
;
using
std
::
memory_order_acq_rel
;
#endif
# include <vlc_common.h>
typedef
struct
vlc_atomic_rc_t
{
...
...
@@ -41,13 +44,14 @@ typedef struct vlc_atomic_rc_t {
/** Init the RC to 1 */
static
inline
void
vlc_atomic_rc_init
(
vlc_atomic_rc_t
*
rc
)
{
atomic_init
(
&
rc
->
refs
,
1
);
atomic_init
(
&
rc
->
refs
,
(
uintptr_t
)
1
);
}
/** Increment the RC */
static
inline
void
vlc_atomic_rc_inc
(
vlc_atomic_rc_t
*
rc
)
{
uintptr_t
prev
=
atomic_fetch_add_explicit
(
&
rc
->
refs
,
1
,
memory_order_relaxed
);
uintptr_t
prev
=
atomic_fetch_add_explicit
(
&
rc
->
refs
,
(
uintptr_t
)
1
,
memory_order_relaxed
);
vlc_assert
(
prev
);
VLC_UNUSED
(
prev
);
}
...
...
@@ -55,7 +59,8 @@ static inline void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
/** Decrement the RC and return true if it reaches 0 */
static
inline
bool
vlc_atomic_rc_dec
(
vlc_atomic_rc_t
*
rc
)
{
uintptr_t
prev
=
atomic_fetch_sub_explicit
(
&
rc
->
refs
,
1
,
memory_order_acq_rel
);
uintptr_t
prev
=
atomic_fetch_sub_explicit
(
&
rc
->
refs
,
(
uintptr_t
)
1
,
memory_order_acq_rel
);
vlc_assert
(
prev
);
return
prev
==
1
;
}
...
...
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