diff --git a/include/mitsuba/core/atomic.h b/include/mitsuba/core/atomic.h new file mode 100644 index 00000000..8d646b8c --- /dev/null +++ b/include/mitsuba/core/atomic.h @@ -0,0 +1,40 @@ +/* + This file is part of Mitsuba, a physically based rendering system. + + Copyright (c) 2007-2010 by Wenzel Jakob and others. + + Mitsuba is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License Version 3 + as published by the Free Software Foundation. + + Mitsuba is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#if !defined(__ATOMIC_H) +#define __ATOMIC_H + +#include + +MTS_NAMESPACE_BEGIN + +#if defined(__OSX__) +#include +#endif + +template inline bool atomicCompareAndExchangePtr(T **v, T *newValue, T *oldValue) { +#if defined(WIN32) + return InterlockedCompareExchange(v, newValue, oldValue) == oldValue; +#else + return __sync_bool_compare_and_swap(v, oldValue, newValue); +#endif +} + +MTS_NAMESPACE_END + +#endif /* __ATOMIC_H */