Merge lp:~loic.molinari/ubuntu-ui-toolkit/uitk-aligned-alloc-for-apple-and-win32 into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Superseded
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/uitk-aligned-alloc-for-apple-and-win32
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 261 lines (+91/-24)
12 files modified
.qmake.conf (+9/-0)
features/ubuntu_common.prf (+25/-13)
features/ubuntu_qml_plugin.prf (+4/-0)
features/ubuntu_qt_module.prf (+4/-0)
src/UbuntuMetrics/UbuntuMetrics.pro (+2/-1)
src/UbuntuMetrics/applicationmonitor.cpp (+1/-1)
src/UbuntuMetrics/events.cpp (+2/-2)
src/UbuntuMetrics/logger.h (+2/-2)
src/UbuntuMetrics/overlay.cpp (+1/-1)
src/UbuntuMetrics/ubuntumetricsglobal.cpp (+34/-0)
src/UbuntuMetrics/ubuntumetricsglobal_p.h (+4/-0)
src/UbuntuToolkit/unitythemeiconprovider.cpp (+3/-4)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/uitk-aligned-alloc-for-apple-and-win32
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Zsombor Egri Pending
Review via email: mp+306471@code.launchpad.net

Commit message

Added aligned alloc support for Apple and Windows.

Description of the change

