File: FindUnalignedMalloc.cmake

package info (click to toggle)
rawtherapee 5.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 124,328 kB
  • sloc: cpp: 271,715; ansic: 27,904; sh: 1,109; python: 521; cs: 155; xml: 57; makefile: 15
file content (49 lines) | stat: -rw-r--r-- 1,423 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# This file is part of RawTherapee.
#
# Copyright (C) 2018 Flössie <floessie.mail@gmail.com>
#
# RawTherapee is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RawTherapee is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.

include(CheckCXXSourceCompiles)

set(CMAKE_REQUIRED_QUIET_COPY "${CMAKE_REQUIRED_QUIET}")
set(CMAKE_REQUIRED_QUIET ON)

set(TEST_SOURCE
"
#include <cstddef>
#include <type_traits>

int main()
{
#if defined(__SSE2__) && (defined(__i386) || defined(_M_IX86)) && defined(__linux)
    static_assert(std::alignment_of<std::max_align_t>::value >= 16, \"Unaligned heap objects possible\");
#endif

    return 0;
}
")

CHECK_CXX_SOURCE_COMPILES("${TEST_SOURCE}" HAVE_ALIGNED_MALLOC)

if(NOT HAVE_ALIGNED_MALLOC)
    set(HAVE_UNALIGNED_MALLOC 1)
else()
    unset(HAVE_ALIGNED_MALLOC)
endif()

unset(TEST_SOURCE)

set(CMAKE_REQUIRED_QUIET "${CMAKE_REQUIRED_QUIET_COPY}")
unset(CMAKE_REQUIRED_QUIET_COPY)