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: Needs review
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/uitk-aligned-alloc-for-apple-and-win32
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~loic.molinari/ubuntu-ui-toolkit/uitk-linux-clang
Diff against target: 106 lines (+44/-5)
6 files modified
src/UbuntuMetrics/UbuntuMetrics.pro (+2/-1)
src/UbuntuMetrics/applicationmonitor.cpp (+1/-1)
src/UbuntuMetrics/events.cpp (+2/-2)
src/UbuntuMetrics/overlay.cpp (+1/-1)
src/UbuntuMetrics/ubuntumetricsglobal.cpp (+34/-0)
src/UbuntuMetrics/ubuntumetricsglobal_p.h (+4/-0)
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 Needs Fixing
Zsombor Egri Approve
Review via email: mp+306472@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
Zsombor Egri (zsombi) wrote :

Looks good, thanks!

review: Approve
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) :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/UbuntuMetrics/UbuntuMetrics.pro'
2--- src/UbuntuMetrics/UbuntuMetrics.pro 2016-09-12 08:18:53 +0000
3+++ src/UbuntuMetrics/UbuntuMetrics.pro 2016-09-22 14:21:44 +0000
4@@ -30,6 +30,7 @@
5 $$PWD/events.cpp \
6 $$PWD/gputimer.cpp \
7 $$PWD/logger.cpp \
8- $$PWD/overlay.cpp
9+ $$PWD/overlay.cpp \
10+ $$PWD/ubuntumetricsglobal.cpp
11
12 load(ubuntu_qt_module)
13
14=== modified file 'src/UbuntuMetrics/applicationmonitor.cpp'
15--- src/UbuntuMetrics/applicationmonitor.cpp 2016-09-12 09:03:50 +0000
16+++ src/UbuntuMetrics/applicationmonitor.cpp 2016-09-22 14:21:44 +0000
17@@ -36,7 +36,7 @@
18 , m_flags(0)
19 {
20 m_queue = static_cast<UMEvent*>(
21- aligned_alloc(logQueueAlignment, logQueueSize * sizeof(UMEvent)));
22+ alignedAlloc(logQueueAlignment, logQueueSize * sizeof(UMEvent)));
23
24 #if !defined(QT_NO_DEBUG)
25 setObjectName(QStringLiteral("UbuntuMetrics logging")); // Thread name.
26
27=== modified file 'src/UbuntuMetrics/events.cpp'
28--- src/UbuntuMetrics/events.cpp 2016-09-22 10:49:07 +0000
29+++ src/UbuntuMetrics/events.cpp 2016-09-22 14:21:44 +0000
30@@ -37,9 +37,9 @@
31 EventUtilsPrivate::EventUtilsPrivate()
32 {
33 #if !defined(QT_NO_DEBUG)
34- ASSERT(m_buffer = static_cast<char*>(aligned_alloc(bufferAlignment, bufferSize)));
35+ ASSERT(m_buffer = static_cast<char*>(alignedAlloc(bufferAlignment, bufferSize)));
36 #else
37- m_buffer = static_cast<char*>(aligned_alloc(bufferAlignment, bufferSize));
38+ m_buffer = static_cast<char*>(alignedAlloc(bufferAlignment, bufferSize));
39 #endif
40 m_cpuTimer.start();
41 m_cpuTicks = times(&m_cpuTimes);
42
43=== modified file 'src/UbuntuMetrics/overlay.cpp'
44--- src/UbuntuMetrics/overlay.cpp 2016-09-09 17:49:07 +0000
45+++ src/UbuntuMetrics/overlay.cpp 2016-09-22 14:21:44 +0000
46@@ -96,7 +96,7 @@
47 {
48 DASSERT(text);
49
50- m_buffer = aligned_alloc(bufferAlignment, bufferSize);
51+ m_buffer = alignedAlloc(bufferAlignment, bufferSize);
52 memset(&m_processEvent, 0, sizeof(m_processEvent));
53 m_processEvent.type = UMEvent::Process;
54 }
55
56=== added file 'src/UbuntuMetrics/ubuntumetricsglobal.cpp'
57--- src/UbuntuMetrics/ubuntumetricsglobal.cpp 1970-01-01 00:00:00 +0000
58+++ src/UbuntuMetrics/ubuntumetricsglobal.cpp 2016-09-22 14:21:44 +0000
59@@ -0,0 +1,34 @@
60+// Copyright © 2016 Canonical Ltd.
61+// Author: Loïc Molinari <loic.molinari@canonical.com>
62+//
63+// This file is part of Ubuntu UI Toolkit.
64+//
65+// Ubuntu UI Toolkit is free software: you can redistribute it and/or modify it
66+// under the terms of the GNU Lesser General Public License as published by the
67+// Free Software Foundation; version 3.
68+//
69+// Ubuntu UI Toolkit is distributed in the hope that it will be useful, but
70+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
71+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
72+// for more details.
73+//
74+// You should have received a copy of the GNU Lesser General Public License
75+// along with Ubuntu UI Toolkit. If not, see <http://www.gnu.org/licenses/>.
76+
77+#include "ubuntumetricsglobal_p.h"
78+
79+void* alignedAlloc(size_t alignment, size_t size)
80+{
81+ DASSERT(IS_POWER_OF_TWO(alignment));
82+ // DASSERT(((size % alignment) == 0)); // FIXME(loicm) ASSERT doesn't support '%'...
83+
84+#if defined(__APPLE__)
85+ void* pointer;
86+ posix_memalign(&pointer, alignment, size);
87+ return pointer;
88+#elif defined(_WIN32)
89+ return _aligned_malloc(size, alignment);
90+#else
91+ return aligned_alloc(alignment, size);
92+#endif
93+}
94
95=== modified file 'src/UbuntuMetrics/ubuntumetricsglobal_p.h'
96--- src/UbuntuMetrics/ubuntumetricsglobal_p.h 2016-09-09 17:49:07 +0000
97+++ src/UbuntuMetrics/ubuntumetricsglobal_p.h 2016-09-22 14:21:44 +0000
98@@ -51,4 +51,8 @@
99
100 #define UBUNTU_METRICS_PRIVATE_EXPORT UBUNTU_METRICS_EXPORT
101
102+// Allocates size bytes and returns an pointer to the aligned memory. alignment
103+// must be a power-of-two and size a multiple of alignment.
104+void* alignedAlloc(size_t alignment, size_t size);
105+
106 #endif // UBUNTUMETRICSGLOBAL_P_H

Subscribers

People subscribed via source and target branches