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>
This commit is contained in:
Thiago Macieira 2015-02-01 14:31:55 -02:00
parent e024eb55c6
commit d6ce94ae63
2 changed files with 21 additions and 2 deletions

View File

@ -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 \

View File

@ -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__))