/*1* Copyright (c) 2012 Ronald S. Bultje <[email protected]>2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVUTIL_ATOMIC_H21#define AVUTIL_ATOMIC_H2223#include "config.h"2425#if HAVE_ATOMICS_NATIVE2627#if HAVE_ATOMICS_GCC28#include "atomic_gcc.h"29#elif HAVE_ATOMICS_WIN3230#include "atomic_win32.h"31#elif HAVE_ATOMICS_SUNCC32#include "atomic_suncc.h"33#endif3435#else3637/**38* Load the current value stored in an atomic integer.39*40* @param ptr atomic integer41* @return the current value of the atomic integer42* @note This acts as a memory barrier.43*/44int avpriv_atomic_int_get(volatile int *ptr);4546/**47* Store a new value in an atomic integer.48*49* @param ptr atomic integer50* @param val the value to store in the atomic integer51* @note This acts as a memory barrier.52*/53void avpriv_atomic_int_set(volatile int *ptr, int val);5455/**56* Add a value to an atomic integer.57*58* @param ptr atomic integer59* @param inc the value to add to the atomic integer (may be negative)60* @return the new value of the atomic integer.61* @note This does NOT act as a memory barrier. This is primarily62* intended for reference counting.63*/64int avpriv_atomic_int_add_and_fetch(volatile int *ptr, int inc);6566/**67* Atomic pointer compare and swap.68*69* @param ptr pointer to the pointer to operate on70* @param oldval do the swap if the current value of *ptr equals to oldval71* @param newval value to replace *ptr with72* @return the value of *ptr before comparison73*/74void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval);7576#endif /* HAVE_ATOMICS_NATIVE */7778#endif /* AVUTIL_ATOMIC_H */798081