diff --git a/CMakeLists.txt b/CMakeLists.txt index 735b469..4b497fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,7 +246,25 @@ check_cxx_source_compiles( "#include int main(){std::list l; __typeof__(l.begin()) p=l.begin();}" CPPCMS_HAVE_UNDERSCORE_TYPEOF) +check_cxx_source_compiles( + "#ifndef _FILE_OFFSET_BITS + #define _FILE_OFFSET_BITS 64 + #endif + #include + int main() + { + char is_big[sizeof(off_t) >= 8 ? 1 : -1]; + fseeko(0,0,0); + }" + CPPCMS_HAVE_FSEEKO +) +check_cxx_source_compiles( + "#include + int main() + { _fseeki64(0,0,0); }" + CPPCMS_HAVE_FSEEKI64 +) if(NOT DISABLE_GZIP) find_library(ZLIB NAMES z zdll zlib${ZLIB_SUFFIX} zlib) find_path(ZLIB_INCLUDE_DIR zlib.h) diff --git a/config.cmake.h b/config.cmake.h index 215bd43..d006ef7 100644 --- a/config.cmake.h +++ b/config.cmake.h @@ -110,6 +110,8 @@ #cmakedefine CPPCMS_NO_GZIP #cmakedefine CPPCMS_SQLITE_LINK_STATIC #cmakedefine CPPCMS_HAS_THREAD_PSHARED +#cmakedefine CPPCMS_HAVE_FSEEKI64 +#cmakedefine CPPCMS_HAVE_FSEEKO #endif diff --git a/private/http_file_buffer.h b/private/http_file_buffer.h index e6bffde..0e50ce4 100644 --- a/private/http_file_buffer.h +++ b/private/http_file_buffer.h @@ -10,10 +10,14 @@ #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #endif - -#ifdef CPPCMS_WIN_NATIVE +#include +#include +#ifdef CPPCMS_HAVE_FSEEKO +// nothing +#elif defined(CPPCMS_HAVE_FSEEKI64) #define fseeko(f,o,w) _fseeki64(f,o,w) -#define ftello(f) _ftelli64(f) +#else +#define fseek(f,o,w) fseek(f,o,w) #endif #include diff --git a/tests/file_buffer_test.cpp b/tests/file_buffer_test.cpp index b87c326..27a5b9d 100644 --- a/tests/file_buffer_test.cpp +++ b/tests/file_buffer_test.cpp @@ -131,8 +131,6 @@ int main() test(size,inmem[m]); } } - FILE *f=0; - TEST(sizeof( ftello(f) ) > 4); } catch(std::exception const &e) { std::cerr << "FAIL: " << e.what() << std::endl;