crt: Provide _lseeki64() function for pre-msvcrt40 builds
Function _lseeki64() is available since msvcrt40.dll. For older CRT
libraries provides emulation via lseek().
Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 9c138c4..b8186de 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -832,6 +832,7 @@
misc/dummy__setusermatherr.c \
stdio/_filelengthi64.c \
stdio/_fstat32i64.c \
+ stdio/_lseeki64.c \
stdio/_stat32i64.c \
stdio/_wstat32i64.c \
stdio/fgetpos.c \
diff --git a/mingw-w64-crt/stdio/_lseeki64.c b/mingw-w64-crt/stdio/_lseeki64.c
new file mode 100644
index 0000000..ce8152e
--- /dev/null
+++ b/mingw-w64-crt/stdio/_lseeki64.c
@@ -0,0 +1,22 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <io.h>
+#include <errno.h>
+#include <limits.h>
+
+/* Define 64-bit _lseeki64() function via 32-bit _lseek() function */
+__int64 __cdecl _lseeki64(int fd, __int64 offset, int whence)
+{
+ if (offset > LONG_MAX)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ return _lseek(fd, offset, whence);
+}
+__int64 (__cdecl *__MINGW_IMP_SYMBOL(_lseeki64))(int, __int64, int) = _lseeki64;