Debian Codegraph @

src/LomiriMetrics/lomirimetricsglobal.cpp

raw
1 // Copyright © 2016 Canonical Ltd.
2 // Author: Loïc Molinari <[email protected]>
3 //
4 // This file is part of Lomiri UI Toolkit.
5 //
6 // Lomiri 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 // Lomiri 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 Lomiri UI Toolkit. If not, see <http://www.gnu.org/licenses/>.
17
18 #include "lomirimetricsglobal_p.h"
19
20 void* 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 }