diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-05 13:40:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-05 13:40:50 +0100 |
commit | abc650b3df5a2ea02357ff579362f790ba27e851 (patch) | |
tree | 046dbd9c7e4dbe34c37d52e895ab8904ce42954e /CMakeLists.txt | |
parent | fe854d75c6f3f6d0f324b832a5b9f5a47df0f5c7 (diff) | |
download | rspamd-abc650b3df5a2ea02357ff579362f790ba27e851.tar.gz rspamd-abc650b3df5a2ea02357ff579362f790ba27e851.zip |
[Fix] Always use shmem on linux
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 86 |
1 files changed, 46 insertions, 40 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 608f5d5df..a2c539cea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1051,47 +1051,53 @@ ELSE() MESSAGE(STATUS "atomic builtins are supported") ENDIF() -CHECK_C_SOURCE_RUNS(" -#include <sys/mman.h> -#include <fcntl.h> -#include <unistd.h> -#define TEST_NAME \"/test-shmem-work\" -int -main (int argc, char **argv) -{ - int fd; - - fd = shm_open (TEST_NAME, O_RDWR | O_CREAT | O_EXCL, 00600); - if (fd == -1) { - return -1; - } - if (ftruncate (fd, 100) == -1) { - shm_unlink (TEST_NAME); - close (fd); - return -1; - } - - if (ftruncate (fd, 200) == -1) { - shm_unlink (TEST_NAME); - close (fd); - return -1; - } - if (ftruncate (fd, 300) == -1) { - shm_unlink (TEST_NAME); - close (fd); - return -1; - } - - close (fd); - shm_unlink (TEST_NAME); - return 0; -} -" HAVE_SANE_SHMEM) - -IF(NOT HAVE_SANE_SHMEM) - MESSAGE(STATUS "shmem support is NOT compatible with POSIX") +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # In linux, we need to mount /run/shm to test which could be unavailable + # on a build system. On the other hand, we know that linux has stupid + # but compatible shmem support, so we assume this macro as true + SET(CACHE HAVE_SANE_SHMEM 1) ELSE() - MESSAGE(STATUS "shmem support is compatible with POSIX") + CHECK_C_SOURCE_RUNS(" + #include <sys/mman.h> + #include <fcntl.h> + #include <unistd.h> + #define TEST_NAME \"/test-shmem-work\" + int + main (int argc, char **argv) + { + int fd; + + fd = shm_open (TEST_NAME, O_RDWR | O_CREAT | O_EXCL, 00600); + if (fd == -1) { + return -1; + } + if (ftruncate (fd, 100) == -1) { + shm_unlink (TEST_NAME); + close (fd); + return -1; + } + + if (ftruncate (fd, 200) == -1) { + shm_unlink (TEST_NAME); + close (fd); + return -1; + } + if (ftruncate (fd, 300) == -1) { + shm_unlink (TEST_NAME); + close (fd); + return -1; + } + + close (fd); + shm_unlink (TEST_NAME); + return 0; + } + " HAVE_SANE_SHMEM) + IF(NOT HAVE_SANE_SHMEM) + MESSAGE(STATUS "shmem support is NOT compatible with POSIX") + ELSE() + MESSAGE(STATUS "shmem support is compatible with POSIX") + ENDIF() ENDIF() # Check queue.h compatibility |