mirror of
https://github.com/transmission/transmission
synced 2025-03-11 14:43:42 +00:00
Define one of LFS macros instead of using xxx64 functions directly.
There're too many functions and types to consider, and benefits of not using LFS macros aren't that big (I was thinking of using fts(3) but that may not happen soon or at all).
This commit is contained in:
parent
8c511dc590
commit
a2037bdbbd
4 changed files with 39 additions and 18 deletions
|
@ -351,6 +351,8 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NEEDED_CXX_COMPILER_FLAGS_STRING}")
|
||||
endif()
|
||||
|
||||
include(LargeFileSupport)
|
||||
|
||||
set(NEEDED_HEADERS
|
||||
stdbool.h
|
||||
sys/statvfs.h
|
||||
|
@ -377,7 +379,6 @@ set(NEEDED_FUNCTIONS
|
|||
htonll
|
||||
iconv_open
|
||||
localtime_r
|
||||
lseek64
|
||||
memmem
|
||||
mkdtemp
|
||||
ntohll
|
||||
|
|
33
cmake/LargeFileSupport.cmake
Normal file
33
cmake/LargeFileSupport.cmake
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Based on AC_SYS_LARGEFILE
|
||||
|
||||
if(NOT DEFINED NO_LFS_MACROS_REQUIRED)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
# Check that off_t can represent 2**63 - 1 correctly.
|
||||
# We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||
# since some C++ compilers masquerading as C compilers
|
||||
# incorrectly reject 9223372036854775807.
|
||||
set(LFS_TEST_PROGRAM "
|
||||
#include <sys/types.h>
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
|
||||
int main() { return 0; }
|
||||
")
|
||||
|
||||
check_c_source_compiles("${LFS_TEST_PROGRAM}" NO_LFS_MACROS_REQUIRED)
|
||||
if(NOT NO_LFS_MACROS_REQUIRED)
|
||||
if(NOT DEFINED FILE_OFFSET_BITS_LFS_MACRO_REQUIRED)
|
||||
check_c_source_compiles("#define _FILE_OFFSET_BITS 64 ${LFS_TEST_PROGRAM}" FILE_OFFSET_BITS_LFS_MACRO_REQUIRED)
|
||||
if(FILE_OFFSET_BITS_LFS_MACRO_REQUIRED)
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||
elseif(NOT DEFINED LARGE_FILES_LFS_MACRO_REQUIRED)
|
||||
check_c_source_compiles("#define _LARGE_FILES 1 ${LFS_TEST_PROGRAM}" LARGE_FILES_LFS_MACRO_REQUIRED)
|
||||
if(LARGE_FILES_LFS_MACRO_REQUIRED)
|
||||
add_definitions(-D_LARGE_FILES=1)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
unset(LFS_TEST_PROGRAM)
|
||||
endif()
|
|
@ -182,7 +182,6 @@ AC_SUBST(CRYPTO_LIBS)
|
|||
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
AC_CHECK_FUNCS([lseek64])
|
||||
|
||||
AC_FUNC_GETMNTENT
|
||||
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
#define _DARWIN_C_SOURCE
|
||||
#endif
|
||||
|
||||
#if !defined (_LARGEFILE64_SOURCE)
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
@ -68,14 +64,6 @@
|
|||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LSEEK64
|
||||
#define tr_off_t off64_t
|
||||
#define tr_lseek lseek64
|
||||
#else
|
||||
#define tr_off_t off_t
|
||||
#define tr_lseek lseek
|
||||
#endif
|
||||
|
||||
/* don't use pread/pwrite on old versions of uClibc because they're buggy.
|
||||
* https://trac.transmissionbt.com/ticket/3826 */
|
||||
#ifdef __UCLIBC__
|
||||
|
@ -542,7 +530,7 @@ tr_sys_file_seek (tr_sys_file_t handle,
|
|||
tr_error ** error)
|
||||
{
|
||||
bool ret = false;
|
||||
tr_off_t my_new_offset;
|
||||
off_t my_new_offset;
|
||||
|
||||
TR_STATIC_ASSERT (TR_SEEK_SET == SEEK_SET, "values should match");
|
||||
TR_STATIC_ASSERT (TR_SEEK_CUR == SEEK_CUR, "values should match");
|
||||
|
@ -553,7 +541,7 @@ tr_sys_file_seek (tr_sys_file_t handle,
|
|||
assert (handle != TR_BAD_SYS_FILE);
|
||||
assert (origin == TR_SEEK_SET || origin == TR_SEEK_CUR || origin == TR_SEEK_END);
|
||||
|
||||
my_new_offset = tr_lseek (handle, offset, origin);
|
||||
my_new_offset = lseek (handle, offset, origin);
|
||||
|
||||
if (my_new_offset != -1)
|
||||
{
|
||||
|
@ -624,7 +612,7 @@ tr_sys_file_read_at (tr_sys_file_t handle,
|
|||
|
||||
#else
|
||||
|
||||
if (tr_lseek (handle, offset, SEEK_SET) != -1)
|
||||
if (lseek (handle, offset, SEEK_SET) != -1)
|
||||
my_bytes_read = read (handle, buffer, size);
|
||||
else
|
||||
my_bytes_read = -1;
|
||||
|
@ -700,7 +688,7 @@ tr_sys_file_write_at (tr_sys_file_t handle,
|
|||
|
||||
#else
|
||||
|
||||
if (tr_lseek (handle, offset, SEEK_SET) != -1)
|
||||
if (lseek (handle, offset, SEEK_SET) != -1)
|
||||
my_bytes_written = write (handle, buffer, size);
|
||||
else
|
||||
my_bytes_written = -1;
|
||||
|
|
Loading…
Add table
Reference in a new issue