Skip to content

Commit

Permalink
Restore 10.11 compat fixes for probably the final time
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Jun 6, 2019
1 parent 36ec9cd commit 2deb975
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
44 changes: 24 additions & 20 deletions mednafen/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ void Time_Init(void)
{
#ifdef WIN32
tgt_base = timeGetTime();
#else
if(MDFN_UNLIKELY(clock_gettime(CLOCK_MONOTONIC, &cgt_base) == -1))
{
ErrnoHolder ene(errno);

throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "clock_gettime()", ene.StrError());
}
// OpenEmu workaround 10.11 missing clock_gettime()
// this code is still unused by our port (i hope :P)
// #else
// if(MDFN_UNLIKELY(clock_gettime(CLOCK_MONOTONIC, &cgt_base) == -1))
// {
// ErrnoHolder ene(errno);
//
// throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "clock_gettime()", ene.StrError());
// }
#endif
Initialized = true;
}
Expand Down Expand Up @@ -200,19 +202,21 @@ int64 MonoUS(void)
{
return (int64)1000 * (timeGetTime() - tgt_base);
}
#else
{
struct timespec tp;

if(MDFN_UNLIKELY(clock_gettime(CLOCK_MONOTONIC, &tp) == -1))
{
ErrnoHolder ene(errno);

throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "clock_gettime()", ene.StrError());
}

return (int64)(tp.tv_sec - cgt_base.tv_sec) * 1000 * 1000 + (tp.tv_nsec - cgt_base.tv_nsec) / 1000;
}
// OpenEmu workaround 10.11 missing clock_gettime()
// this code is still unused by our port (i hope :P)
// #else
// {
// struct timespec tp;
//
// if(MDFN_UNLIKELY(clock_gettime(CLOCK_MONOTONIC, &tp) == -1))
// {
// ErrnoHolder ene(errno);
//
// throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "clock_gettime()", ene.StrError());
// }
//
// return (int64)(tp.tv_sec - cgt_base.tv_sec) * 1000 * 1000 + (tp.tv_nsec - cgt_base.tv_nsec) / 1000;
// }
#endif
}

Expand Down
9 changes: 5 additions & 4 deletions mednafen/pce/huc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,11 @@ static void LoadSaveMemory(const std::string& path, uint8* const data, const uin
try
{
std::unique_ptr<Stream> fp(possibly_gz ? (Stream*)(new GZFileStream(path, GZFileStream::MODE::READ)) : (Stream*)(new FileStream(path, FileStream::MODE_READ)));
const uint64 fp_size_tmp = fp->size();

if(fp_size_tmp != len)
throw MDFN_Error(0, _("Save game memory file \"%s\" is an incorrect size(%llu bytes). The correct size is %llu bytes."), path.c_str(), (unsigned long long)fp_size_tmp, (unsigned long long)len);
// OpenEmu work around 10.11 zlib bug
// const uint64 fp_size_tmp = fp->size();
//
// if(fp_size_tmp != len)
// throw MDFN_Error(0, _("Save game memory file \"%s\" is an incorrect size(%llu bytes). The correct size is %llu bytes."), path.c_str(), (unsigned long long)fp_size_tmp, (unsigned long long)len);

fp->read(data, len);
}
Expand Down
9 changes: 5 additions & 4 deletions mednafen/pcfx/pcfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,11 @@ static MDFN_COLD void LoadCommon(std::vector<CDInterface*> *CDInterfaces)
{
std::string save_path = MDFN_MakeFName(MDFNMKF_SAV, 0, "sav");
GZFileStream savefp(save_path, GZFileStream::MODE::READ);
const uint64 fp_size_tmp = savefp.size();

if(fp_size_tmp != 65536)
throw MDFN_Error(0, _("Save game memory file \"%s\" is an incorrect size(%llu bytes). The correct size is %llu bytes."), save_path.c_str(), (unsigned long long)fp_size_tmp, (unsigned long long)65536);
// OpenEmu work around 10.11 zlib bug
// const uint64 fp_size_tmp = savefp.size();
//
// if(fp_size_tmp != 65536)
// throw MDFN_Error(0, _("Save game memory file \"%s\" is an incorrect size(%llu bytes). The correct size is %llu bytes."), save_path.c_str(), (unsigned long long)fp_size_tmp, (unsigned long long)65536);

savefp.read(BackupRAM, 0x8000);
savefp.read(ExBackupRAM, 0x8000);
Expand Down

0 comments on commit 2deb975

Please sign in to comment.