Ryan C. Gordon 24 лет назад
Родитель
Сommit
3b0f1c896f
4 измененных файлов с 26 добавлено и 1 удалено
  1. 11 0
      configure.in
  2. 4 0
      platform/posix.c
  3. 6 0
      platform/unix.c
  4. 5 1
      platform/win32.c

+ 11 - 0
configure.in

@@ -205,6 +205,16 @@ fi
 
 AC_MSG_RESULT([$this_is_beos])
 
+AC_MSG_CHECKING([if this is Cygwin])
+if test x$build_os = xcygwin; then
+  this_is_cygwin=yes
+  CFLAGS="$CFLAGS -DWIN32"
+else
+  this_is_cygwin=no
+fi
+
+AC_MSG_RESULT([$this_is_cygwin])
+
 this_is_macosx=no
 if test x$we_have_sed = xyes; then
   AC_MSG_CHECKING([if this is MacOS X])
@@ -237,6 +247,7 @@ AM_CONDITIONAL(BUILD_ZLIB, test x$enable_internal_zlib = xyes)
 AM_CONDITIONAL(BUILD_TEST_PHYSFS, test x$enable_testprog = xyes)
 AM_CONDITIONAL(BUILD_MACOSX, test x$this_is_macosx = xyes)
 AM_CONDITIONAL(BUILD_BEOS, test x$this_is_beos = xyes)
+AM_CONDITIONAL(BUILD_CYGWIN, test x$this_is_cygwin = xyes)
 
 LDFLAGS="$LDFLAGS -no-undefined"
 

+ 4 - 0
platform/posix.c

@@ -10,6 +10,8 @@
 #  include <config.h>
 #endif
 
+#if (!defined WIN32)
+
 #if (defined __STRICT_ANSI__)
 #define __PHYSFS_DOING_STRICT_ANSI__
 #endif
@@ -512,5 +514,7 @@ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
     return statbuf.st_mtime;
 } /* __PHYSFS_platformGetLastModTime */
 
+#endif /* !defined WIN32 */
+
 /* end of posix.c ... */
 

+ 6 - 0
platform/unix.c

@@ -12,6 +12,10 @@
 
 #if (!defined __BEOS__) /* BeOS uses beos.cpp and posix.c ... */
 
+#if (defined WIN32) /* cygwin/mingw32? */
+#include "win32.c"  /* !!! FIXME: holy friggin' hack. */
+#else
+
 #if ((defined __APPLE__) && (defined __MACH__))
 #  if (!defined __DARWIN__)
 #    define __DARWIN__
@@ -302,6 +306,8 @@ void __PHYSFS_platformReleaseMutex(void *mutex)
     pthread_mutex_unlock((pthread_mutex_t *) mutex);
 } /* __PHYSFS_platformReleaseMutex */
 
+#endif /* win32 check. */
+
 #endif /* !defined __BEOS__ */
 
 /* end of unix.c ... */

+ 5 - 1
platform/win32.c

@@ -20,6 +20,10 @@
 #define __PHYSICSFS_INTERNAL__
 #include "physfs_internal.h"
 
+#ifndef _MSC_VER /* for Cygwin, etc. */
+#define _alloca alloca
+#endif
+
 #define LOWORDER_UINT64(pos)       (PHYSFS_uint32)(pos & 0x00000000FFFFFFFF)
 #define HIGHORDER_UINT64(pos)      (PHYSFS_uint32)(pos & 0xFFFFFFFF00000000)
 
@@ -701,7 +705,7 @@ PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
     return retval;
 }
 
-PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, void *buffer,
+PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
                                      PHYSFS_uint32 size, PHYSFS_uint32 count)
 {
     HANDLE FileHandle;