diff options
author | Brad King <brad.king@kitware.com> | 2005-04-13 19:39:03 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-04-13 19:39:03 (GMT) |
commit | be1084b5241725095a7e0591eaf593a4606204a1 (patch) | |
tree | cc9f9c5e94b5c22dd4f375d718e3eed75d82afd3 | |
parent | 551b28d501058c3437b0c8d962e1662ccdbef392 (diff) | |
download | CMake-be1084b5241725095a7e0591eaf593a4606204a1.zip CMake-be1084b5241725095a7e0591eaf593a4606204a1.tar.gz CMake-be1084b5241725095a7e0591eaf593a4606204a1.tar.bz2 |
COMP: Added KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT check for non-standard argument to stl allocator<>::max_size method. Needed for kwsys hashtable to compile on Sun CC.
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Source/kwsys/Configure.hxx.in | 4 | ||||
-rw-r--r-- | Source/kwsys/hashtable.hxx.in | 7 | ||||
-rw-r--r-- | Source/kwsys/kwsysPlatformCxxTests.cxx | 13 | ||||
-rwxr-xr-x | bootstrap | 11 |
5 files changed, 37 insertions, 0 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 7787933..7926da1 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -184,6 +184,8 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR "Checking whether stl string has operator!= for char*" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND "Checking for rebind member of stl allocator" DIRECT) +KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT + "Checking for non-standard argument to stl allocator<>::max_size" DIRECT) IF(KWSYS_IOS_USE_ANSI) # ANSI streams always have string operators. SET(KWSYS_STL_STRING_HAVE_OSTREAM 1) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 13d3a97..1ea8b37 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -96,6 +96,9 @@ /* Whether the stl allocator has rebind. */ #define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND @KWSYS_STL_HAS_ALLOCATOR_REBIND@ +/* Whether the stl allocator has a size argument for max_size. */ +#define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT @KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@ + /* Whether struct stat has the st_mtim member for high resolution times. */ #define @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM @KWSYS_STAT_HAS_ST_MTIM@ @@ -124,6 +127,7 @@ # define KWSYS_CXX_DEFINE_SPECIALIZATION @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION # define KWSYS_CXX_DECL_TYPENAME @KWSYS_NAMESPACE@_CXX_DECL_TYPENAME # define KWSYS_STL_HAS_ALLOCATOR_REBIND @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND +# define KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT #endif #endif diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in index a8cf6c7..033bcfd 100644 --- a/Source/kwsys/hashtable.hxx.in +++ b/Source/kwsys/hashtable.hxx.in @@ -119,11 +119,18 @@ public: alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p)), n*chunk()); } } +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT + size_type max_size(size_type s) const throw() + { + return alloc_.max_size(s); + } +#else size_type max_size() const throw() { size_type n = alloc_.max_size() / chunk(); return n>0? n:1; } +#endif void construct(pointer p, const value_type& val) { new (p) value_type(val); } void destroy(pointer p) { (void)p; p->~value_type(); } private: diff --git a/Source/kwsys/kwsysPlatformCxxTests.cxx b/Source/kwsys/kwsysPlatformCxxTests.cxx index 5c1288e..74e83bd 100644 --- a/Source/kwsys/kwsysPlatformCxxTests.cxx +++ b/Source/kwsys/kwsysPlatformCxxTests.cxx @@ -122,6 +122,19 @@ int main() } #endif +#ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT +#include <memory> +void f(kwsys_stl::allocator<char> const& a) +{ + a.max_size(sizeof(int)); +}; +int main() +{ + f(kwsys_stl::allocator<char>()); + return 0; +} +#endif + #ifdef TEST_KWSYS_STAT_HAS_ST_MTIM #include <sys/types.h> #include <sys/stat.h> @@ -204,6 +204,7 @@ cmake_kwsys_config_replace_string () s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g; s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g; s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g; + s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g; s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g; s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g; s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g; @@ -716,6 +717,7 @@ KWSYS_STL_HAVE_STD=0 KWSYS_STAT_HAS_ST_MTIM=0 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0 KWSYS_STL_HAS_ALLOCATOR_REBIND=0 +KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0 @@ -801,6 +803,15 @@ else fi if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then + KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1 + echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument" +else + echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument" +fi + +if cmake_try_run "${cmake_cxx_compiler}" \ "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \ "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then echo "${cmake_cxx_compiler} does not require template friends to use <>" |