From d510ef2557df9da0b8949409e73b526d137bd13d Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Tue, 22 Aug 2006 15:34:14 -0400 Subject: ENH: Support large file systems in kwsys --- Source/kwsys/CMakeLists.txt | 17 +++++++++++++++++ Source/kwsys/Configure.h.in | 14 ++++++++++++++ Source/kwsys/RequireLargeFilesSupport.cxx | 28 ++++++++++++++++++++++++++++ bootstrap | 2 ++ 4 files changed, 61 insertions(+) create mode 100644 Source/kwsys/RequireLargeFilesSupport.cxx diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 2145b7d..aee68e2 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -241,6 +241,23 @@ IF(NOT KWSYS_IN_SOURCE_BUILD) ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE) ENDIF(NOT KWSYS_IN_SOURCE_BUILD) + +IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4) + MESSAGE(STATUS "Skip large files support because CMake is earlier than 2.4") +ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4) + INCLUDE(CheckCXXSourceRuns) + FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/RequireLargeFilesSupport.cxx" + __kwsys_require_large_files_support) + CHECK_CXX_SOURCE_RUNS("${__kwsys_require_large_files_support}" + REQUIRE_LARGE_FILE_SUPPORT + "Support for 64 bit file systems") + IF(REQUIRE_LARGE_FILE_SUPPORT) + SET(KWSYS_REQUIRE_LARGE_FILE_SUPPORT 1) + ELSE(REQUIRE_LARGE_FILE_SUPPORT) + SET(KWSYS_REQUIRE_LARGE_FILE_SUPPORT 0) + ENDIF(REQUIRE_LARGE_FILE_SUPPORT) +ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4) + #----------------------------------------------------------------------------- # We require ANSI support from the C compiler. Add any needed flags. IF(CMAKE_ANSI_CFLAGS) diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in index 744e884..5456467 100644 --- a/Source/kwsys/Configure.h.in +++ b/Source/kwsys/Configure.h.in @@ -22,6 +22,20 @@ # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT #endif +/* This is a support for files on the disk that are larger than 2GB. Since + this is the first place that any include should happen, do this here. */ +#if @KWSYS_REQUIRE_LARGE_FILE_SUPPORT@ +# ifndef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE +# endif +# ifndef _LARGE_FILES +# define _LARGE_FILES +# endif +# ifndef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 +# endif +#endif + /* Setup the export macro. */ #if defined(_WIN32) && @KWSYS_BUILD_SHARED@ # if defined(@KWSYS_NAMESPACE@_EXPORTS) diff --git a/Source/kwsys/RequireLargeFilesSupport.cxx b/Source/kwsys/RequireLargeFilesSupport.cxx new file mode 100644 index 0000000..596bd60 --- /dev/null +++ b/Source/kwsys/RequireLargeFilesSupport.cxx @@ -0,0 +1,28 @@ +#define _LARGEFILE_SOURCE +#define _LARGE_FILES +#define _FILE_OFFSET_BITS 64 +#include +#include +#include +#include + +int main( int, char **argv ) +{ + // check that off_t can hold 2^63 - 1 and perform basic operations... +#define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + if (OFF_T_64 % 2147483647 != 1) + return 1; + + // stat breaks on SCO OpenServer + struct stat buf; + stat( argv[0], &buf ); + if (!S_ISREG(buf.st_mode)) + return 2; + + FILE *file = fopen( argv[0], "r" ); + off_t offset = ftello( file ); + fseek( file, offset, SEEK_CUR ); + fclose( file ); + return 0; +} + diff --git a/bootstrap b/bootstrap index d6331df..49158b2 100755 --- a/bootstrap +++ b/bootstrap @@ -279,6 +279,7 @@ cmake_kwsys_config_replace_string () cat "${INFILE}" | sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g; s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g; + s/@KWSYS_REQUIRE_LARGE_FILE_SUPPORT@/${KWSYS_REQUIRE_LARGE_FILE_SUPPORT}/g; s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g; s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g; s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g; @@ -821,6 +822,7 @@ fi # Test for kwsys features KWSYS_NAME_IS_KWSYS=0 KWSYS_BUILD_SHARED=0 +KWSYS_REQUIRE_LARGE_FILE_SUPPORT=0 KWSYS_IOS_USE_STRSTREAM_H=0 KWSYS_IOS_USE_STRSTREA_H=0 KWSYS_IOS_HAVE_STD=0 -- cgit v0.12