From 1030e5d5ecc8ca631254de5f7acf3d227e4221e3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 18 Mar 2012 12:31:29 -0400 Subject: [PATCH] Removed llseek(). Use Linux's off64_t support instead. --- CMakeLists.txt | 2 -- src/physfs_internal.h | 4 ++++ src/platform_posix.c | 29 +++-------------------------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16654e75..9b4e5a72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,8 +147,6 @@ IF(UNIX) SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE) SET(HAVE_PTHREAD_H TRUE) ELSE(BEOS) - # !!! FIXME - # AC_DEFINE([PHYSFS_HAVE_LLSEEK], 1, [define if we have llseek]) CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H) IF(HAVE_UCRED_H) ADD_DEFINITIONS(-DPHYSFS_HAVE_SYS_UCRED_H=1) diff --git a/src/physfs_internal.h b/src/physfs_internal.h index 96d7272c..15243499 100644 --- a/src/physfs_internal.h +++ b/src/physfs_internal.h @@ -55,6 +55,10 @@ extern "C" { # define inline __inline #endif +#if defined(__linux__) && !defined(_FILE_OFFSET_BITS) +#define _FILE_OFFSET_BITS 64 +#endif + /* * Interface for small allocations. If you need a little scratch space for * a throwaway buffer or string, use this. It will make small allocations diff --git a/src/platform_posix.c b/src/platform_posix.c index 50b19691..f9909045 100644 --- a/src/platform_posix.c +++ b/src/platform_posix.c @@ -24,10 +24,6 @@ #include #endif -#ifdef PHYSFS_HAVE_LLSEEK -#include -#endif - #include "physfs_internal.h" char *__PHYSFS_platformCopyEnvironmentVariable(const char *varname) @@ -286,17 +282,7 @@ PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer, int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos) { const int fd = *((int *) opaque); - - #ifdef PHYSFS_HAVE_LLSEEK - unsigned long offset_high = ((pos >> 32) & 0xFFFFFFFF); - unsigned long offset_low = (pos & 0xFFFFFFFF); - loff_t retoffset; - int rc = llseek(fd, offset_high, offset_low, &retoffset, SEEK_SET); - BAIL_IF_MACRO(rc == -1, strerror(errno), 0); - #else - BAIL_IF_MACRO(lseek(fd, (int) pos, SEEK_SET) == -1, strerror(errno), 0); - #endif - + BAIL_IF_MACRO(lseek(fd, (off_t) pos, SEEK_SET) == -1, strerror(errno), 0); return 1; } /* __PHYSFS_platformSeek */ @@ -305,17 +291,8 @@ PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) { const int fd = *((int *) opaque); PHYSFS_sint64 retval; - - #ifdef PHYSFS_HAVE_LLSEEK - loff_t retoffset; - int rc = llseek(fd, 0, &retoffset, SEEK_CUR); - BAIL_IF_MACRO(rc == -1, strerror(errno), -1); - retval = (PHYSFS_sint64) retoffset; - #else - retval = (PHYSFS_sint64) lseek(fd, 0, SEEK_CUR); - BAIL_IF_MACRO(retval == -1, strerror(errno), -1); - #endif - + retval = (PHYSFS_sint64) lseek(fd, 0, SEEK_CUR); + BAIL_IF_MACRO(retval == -1, strerror(errno), -1); return retval; } /* __PHYSFS_platformTell */