Added aligned alloc support for Apple and Windows.

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.qmake.conf'
2--- .qmake.conf 2016-09-15 15:25:54 +0000
3+++ .qmake.conf 2016-09-22 14:19:53 +0000
4@@ -15,6 +15,15 @@
5
6 exists($$PWD/../qt.pro): CONFIG += qt_submodule_build
7
8+# Set QT_CLANG_*_VERSION if not defined to make internal qmake features
9+# (warnings_are_errors and others) work since these variables are defined only
10+# when clang is chosen as compiler at configure time. The regexp is based on the
11+# Qt one used in the qtbase configure script.
12+clang:!defined(QT_CLANG_MAJOR_VERSION, var) {
13+ QT_CLANG_MAJOR_VERSION = $$system("clang -v 2>&1 | sed -n -E '/^clang version /{s///; s/^([0-9]*)\.([0-9]*).*$/\1/;p;q;}'")
14+ QT_CLANG_MINOR_VERSION = $$system("clang -v 2>&1 | sed -n -E '/^clang version /{s///; s/^([0-9]*)\.([0-9]*).*$/\2/;p;q;}'")
15+}
16+
17 # FIXME: Fix bug 1606247 and enable the UbuntuToolkit namespace.
18 # build UbuntuToolkit without namespace
19 DEFINES += UBUNTUTOOLKIT_NO_NAMESPACE
20
21=== modified file 'features/ubuntu_common.prf'
22--- features/ubuntu_common.prf 2016-09-15 15:37:57 +0000
23+++ features/ubuntu_common.prf 2016-09-22 14:19:53 +0000
24@@ -13,27 +13,39 @@
25 # order to workaround these issues, we unset these variables and set the
26 # different flags apart from -g and -O2 in the right qmake variables. This
27 # allows to keep compiling with the Debian flags but in a more flexible way.
28-gcc:!qt_submodule_build:!debian_build {
29- QMAKE_CFLAGS = -fstack-protector
30- QMAKE_CXXFLAGS = -fstack-protector
31+!qt_submodule_build:!debian_build {
32+ gcc:!clang {
33+ QMAKE_CFLAGS = -fstack-protector
34+ QMAKE_CXXFLAGS = -fstack-protector
35+ QMAKE_CXXFLAGS_WARN_ON += -Wdate-time -Wformat -Werror=format-security
36+ QMAKE_LFLAGS_SHLIB += -Wl,-z,relro
37+ DEFINES += _FORTIFY_SOURCE=2
38+ unix:!contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions
39+ } else {
40+ QMAKE_CFLAGS =
41+ QMAKE_CXXFLAGS =
42+ }
43 QMAKE_LFLAGS =
44- QMAKE_CXXFLAGS_WARN_ON += -Wdate-time -Wformat -Werror=format-security
45- QMAKE_LFLAGS_SHLIB += -Wl,-z,relro
46- DEFINES += _FORTIFY_SOURCE=2
47- unix:!contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions
48 }
49
50-# Add suggest-override to warn about overriding virtual functions not marked
51-# with the override keyword. Breaks the build when built as a Qt submodule.
52-# Should be fixed in Qt 5.6, see https://codereview.qt-project.org/#/c/169969/
53-gcc:!qt_submodule_build:greaterThan(QT_GCC_MAJOR_VERSION, 4) {
54- QMAKE_CXXFLAGS_WARN_ON += -Wsuggest-override
55+# Warn about overriding virtual functions not marked with the override keyword.
56+gcc:!clang {
57+ # Breaks the build when built as a Qt submodule. Should be fixed in Qt 5.6,
58+ # see https://codereview.qt-project.org/#/c/169969/
59+ !qt_submodule_build:!lessThan(QT_GCC_MAJOR_VERSION, 5): \
60+ QMAKE_CXXFLAGS_WARN_ON += -Wsuggest-override
61+} else {
62+ greaterThan(QT_CLANG_MAJOR_VERSION, 3)| \
63+ if(equals(QT_CLANG_MAJOR_VERSION, 3):!lessThan(QT_CLANG_MINOR_VERSION, 6)): \
64+ QMAKE_CXXFLAGS_WARN_ON += -Winconsistent-missing-override
65 }
66
67 # Use the 2011 ISO C++ standard plus amendments. Since Qt 5.6, GNU extensions
68 # are enabled by default with Clang, GCC and ICC, strict_c++ disables them.
69 CONFIG += c++11
70-equals(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 5): CONFIG += strict_c++
71+greaterThan(QT_MAJOR_VERSION, 5)| \
72+ if(equals(QT_MAJOR_VERSION, 5):!lessThan(QT_MINOR_VERSION, 6)): \
73+ CONFIG += strict_c++
74
75 CONFIG += no_keywords
76
77
78=== modified file 'features/ubuntu_qml_plugin.prf'
79--- features/ubuntu_qml_plugin.prf 2016-09-15 15:25:54 +0000
80+++ features/ubuntu_qml_plugin.prf 2016-09-22 14:19:53 +0000
81@@ -72,3 +72,7 @@
82 INSTALLS+=autobld_install_qmltypes
83 QMAKE_EXTRA_TARGETS += autobld_qmltypes
84 }
85+
86+# warnings_are_errors depending on the compiler version, sometimes it doesn't
87+# add the required flags (for instance for recent clang version on old Qt).
88+!contains(QMAKE_CXXFLAGS_WARN_ON, -Werror): QMAKE_CXXFLAGS_WARN_ON += -Werror
89
90=== modified file 'features/ubuntu_qt_module.prf'
91--- features/ubuntu_qt_module.prf 2016-09-15 15:25:54 +0000
92+++ features/ubuntu_qt_module.prf 2016-09-22 14:19:53 +0000
93@@ -11,3 +11,7 @@
94 CONFIG -= create_cmake
95
96 CONFIG += dll
97+
98+# warnings_are_errors depending on the compiler version, sometimes it doesn't
99+# add the required flags (for instance for recent clang version on old Qt).
100+!contains(QMAKE_CXXFLAGS_WARN_ON, -Werror): QMAKE_CXXFLAGS_WARN_ON += -Werror
101
102=== modified file 'src/UbuntuMetrics/UbuntuMetrics.pro'
103--- src/UbuntuMetrics/UbuntuMetrics.pro 2016-09-12 08:18:53 +0000
104+++ src/UbuntuMetrics/UbuntuMetrics.pro 2016-09-22 14:19:53 +0000
105@@ -30,6 +30,7 @@
106 $$PWD/events.cpp \
107 $$PWD/gputimer.cpp \
108 $$PWD/logger.cpp \
109- $$PWD/overlay.cpp
110+ $$PWD/overlay.cpp \
111+ $$PWD/ubuntumetricsglobal.cpp
112
113 load(ubuntu_qt_module)
114
115=== modified file 'src/UbuntuMetrics/applicationmonitor.cpp'
116--- src/UbuntuMetrics/applicationmonitor.cpp 2016-09-12 09:03:50 +0000
117+++ src/UbuntuMetrics/applicationmonitor.cpp 2016-09-22 14:19:53 +0000
118@@ -36,7 +36,7 @@
119 , m_flags(0)
120 {
121 m_queue = static_cast<UMEvent*>(
122- aligned_alloc(logQueueAlignment, logQueueSize * sizeof(UMEvent)));
123+ alignedAlloc(logQueueAlignment, logQueueSize * sizeof(UMEvent)));
124
125 #if !defined(QT_NO_DEBUG)
126 setObjectName(QStringLiteral("UbuntuMetrics logging")); // Thread name.
127
128=== modified file 'src/UbuntuMetrics/events.cpp'
129--- src/UbuntuMetrics/events.cpp 2016-09-22 10:49:07 +0000
130+++ src/UbuntuMetrics/events.cpp 2016-09-22 14:19:53 +0000
131@@ -37,9 +37,9 @@
132 EventUtilsPrivate::EventUtilsPrivate()
133 {
134 #if !defined(QT_NO_DEBUG)
135- ASSERT(m_buffer = static_cast<char*>(aligned_alloc(bufferAlignment, bufferSize)));
136+ ASSERT(m_buffer = static_cast<char*>(alignedAlloc(bufferAlignment, bufferSize)));
137 #else
138- m_buffer = static_cast<char*>(aligned_alloc(bufferAlignment, bufferSize));
139+ m_buffer = static_cast<char*>(alignedAlloc(bufferAlignment, bufferSize));
140 #endif
141 m_cpuTimer.start();
142 m_cpuTicks = times(&m_cpuTimes);
143
144=== modified file 'src/UbuntuMetrics/logger.h'
145--- src/UbuntuMetrics/logger.h 2016-09-09 17:49:07 +0000
146+++ src/UbuntuMetrics/logger.h 2016-09-22 14:19:53 +0000
147@@ -22,9 +22,9 @@
148
149 #include <UbuntuMetrics/ubuntumetricsglobal.h>
150
151-class UMEvent;
152 class UMFileLoggerPrivate;
153 struct UMLTTNGPlugin;
154+struct UMEvent;
155
156 // Log events to a specific device.
157 class UBUNTU_METRICS_EXPORT UMLogger
158@@ -70,7 +70,7 @@
159 static UMLTTNGPlugin* m_plugin;
160 static bool m_error;
161
162- void* __reserved;
163+ Q_DECL_UNUSED_MEMBER void* __reserved;
164 };
165
166 #endif // LOGGER_H
167
168=== modified file 'src/UbuntuMetrics/overlay.cpp'
169--- src/UbuntuMetrics/overlay.cpp 2016-09-09 17:49:07 +0000
170+++ src/UbuntuMetrics/overlay.cpp 2016-09-22 14:19:53 +0000
171@@ -96,7 +96,7 @@
172 {
173 DASSERT(text);
174
175- m_buffer = aligned_alloc(bufferAlignment, bufferSize);
176+ m_buffer = alignedAlloc(bufferAlignment, bufferSize);
177 memset(&m_processEvent, 0, sizeof(m_processEvent));
178 m_processEvent.type = UMEvent::Process;
179 }
180
181=== added file 'src/UbuntuMetrics/ubuntumetricsglobal.cpp'
182--- src/UbuntuMetrics/ubuntumetricsglobal.cpp 1970-01-01 00:00:00 +0000
183+++ src/UbuntuMetrics/ubuntumetricsglobal.cpp 2016-09-22 14:19:53 +0000
184@@ -0,0 +1,34 @@
185+// Copyright © 2016 Canonical Ltd.
186+// Author: Loïc Molinari <loic.molinari@canonical.com>
187+//
188+// This file is part of Ubuntu UI Toolkit.
189+//
190+// Ubuntu UI Toolkit is free software: you can redistribute it and/or modify it
191+// under the terms of the GNU Lesser General Public License as published by the
192+// Free Software Foundation; version 3.
193+//
194+// Ubuntu UI Toolkit is distributed in the hope that it will be useful, but
195+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
196+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
197+// for more details.
198+//
199+// You should have received a copy of the GNU Lesser General Public License
200+// along with Ubuntu UI Toolkit. If not, see <http://www.gnu.org/licenses/>.
201+
202+#include "ubuntumetricsglobal_p.h"
203+
204+void* alignedAlloc(size_t alignment, size_t size)
205+{
206+ DASSERT(IS_POWER_OF_TWO(alignment));
207+ // DASSERT(((size % alignment) == 0)); // FIXME(loicm) ASSERT doesn't support '%'...
208+
209+#if defined(__APPLE__)
210+ void* pointer;
211+ posix_memalign(&pointer, alignment, size);
212+ return pointer;
213+#elif defined(_WIN32)
214+ return _aligned_malloc(size, alignment);
215+#else
216+ return aligned_alloc(alignment, size);
217+#endif
218+}
219
220=== modified file 'src/UbuntuMetrics/ubuntumetricsglobal_p.h'
221--- src/UbuntuMetrics/ubuntumetricsglobal_p.h 2016-09-09 17:49:07 +0000
222+++ src/UbuntuMetrics/ubuntumetricsglobal_p.h 2016-09-22 14:19:53 +0000
223@@ -51,4 +51,8 @@
224
225 #define UBUNTU_METRICS_PRIVATE_EXPORT UBUNTU_METRICS_EXPORT
226
227+// Allocates size bytes and returns an pointer to the aligned memory. alignment
228+// must be a power-of-two and size a multiple of alignment.
229+void* alignedAlloc(size_t alignment, size_t size);
230+
231 #endif // UBUNTUMETRICSGLOBAL_P_H
232
233=== modified file 'src/UbuntuToolkit/unitythemeiconprovider.cpp'
234--- src/UbuntuToolkit/unitythemeiconprovider.cpp 2016-09-12 09:03:50 +0000
235+++ src/UbuntuToolkit/unitythemeiconprovider.cpp 2016-09-22 14:19:53 +0000
236@@ -138,15 +138,13 @@
237
238 static QImage loadIcon(const QString &filename, QSize *impsize, const QSize &requestSize)
239 {
240- QImage image;
241 QImageReader imgio(filename);
242
243- const bool force_scale = imgio.format() == QStringLiteral("svg")
244- || imgio.format() == QStringLiteral("svgz");
245-
246 if (requestSize.width() > 0 || requestSize.height() > 0) {
247+ const bool force_scale = (imgio.format() == "svg") || (imgio.format() == "svgz");
248 QSize s = imgio.size();
249 qreal ratio = 0.0;
250+
251 if (requestSize.width() > 0 && (force_scale || requestSize.width() < s.width())) {
252 ratio = qreal(requestSize.width())/s.width();
253 }
254@@ -165,6 +163,7 @@
255 if (impsize)
256 *impsize = imgio.scaledSize();
257
258+ QImage image;
259 if (imgio.read(&image)) {
260 if (impsize)
261 *impsize = image.size();

Subscribers

People subscribed via source and target branches