Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building on MSVC #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libgambatte/src/file/unzip/crypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab __attribute__((unused)))
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{
(void)pcrc_32_tab;
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
Expand Down
47 changes: 15 additions & 32 deletions libgambatte/src/file/unzip/ioapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include <zlib.h>
#include "ioapi.h"



/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */

#ifndef SEEK_CUR
Expand Down Expand Up @@ -65,11 +63,9 @@ int ZCALLBACK ferror_file_func OF((
voidpf stream));


voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
voidpf opaque __attribute__((unused));
const char* filename;
int mode;
voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
{
(void)opaque;
FILE* file = NULL;
const char* mode_fopen = NULL;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
Expand All @@ -87,44 +83,34 @@ voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
}


uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
voidpf opaque __attribute__((unused));
voidpf stream;
void* buf;
uLong size;
uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
{
(void)opaque;
uLong ret;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}


uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
voidpf opaque __attribute__((unused));
voidpf stream;
const void* buf;
uLong size;
uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
{
(void)opaque;
uLong ret;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}

long ZCALLBACK ftell_file_func (opaque, stream)
voidpf opaque __attribute__((unused));
voidpf stream;
long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
{
(void)opaque;
long ret;
ret = ftell((FILE *)stream);
return ret;
}

long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
voidpf opaque __attribute__((unused));
voidpf stream;
uLong offset;
int origin;
long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
{
(void)opaque;
int fseek_origin=0;
long ret;
switch (origin)
Expand All @@ -145,26 +131,23 @@ long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
return ret;
}

int ZCALLBACK fclose_file_func (opaque, stream)
voidpf opaque __attribute__((unused));
voidpf stream;
int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
{
(void)opaque;
int ret;
ret = fclose((FILE *)stream);
return ret;
}

int ZCALLBACK ferror_file_func (opaque, stream)
voidpf opaque __attribute__((unused));
voidpf stream;
int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
{
(void)opaque;
int ret;
ret = ferror((FILE *)stream);
return ret;
}

void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;
Expand Down
7 changes: 4 additions & 3 deletions libgambatte/src/statesaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <algorithm>
#include <fstream>
#include <functional>
#include <memory>
#include <sstream>
#include <vector>
#include <cstring>
Expand Down Expand Up @@ -550,10 +551,10 @@ bool StateSaver::saveState(SaveState const &state,
return false;

std::size_t size = saveState(state, videoBuf, pitch, NULL, mode);
char stateBuf[size];
std::unique_ptr<char[]> stateBuf {new char[size]};

saveState(state, videoBuf, pitch, stateBuf, mode);
file.write(stateBuf, size);
saveState(state, videoBuf, pitch, stateBuf.get(), mode);
file.write(stateBuf.get(), size);

return !file.fail();
}
Expand Down