From 2a87706114fec08fd19b001ee226d476bf5fa510 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 4 Feb 2014 14:44:16 -0800 Subject: [PATCH] Revert "fix Mac OSX build (and remove 'weak link' warning)" This reverts commit 146bbefc03fe87433a5516bf9ae4eab7c832dc4a. --- btgui/minizip/ioapi.c | 28 ++++++++++++++++++++++++++++ btgui/minizip/unzip.c | 6 +++--- btgui/minizip/zip.c | 6 +++--- src/clew/clew.h | 2 +- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/btgui/minizip/ioapi.c b/btgui/minizip/ioapi.c index 7b665ff76..49958f61f 100644 --- a/btgui/minizip/ioapi.c +++ b/btgui/minizip/ioapi.c @@ -98,6 +98,23 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in return file; } +static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) +{ + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = fopen64((const char*)filename, mode_fopen); + return file; +} static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) @@ -205,3 +222,14 @@ void fill_fopen_filefunc (pzlib_filefunc_def) pzlib_filefunc_def->opaque = NULL; } +void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = fopen64_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell64_file = ftell64_file_func; + pzlib_filefunc_def->zseek64_file = fseek64_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; +} diff --git a/btgui/minizip/unzip.c b/btgui/minizip/unzip.c index 8125ba83f..21878de0f 100644 --- a/btgui/minizip/unzip.c +++ b/btgui/minizip/unzip.c @@ -605,9 +605,9 @@ local unzFile unzOpenInternal (const void *path, us.z_filefunc.zseek32_file = NULL; us.z_filefunc.ztell32_file = NULL; - // if (pzlib_filefunc64_32_def==NULL) - // fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); - //else + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); + else us.z_filefunc = *pzlib_filefunc64_32_def; us.is64bitOpenFunction = is64bitOpenFunction; diff --git a/btgui/minizip/zip.c b/btgui/minizip/zip.c index 76b829c05..a024136a0 100644 --- a/btgui/minizip/zip.c +++ b/btgui/minizip/zip.c @@ -854,9 +854,9 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl ziinit.z_filefunc.zseek32_file = NULL; ziinit.z_filefunc.ztell32_file = NULL; - // if (pzlib_filefunc64_32_def==NULL) - // fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); - // else + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); + else ziinit.z_filefunc = *pzlib_filefunc64_32_def; ziinit.filestream = ZOPEN64(ziinit.z_filefunc, diff --git a/src/clew/clew.h b/src/clew/clew.h index de69b04db..063eeb337 100644 --- a/src/clew/clew.h +++ b/src/clew/clew.h @@ -73,7 +73,7 @@ extern "C" { #define CL_CALLBACK #endif -#ifdef __APPLE1__ +#ifdef __APPLE__ #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import)) #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER