From 2dbae9c334c4c250f16e105e5579b0c3f2f3fb22 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Mon, 10 Aug 2009 00:56:46 +0000 Subject: [PATCH] Fix a FIXME for configure check for HAVE_SYSCONF. llvm-svn: 78545 --- compiler-rt/ConfigureChecks.cmake | 2 +- compiler-rt/lib/enable_execute_stack.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler-rt/ConfigureChecks.cmake b/compiler-rt/ConfigureChecks.cmake index 57ae7909c1f4..8b027bc38978 100644 --- a/compiler-rt/ConfigureChecks.cmake +++ b/compiler-rt/ConfigureChecks.cmake @@ -11,4 +11,4 @@ SET( SOURCEDIR ${CMAKE_SOURCE_DIR} ) CHECK_INCLUDE_FILE( sys/byteorder.h HAVE_SYS_BYTEORDER_H ) # FUNCTIONS -#CHECK_FUNCTION_EXISTS( strlcpy HAVE_STRLCPY ) +CHECK_FUNCTION_EXISTS( sysconf HAVE_SYSCONF ) diff --git a/compiler-rt/lib/enable_execute_stack.c b/compiler-rt/lib/enable_execute_stack.c index 6f17c9b95284..07c1645ce768 100644 --- a/compiler-rt/lib/enable_execute_stack.c +++ b/compiler-rt/lib/enable_execute_stack.c @@ -10,9 +10,14 @@ #include #include + +/* #include "config.h" + * FIXME: CMake - include when cmake system is ready. + */ + #ifndef __APPLE__ #include -#endif +#endif /* __APPLE__ */ /* @@ -25,13 +30,16 @@ void __enable_execute_stack(void* addr) { + #if __APPLE__ /* On Darwin, pagesize is always 4096 bytes */ const uintptr_t pageSize = 4096; +#elif !defined(HAVE_SYSCONF) +#error "HAVE_SYSCONF not defined! See enable_execute_stack.c" #else - /* FIXME: We should have a configure check for this. */ const uintptr_t pageSize = sysconf(_SC_PAGESIZE); -#endif +#endif /* __APPLE__ */ + const uintptr_t pageAlignMask = ~(pageSize-1); uintptr_t p = (uintptr_t)addr; unsigned char* startPage = (unsigned char*)(p & pageAlignMask);