From 3b0f1c896f0796a1affba1ba9104d83704ee940f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 29 Jun 2002 10:23:17 +0000 Subject: [PATCH] Patched to compile on Cygwin. --- configure.in | 11 +++++++++++ platform/posix.c | 4 ++++ platform/unix.c | 6 ++++++ platform/win32.c | 6 +++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 49a885dc..a2764b1b 100644 --- a/configure.in +++ b/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" diff --git a/platform/posix.c b/platform/posix.c index 81ac8694..1fa2df33 100644 --- a/platform/posix.c +++ b/platform/posix.c @@ -10,6 +10,8 @@ # include #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 ... */ diff --git a/platform/unix.c b/platform/unix.c index 269f6526..cd6bf0b9 100644 --- a/platform/unix.c +++ b/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 ... */ diff --git a/platform/win32.c b/platform/win32.c index d36ef1cf..243ed91a 100644 --- a/platform/win32.c +++ b/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;