1/*
2* Copyright (C) 2015 The Qt Company Ltd.
3* Copyright (C) 2015 Konstantin Ritt
4*
5* Permission is hereby granted, without written agreement and without
6* license or royalty fees, to use, copy, modify, and distribute this
7* software and its documentation for any purpose, provided that the
8* above copyright notice and the following two paragraphs appear in
9* all copies of this software.
10*
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
12* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
13* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
14* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
15* DAMAGE.
16*
17* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
18* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
20* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
21* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
22*
23*/
24
25#include <QtCore/qatomic.h>
26
27QT_USE_NAMESPACE
28
29namespace {
30
31// We need to cast hb_atomic_int_t to QAtomicInt and pointers to
32// QAtomicPointer instead of using QAtomicOps, otherwise we get a failed
33// overload resolution of the template arguments for testAndSetOrdered.
34template <typename T>
35inline QAtomicPointer<T> *makeAtomicPointer(T * const &ptr)
36{
37 return reinterpret_cast<QAtomicPointer<T> *>(const_cast<T **>(&ptr));
38}
39
40} // namespace
41
42typedef int hb_atomic_int_impl_t;
43#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
44#define hb_atomic_int_impl_add(AI, V) reinterpret_cast<QAtomicInt &>(AI).fetchAndAddOrdered(V)
45
46#define hb_atomic_ptr_impl_get(P) makeAtomicPointer(*(P))->loadAcquire()
47#define hb_atomic_ptr_impl_cmpexch(P,O,N) makeAtomicPointer(*(P))->testAndSetOrdered((O), (N))
48

source code of qtbase/src/3rdparty/harfbuzz-ng/config.h