mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2024-11-23 07:50:03 +00:00
Error class is causing compilation issues with PS3, so get rid of
it - we don't want exception throwing with libretro cores anyway since it prevents proper error handling
This commit is contained in:
parent
e66f5bbec0
commit
c91788e673
@ -162,7 +162,6 @@ endif
|
||||
|
||||
ifneq ($(HAVE_GRIFFIN), 1)
|
||||
SOURCES_CXX += \
|
||||
$(MEDNAFEN_DIR)/error.cpp \
|
||||
$(MEDNAFEN_DIR)/settings.cpp \
|
||||
$(MEDNAFEN_DIR)/general.cpp \
|
||||
$(MEDNAFEN_DIR)/FileStream.cpp \
|
||||
|
15
deps/crypto/crypto_types.h
vendored
Normal file
15
deps/crypto/crypto_types.h
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/*********************************************************************
|
||||
* Filename: crypto_types.h
|
||||
* Author: Brad Conte (brad AT bradconte.com)
|
||||
* Copyright:
|
||||
* Disclaimer: This code is presented "as is" without any guarantees.
|
||||
* Details: Defines the API for the corresponding AES implementation.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef CRYPTO_TYPES_H
|
||||
#define CRYPTO_TYPES_H
|
||||
|
||||
typedef unsigned char BYTE; // 8-bit byte
|
||||
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
|
||||
|
||||
#endif
|
3
deps/crypto/md5.h
vendored
3
deps/crypto/md5.h
vendored
@ -11,13 +11,12 @@
|
||||
|
||||
/*************************** HEADER FILES ***************************/
|
||||
#include <stddef.h>
|
||||
#include "crypto_types.h"
|
||||
|
||||
/****************************** MACROS ******************************/
|
||||
#define MD5_BLOCK_SIZE 16 // MD5 outputs a 16 byte digest
|
||||
|
||||
/**************************** DATA TYPES ****************************/
|
||||
typedef unsigned char BYTE; // 8-bit byte
|
||||
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
|
||||
|
||||
typedef struct {
|
||||
BYTE data[64];
|
||||
|
5
deps/crypto/sha1.h
vendored
5
deps/crypto/sha1.h
vendored
@ -12,13 +12,12 @@
|
||||
/*************************** HEADER FILES ***************************/
|
||||
#include <stddef.h>
|
||||
|
||||
#include "crypto_types.h"
|
||||
|
||||
/****************************** MACROS ******************************/
|
||||
#define SHA1_BLOCK_SIZE 20 // SHA1 outputs a 20 byte digest
|
||||
|
||||
/**************************** DATA TYPES ****************************/
|
||||
typedef unsigned char BYTE; // 8-bit byte
|
||||
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
|
||||
|
||||
typedef struct {
|
||||
BYTE data[64];
|
||||
WORD datalen;
|
||||
|
@ -27,16 +27,8 @@
|
||||
|
||||
FileStream::FileStream(const char *path, const int mode)
|
||||
{
|
||||
OpenedMode = mode;
|
||||
fp = filestream_open(path, (mode == MODE_WRITE) ? RFILE_MODE_WRITE : RFILE_MODE_READ, -1);
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
ErrnoHolder ene(errno);
|
||||
|
||||
throw(MDFN_Error(ene.Errno(), "Error opening file %s", ene.StrError()));
|
||||
}
|
||||
|
||||
OpenedMode = mode;
|
||||
fp = filestream_open(path, (mode == MODE_WRITE) ? RFILE_MODE_WRITE : RFILE_MODE_READ, -1);
|
||||
original_path = strdup(path);
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,7 @@ MemoryStream::MemoryStream() : data_buffer(NULL), data_buffer_size(0), data_buff
|
||||
{
|
||||
data_buffer_size = 0;
|
||||
data_buffer_alloced = 64;
|
||||
if(!(data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced)))
|
||||
throw MDFN_Error(ErrnoHolder(errno));
|
||||
data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced);
|
||||
}
|
||||
|
||||
MemoryStream::MemoryStream(uint64 size_hint) : data_buffer(NULL), data_buffer_size(0), data_buffer_alloced(0), position(0)
|
||||
@ -29,8 +28,7 @@ MemoryStream::MemoryStream(uint64 size_hint) : data_buffer(NULL), data_buffer_si
|
||||
data_buffer_size = 0;
|
||||
data_buffer_alloced = (size_hint > SIZE_MAX) ? SIZE_MAX : size_hint;
|
||||
|
||||
if(!(data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced)))
|
||||
throw MDFN_Error(ErrnoHolder(errno));
|
||||
data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced);
|
||||
}
|
||||
|
||||
MemoryStream::MemoryStream(Stream *stream) : data_buffer(NULL), data_buffer_size(0), data_buffer_alloced(0), position(0)
|
||||
@ -40,8 +38,7 @@ MemoryStream::MemoryStream(Stream *stream) : data_buffer(NULL), data_buffer_size
|
||||
|
||||
data_buffer_size = stream->size();
|
||||
data_buffer_alloced = data_buffer_size;
|
||||
if(!(data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced)))
|
||||
throw MDFN_Error(ErrnoHolder(errno));
|
||||
data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced);
|
||||
|
||||
stream->read(data_buffer, data_buffer_size);
|
||||
|
||||
@ -53,8 +50,7 @@ MemoryStream::MemoryStream(const MemoryStream &zs)
|
||||
{
|
||||
data_buffer_size = zs.data_buffer_size;
|
||||
data_buffer_alloced = zs.data_buffer_alloced;
|
||||
if(!(data_buffer = (uint8*)malloc(data_buffer_alloced)))
|
||||
throw MDFN_Error(ErrnoHolder(errno));
|
||||
data_buffer = (uint8*)malloc(data_buffer_alloced);
|
||||
|
||||
memcpy(data_buffer, zs.data_buffer, data_buffer_size);
|
||||
|
||||
@ -101,12 +97,13 @@ INLINE void MemoryStream::grow_if_necessary(uint64 new_required_size)
|
||||
if(new_required_alloced < new_required_size || new_required_alloced > SIZE_MAX)
|
||||
new_required_alloced = SIZE_MAX;
|
||||
|
||||
#if 0
|
||||
// If constrained alloc size isn't enough, throw an out-of-memory/address-space type error.
|
||||
if(new_required_alloced < new_required_size)
|
||||
throw MDFN_Error(ErrnoHolder(ENOMEM));
|
||||
#endif
|
||||
|
||||
if(!(new_data_buffer = (uint8*)realloc(data_buffer, new_required_alloced)))
|
||||
throw MDFN_Error(ErrnoHolder(errno));
|
||||
new_data_buffer = (uint8*)realloc(data_buffer, new_required_alloced);
|
||||
|
||||
//
|
||||
// Assign all in one go after the realloc() so we don't leave our object in an inconsistent state if the realloc() fails.
|
||||
@ -142,8 +139,10 @@ void MemoryStream::write(const void *data, uint64 count)
|
||||
{
|
||||
uint64 nrs = position + count;
|
||||
|
||||
#if 0
|
||||
if(nrs < position)
|
||||
throw MDFN_Error(ErrnoHolder(EFBIG));
|
||||
#endif
|
||||
|
||||
grow_if_necessary(nrs);
|
||||
|
||||
@ -157,10 +156,6 @@ void MemoryStream::seek(int64 offset, int whence)
|
||||
|
||||
switch(whence)
|
||||
{
|
||||
default:
|
||||
throw MDFN_Error(ErrnoHolder(EINVAL));
|
||||
break;
|
||||
|
||||
case SEEK_SET:
|
||||
new_position = offset;
|
||||
break;
|
||||
@ -174,9 +169,7 @@ void MemoryStream::seek(int64 offset, int whence)
|
||||
break;
|
||||
}
|
||||
|
||||
if(new_position < 0)
|
||||
throw MDFN_Error(ErrnoHolder(EINVAL));
|
||||
else
|
||||
if(!(new_position < 0))
|
||||
grow_if_necessary(new_position);
|
||||
|
||||
position = new_position;
|
||||
|
@ -52,8 +52,8 @@ static T CCD_ReadInt(CCD_Section &s, const std::string &propname, const bool hav
|
||||
{
|
||||
if(have_defval)
|
||||
return defval;
|
||||
else
|
||||
throw MDFN_Error(0, _("Missing property: %s"), propname.c_str());
|
||||
printf("Missing property: %s", propname.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::string &v = zit->second;
|
||||
@ -77,7 +77,8 @@ static T CCD_ReadInt(CCD_Section &s, const std::string &propname, const bool hav
|
||||
|
||||
if(!vp[0] || ep[0])
|
||||
{
|
||||
throw MDFN_Error(0, _("Property %s: Malformed integer: %s"), propname.c_str(), v.c_str());
|
||||
printf("Property %s: Malformed integer: %s", propname.c_str(), v.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -428,10 +428,11 @@ int32_t CDAccess_CHD::MakeSubPQ(int32_t lba, uint8_t *SubPWBuf) const
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!track_found) {
|
||||
//printf("Could not find track for sector %d\n!", lba);
|
||||
throw(MDFN_Error(0, _("Could not find track for sector %u!"), lba));
|
||||
printf("Could not find track for sector %d\n!", lba);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lba < Tracks[track].LBA)
|
||||
lba_relative = Tracks[track].LBA - 1 - lba;
|
||||
|
@ -1235,8 +1235,10 @@ int32_t CDAccess_Image::MakeSubPQ(int32_t lba, uint8_t *SubPWBuf) const
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if(!track_found)
|
||||
throw(MDFN_Error(0, _("Could not find track for sector %u!"), lba));
|
||||
#endif
|
||||
|
||||
if(lba < Tracks[track].LBA)
|
||||
lba_relative = Tracks[track].LBA - 1 - lba;
|
||||
|
@ -202,7 +202,7 @@ CDIF_ST::CDIF_ST(CDAccess *cda) : disc_cdaccess(cda)
|
||||
|
||||
if(disc_toc.first_track < 1 || disc_toc.last_track > 99 || disc_toc.first_track > disc_toc.last_track)
|
||||
{
|
||||
throw(MDFN_Error(0, "TOC first(%d)/last(%d) track numbers bad.", disc_toc.first_track, disc_toc.last_track));
|
||||
printf("TOC first(%d)/last(%d) track numbers bad.", disc_toc.first_track, disc_toc.last_track);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,129 +0,0 @@
|
||||
/* Mednafen - Multi-system Emulator
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "mednafen.h"
|
||||
#include "error.h"
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "../libretro.h"
|
||||
|
||||
extern retro_log_printf_t log_cb;
|
||||
|
||||
MDFN_Error::MDFN_Error()
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
MDFN_Error::MDFN_Error(int errno_code_new, const char *format, ...)
|
||||
{
|
||||
errno_code = errno_code_new;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(error_message, 4096, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_ERROR, "%s\n", error_message);
|
||||
}
|
||||
|
||||
|
||||
MDFN_Error::MDFN_Error(const ErrnoHolder &enh)
|
||||
{
|
||||
errno_code = enh.Errno();
|
||||
|
||||
error_message = strdup(enh.StrError());
|
||||
}
|
||||
|
||||
|
||||
MDFN_Error::~MDFN_Error()
|
||||
{
|
||||
if(error_message)
|
||||
{
|
||||
free(error_message);
|
||||
error_message = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
MDFN_Error::MDFN_Error(const MDFN_Error &ze_error)
|
||||
{
|
||||
if(ze_error.error_message)
|
||||
error_message = strdup(ze_error.error_message);
|
||||
else
|
||||
error_message = NULL;
|
||||
|
||||
errno_code = ze_error.errno_code;
|
||||
}
|
||||
|
||||
MDFN_Error& MDFN_Error::operator=(const MDFN_Error &ze_error)
|
||||
{
|
||||
char *new_error_message = ze_error.error_message ? strdup(ze_error.error_message) : NULL;
|
||||
int new_errno_code = ze_error.errno_code;
|
||||
|
||||
if(error_message)
|
||||
free(error_message);
|
||||
|
||||
error_message = new_error_message;
|
||||
errno_code = new_errno_code;
|
||||
|
||||
return(*this);
|
||||
}
|
||||
|
||||
|
||||
const char * MDFN_Error::what(void)
|
||||
{
|
||||
if(!error_message)
|
||||
return("Error allocating memory for the error message!");
|
||||
|
||||
return(error_message);
|
||||
}
|
||||
|
||||
int MDFN_Error::GetErrno(void)
|
||||
{
|
||||
return(errno_code);
|
||||
}
|
||||
|
||||
static const char *srr_wrap(int ret, const char *local_strerror)
|
||||
{
|
||||
if(ret == -1)
|
||||
return("ERROR IN strerror_r()!!!");
|
||||
|
||||
return(local_strerror);
|
||||
}
|
||||
|
||||
static const char *srr_wrap(const char *ret, const char *local_strerror)
|
||||
{
|
||||
if(ret == NULL)
|
||||
return("ERROR IN strerror_r()!!!");
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void ErrnoHolder::SetErrno(int the_errno)
|
||||
{
|
||||
local_errno = the_errno;
|
||||
|
||||
if(the_errno == 0)
|
||||
local_strerror[0] = 0;
|
||||
else
|
||||
{
|
||||
strncpy(local_strerror, strerror(the_errno), 255);
|
||||
|
||||
local_strerror[255] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,73 +0,0 @@
|
||||
#ifndef __MDFN_ERROR_H
|
||||
#define __MDFN_ERROR_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class ErrnoHolder;
|
||||
class MDFN_Error
|
||||
{
|
||||
public:
|
||||
|
||||
MDFN_Error();
|
||||
|
||||
MDFN_Error(int errno_code_new, const char *format, ...);
|
||||
MDFN_Error(const ErrnoHolder &enh);
|
||||
|
||||
~MDFN_Error();
|
||||
|
||||
MDFN_Error(const MDFN_Error &ze_error);
|
||||
MDFN_Error & operator=(const MDFN_Error &ze_error);
|
||||
|
||||
virtual const char *what(void);
|
||||
int GetErrno(void);
|
||||
|
||||
private:
|
||||
|
||||
int errno_code;
|
||||
char *error_message;
|
||||
};
|
||||
|
||||
class ErrnoHolder
|
||||
{
|
||||
public:
|
||||
|
||||
ErrnoHolder()
|
||||
{
|
||||
local_errno = 0;
|
||||
local_strerror[0] = 0;
|
||||
}
|
||||
|
||||
ErrnoHolder(int the_errno)
|
||||
{
|
||||
SetErrno(the_errno);
|
||||
}
|
||||
|
||||
inline int Errno(void) const
|
||||
{
|
||||
return(local_errno);
|
||||
}
|
||||
|
||||
const char *StrError(void) const
|
||||
{
|
||||
return(local_strerror);
|
||||
}
|
||||
|
||||
void operator=(int the_errno)
|
||||
{
|
||||
SetErrno(the_errno);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void SetErrno(int the_errno);
|
||||
|
||||
int local_errno;
|
||||
char local_strerror[256];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -125,20 +125,15 @@ void MDFN_GetFilePathComponents(const std::string &file_path,
|
||||
|
||||
std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_path, bool skip_safety_check)
|
||||
{
|
||||
char slash;
|
||||
#ifdef _WIN32
|
||||
slash = '\\';
|
||||
char slash = '\\';
|
||||
#else
|
||||
slash = '/';
|
||||
char slash = '/';
|
||||
#endif
|
||||
|
||||
if(!skip_safety_check && !MDFN_IsFIROPSafe(rel_path))
|
||||
throw MDFN_Error(0, _("Referenced path \"%s\" is potentially unsafe. See \"filesys.untrusted_fip_check\" setting.\n"), rel_path.c_str());
|
||||
|
||||
if(IsAbsolutePath(rel_path.c_str()))
|
||||
return(rel_path);
|
||||
else
|
||||
return(dir_path + slash + rel_path);
|
||||
return(dir_path + slash + rel_path);
|
||||
}
|
||||
|
||||
// Remove whitespace from beginning of string
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <streams/file_stream_transforms.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -118,7 +118,4 @@ typedef unsigned char Boolean; /* 0 or 1 */
|
||||
#undef require
|
||||
#define require( expr ) assert( expr )
|
||||
|
||||
#include "error.h"
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -21,11 +21,6 @@
|
||||
#define GET_FDATA_PTR(fp) (fp->data)
|
||||
#define GET_FSIZE_PTR(fp) (fp->size)
|
||||
#define GET_FEXTS_PTR(fp) (fp->ext)
|
||||
#define gzopen(a, b) fopen(a, b)
|
||||
#define gzread(a, b, c) fread(b, c, 1, a)
|
||||
#define gzclose(a) fclose(a)
|
||||
#define gzgetc(a) fgetc(a)
|
||||
#define gzseek(a,b,c) fseek(a,b,c)
|
||||
|
||||
extern MDFNGI *MDFNGameInfo;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user