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
d635ae4e
Commit
d635ae4e
authored
Sep 18, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GCC atomics
parent
e3d6b0ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
src/libvlc.c
src/libvlc.c
+21
-7
No files found.
src/libvlc.c
View file @
d635ae4e
...
...
@@ -118,11 +118,15 @@ void *vlc_gc_init (gc_object_t *p_gc, void (*pf_destruct) (gc_object_t *))
{
p_gc
->
pf_destructor
=
pf_destruct
;
p_gc
->
refs
=
1
;
#ifdef __GNUC__
__sync_synchronize
();
#else
/* Nobody else can possibly lock the spin - it's there as a barrier */
vlc_spin_init
(
&
p_gc
->
spin
);
vlc_spin_lock
(
&
p_gc
->
spin
);
p_gc
->
refs
=
1
;
vlc_spin_unlock
(
&
p_gc
->
spin
);
#endif
return
p_gc
;
}
...
...
@@ -133,12 +137,17 @@ void *vlc_gc_init (gc_object_t *p_gc, void (*pf_destruct) (gc_object_t *))
*/
void
*
vlc_hold
(
gc_object_t
*
p_gc
)
{
uintptr_t
refs
;
assert
(
p_gc
);
#ifdef __GNUC__
refs
=
__sync_fetch_and_add
(
&
p_gc
->
refs
,
1
);
#else
vlc_spin_lock
(
&
p_gc
->
spin
);
assert
(
p_gc
->
refs
>
0
);
p_gc
->
refs
++
;
refs
=
p_gc
->
refs
++
;
vlc_spin_unlock
(
&
p_gc
->
spin
);
#endif
assert
(
refs
>
0
);
return
p_gc
;
}
...
...
@@ -148,15 +157,20 @@ void *vlc_hold (gc_object_t * p_gc)
*/
void
vlc_release
(
gc_object_t
*
p_gc
)
{
bool
dead
;
unsigned
refs
;
assert
(
p_gc
);
#ifdef __GNUC__
refs
=
__sync_fetch_and_sub
(
&
p_gc
->
refs
,
1
);
#else
vlc_spin_lock
(
&
p_gc
->
spin
);
assert
(
p_gc
->
refs
>
0
);
dead
=
!--
p_gc
->
refs
;
refs
=
p_gc
->
refs
--
;
vlc_spin_unlock
(
&
p_gc
->
spin
);
#endif
if
(
dead
)
assert
(
refs
>
0
);
if
(
refs
==
1
)
{
vlc_spin_destroy
(
&
p_gc
->
spin
);
p_gc
->
pf_destructor
(
p_gc
);
...
...
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