shithub: sox

Download patch

ref: 16fcc452e6ee97c261d9c30c1045ab31b144decb
parent: f7c7904142abadfbf7a3b4cecdc783d3e267cafc
author: idigdoug <idigdoug>
date: Fri Jan 1 07:30:21 EST 2010

64-bit file support in MinGW builds for windows.

--- a/msvc9/Sox/soxconfig.h
+++ b/msvc9/Sox/soxconfig.h
@@ -80,7 +80,7 @@
 #define STATIC_WAVPACK 1
 
 #define HAVE_CONIO_H 1
-#define HAVE_FSEEKI64 1
+#define HAVE__FSEEKI64 1
 #define HAVE_FCNTL_H 1
 #define HAVE_IO_H 1
 #define HAVE_MEMORY_H 1
--- a/src/libsox_i.c
+++ b/src/libsox_i.c
@@ -27,9 +27,12 @@
 
 #ifdef HAVE_UNISTD_H
   #include <unistd.h>
-  #define MKTEMP_X 0
-#else /* win32 */
+#endif
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
   #define MKTEMP_X _O_BINARY|_O_TEMPORARY
+#else
+  #define MKTEMP_X 0
 #endif
 
 #ifndef HAVE_MKSTEMP
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -40,10 +40,6 @@
 typedef enum {SOX_WAVE_SINE, SOX_WAVE_TRIANGLE} lsx_wave_t;
 extern lsx_enum_item const lsx_wave_enum[];
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h> /* For off_t not found in stdio.h */
-#endif
-
 /* Define fseeko and ftello for platforms lacking them */
 #ifndef HAVE_FSEEKO
 #define fseeko fseek
--- a/src/util.h
+++ b/src/util.h
@@ -17,6 +17,14 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h> /* For off_t not found in stdio.h */
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h> /* Needs to be included before we redefine off_t. */
+#endif
+
 #include "xmalloc.h"
 
 /*---------------------------- Portability stuff -----------------------------*/
@@ -46,7 +54,13 @@
 #define dup _dup
 #define fdopen _fdopen
 #define fileno _fileno
+
+#ifdef _fstati64
+#define fstat _fstati64
+#else
 #define fstat _fstat
+#endif
+
 #define ftime _ftime
 #define inline __inline
 #define isatty _isatty
@@ -58,16 +72,34 @@
 #define popen _popen
 #define setmode _setmode
 #define snprintf _snprintf
+
+#ifdef _stati64
+#define stat _stati64
+#else
 #define stat _stat
+#endif
+
 #define strdup _strdup
 #define timeb _timeb
 #define unlink _unlink
 
-#if defined(HAVE_FSEEKI64) && !defined(HAVE_FSEEKO)
+#if defined(HAVE__FSEEKI64) && !defined(HAVE_FSEEKO)
 #undef off_t
 #define fseeko _fseeki64
 #define ftello _ftelli64
 #define off_t __int64
+#define HAVE_FSEEKO 1
+#endif
+
+#elif defined(__MINGW32__)
+
+#if !defined(HAVE_FSEEKO)
+#undef off_t
+#define fseeko fseeko64
+#define fstat _fstati64
+#define ftello ftello64
+#define off_t off64_t
+#define stat _stati64
 #define HAVE_FSEEKO 1
 #endif