]> git.sesse.net Git - vlc/blob - include/vlc_atomic.h
Use var_Inherit* instead of var_CreateGet*.
[vlc] / include / vlc_atomic.h
1 /*****************************************************************************
2  * vlc_atomic.h:
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 #ifndef VLC_ATOMIC_H
22 # define VLC_ATOMIC_H
23
24 /**
25  * \file
26  * Atomic operations do not require locking, but they are not very powerful.
27  */
28
29 /* All functions return the atom value _after_ the operation. */
30
31 VLC_EXPORT(uintptr_t, vlc_atomic_get, (const vlc_atomic_t *));
32 VLC_EXPORT(uintptr_t, vlc_atomic_set, (vlc_atomic_t *, uintptr_t));
33 VLC_EXPORT(uintptr_t, vlc_atomic_add, (vlc_atomic_t *, uintptr_t));
34
35 static inline uintptr_t vlc_atomic_sub (vlc_atomic_t *atom, uintptr_t v)
36 {
37     return vlc_atomic_add (atom, -v);
38 }
39
40 static inline uintptr_t vlc_atomic_inc (vlc_atomic_t *atom)
41 {
42     return vlc_atomic_add (atom, 1);
43 }
44
45 static inline uintptr_t vlc_atomic_dec (vlc_atomic_t *atom)
46 {
47     return vlc_atomic_sub (atom, 1);
48 }
49
50 #endif