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
=== modified file '.qmake.conf'
--- .qmake.conf 2016-09-15 15:25:54 +0000
+++ .qmake.conf 2016-09-22 14:19:53 +0000
@@ -15,6 +15,15 @@
1515
16exists($$PWD/../qt.pro): CONFIG += qt_submodule_build16exists($$PWD/../qt.pro): CONFIG += qt_submodule_build
1717
18# Set QT_CLANG_*_VERSION if not defined to make internal qmake features
19# (warnings_are_errors and others) work since these variables are defined only
20# when clang is chosen as compiler at configure time. The regexp is based on the
21# Qt one used in the qtbase configure script.
22clang:!defined(QT_CLANG_MAJOR_VERSION, var) {
23 QT_CLANG_MAJOR_VERSION = $$system("clang -v 2>&1 | sed -n -E '/^clang version /{s///; s/^([0-9]*)\.([0-9]*).*$/\1/;p;q;}'")
24 QT_CLANG_MINOR_VERSION = $$system("clang -v 2>&1 | sed -n -E '/^clang version /{s///; s/^([0-9]*)\.([0-9]*).*$/\2/;p;q;}'")
25}
26
18# FIXME: Fix bug 1606247 and enable the UbuntuToolkit namespace.27# FIXME: Fix bug 1606247 and enable the UbuntuToolkit namespace.
19# build UbuntuToolkit without namespace28# build UbuntuToolkit without namespace
20DEFINES += UBUNTUTOOLKIT_NO_NAMESPACE29DEFINES += UBUNTUTOOLKIT_NO_NAMESPACE
2130
=== modified file 'features/ubuntu_common.prf'
--- features/ubuntu_common.prf 2016-09-15 15:37:57 +0000
+++ features/ubuntu_common.prf 2016-09-22 14:19:53 +0000
@@ -13,27 +13,39 @@
13# order to workaround these issues, we unset these variables and set the13# order to workaround these issues, we unset these variables and set the
14# different flags apart from -g and -O2 in the right qmake variables. This14# different flags apart from -g and -O2 in the right qmake variables. This
15# allows to keep compiling with the Debian flags but in a more flexible way.15# allows to keep compiling with the Debian flags but in a more flexible way.
16gcc:!qt_submodule_build:!debian_build {16!qt_submodule_build:!debian_build {
17 QMAKE_CFLAGS = -fstack-protector17 gcc:!clang {
18 QMAKE_CXXFLAGS = -fstack-protector18 QMAKE_CFLAGS = -fstack-protector
19 QMAKE_CXXFLAGS = -fstack-protector
20 QMAKE_CXXFLAGS_WARN_ON += -Wdate-time -Wformat -Werror=format-security
21 QMAKE_LFLAGS_SHLIB += -Wl,-z,relro
22 DEFINES += _FORTIFY_SOURCE=2
23 unix:!contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions
24 } else {
25 QMAKE_CFLAGS =
26 QMAKE_CXXFLAGS =
27 }
19 QMAKE_LFLAGS =28 QMAKE_LFLAGS =
20 QMAKE_CXXFLAGS_WARN_ON += -Wdate-time -Wformat -Werror=format-security
21 QMAKE_LFLAGS_SHLIB += -Wl,-z,relro
22 DEFINES += _FORTIFY_SOURCE=2
23 unix:!contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions
24}29}
2530
26# Add suggest-override to warn about overriding virtual functions not marked31# Warn about overriding virtual functions not marked with the override keyword.
27# with the override keyword. Breaks the build when built as a Qt submodule.32gcc:!clang {
28# Should be fixed in Qt 5.6, see https://codereview.qt-project.org/#/c/169969/33 # Breaks the build when built as a Qt submodule. Should be fixed in Qt 5.6,
29gcc:!qt_submodule_build:greaterThan(QT_GCC_MAJOR_VERSION, 4) {34 # see https://codereview.qt-project.org/#/c/169969/
30 QMAKE_CXXFLAGS_WARN_ON += -Wsuggest-override35 !qt_submodule_build:!lessThan(QT_GCC_MAJOR_VERSION, 5): \
36 QMAKE_CXXFLAGS_WARN_ON += -Wsuggest-override
37} else {
38 greaterThan(QT_CLANG_MAJOR_VERSION, 3)| \
39 if(equals(QT_CLANG_MAJOR_VERSION, 3):!lessThan(QT_CLANG_MINOR_VERSION, 6)): \
40 QMAKE_CXXFLAGS_WARN_ON += -Winconsistent-missing-override
31}41}
3242
33# Use the 2011 ISO C++ standard plus amendments. Since Qt 5.6, GNU extensions43# Use the 2011 ISO C++ standard plus amendments. Since Qt 5.6, GNU extensions
34# are enabled by default with Clang, GCC and ICC, strict_c++ disables them.44# are enabled by default with Clang, GCC and ICC, strict_c++ disables them.
35CONFIG += c++1145CONFIG += c++11
36equals(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 5): CONFIG += strict_c++46greaterThan(QT_MAJOR_VERSION, 5)| \
47 if(equals(QT_MAJOR_VERSION, 5):!lessThan(QT_MINOR_VERSION, 6)): \
48 CONFIG += strict_c++
3749
38CONFIG += no_keywords50CONFIG += no_keywords
3951
4052
=== modified file 'features/ubuntu_qml_plugin.prf'
--- features/ubuntu_qml_plugin.prf 2016-09-15 15:25:54 +0000
+++ features/ubuntu_qml_plugin.prf 2016-09-22 14:19:53 +0000
@@ -72,3 +72,7 @@
72 INSTALLS+=autobld_install_qmltypes72 INSTALLS+=autobld_install_qmltypes
73 QMAKE_EXTRA_TARGETS += autobld_qmltypes73 QMAKE_EXTRA_TARGETS += autobld_qmltypes
74}74}
75
76# warnings_are_errors depending on the compiler version, sometimes it doesn't
77# add the required flags (for instance for recent clang version on old Qt).
78!contains(QMAKE_CXXFLAGS_WARN_ON, -Werror): QMAKE_CXXFLAGS_WARN_ON += -Werror
7579
=== modified file 'features/ubuntu_qt_module.prf'
--- features/ubuntu_qt_module.prf 2016-09-15 15:25:54 +0000
+++ features/ubuntu_qt_module.prf 2016-09-22 14:19:53 +0000
@@ -11,3 +11,7 @@
11CONFIG -= create_cmake11CONFIG -= create_cmake
1212
13CONFIG += dll13CONFIG += dll
14
15# warnings_are_errors depending on the compiler version, sometimes it doesn't
16# add the required flags (for instance for recent clang version on old Qt).
17!contains(QMAKE_CXXFLAGS_WARN_ON, -Werror): QMAKE_CXXFLAGS_WARN_ON += -Werror
1418
=== modified file 'src/UbuntuMetrics/UbuntuMetrics.pro'
--- src/UbuntuMetrics/UbuntuMetrics.pro 2016-09-12 08:18:53 +0000
+++ src/UbuntuMetrics/UbuntuMetrics.pro 2016-09-22 14:19:53 +0000
@@ -30,6 +30,7 @@
30 $$PWD/events.cpp \30 $$PWD/events.cpp \
31 $$PWD/gputimer.cpp \31 $$PWD/gputimer.cpp \
32 $$PWD/logger.cpp \32 $$PWD/logger.cpp \
33 $$PWD/overlay.cpp33 $$PWD/overlay.cpp \
34 $$PWD/ubuntumetricsglobal.cpp
3435
35load(ubuntu_qt_module)36load(ubuntu_qt_module)
3637
=== modified file 'src/UbuntuMetrics/applicationmonitor.cpp'
--- src/UbuntuMetrics/applicationmonitor.cpp 2016-09-12 09:03:50 +0000
+++ src/UbuntuMetrics/applicationmonitor.cpp 2016-09-22 14:19:53 +0000
@@ -36,7 +36,7 @@
36 , m_flags(0)36 , m_flags(0)
37{37{
38 m_queue = static_cast<UMEvent*>(38 m_queue = static_cast<UMEvent*>(
39 aligned_alloc(logQueueAlignment, logQueueSize * sizeof(UMEvent)));39 alignedAlloc(logQueueAlignment, logQueueSize * sizeof(UMEvent)));
4040
41#if !defined(QT_NO_DEBUG)41#if !defined(QT_NO_DEBUG)
42 setObjectName(QStringLiteral("UbuntuMetrics logging")); // Thread name.42 setObjectName(QStringLiteral("UbuntuMetrics logging")); // Thread name.
4343
=== modified file 'src/UbuntuMetrics/events.cpp'
--- src/UbuntuMetrics/events.cpp 2016-09-22 10:49:07 +0000
+++ src/UbuntuMetrics/events.cpp 2016-09-22 14:19:53 +0000
@@ -37,9 +37,9 @@
37EventUtilsPrivate::EventUtilsPrivate()37EventUtilsPrivate::EventUtilsPrivate()
38{38{
39#if !defined(QT_NO_DEBUG)39#if !defined(QT_NO_DEBUG)
40 ASSERT(m_buffer = static_cast<char*>(aligned_alloc(bufferAlignment, bufferSize)));40 ASSERT(m_buffer = static_cast<char*>(alignedAlloc(bufferAlignment, bufferSize)));
41#else41#else
42 m_buffer = static_cast<char*>(aligned_alloc(bufferAlignment, bufferSize));42 m_buffer = static_cast<char*>(alignedAlloc(bufferAlignment, bufferSize));
43#endif43#endif
44 m_cpuTimer.start();44 m_cpuTimer.start();
45 m_cpuTicks = times(&m_cpuTimes);45 m_cpuTicks = times(&m_cpuTimes);
4646
=== modified file 'src/UbuntuMetrics/logger.h'
--- src/UbuntuMetrics/logger.h 2016-09-09 17:49:07 +0000
+++ src/UbuntuMetrics/logger.h 2016-09-22 14:19:53 +0000
@@ -22,9 +22,9 @@
2222
23#include <UbuntuMetrics/ubuntumetricsglobal.h>23#include <UbuntuMetrics/ubuntumetricsglobal.h>
2424
25class UMEvent;
26class UMFileLoggerPrivate;25class UMFileLoggerPrivate;
27struct UMLTTNGPlugin;26struct UMLTTNGPlugin;
27struct UMEvent;
2828
29// Log events to a specific device.29// Log events to a specific device.
30class UBUNTU_METRICS_EXPORT UMLogger30class UBUNTU_METRICS_EXPORT UMLogger
@@ -70,7 +70,7 @@
70 static UMLTTNGPlugin* m_plugin;70 static UMLTTNGPlugin* m_plugin;
71 static bool m_error;71 static bool m_error;
7272
73 void* __reserved;73 Q_DECL_UNUSED_MEMBER void* __reserved;
74};74};
7575
76#endif // LOGGER_H76#endif // LOGGER_H
7777
=== modified file 'src/UbuntuMetrics/overlay.cpp'
--- src/UbuntuMetrics/overlay.cpp 2016-09-09 17:49:07 +0000
+++ src/UbuntuMetrics/overlay.cpp 2016-09-22 14:19:53 +0000
@@ -96,7 +96,7 @@
96{96{
97 DASSERT(text);97 DASSERT(text);
9898
99 m_buffer = aligned_alloc(bufferAlignment, bufferSize);99 m_buffer = alignedAlloc(bufferAlignment, bufferSize);
100 memset(&m_processEvent, 0, sizeof(m_processEvent));100 memset(&m_processEvent, 0, sizeof(m_processEvent));
101 m_processEvent.type = UMEvent::Process;101 m_processEvent.type = UMEvent::Process;
102}102}
103103
=== added file 'src/UbuntuMetrics/ubuntumetricsglobal.cpp'
--- src/UbuntuMetrics/ubuntumetricsglobal.cpp 1970-01-01 00:00:00 +0000
+++ src/UbuntuMetrics/ubuntumetricsglobal.cpp 2016-09-22 14:19:53 +0000
@@ -0,0 +1,34 @@
1// Copyright © 2016 Canonical Ltd.
2// Author: Loïc Molinari <loic.molinari@canonical.com>
3//
4// This file is part of Ubuntu UI Toolkit.
5//
6// Ubuntu UI Toolkit is free software: you can redistribute it and/or modify it
7// under the terms of the GNU Lesser General Public License as published by the
8// Free Software Foundation; version 3.
9//
10// Ubuntu UI Toolkit is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13// for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with Ubuntu UI Toolkit. If not, see <http://www.gnu.org/licenses/>.
17
18#include "ubuntumetricsglobal_p.h"
19
20void* alignedAlloc(size_t alignment, size_t size)
21{
22 DASSERT(IS_POWER_OF_TWO(alignment));
23 // DASSERT(((size % alignment) == 0)); // FIXME(loicm) ASSERT doesn't support '%'...
24
25#if defined(__APPLE__)
26 void* pointer;
27 posix_memalign(&pointer, alignment, size);
28 return pointer;
29#elif defined(_WIN32)
30 return _aligned_malloc(size, alignment);
31#else
32 return aligned_alloc(alignment, size);
33#endif
34}
035
=== modified file 'src/UbuntuMetrics/ubuntumetricsglobal_p.h'
--- src/UbuntuMetrics/ubuntumetricsglobal_p.h 2016-09-09 17:49:07 +0000
+++ src/UbuntuMetrics/ubuntumetricsglobal_p.h 2016-09-22 14:19:53 +0000
@@ -51,4 +51,8 @@
5151
52#define UBUNTU_METRICS_PRIVATE_EXPORT UBUNTU_METRICS_EXPORT52#define UBUNTU_METRICS_PRIVATE_EXPORT UBUNTU_METRICS_EXPORT
5353
54// Allocates size bytes and returns an pointer to the aligned memory. alignment
55// must be a power-of-two and size a multiple of alignment.
56void* alignedAlloc(size_t alignment, size_t size);
57
54#endif // UBUNTUMETRICSGLOBAL_P_H58#endif // UBUNTUMETRICSGLOBAL_P_H
5559
=== modified file 'src/UbuntuToolkit/unitythemeiconprovider.cpp'
--- src/UbuntuToolkit/unitythemeiconprovider.cpp 2016-09-12 09:03:50 +0000
+++ src/UbuntuToolkit/unitythemeiconprovider.cpp 2016-09-22 14:19:53 +0000
@@ -138,15 +138,13 @@
138138
139 static QImage loadIcon(const QString &filename, QSize *impsize, const QSize &requestSize)139 static QImage loadIcon(const QString &filename, QSize *impsize, const QSize &requestSize)
140 {140 {
141 QImage image;
142 QImageReader imgio(filename);141 QImageReader imgio(filename);
143142
144 const bool force_scale = imgio.format() == QStringLiteral("svg")
145 || imgio.format() == QStringLiteral("svgz");
146
147 if (requestSize.width() > 0 || requestSize.height() > 0) {143 if (requestSize.width() > 0 || requestSize.height() > 0) {
144 const bool force_scale = (imgio.format() == "svg") || (imgio.format() == "svgz");
148 QSize s = imgio.size();145 QSize s = imgio.size();
149 qreal ratio = 0.0;146 qreal ratio = 0.0;
147
150 if (requestSize.width() > 0 && (force_scale || requestSize.width() < s.width())) {148 if (requestSize.width() > 0 && (force_scale || requestSize.width() < s.width())) {
151 ratio = qreal(requestSize.width())/s.width();149 ratio = qreal(requestSize.width())/s.width();
152 }150 }
@@ -165,6 +163,7 @@
165 if (impsize)163 if (impsize)
166 *impsize = imgio.scaledSize();164 *impsize = imgio.scaledSize();
167165
166 QImage image;
168 if (imgio.read(&image)) {167 if (imgio.read(&image)) {
169 if (impsize)168 if (impsize)
170 *impsize = image.size();169 *impsize = image.size();

Subscribers

People subscribed via source and target branches