QtBase  v6.3.1
config.h
Go to the documentation of this file.
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 #ifndef QHARFBUZZ_CONFIG_H
26 #define QHARFBUZZ_CONFIG_H
27 
28 #include <QtCore/qatomic.h>
29 
31 
32 namespace {
33 
34 // We need to cast hb_atomic_int_t to QAtomicInt and pointers to
35 // QAtomicPointer instead of using QAtomicOps, otherwise we get a failed
36 // overload resolution of the template arguments for testAndSetOrdered.
37 template <typename T>
38 inline QAtomicPointer<T> *makeAtomicPointer(T * const &ptr)
39 {
40  return reinterpret_cast<QAtomicPointer<T> *>(const_cast<T **>(&ptr));
41 }
42 
43 static inline void _hb_memory_barrier ()
44 {
45  QAtomicInt a;
46  a.ref(); // Ordered memory semantics, so imposes a memory barrier at this point
47 }
48 
49 } // namespace
50 
52 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
53 #define hb_atomic_int_impl_add(AI, V) reinterpret_cast<QAtomicInt *>(AI)->fetchAndAddOrdered(V)
54 
55 #define hb_atomic_ptr_impl_get(P) makeAtomicPointer(*(P))->loadAcquire()
56 #define hb_atomic_ptr_impl_cmpexch(P,O,N) makeAtomicPointer(*(P))->testAndSetOrdered((O), (N))
57 
58 #endif // QHARFBUZZ_CONFIG_H
The QAtomicInt class provides platform-independent atomic operations on int.
Definition: qatomic.h:158
The QAtomicPointer class is a template class that provides platform-independent atomic operations on ...
Definition: qatomic.h:172
int hb_atomic_int_impl_t
Definition: config.h:51
QAtomicPointer< T > * makeAtomicPointer(T *const &ptr)
Definition: config.h:38
GLboolean GLboolean GLboolean GLboolean a
[7]
Definition: main.cpp:38