check if platform provides 64-bit offset functions

apparently FreeBSD does not support all of them, including some types

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-01-15 01:54:46 +00:00
parent 97ef7d3961
commit fb9fad4460
4 changed files with 72 additions and 52 deletions

View file

@ -231,6 +231,26 @@ katie_check_function(gmtime_r "time.h")
katie_check_function(fcvt "stdlib.h")
katie_check_function(ecvt "stdlib.h")
# 64-bit offset alternatives, if any of the function 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")
if(KATIE_COMPILER MATCHES "(gcc|clang)")
set(QT_VISIBILITY_AVAILABLE TRUE)
endif()

View file

@ -25,12 +25,29 @@ macro(KATIE_CHECK_FUNCTION FORFUNCTION FROMHEADER)
if(NOT HAVE_${FORFUNCTION})
check_function_exists("${FORFUNCTION}" HAVE_${FORFUNCTION})
endif()
if(HAVE_${FORFUNCTION})
string(TOUPPER "${FORFUNCTION}" upperfunction)
add_definitions(-DQT_HAVE_${upperfunction})
endif()
endmacro()
# a macro to check for function with 64-bit offset alternative, sets the result
# of the check to regular function name if not available
macro(KATIE_CHECK_FUNCTION64 FORFUNCTION FROMHEADER)
set(savedefinitions ${CMAKE_REQUIRED_DEFINITIONS})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
check_symbol_exists("${FORFUNCTION}" "${FROMHEADER}" HAVE_${FORFUNCTION})
if(NOT HAVE_${FORFUNCTION})
check_function_exists("${FORFUNCTION}" HAVE_${FORFUNCTION})
endif()
if(NOT HAVE_${FORFUNCTION})
set(QT_LARGEFILE_SUPPORT FALSE)
endif()
set(CMAKE_REQUIRED_DEFINITIONS ${savedefinitions})
endmacro()
# a macro to write data to file, does nothing if the file exists and its
# content is the same as the data
macro(KATIE_WRITE_FILE OUTFILE DATA)

View file

@ -114,6 +114,7 @@
/* Build specs */
#define QT_KATIE
#cmakedefine QT_VISIBILITY_AVAILABLE
#cmakedefine QT_LARGEFILE_SUPPORT
#cmakedefine QT_POINTER_SIZE ${QT_POINTER_SIZE}
#cmakedefine QT_NO_USING_NAMESPACE

View file

@ -37,13 +37,6 @@
// Get defines/settings
#include "qconfig.h"
// use LFS extension if required macros are defined, unless interface
// offset is set to 64 in which case both interfaces are the same
#if defined(_LARGEFILE64_SOURCE) && defined(_LARGEFILE_SOURCE) \
&& (_FILE_OFFSET_BITS-0) != 64
# define QT_LARGEFILE_SUPPORT
#endif
#if defined(__linux__)
// 1) need to reset default environment if _BSD_SOURCE is defined
// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
@ -69,7 +62,12 @@
#include <sys/socket.h>
#include <sys/stat.h>
#if defined(QT_LARGEFILE_SUPPORT)
// 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) \
&& (_FILE_OFFSET_BITS-0) != 64 && defined(QT_LARGEFILE_SUPPORT)
#define QT_STATBUF struct stat64
#define QT_FPOS_T fpos64_t
@ -77,47 +75,50 @@
#define QT_STAT ::stat64
#define QT_LSTAT ::lstat64
#define QT_TRUNCATE ::truncate64
// File I/O
#define QT_OPEN ::open64
#define QT_LSEEK ::lseek64
#define QT_FSTAT ::fstat64
#define QT_FTRUNCATE ::ftruncate64
#define QT_CREAT ::creat64
// Standard C89
#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
#else // defined(QT_LARGEFILE_SUPPORT)
#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
#define QT_STAT ::stat
#define QT_LSTAT ::lstat
#define QT_FSTAT ::fstat
#define QT_OPEN ::open
#define QT_CREAT ::creat
#define QT_LSEEK ::lseek
#define QT_TRUNCATE ::truncate
#define QT_FOPEN ::fopen
#define QT_FSEEK ::fseek
#define QT_FTELL ::ftell
#define QT_FGETPOS ::fgetpos
#define QT_FSETPOS ::fsetpos
#define QT_STATBUF struct stat
#define QT_STAT ::stat
#define QT_LSTAT ::lstat
#define QT_TRUNCATE ::truncate
// File I/O
#define QT_OPEN ::open
#define QT_LSEEK ::lseek
#define QT_FSTAT ::fstat
#define QT_FTRUNCATE ::ftruncate
#define QT_CREAT ::creat
#define QT_MMAP ::mmap
#define QT_DIRENT struct dirent
#define QT_READDIR ::readdir
#define QT_READDIR_R ::readdir_r
// Posix extensions to C89
#if !defined(QT_NO_USE_FSEEKO)
@ -131,9 +132,9 @@
#define QT_FTELL ::ftello
#endif
#define QT_MMAP ::mmap
#define QT_OPEN_LARGEFILE 0
#endif // defined(QT_LARGEFILE_SUPPORT)
#endif // QT_LARGEFILE_SUPPORT
#define QT_STAT_MASK S_IFMT
#define QT_STAT_REG S_IFREG
@ -145,17 +146,10 @@
#define QT_CHDIR ::chdir
#define QT_MKDIR ::mkdir
#define QT_RMDIR ::rmdir
// File I/O
#define QT_CLOSE ::close
#define QT_READ ::read
#define QT_WRITE ::write
#if defined(__FreeBSD__) || defined(__OpenBSD__)
# define QT_OPEN_LARGEFILE 0
#else
# define QT_OPEN_LARGEFILE O_LARGEFILE
#endif
#define QT_OPEN_RDONLY O_RDONLY
#define QT_OPEN_WRONLY O_WRONLY
#define QT_OPEN_RDWR O_RDWR
@ -164,25 +158,13 @@
#define QT_OPEN_APPEND O_APPEND
// Posix extensions to C89
#define QT_FILENO fileno
#define QT_FILENO ::fileno
// Directory iteration
#define QT_DIR DIR
#define QT_OPENDIR ::opendir
#define QT_CLOSEDIR ::closedir
#if defined(QT_LARGEFILE_SUPPORT) \
&& !defined(QT_NO_READDIR64)
#define QT_DIRENT struct dirent64
#define QT_READDIR ::readdir64
#define QT_READDIR_R ::readdir64_r
#else
#define QT_DIRENT struct dirent
#define QT_READDIR ::readdir
#define QT_READDIR_R ::readdir_r
#endif
#if defined(__GLIBC__) && (__GLIBC__ < 2)
#define QT_SOCKLEN_T int
#else