summaryrefslogtreecommitdiff
path: root/src/cairo-atomic-private.h
Commit message (Collapse)AuthorAgeFilesLines
* win32: InterlockedCompareExchange uses LONGAdrian Johnson2023-04-131-4/+4
| | | | Fixes #776
* sizeof(cairo_atomic_int_t) should be sizeof(int)Fujii Hironori2023-01-111-3/+5
| | | | | | | | | | | | | | | | `_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 msvc c++ compile errorAdrian Johnson2022-02-271-1/+1
|
* Drop the conditional inclusion of config.hEmmanuele Bassi2021-05-011-3/+1
| | | | | | | | | | | | We *always* generate this file, and we depend on its existence. The idea behind HAVE_CONFIG_H was being able to include random files from different projects, back in a time where "libraries" were literally just random files instead of actual shared objects. Since we're not in the '80s any more, and our build system(s) define HAVE_CONFIG_H *and* generate the config.h header file, we don't need a conditional guard around its inclusion.
* atomic: Add support for WIN32 atomic operationsSeungha Yang2021-04-091-0/+61
| | | | Windows provides atomic operation APIs so use it
* Fix code generation when using GCC legacy atomic operationsMikhail Fludkov2017-11-261-8/+1
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=103559
* Surround initialisations with atomic critical sectionMikhail Fludkov2017-10-151-0/+33
| | | | | | | | | | | | | | | Fixes the race condition when one thread uses cairo_mask_compositor_t pointer returned by _cairo_image_mask_compositor_get, while another one started but has not finished it's initialisation yet Usage: static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT; if (_cairo_atomic_init_once_enter(&once)) { /* Initialization code */ _cairo_atomic_init_once_leave(&once); } https://bugs.freedesktop.org/show_bug.cgi?id=103037
* Fix data race in freed_poolWan-Teh Chang2016-03-051-0/+36
| | | | | | | | | | | 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>
* Support new-style __atomic_* primitivesNathan Froyd2015-06-041-0/+90
| | | | | | | | | | | | | | Recent versions of GCC/clang feature a new set of compiler intrinsics for performing atomic operations, motivated by the operations needed to support the C++11 memory model. These intrinsics are more flexible than the old __sync_* intrinstics and offer efficient support for atomic load and store operations. Having the load appear atomic to the compiler is particular important for tools like ThreadSanitizer so they don't report false positives on memory operations that we intend to be atomic. Patch from Nathan Froyd <froydnj@mozilla.com>
* Introduce a new compositor architectureChris Wilson2011-09-121-0/+5
| | | | | | | | | | | | | | | | | | Having spent the last dev cycle looking at how we could specialize the compositors for various backends, we once again look for the commonalities in order to reduce the duplication. In part this is motivated by the idea that spans is a good interface for both the existent GL backend and pixman, and so they deserve a dedicated compositor. xcb/xlib target an identical rendering system and so they should be using the same compositor, and it should be possible to run that same compositor locally against pixman to generate reference tests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> P.S. This brings massive upheaval (read breakage) I've tried delaying in order to fix as many things as possible but now this one patch does far, far, far too much. Apologies in advance for breaking your favourite backend, but trust me in that the end result will be much better. :)
* Declare variables first so gcc shuts upBenjamin Otte2011-02-191-1/+2
|
* Assert that an error is valid when setBenjamin Otte2011-02-181-0/+1
|
* atomic: Add memory barriers if required for intel primitivesChris Wilson2010-05-201-0/+16
|
* atomic: Add Andrea's copyright noticeChris Wilson2010-04-301-0/+2
| | | | | Note Andrea's copyright for his contribution of platform agnostic fallbacks and the implementation for MacOS/X.
* atomic: Tweak for compilation x86.Chris Wilson2010-04-291-7/+20
| | | | Missing definition of _cairo_atomic_ptr_get() used in the fallbacks.
* atomic: Add MacOSX atomic implementationAndrea Canciani2010-04-291-0/+30
| | | | | | | Enable atomic operation on MacOS X, using the functions provided by libkern/OSAtomic.h Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* atomic: Separate bool and old-value compare-and-exchangeAndrea Canciani2010-04-291-6/+62
| | | | | | | | | | | | | 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-10/+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-2/+0
|
* atomic: correct libatomic_ops version of _cairo_atomic_int_cmpxchgLuo Jinghua2009-10-191-1/+1
| | | | | | AO_compare_and_swap_full() doesn't have the same semantic as _cairo_atomic_int_cmpxchg(). The former returns a TRUE on success FALSE otherwise while the later returns the atomic value.
* [atomic] Fallback to libatomic-ops-devChris Wilson2009-10-151-5/+36
| | | | | Use libatomic-ops-dev in preference to mutex-based atomics, if we do not have the builtin atomic intrinsics available.
* [autoconf] Comment on the SIZEOF_VOID__ -> SIZEOF_VOID_P workaround.M Joonas Pihlaja2009-09-141-0/+2
| | | | Explain where the weird SIZEOF_VOID__ comes from.
* [build] Work around autoconf void* -> VOID__ name conversion bug.M Joonas Pihlaja2009-09-141-0/+4
| | | | | | The autoconf shipping with OpenBSD 4.5 converts sizeof(void*) to SIZEOF_VOID__ rather than SIZEOF_VOID_P. Work around that by defining SIZEOF_VOID_P if required.
* [atomic] Silence compiler warnings by defining an intptr_tChris Wilson2009-06-211-7/+12
| | | | | | Evaulate the integer sizes during configure to find one of the exact same size as a void* to use in the conversion of the atomic ptr cmpxchg to an atomic int cmpxchg.
* [atomic] Use an integer __sync_val_compare_and_swap() for pointer CAS.M Joonas Pihlaja2009-06-211-1/+8
| | | | | | | | | | | 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] Hide compiler warningsChris Wilson2009-06-051-0/+3
| | | | | Add uint variants of _cairo_atomic_int_*() to hide the compiler warnings about sign conversions.
* [atomic] Provide mutex-based ptr cmpxchgChris Wilson2009-06-051-0/+3
| | | | To handle those CPUs where we do not have an atomic cmpxchg.
* [pattern] Generalise the freed pattern poolChris Wilson2009-06-051-0/+1
| | | | | | Also cache recently freed surface and gradient patterns. With thanks to Jonathan Morton for the inspiration and initial pointer pool code for pixman.
* Make sure feature macros are checked using #if, not #ifdef; add a test for itBehdad Esfahbod2008-09-201-2/+2
| | | | | This is more robust to cases where people want to assign 0 to those variables. (win32/alternate build systems, etc)
* Make sure (and check) that all private headers include some cairo header firstBehdad Esfahbod2008-09-191-2/+2
| | | | | | | | | | | | | | | The macros CAIRO_BEGIN_DECLS and CAIRO_END_DECLS are declared in two places: config.h and cairo.h. On Win32 build there is no config.h. So, we can't rely on pulling CAIRO_BEGIN_DECLS from there. Hence, we now: * Not add those declarations to config.h anymore, * Test that every cairo private header includes some other cairo header before any other includes. These two are fairly enough to ensure that cairo.h is seen from all private headers. There's still the case of headers not including any header file at all. I'll fix that later.
* Cleanup configure.in macrosBehdad Esfahbod2008-09-041-6/+7
|
* [cairo-atomic] Check whether we can access int/pointers atomically.Chris Wilson2007-11-051-5/+15
| | | | | | Add a configure check to determine whether the host cpu can read/write cairo_atomic_t without an explicit memory barrier, and update the macros within cairo-atomic-private.h to reflect this knowledge.
* [cairo-atomic] Hide compiler warnings for _cairo_status_set_error().Chris Wilson2007-10-051-2/+6
| | | | | | | gcc treats cairo_status_t as an unsigned integer and so generates a warning when passing it address as signed integer pointer to _cairo_atomic_int_cmpxchg(). Use an ugly cast to hide the warning and similarly to hide the warning about the unused result.
* [cairo-atomic] Use an atomic operation to set the status on a shared resource.Chris Wilson2007-10-041-0/+8
| | | | | | | | 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/+81
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.