Skip to content

Commit 151eb80

Browse files
committed
Handle <alloca.h> better
- Test for existence, assume symbols/functionality provided elsewhere if it is missing. Should induce compile time error if this is not true.
1 parent dd8442e commit 151eb80

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/mpi/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ if(CAF_EXPOSE_INIT_FINALIZE)
2828
add_definitions(-DEXPOSE_INIT_FINALIZE)
2929
endif()
3030

31+
include(CheckIncludeFile)
32+
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA)
33+
if(NOT HAVE_ALLOCA)
34+
add_definitions(-DALLOCA_MISSING)
35+
message(WARNING "Could not find <alloca.h>. Assuming functionality is provided elsewhere.")
36+
endif()
37+
3138
#----------------------------------------------------------------------
3239
# Test if MPI implementation provides features needed for failed images
3340
#----------------------------------------------------------------------

src/mpi/mpi_caf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
3737
#include <stdlib.h>
3838
#include <string.h> /* For memcpy. */
3939
#include <stdarg.h> /* For variadic arguments. */
40-
#include <alloca.h>
40+
#ifndef ALLOCA_MISSING
41+
#include <alloca.h> /* Assume functionality provided elsewhere if missing */
42+
#endif
4143
#include <unistd.h>
4244
#include <mpi.h>
4345
#include <pthread.h>

0 commit comments

Comments
 (0)