aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2021-12-11 11:13:00 +0000
committerSimon Tatham <anakin@pobox.com>2021-12-11 11:59:25 +0000
commit57fbcd2b29aa74423d47a9efd783a1508ab1bfc5 (patch)
tree9c8d1664994e582cddbd3402da0afe4c70f0c8f0 /cmake
parent5c5c607fdb834bc73033736f5774ef53c42008aa (diff)
downloadpuzzles-57fbcd2b29aa74423d47a9efd783a1508ab1bfc5.zip
puzzles-57fbcd2b29aa74423d47a9efd783a1508ab1bfc5.tar.gz
puzzles-57fbcd2b29aa74423d47a9efd783a1508ab1bfc5.tar.bz2
puzzles-57fbcd2b29aa74423d47a9efd783a1508ab1bfc5.tar.xz
malloc.c: check allocation sizes against PTRDIFF_MAX.
I don't expect this to actually come up in any circumstance, but it prevents a warning in some versions of gcc that would otherwise arise from the use of 'int' to compute the input size: if gcc isn't confident that the int is positive, then it complains that possible inputs to malloc might be in the region of 2^64 - (small multiple of a negative 32-bit int). I would hope malloc would fail in any case on such an input, so failing a couple of lines earlier makes no important difference. Annoyingly, stdint.h is missing in my NestedVM build setup (though it has stdbool.h - it's not _totally_ C90). So I have to check that at cmake time. Also, removed the #defines for smalloc and friends from the tree234 test mode. These were needed in the old build system, when tree234-test was built ad-hoc without being linked against malloc.c. But now tree234-test links against the same utils library as everything else, and can use the real smalloc - and doing so prevents another of these warnings when compiling with -flto.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/setup.cmake6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmake/setup.cmake b/cmake/setup.cmake
index ee39dbf..e8e0309 100644
--- a/cmake/setup.cmake
+++ b/cmake/setup.cmake
@@ -32,6 +32,12 @@ endif()
set(puzzle_names)
set(puzzle_sources)
+include(CheckIncludeFile)
+check_include_file(stdint.h HAVE_STDINT_H)
+if(NOT HAVE_STDINT_H)
+ add_compile_definitions(NO_STDINT_H)
+endif()
+
include(icons/icons.cmake)
# The main function called from the top-level CMakeLists.txt to define