summaryrefslogtreecommitdiff
path: root/src/cairo-atomic.c
Commit message (Collapse)AuthorAgeFilesLines
* sizeof(cairo_atomic_int_t) should be sizeof(int)Fujii Hironori2023-01-111-11/+23
| | | | | | | | | | | | | | | | `_cairo_status_set_error` was using `_cairo_atomic_int_cmpxchg` to set a `cairo_status_t` variable by casting a `cairo_status_t*` to `cairo_atomic_int_t*`. `cairo_atomic_int` has a generic implementation which is using a mutex. In the implementation, `cairo_atomic_int_t` was typedef-ed to `cairo_atomic_intptr_t`. In a typical 64bit system, cairo_atomic_intptr_t is 64bit and cairo_status_t is 32bit, _cairo_status_set_error didn't work as expected. Define `cairo_atomic_int_t` as an alias of `int`. Added an assertion in `_cairo_status_set_error` to ensure that `*err` has the same size with `cairo_atomic_int_t`. Fixes cairo/cairo#606
* Fix data race in freed_poolWan-Teh Chang2016-03-051-0/+14
| | | | | | | | | | | This adds _cairo_atomic_int_get_relaxed and _cairo_atomic_int_set_relaxed which are meant to have a behaviour of relaxed read/writes in C11's memory model. This patch also uses these new function to fix a data race with freed_pool_t's |top| data member. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=90318 Signed-off-by: Wan-Teh Chang <wtc@google.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
* atomic: Tweak for compilation x86.Chris Wilson2010-04-291-8/+8
| | | | Missing definition of _cairo_atomic_ptr_get() used in the fallbacks.
* atomic: Separate bool and old-value compare-and-exchangeAndrea Canciani2010-04-291-2/+2
| | | | | | | | | | | | | Some implementations only offer one version of compare-and-exchange, thus we expose both through cairo-atomic, implementing what is missing through appropriate fallbacks. *_cmpxchg() now return a boolean (this unbreaks _cairo_atomic_uint_cmpxchg) *_cmpxchg_return_old() return the old value Code is updated everywhere to reflect this, by using *_cmpxchg() wherever the returned value was only tested to check if the exchange had really taken place. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* atomic: Remove unused function _cairo_atomic_int_set()Andrea Canciani2010-04-291-8/+0
| | | | | | | _cairo_atomic_int_set() was only used in the definition of CAIRO_REFERENCE_SET_VALUE, which was never used. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* Update FSF addressAndrea Canciani2010-04-271-1/+1
| | | | | | | | | | | I updated the Free Software Foundation address using the following script. for i in $(git grep Temple | cut -d: -f1 ) do sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i" done Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
* atomic: Fix up compile on PPC with libatomic-opsChris Wilson2010-01-291-1/+2
|
* [atomic] Use an integer __sync_val_compare_and_swap() for pointer CAS.M Joonas Pihlaja2009-06-211-1/+5
| | | | | | | | | | | Fix an implicit pointer/integer cast in _cairo_atomic_ptr_cmpxchg() when building with LLVM/clang. The Intel synchronization primitives __sync_val_compare_and_swap() are only defined by Intel for types int, long, long long and their unsigned variants. This patch uses one of those for _cairo_atomic_ptr_cmpxchg() instead of relying on a gcc extension of __sync_val_compare_and_swap() to pointer types.
* [atomic] Provide mutex-based ptr cmpxchgChris Wilson2009-06-051-0/+13
| | | | To handle those CPUs where we do not have an atomic cmpxchg.
* Make sure feature macros are checked using #if, not #ifdef; add a test for itBehdad Esfahbod2008-09-201-1/+1
| | | | | This is more robust to cases where people want to assign 0 to those variables. (win32/alternate build systems, etc)
* Cleanup configure.in macrosBehdad Esfahbod2008-09-041-1/+1
|
* [cairo-atomic] Rearrange code under the correct ifdefs.Chris Wilson2007-11-011-11/+13
| | | | | The atomic get/set depend upon NEED_MEMORY_BARRIER which is separate from HAVE_ATOMIC_OPS.
* [cairo-atomic] Use an atomic operation to set the status on a shared resource.Chris Wilson2007-10-041-0/+15
| | | | | | | | Since the objects can be shared and may be in use simultaneously across multiple threads, setting the status needs to be atomic. We use a locked compare and exchange in order to avoid overwriting an existing error - that is we use an atomic operation that only sets the new status value if the current value is CAIRO_STATUS_SUCCESS.
* [cairo-atomic] Introduce atomic ops.Chris Wilson2007-09-251-0/+79
Test for the availability of the Intel __sync_* atomic primitives and use them to define a few operations useful for reference counting - providing a generic interface that may be targeted at more architectures in the future. If no atomic primitives are available, use a mutex based variant. If the contention on that mutex is too high, we can consider using an array of mutexes using the address of the atomic variable as the hash.