From 5f450d88f7dc79fa13371bdef6bc6dedb1c56aa5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 29 Jun 2016 14:51:50 +0100 Subject: [PATCH] [Feature] Add test to check shared memory support sanity --- CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ config.h.in | 1 + 2 files changed, 44 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d1f8cf94..40b4907a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1051,6 +1051,49 @@ ELSE() MESSAGE(STATUS "atomic builtins are supported") ENDIF() +CHECK_C_SOURCE_RUNS(" +#include +#include +#include +#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() + # Check queue.h compatibility IF(NOT HAVE_COMPATIBLE_QUEUE_H) INCLUDE_DIRECTORIES(compat) diff --git a/config.h.in b/config.h.in index 30b07797a..8ebb2e56d 100644 --- a/config.h.in +++ b/config.h.in @@ -69,6 +69,7 @@ #cmakedefine HAVE_PWD_H 1 #cmakedefine HAVE_READPASSPHRASE_H 1 #cmakedefine HAVE_SA_SIGINFO 1 +#cmakedefine HAVE_SANE_SHMEM 1 #cmakedefine HAVE_SCHED_YEILD 1 #cmakedefine HAVE_SC_NPROCESSORS_ONLN 1 #cmakedefine HAVE_SEARCH_H 1 -- 2.39.5