1 /* 2 This file is part of darktable, 3 Copyright (C) 2020 darktable developers. 4 5 darktable is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 darktable is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with darktable. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #include "common/atomic.h" 20 21 extern inline void dt_atomic_set_int(dt_atomic_int *var, int value); 22 extern inline int dt_atomic_get_int(dt_atomic_int *var); 23 extern inline int dt_atomic_add_int(dt_atomic_int *var, int incr); 24 extern inline int dt_atomic_sub_int(dt_atomic_int *var, int decr); 25 extern inline int dt_atomic_exch_int(dt_atomic_int *var, int value); 26 extern inline int dt_atomic_CAS_int(dt_atomic_int *var, int *expected, int value); 27 28 #if !defined(__STDC_NO_ATOMICS__) 29 // using C11 atomics, everything is handled in the header file, so we don't need to define anything in this file 30 31 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNU_MINOR__ >= 8)) 32 // using GNU intrinsics. everything is handled in the header file 33 34 #else 35 // we fell back to using a global mutex for synchronization 36 // this is that mutex's definition 37 pthread_mutex_t dt_atom_mutex = PTHREAD_MUTEX_INITIALIZER; 38 39 #endif // __STDC_NO_ATOMICS__ 40