From 7bcdcb69fa6623a829b24b4dcf73a73f13439648 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 10 Jun 2021 10:08:35 +0300 Subject: [PATCH] use _FILE_OFFSET_BITS definition for LFS support noted as recommended method for LFS support on 32-bit systems at: https://man7.org/linux/man-pages/man2/open.2.html Signed-off-by: Ivailo Monev --- CMakeLists.txt | 22 +------------------- cmake/modules/KatieBuildMacros.cmake | 16 --------------- src/core/global/qconfig.h.cmake | 1 - src/core/global/qplatformdefs.h | 40 ------------------------------------ src/core/io/qfsfileengine.cpp | 4 ---- 5 files changed, 1 insertion(+), 82 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 889ee98fa..9f7d2671b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ endforeach() # https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html # https://github.com/Kitware/CMake/blob/master/Modules/CMakeDetermineSystem.cmake if(CMAKE_SYSTEM_NAME MATCHES "(Linux|GNU)") - katie_definition(-D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_GNU_SOURCE) + katie_definition(-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE) elseif(CMAKE_SYSTEM_NAME MATCHES "(FreeBSD|DragonFly)") katie_definition(-D_THREAD_SAFE) elseif(NOT CMAKE_SYSTEM_NAME MATCHES "(OpenBSD|NetBSD|Solaris|SunOS)") @@ -410,26 +410,6 @@ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) katie_check_function(pthread_setname_np "pthread.h") cmake_reset_check_state() -# 64-bit offset alternatives, if any of the functions is not found it will set -# QT_LARGEFILE_SUPPORT to FALSE. QT_LARGEFILE_SUPPORT is used in qconfig.h -set(QT_LARGEFILE_SUPPORT TRUE) -katie_check_function64(stat64 "sys/stat.h") -katie_check_function64(lstat64 "sys/stat.h") -katie_check_function64(fstat64 "sys/stat.h") -katie_check_function64(open64 "fcntl.h") -katie_check_function64(creat64 "fcntl.h") -katie_check_function64(lseek64 "unistd.h") -katie_check_function64(truncate64 "unistd.h") -katie_check_function64(ftruncate64 "unistd.h") -katie_check_function64(fopen64 "stdio.h") -katie_check_function64(fseeko64 "stdio.h") -katie_check_function64(ftello64 "stdio.h") -katie_check_function64(fgetpos64 "stdio.h") -katie_check_function64(fsetpos64 "stdio.h") -katie_check_function64(mmap64 "sys/mman.h") -katie_check_function64(readdir64 "dirent.h") -katie_check_function64(readdir64_r "dirent.h") - katie_check_proc(exe) katie_check_proc(cmdline) diff --git a/cmake/modules/KatieBuildMacros.cmake b/cmake/modules/KatieBuildMacros.cmake index bf97a2b46..c6ee6f6b5 100644 --- a/cmake/modules/KatieBuildMacros.cmake +++ b/cmake/modules/KatieBuildMacros.cmake @@ -51,22 +51,6 @@ macro(KATIE_CHECK_FUNCTION FORFUNCTION FROMHEADER) endif() endmacro() -# a function to check for C function with 64-bit offset alternative, sets -# QT_LARGEFILE_SUPPORT to FALSE if not available and does not perform -# additional checks if one fails -function(KATIE_CHECK_FUNCTION64 FORFUNCTION FROMHEADER) - if(QT_LARGEFILE_SUPPORT) - cmake_reset_check_state() - set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) - katie_check_defined("${FORFUNCTION}" "${FROMHEADER}") - cmake_reset_check_state() - - if(NOT HAVE_${FORFUNCTION}) - set(QT_LARGEFILE_SUPPORT FALSE PARENT_SCOPE) - endif() - endif() -endfunction() - # a function to check for C struct member presence in header, if member is # found a definition is added function(KATIE_CHECK_STRUCT FORSTRUCT FORMEMBER FROMHEADER) diff --git a/src/core/global/qconfig.h.cmake b/src/core/global/qconfig.h.cmake index 2c47ab318..81c1b37ef 100644 --- a/src/core/global/qconfig.h.cmake +++ b/src/core/global/qconfig.h.cmake @@ -31,7 +31,6 @@ #define QT_VERSION ${KATIE_HEX} #define QT_KATIE -#cmakedefine QT_LARGEFILE_SUPPORT #cmakedefine QT_POINTER_SIZE ${QT_POINTER_SIZE} // No longer supported diff --git a/src/core/global/qplatformdefs.h b/src/core/global/qplatformdefs.h index f32d3528a..fa387f269 100644 --- a/src/core/global/qplatformdefs.h +++ b/src/core/global/qplatformdefs.h @@ -34,42 +34,6 @@ #include #include -// use LFS extension if required macros are defined, unless interface -// offset is set to 64 in which case both interfaces are the same. -// the host must support all of the functions, if that is the case -// QT_LARGEFILE_SUPPORT is defined -#if defined(_LARGEFILE64_SOURCE) && defined(_LARGEFILE_SOURCE) \ - && defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS != 64 \ - && defined(QT_LARGEFILE_SUPPORT) - -#define QT_STATBUF struct stat64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t - -#define QT_STAT ::stat64 -#define QT_LSTAT ::lstat64 -#define QT_FSTAT ::fstat64 - -#define QT_OPEN ::open64 -#define QT_CREAT ::creat64 -#define QT_LSEEK ::lseek64 -#define QT_TRUNCATE ::truncate64 -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_MMAP ::mmap64 - -#define QT_DIRENT struct dirent64 -#define QT_READDIR ::readdir64 -#define QT_READDIR_R ::readdir64_r - -#define QT_OPEN_LARGEFILE O_LARGEFILE - -#else // QT_LARGEFILE_SUPPORT - #define QT_STATBUF struct stat #define QT_FPOS_T fpos_t #define QT_OFF_T long @@ -105,10 +69,6 @@ #define QT_FTELL ::ftello #endif -#define QT_OPEN_LARGEFILE 0 - -#endif // QT_LARGEFILE_SUPPORT - #define QT_STAT_MASK S_IFMT #define QT_STAT_REG S_IFREG #define QT_STAT_DIR S_IFDIR diff --git a/src/core/io/qfsfileengine.cpp b/src/core/io/qfsfileengine.cpp index dbe581a40..8114ff0bd 100644 --- a/src/core/io/qfsfileengine.cpp +++ b/src/core/io/qfsfileengine.cpp @@ -146,11 +146,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode) d->metaData.clear(); d->fd = -1; -#ifdef QT_LARGEFILE_SUPPORT - int flags = QT_OPEN_RDONLY | QT_OPEN_LARGEFILE; -#else int flags = QT_OPEN_RDONLY; -#endif if ((d->openMode & QFile::ReadWrite) == QFile::ReadWrite) { flags = QT_OPEN_RDWR | QT_OPEN_CREAT; -- 2.11.0