diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-02-01 14:31:55 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-02-10 03:21:08 +0000 |
commit | d6ce94ae6367337ade2c590f182b973e2bcfa98c (patch) | |
tree | 793b95b65fb7a8230835d7638092f3ef1e756e27 | |
parent | e024eb55c6eb4582ce22aadec440ada3c9deaab9 (diff) |
Force Harfbuzz-NG to use the Qt atomics when built inside Qt
For most cases, the GCC/Intel atomics (__sync functions) are fine, but
there are some systems for which libgcc is incorrectly built (QNX
6.5.0). Additionally, this will allow Harfbuzz-NG to be supported in
exactly the same systems as Qt itself.
Task-number: QTBUG-43850
Change-Id: Ib53f57f70d4ad46863c45e74d60b0eb45ba9bd02
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
-rw-r--r-- | src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro | 4 | ||||
-rw-r--r-- | src/3rdparty/harfbuzz-ng/src/hb-atomic-private.hh | 19 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro index 6b51d9679a..a8885d71df 100644 --- a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro +++ b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro @@ -7,14 +7,14 @@ CONFIG += \ load(qt_helper_lib) -DEFINES += HAVE_OT HB_NO_UNICODE_FUNCS HB_DISABLE_DEPRECATED +DEFINES += HAVE_OT HAVE_QT5_ATOMICS HB_NO_UNICODE_FUNCS HB_DISABLE_DEPRECATED # platform/compiler specific definitions DEFINES += HAVE_ATEXIT -gcc: DEFINES += HAVE_INTEL_ATOMIC_PRIMITIVES unix: DEFINES += HAVE_PTHREAD HAVE_SCHED_H HAVE_SCHED_YIELD INCLUDEPATH += $$PWD/include +INCLUDEPATH += $$OUT_PWD/../../../include SOURCES += \ $$PWD/src/hb-blob.cc \ diff --git a/src/3rdparty/harfbuzz-ng/src/hb-atomic-private.hh b/src/3rdparty/harfbuzz-ng/src/hb-atomic-private.hh index 60cbcf91be..f15ef09799 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-atomic-private.hh +++ b/src/3rdparty/harfbuzz-ng/src/hb-atomic-private.hh @@ -41,6 +41,25 @@ #if 0 +#elif !defined(HB_NO_MT) && defined(HAVE_QT5_ATOMICS) +#include <QtCore/qatomic.h> + +QT_USE_NAMESPACE + +namespace { +// We need to cast hb_atomic_int_t to QAtomicInt and pointers to +// QAtomicPointer instead of using QAtomicOps, otherwise we get a failed +// overload resolution of the template arguments for testAndSetOrdered. +template <typename T> QAtomicPointer<T> *makeAtomicPointer(T * const &ptr) +{ + return reinterpret_cast<QAtomicPointer<T> *>(const_cast<T **>(&ptr)); +} +} + +typedef int hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) reinterpret_cast<QAtomicInt &>(AI).fetchAndAddOrdered(V) +#define hb_atomic_ptr_get(P) makeAtomicPointer(*P)->loadAcquire() +#define hb_atomic_ptr_cmpexch(P,O,N) makeAtomicPointer(*P)->testAndSetOrdered((O), (N)) #elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) |