From 95bb7f5aa59d0e3a277c69f171d640577f315684 Mon Sep 17 00:00:00 2001
From: Brad Parker <cbparker@gmail.com>
Date: Wed, 14 Feb 2018 06:16:12 +0000
Subject: [PATCH] use 64-bit file offsets/seeking on windows

---
 Makefile                                 | 2 +-
 libretro-common/vfs/vfs_implementation.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 9a33100f44..a9e72cb4b7 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ endif
 
 OBJ :=
 LIBS :=
-DEFINES := -DHAVE_CONFIG_H -DRARCH_INTERNAL
+DEFINES := -DHAVE_CONFIG_H -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64
 DEFINES += -DGLOBAL_CONFIG_DIR='"$(GLOBAL_CONFIG_DIR)"'
 
 ifneq ($(findstring BSD,$(OS)),)
diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c
index 948e9a337b..0e96f2957f 100644
--- a/libretro-common/vfs/vfs_implementation.c
+++ b/libretro-common/vfs/vfs_implementation.c
@@ -120,7 +120,12 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i
       goto error;
 
    if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
-      return fseek(stream->fp, (long)offset, whence);
+/* VC2005 and up have a special 64-bit fseek */
+#ifdef ATLEAST_VC2005
+      return _fseeki64(stream->fp, offset, whence);
+#else
+      return fseeko(stream->fp, (off_t)offset, whence);
+#endif
 
 #ifdef HAVE_MMAP
    /* Need to check stream->mapped because this function is