vlc_atomic.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_atomic.h:
00003  *****************************************************************************
00004  * Copyright (C) 2010 Rémi Denis-Courmont
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00019  *****************************************************************************/
00020 
00021 #ifndef VLC_ATOMIC_H
00022 # define VLC_ATOMIC_H
00023 
00024 /**
00025  * \file
00026  * Atomic operations do not require locking, but they are not very powerful.
00027  */
00028 
00029 /* All functions return the atom value _after_ the operation. */
00030 
00031 VLC_EXPORT(uintptr_t, vlc_atomic_get, (const vlc_atomic_t *));
00032 VLC_EXPORT(uintptr_t, vlc_atomic_set, (vlc_atomic_t *, uintptr_t));
00033 VLC_EXPORT(uintptr_t, vlc_atomic_add, (vlc_atomic_t *, uintptr_t));
00034 
00035 static inline uintptr_t vlc_atomic_sub (vlc_atomic_t *atom, uintptr_t v)
00036 {
00037     return vlc_atomic_add (atom, -v);
00038 }
00039 
00040 static inline uintptr_t vlc_atomic_inc (vlc_atomic_t *atom)
00041 {
00042     return vlc_atomic_add (atom, 1);
00043 }
00044 
00045 static inline uintptr_t vlc_atomic_dec (vlc_atomic_t *atom)
00046 {
00047     return vlc_atomic_sub (atom, 1);
00048 }
00049 
00050 #endif

Generated on Mon Nov 22 07:55:19 2010 for VLC by  doxygen 1.5.6