[Scummvm-git-logs] scummvm master -> b79e5a3b2d648353f24a9e4f7badee59b4f5358a
sev-
noreply at scummvm.org
Sun Dec 11 20:48:37 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
700a8071e5 BUILD: Check if there's an fseeko/ftello with 64-bit off_t
0eb9ca84de BACKENDS: Make StdioStream use a 64-bit fseeko/ftello on more platforms
b79e5a3b2d CONFIGURE: Do more getconf checks before using its output
Commit: 700a8071e553c99f1260e02756b20ae39eb80ccd
https://github.com/scummvm/scummvm/commit/700a8071e553c99f1260e02756b20ae39eb80ccd
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2022-12-11T21:48:33+01:00
Commit Message:
BUILD: Check if there's an fseeko/ftello with 64-bit off_t
Some systems have fseeko but you need to check that off_t is a 64-bit
value (and this requires some magic incantation on some platforms),
others need fseeko64(), Windows has a different symbol, and then some
systems only have an fseek() that's limited to <2GB files.
This is a first step in trying to improve this.
Changed paths:
configure
devtools/create_project/cmake.cpp
devtools/create_project/xcode.cpp
diff --git a/configure b/configure
index 7bbfa5644e0..620dd63fc9d 100755
--- a/configure
+++ b/configure
@@ -256,6 +256,8 @@ _detection_features_full=yes
# be modified otherwise. Consider them read-only.
_posix=no
_has_posix_spawn=no
+_has_fseeko_offt_64=no
+_has_fseeko64=no
_endian=unknown
_need_memalign=yes
_have_x86=no
@@ -2983,11 +2985,6 @@ EOF
_ranlib=:
;;
linux* | uclinux*)
- # When not cross-compiling, enable large file support, but don't
- # care if getconf doesn't exist or doesn't recognize LFS_CFLAGS.
- if test -z "$_host"; then
- append_var CXXFLAGS "`getconf LFS_CFLAGS 2>/dev/null`"
- fi
;;
mingw*)
append_var DEFINES "-DWIN32"
@@ -4061,6 +4058,84 @@ EOF
fi
fi
+#
+# Check for 64-bit file offset compatibility
+#
+# This is currently only used by StdioStream. If nothing is found,
+# you'll be limited to <2GB files, which still covers the vast majority
+# of supported games.
+#
+case $_host_os in
+ mingw*)
+ # StdioStream just uses _ftelli64
+ ;;
+ *)
+ echo_n "Checking if fseeko with 64-bit off_t is supported... "
+ cat > $TMPC << EOF
+#include <stdio.h>
+#include <sys/types.h> /* off_t on legacy systems */
+int main() {
+ static int test_array[1 - 2 * !(sizeof(off_t) >= 8)];
+ fseeko(stdin, 0, SEEK_SET);
+ test_array[0] = 0;
+ return 0;
+}
+EOF
+ cc_check_no_clean && _has_fseeko_offt_64=yes
+ # Good, there's fseeko with a 64-bit off_t by default
+ if test "$_has_fseeko_offt_64" = yes ; then
+ echo yes
+ append_var DEFINES "-DHAS_FSEEKO_OFFT_64"
+ else
+ # Otherwise, when not cross-compiling, try with LFS_CFLAGS
+ if test -z "$_host"; then
+ TMPFLAGS=`getconf LFS_CFLAGS 2>/dev/null`
+ if ! test -z "$TMPFLAGS" ; then
+ cc_check_no_clean $TMPFLAGS && _has_fseeko_offt_64=yes
+ if test "$_has_fseeko_offt_64" = yes ; then
+ echo "yes (adding $TMPFLAGS)"
+ append_var DEFINES "-DHAS_FSEEKO_OFFT_64"
+ append_var CXXFLAGS "$TMPFLAGS"
+ fi
+ fi
+ fi
+
+ # Otherwise, try the usual magical suspects
+ if test "$_has_fseeko_offt_64" = no ; then
+ # note: -D__LARGE64_FILES is another option, but it may be broken on
+ # some platforms, so add it to your platform defines instead, if it
+ # requires it and you've checked that the result works.
+ for largeflag in "-D_FILE_OFFSET_BITS=64" "-D_LARGE_FILES" "-D_LARGEFILE_SOURCE" ; do
+ cc_check_no_clean $largeflag && _has_fseeko_offt_64=yes
+ if test "$_has_fseeko_offt_64" = yes ; then
+ echo "yes (adding $largeflag)"
+ append_var DEFINES "-DHAS_FSEEKO_OFFT_64"
+ append_var CXXFLAGS "$largeflag"
+ break
+ fi
+ done
+ fi
+
+ # Otherwise, fseeko64 is your last chance
+ if test "$_has_fseeko_offt_64" = no ; then
+ echo no
+ echo_n "Checking if fseeko64 is supported... "
+ cat > $TMPC << EOF
+#include <stdio.h>
+int main() { fseeko64(stdin, 0, SEEK_SET); return 0; }
+EOF
+ cc_check_no_clean -D_LARGEFILE64_SOURCE && _has_fseeko64=yes
+ echo $_has_fseeko64
+ if test "$_has_fseeko64" = yes ; then
+ append_var DEFINES "-DHAS_FSEEKO64"
+ append_var CXXFLAGS "-D_LARGEFILE64_SOURCE"
+ fi
+ fi
+ fi
+ cc_check_clean
+ ;;
+esac
+
#
# Check whether to enable a verbose build
#
diff --git a/devtools/create_project/cmake.cpp b/devtools/create_project/cmake.cpp
index d7615784777..4fd9f9581de 100644
--- a/devtools/create_project/cmake.cpp
+++ b/devtools/create_project/cmake.cpp
@@ -341,6 +341,9 @@ void CMakeProvider::writeDefines(const BuildSetup &setup, std::ofstream &output)
output << "\tadd_definitions(-DWIN32)\n";
output << "else()\n";
output << "\tadd_definitions(-DPOSIX)\n";
+ output << "\t# Hope for the best regarding fseeko and 64-bit off_t\n";
+ output << "\tadd_definitions(-D_FILE_OFFSET_BITS=64)\n";
+ output << "\tadd_definitions(-DHAS_FSEEKO_OFFT_64)\n";
output << "endif()\n";
output << "add_definitions(-DSDL_BACKEND)\n";
diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index 6539ae6db53..b9c4a3a8e29 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -1343,6 +1343,7 @@ void XcodeProvider::setupDefines(const BuildSetup &setup) {
REMOVE_DEFINE(_defines, "SDL_BACKEND");
ADD_DEFINE(_defines, "CONFIG_H");
ADD_DEFINE(_defines, "UNIX");
+ ADD_DEFINE(_defines, "HAS_FSEEKO_OFFT_64");
ADD_DEFINE(_defines, "SCUMMVM");
}
Commit: 0eb9ca84de26e3ee13a14567649c0df43bd76e97
https://github.com/scummvm/scummvm/commit/0eb9ca84de26e3ee13a14567649c0df43bd76e97
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2022-12-11T21:48:33+01:00
Commit Message:
BACKENDS: Make StdioStream use a 64-bit fseeko/ftello on more platforms
Note that using fseeko64() means that fopen64() should be used instead.
Changed paths:
backends/fs/posix/posix-iostream.cpp
backends/fs/stdiostream.cpp
diff --git a/backends/fs/posix/posix-iostream.cpp b/backends/fs/posix/posix-iostream.cpp
index f8a83647e47..4a97577be7b 100644
--- a/backends/fs/posix/posix-iostream.cpp
+++ b/backends/fs/posix/posix-iostream.cpp
@@ -32,7 +32,11 @@
PosixIoStream *PosixIoStream::makeFromPath(const Common::String &path, bool writeMode) {
+#if defined(HAS_FSEEKO64)
+ FILE *handle = fopen64(path.c_str(), writeMode ? "wb" : "rb");
+#else
FILE *handle = fopen(path.c_str(), writeMode ? "wb" : "rb");
+#endif
if (handle)
return new PosixIoStream(handle);
diff --git a/backends/fs/stdiostream.cpp b/backends/fs/stdiostream.cpp
index 29d782c043a..c24de4f6725 100644
--- a/backends/fs/stdiostream.cpp
+++ b/backends/fs/stdiostream.cpp
@@ -57,8 +57,10 @@ bool StdioStream::eos() const {
int64 StdioStream::pos() const {
#if defined(WIN32)
return _ftelli64((FILE *)_handle);
-#elif defined(__linux__) || defined(__APPLE__)
+#elif defined(HAS_FSEEKO_OFFT_64)
return ftello((FILE *)_handle);
+#elif defined(HAS_FSEEKO64)
+ return ftello64((FILE *)_handle);
#else
return ftell((FILE *)_handle);
#endif
@@ -70,11 +72,16 @@ int64 StdioStream::size() const {
_fseeki64((FILE *)_handle, 0, SEEK_END);
int64 length = _ftelli64((FILE *)_handle);
_fseeki64((FILE *)_handle, oldPos, SEEK_SET);
-#elif defined(__linux__) || defined(__APPLE__)
+#elif defined(HAS_FSEEKO_OFFT_64)
int64 oldPos = ftello((FILE *)_handle);
fseeko((FILE *)_handle, 0, SEEK_END);
int64 length = ftello((FILE *)_handle);
fseeko((FILE *)_handle, oldPos, SEEK_SET);
+#elif defined(HAS_FSEEKO64)
+ int64 oldPos = ftello64((FILE *)_handle);
+ fseeko64((FILE *)_handle, 0, SEEK_END);
+ int64 length = ftello64((FILE *)_handle);
+ fseeko64((FILE *)_handle, oldPos, SEEK_SET);
#else
int64 oldPos = ftell((FILE *)_handle);
fseek((FILE *)_handle, 0, SEEK_END);
@@ -88,8 +95,10 @@ int64 StdioStream::size() const {
bool StdioStream::seek(int64 offs, int whence) {
#if defined(WIN32)
return _fseeki64((FILE *)_handle, offs, whence) == 0;
-#elif defined(__linux__) || defined(__APPLE__)
+#elif defined(HAS_FSEEKO_OFFT_64)
return fseeko((FILE *)_handle, offs, whence) == 0;
+#elif defined(HAS_FSEEKO64)
+ return fseeko64((FILE *)_handle, offs, whence) == 0;
#else
return fseek((FILE *)_handle, offs, whence) == 0;
#endif
@@ -120,6 +129,8 @@ StdioStream *StdioStream::makeFromPath(const Common::String &path, bool writeMod
wchar_t *wPath = Win32::stringToTchar(path);
FILE *handle = _wfopen(wPath, writeMode ? L"wb" : L"rb");
free(wPath);
+#elif defined(HAS_FSEEKO64)
+ FILE *handle = fopen64(path.c_str(), writeMode ? "wb" : "rb");
#else
FILE *handle = fopen(path.c_str(), writeMode ? "wb" : "rb");
#endif
Commit: b79e5a3b2d648353f24a9e4f7badee59b4f5358a
https://github.com/scummvm/scummvm/commit/b79e5a3b2d648353f24a9e4f7badee59b4f5358a
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2022-12-11T21:48:33+01:00
Commit Message:
CONFIGURE: Do more getconf checks before using its output
Based on its POSIX specification.
Changed paths:
configure
diff --git a/configure b/configure
index 620dd63fc9d..258bd8fa50e 100755
--- a/configure
+++ b/configure
@@ -4090,7 +4090,7 @@ EOF
# Otherwise, when not cross-compiling, try with LFS_CFLAGS
if test -z "$_host"; then
TMPFLAGS=`getconf LFS_CFLAGS 2>/dev/null`
- if ! test -z "$TMPFLAGS" ; then
+ if test $? -eq 0 && test ! -z "$TMPFLAGS" && test "$TMPFLAGS" != undefined ; then
cc_check_no_clean $TMPFLAGS && _has_fseeko_offt_64=yes
if test "$_has_fseeko_offt_64" = yes ; then
echo "yes (adding $TMPFLAGS)"
More information about the Scummvm-git-logs
mailing list