Commit 57dc590f authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Get rid of noexcept/no override

parent 2de83c32
......@@ -26,7 +26,7 @@ static struct
static int Initialized = 0;
// MDFN_NOTICE_STATUS, MDFN_NOTICE_WARNING, MDFN_NOTICE_ERROR
void Mednafen::MDFND_OutputNotice(MDFN_NoticeType t, const char* s) noexcept
void Mednafen::MDFND_OutputNotice(MDFN_NoticeType t, const char* s)
{
if(cb.log && Initialized)
{
......@@ -45,7 +45,7 @@ void Mednafen::MDFND_OutputNotice(MDFN_NoticeType t, const char* s) noexcept
}
// Output from MDFN_printf(); fairly verbose informational messages.
void Mednafen::MDFND_OutputInfo(const char* s) noexcept
void Mednafen::MDFND_OutputInfo(const char* s)
{
if(cb.log)
cb.log(RETRO_LOG_INFO, "%s", s);
......
......@@ -49,17 +49,17 @@ uint64 ExtMemStream::attributes(void)
}
uint8 *ExtMemStream::map(void) noexcept
uint8 *ExtMemStream::map(void)
{
return data_buffer;
}
uint64 ExtMemStream::map_size(void) noexcept
uint64 ExtMemStream::map_size(void)
{
return data_buffer_size;
}
void ExtMemStream::unmap(void) noexcept
void ExtMemStream::unmap(void)
{
}
......
......@@ -34,24 +34,24 @@ class ExtMemStream : public Stream
ExtMemStream(void*, uint64);
ExtMemStream(const void*, uint64);
virtual ~ExtMemStream() override;
virtual ~ExtMemStream();
virtual uint64 attributes(void) override;
virtual uint64 attributes(void);
virtual uint8 *map(void) noexcept override;
virtual uint64 map_size(void) noexcept override;
virtual void unmap(void) noexcept override;
virtual uint8 *map(void);
virtual uint64 map_size(void);
virtual void unmap(void);
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true) override;
virtual void write(const void *data, uint64 count) override;
virtual void truncate(uint64 length) override;
virtual void seek(int64 offset, int whence) override;
virtual uint64 tell(void) override;
virtual uint64 size(void) override;
virtual void flush(void) override;
virtual void close(void) override;
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true);
virtual void write(const void *data, uint64 count);
virtual void truncate(uint64 length);
virtual void seek(int64 offset, int whence);
virtual uint64 tell(void);
virtual uint64 size(void);
virtual void flush(void);
virtual void close(void);
virtual int get_line(std::string &str) override;
virtual int get_line(std::string &str);
private:
......
......@@ -178,35 +178,20 @@ FileStream::FileStream(const std::string& path, const uint32 mode) : OpenedMode(
if(mode == MODE_WRITE)
{
try
{
truncate(0);
}
catch(...)
{
try { close(); } catch(...) { }
throw;
}
}
}
FileStream::~FileStream()
{
try
{
#if 0
if(fp && (attributes() & ATTRIBUTE_WRITEABLE))
{
MDFN_printf(_("FileStream::close() not explicitly called for file \"%s\" opened for writing!\n"), path_save.c_str());
}
if(fp && (attributes() & ATTRIBUTE_WRITEABLE))
{
MDFN_printf(_("FileStream::close() not explicitly called for file \"%s\" opened for writing!\n"), path_save.c_str());
}
#endif
close();
}
catch(std::exception &e)
{
MDFND_OutputNotice(MDFN_NOTICE_ERROR, e.what());
}
close();
}
uint64 FileStream::attributes(void)
......@@ -233,7 +218,7 @@ uint64 FileStream::attributes(void)
return ret;
}
uint8 *FileStream::map(void) noexcept
uint8 *FileStream::map(void)
{
if(!mapping)
{
......@@ -274,12 +259,12 @@ uint8 *FileStream::map(void) noexcept
return((uint8*)mapping);
}
uint64 FileStream::map_size(void) noexcept
uint64 FileStream::map_size(void)
{
return mapping_size;
}
void FileStream::unmap(void) noexcept
void FileStream::unmap(void)
{
if(mapping)
{
......
......@@ -60,24 +60,24 @@ class FileStream : public Stream
};
FileStream(const std::string& path, const uint32 mode);
virtual ~FileStream() override;
virtual ~FileStream();
virtual uint64 attributes(void) override;
virtual uint64 attributes(void);
virtual uint8 *map(void) noexcept override;
virtual uint64 map_size(void) noexcept override;
virtual void unmap(void) noexcept override;
virtual uint8 *map(void);
virtual uint64 map_size(void);
virtual void unmap(void);
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true) override;
virtual void write(const void *data, uint64 count) override;
virtual void truncate(uint64 length) override;
virtual void seek(int64 offset, int whence) override;
virtual uint64 tell(void) override;
virtual uint64 size(void) override;
virtual void flush(void) override;
virtual void close(void) override;
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true);
virtual void write(const void *data, uint64 count);
virtual void truncate(uint64 length);
virtual void seek(int64 offset, int whence);
virtual uint64 tell(void);
virtual uint64 size(void);
virtual void flush(void);
virtual void close(void);
virtual int get_line(std::string &str) override;
virtual int get_line(std::string &str);
INLINE int get_char(void)
{
......
......@@ -58,31 +58,31 @@ uint64 Thread_SetAffinity(Thread* thread, uint64 mask) MDFN_COLD;
// Mutexes
//
Mutex* Mutex_Create(void) MDFN_COLD;
void Mutex_Destroy(Mutex* mutex) noexcept MDFN_COLD;
void Mutex_Destroy(Mutex* mutex) MDFN_COLD;
bool Mutex_Lock(Mutex* mutex) noexcept;
bool Mutex_Unlock(Mutex* mutex) noexcept;
bool Mutex_Lock(Mutex* mutex);
bool Mutex_Unlock(Mutex* mutex);
//
// Condition variables
//
Cond* Cond_Create(void) MDFN_COLD;
void Cond_Destroy(Cond* cond) noexcept MDFN_COLD;
void Cond_Destroy(Cond* cond) MDFN_COLD;
// SignalCond() *MUST* be called with a lock on the mutex used with WaitCond() or WaitCondTimeout()
bool Cond_Signal(Cond* cond) noexcept;
bool Cond_Wait(Cond* cond, Mutex* mutex) noexcept;
bool Cond_TimedWait(Cond* cond, Mutex* mutex, unsigned ms) noexcept;
bool Cond_Signal(Cond* cond);
bool Cond_Wait(Cond* cond, Mutex* mutex);
bool Cond_TimedWait(Cond* cond, Mutex* mutex, unsigned ms);
//
// Semaphores
//
Sem* Sem_Create(void) MDFN_COLD;
void Sem_Destroy(Sem* sem) noexcept MDFN_COLD;
void Sem_Destroy(Sem* sem) MDFN_COLD;
bool Sem_Wait(Sem* sem) noexcept;
bool Sem_TimedWait(Sem* sem, unsigned ms) noexcept;
bool Sem_Post(Sem* sem) noexcept;
bool Sem_Wait(Sem* sem);
bool Sem_TimedWait(Sem* sem, unsigned ms);
bool Sem_Post(Sem* sem);
}
}
......
......@@ -71,28 +71,14 @@ MemoryStream::MemoryStream(uint64 alloc_hint, int alloc_hint_is_size) : data_buf
MemoryStream::MemoryStream(Stream *stream, uint64 size_limit) : data_buffer(NULL), data_buffer_size(0), data_buffer_alloced(0), position(0)
{
try
{
if((position = stream->tell()) != 0)
stream->seek(0, SEEK_SET);
void* tp;
data_buffer_size = data_buffer_alloced = stream->alloc_and_read(&tp, size_limit);
data_buffer = (uint8*)tp;
stream->close();
}
catch(...)
{
if(data_buffer)
{
free(data_buffer);
data_buffer = NULL;
}
delete stream;
throw;
}
delete stream;
if((position = stream->tell()) != 0)
stream->seek(0, SEEK_SET);
void* tp;
data_buffer_size = data_buffer_alloced = stream->alloc_and_read(&tp, size_limit);
data_buffer = (uint8*)tp;
stream->close();
delete stream;
}
MemoryStream::MemoryStream(const MemoryStream &zs)
......@@ -143,17 +129,17 @@ uint64 MemoryStream::attributes(void)
}
uint8 *MemoryStream::map(void) noexcept
uint8 *MemoryStream::map(void)
{
return data_buffer;
}
uint64 MemoryStream::map_size(void) noexcept
uint64 MemoryStream::map_size(void)
{
return data_buffer_size;
}
void MemoryStream::unmap(void) noexcept
void MemoryStream::unmap(void)
{
}
......@@ -197,7 +183,7 @@ INLINE void MemoryStream::grow_if_necessary(uint64 new_required_size, uint64 hol
}
}
void MemoryStream::shrink_to_fit(void) noexcept
void MemoryStream::shrink_to_fit(void)
{
if(data_buffer_alloced > data_buffer_size)
{
......
......@@ -51,26 +51,26 @@ class MemoryStream : public Stream
MemoryStream(const MemoryStream &zs);
MemoryStream & operator=(const MemoryStream &zs);
virtual ~MemoryStream() override;
virtual ~MemoryStream();
virtual uint64 attributes(void) override;
virtual uint64 attributes(void);
virtual uint8 *map(void) noexcept override;
virtual uint64 map_size(void) noexcept override;
virtual void unmap(void) noexcept override;
virtual uint8 *map(void);
virtual uint64 map_size(void);
virtual void unmap(void);
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true) override;
virtual void write(const void *data, uint64 count) override;
virtual void truncate(uint64 length) override;
virtual void seek(int64 offset, int whence) override;
virtual uint64 tell(void) override;
virtual uint64 size(void) override;
virtual void flush(void) override;
virtual void close(void) override;
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true);
virtual void write(const void *data, uint64 count);
virtual void truncate(uint64 length);
virtual void seek(int64 offset, int whence);
virtual uint64 tell(void);
virtual uint64 size(void);
virtual void flush(void);
virtual void close(void);
virtual int get_line(std::string &str) override;
virtual int get_line(std::string &str);
void shrink_to_fit(void) noexcept; // Minimizes alloced memory.
void shrink_to_fit(void); // Minimizes alloced memory.
void mswin_utf8_convert_kludge(void);
......
......@@ -182,17 +182,17 @@ uint64 Stream::alloc_and_read(void** data_out, uint64 size_limit)
}
uint8* Stream::map(void) noexcept
uint8* Stream::map(void)
{
return(NULL);
}
uint64 Stream::map_size(void) noexcept
uint64 Stream::map_size(void)
{
return 0;
}
void Stream::unmap(void) noexcept
void Stream::unmap(void)
{
}
......
......@@ -57,7 +57,7 @@ class Stream
//
virtual void require_fast_seekable(void);
virtual uint8 *map(void) noexcept;
virtual uint8 *map(void);
// Map the entirety of the stream data into the address space of the process, if possible, and return a pointer.
// (the returned pointer must be cached, and returned on any subsequent calls to map() without an unmap()
// in-between, to facilitate a sort of "feature-testing", to determine if an alternative like "MemoryStream"
......@@ -68,12 +68,12 @@ class Stream
// For code using this functionality, ensure usage of map_size() instead of size(), unless you're only using a specific derived
// class like MemoryStream() where the value returned by size() won't change unexpectedly due to outside factors.
virtual uint64 map_size(void) noexcept;
virtual uint64 map_size(void);
// The size of the memory mapping area, point to which returned by map().
//
// Returns 0 on supported, or if no mapping currently exists.
virtual void unmap(void) noexcept;
virtual void unmap(void);
// Unmap the stream data from the address space. (Possibly invalidating the pointer returned from map()).
// (must automatically be called, if necessary, from the destructor).
//
......@@ -264,15 +264,15 @@ class StreamPosFilter final : public Stream
public:
StreamPosFilter(std::shared_ptr<Stream> s_);
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true) override;
virtual void write(const void *data, uint64 count) override;
virtual void seek(int64 offset, int whence) override;
virtual uint64 tell(void) override;
virtual uint64 size(void) override;
virtual void close(void) override;
virtual uint64 attributes(void) override;
virtual void truncate(uint64 length) override;
virtual void flush(void) override;
virtual uint64 read(void *data, uint64 count, bool error_on_eos = true);
virtual void write(const void *data, uint64 count);
virtual void seek(int64 offset, int whence);
virtual uint64 tell(void);
virtual uint64 size(void);
virtual void close(void);
virtual uint64 attributes(void);
virtual void truncate(uint64 length);
virtual void flush(void);
private:
......
......@@ -26,12 +26,12 @@
namespace Mednafen
{
MDFN_Error::MDFN_Error() noexcept
MDFN_Error::MDFN_Error()
{
abort();
}
MDFN_Error::MDFN_Error(int errno_code_new, const char *format, ...) noexcept
MDFN_Error::MDFN_Error(int errno_code_new, const char *format, ...)
{
errno_code = errno_code_new;
......@@ -50,7 +50,7 @@ MDFN_Error::MDFN_Error(const ErrnoHolder &enh)
}
MDFN_Error::~MDFN_Error() noexcept
MDFN_Error::~MDFN_Error()
{
if(error_message)
{
......@@ -59,7 +59,7 @@ MDFN_Error::~MDFN_Error() noexcept
}
}
MDFN_Error::MDFN_Error(const MDFN_Error &ze_error) noexcept
MDFN_Error::MDFN_Error(const MDFN_Error &ze_error)
{
if(ze_error.error_message)
error_message = strdup(ze_error.error_message);
......@@ -69,7 +69,7 @@ MDFN_Error::MDFN_Error(const MDFN_Error &ze_error) noexcept
errno_code = ze_error.errno_code;
}
MDFN_Error& MDFN_Error::operator=(const MDFN_Error &ze_error) noexcept
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;
......@@ -84,7 +84,7 @@ MDFN_Error& MDFN_Error::operator=(const MDFN_Error &ze_error) noexcept
}
const char * MDFN_Error::what(void) const noexcept
const char * MDFN_Error::what(void)
{
if(!error_message)
return("Error allocating memory for the error message!");
......@@ -92,7 +92,7 @@ const char * MDFN_Error::what(void) const noexcept
return(error_message);
}
int MDFN_Error::GetErrno(void) const noexcept
int MDFN_Error::GetErrno(void)
{
return(errno_code);
}
......
......@@ -32,18 +32,18 @@ class MDFN_Error : public std::exception
{
public:
MDFN_Error() noexcept MDFN_COLD;
MDFN_Error() MDFN_COLD;
MDFN_Error(int errno_code_new, const char *format, ...) noexcept MDFN_FORMATSTR(gnu_printf, 3, 4) MDFN_COLD;
MDFN_Error(int errno_code_new, const char *format, ...) MDFN_FORMATSTR(gnu_printf, 3, 4) MDFN_COLD;
MDFN_Error(const ErrnoHolder &enh) MDFN_COLD;
~MDFN_Error() noexcept MDFN_COLD;
~MDFN_Error() MDFN_COLD;
MDFN_Error(const MDFN_Error &ze_error) noexcept MDFN_COLD;
MDFN_Error & operator=(const MDFN_Error &ze_error) noexcept MDFN_COLD;
MDFN_Error(const MDFN_Error &ze_error) MDFN_COLD;
MDFN_Error & operator=(const MDFN_Error &ze_error) MDFN_COLD;
virtual const char *what(void) const noexcept;
int GetErrno(void) const noexcept;
virtual const char *what(void);
int GetErrno(void);
private:
......
......@@ -450,7 +450,7 @@ void MDFN_indent(int indent)
}
static uint8 lastchar = 0;
void MDFN_printf(const char *format, ...) noexcept
void MDFN_printf(const char *format, ...)
{
char *format_temp;
char *temp;
......@@ -501,7 +501,7 @@ void MDFN_printf(const char *format, ...) noexcept
va_end(ap);
}
void MDFN_Notify(MDFN_NoticeType t, const char* format, ...) noexcept
void MDFN_Notify(MDFN_NoticeType t, const char* format, ...)
{
char* s;
va_list ap;
......
......@@ -32,10 +32,10 @@ enum MDFN_NoticeType : uint8
MDFN_NOTICE_ERROR
};
void MDFN_Notify(MDFN_NoticeType t, const char* format, ...) noexcept MDFN_FORMATSTR(gnu_printf, 2, 3);
void MDFN_Notify(MDFN_NoticeType t, const char* format, ...) MDFN_FORMATSTR(gnu_printf, 2, 3);
// Verbose status and informational messages, primarily during startup and exit.
void MDFN_printf(const char *format, ...) noexcept MDFN_FORMATSTR(gnu_printf, 1, 2);
void MDFN_printf(const char *format, ...) MDFN_FORMATSTR(gnu_printf, 1, 2);
void MDFN_StateAction(StateMem *sm, const unsigned load, const bool data_only);
......@@ -53,15 +53,15 @@ struct MDFN_AutoIndent
private:
int indented;
};
void MDFN_printf(const char *format, ...) noexcept MDFN_FORMATSTR(gnu_printf, 1, 2);
void MDFN_printf(const char *format, ...) MDFN_FORMATSTR(gnu_printf, 1, 2);
#define MDFNI_printf MDFN_printf
// MDFN_NOTICE_ERROR may block(e.g. for user confirmation), other notice types should be as non-blocking as possible.
void MDFND_OutputNotice(MDFN_NoticeType t, const char* s) noexcept;
void MDFND_OutputNotice(MDFN_NoticeType t, const char* s);
// Output from MDFN_printf(); fairly verbose informational messages.
void MDFND_OutputInfo(const char* s) noexcept;
void MDFND_OutputInfo(const char* s);
// Synchronize virtual time to actual time using members of espec:
//
......
......@@ -177,33 +177,26 @@ Thread* Thread_Create(int (*fn)(void *), void *data, const char* debug_name)
void Thread_Wait(Thread* thread, int* status)
{
try
{
void* vp;
int ptec;
void* vp;
int ptec;
if((ptec = pthread_join(thread->t, &vp)))
{
ErrnoHolder ene(ptec);
if((ptec = pthread_join(thread->t, &vp)))
{
ErrnoHolder ene(ptec);
throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "pthread_join()", ene.StrError());
}
throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "pthread_join()", ene.StrError());
}
if(vp != &thread->rv)
{
delete thread;
throw MDFN_Error(0, _("Thread being joined exited improperly."));
}
if(vp != &thread->rv)
{
delete thread;
throw MDFN_Error(0, _("Thread being joined exited improperly."));
}
if(status)
*status = thread->rv;
if(status)
*status = thread->rv;
delete thread;
}
catch(std::exception& e)
{
MDFND_OutputNotice(MDFN_NOTICE_ERROR, e.what());
}
delete thread;
}
uintptr_t Thread_ID(void)
......@@ -218,59 +211,52 @@ uintptr_t Thread_ID(void)
uint64 Thread_SetAffinity(Thread* thread, const uint64 mask)
{
try
{
assert(mask != 0);
//
pthread_t const t = thread ? thread->t : pthread_self();
PTHREAD_AFFINITY_NP c;
uint64 ret = 0;
int ptec;
//printf("SetAffinity() %016llx %08x\n", (unsigned long long)t, mask);
//
//
CPU_ZERO(&c);
if((ptec = pthread_getaffinity_np(t, sizeof(c), &c)))
{
ErrnoHolder ene(ptec);
throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "pthread_getaffinity_np()", ene.StrError());
}
for(unsigned i = 0; i < sizeof(ret) * 8 && i < CPU_SETSIZE; i++)
{