]> git.sesse.net Git - vlc/blob - src/win32/atomic.c
Atomic operations (currently same ones as in garbage collector)
[vlc] / src / win32 / atomic.c
1 /*****************************************************************************
2  * atomic.c:
3  *****************************************************************************
4  * Copyright (C) 2010 RĂ©mi Denis-Courmont
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24
25 #include <vlc_common.h>
26 #include <vlc_atomic.h>
27
28 uintptr_t vlc_atomic_get (const vlc_atomic_t *atom)
29 {
30     return atom->u;
31 }
32
33 uintptr_t vlc_atomic_set (vlc_atomic_t *atom, uintptr_t v)
34 {
35     atom->u = v;
36     return v;
37 }
38
39 uintptr_t vlc_atomic_add (vlc_atomic_t *atom, uintptr_t v)
40 {
41 #if defined (WIN64)
42     return InterlockedAdd64 (&atom->s, v);
43 #else
44     return InterlockedAdd (&atom->s, v);
45 #endif
46 }