Compile fixes for GCC

This commit is contained in:
Connor McLaughlin
2019-10-22 23:07:51 +10:00
parent dc7b72b156
commit a76ec6fc19
19 changed files with 47 additions and 52 deletions

View File

@ -10,10 +10,8 @@
template<typename BackingDataType, typename DataType, unsigned BitIndex, unsigned BitCount>
struct BitField
{
constexpr BitField() = default;
#ifndef _MSC_VER
BitField& operator=(const BitField& value) = delete;
#endif
// We have to delete the copy assignment operator otherwise we can't use this class in anonymous structs/unions.
BitField& operator=(const BitField& rhs) = delete;
constexpr BackingDataType GetMask() const
{
@ -138,4 +136,4 @@ struct BitField
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif

View File

@ -171,7 +171,7 @@ const CDImage::Index* CDImage::GetIndexForTrackPosition(u32 track_number, LBA tr
const Track& track = m_tracks[track_number - 1];
if (track_pos >= track.length)
return false;
return nullptr;
return GetIndexForDiscPosition(track.start_lba + track_pos);
}

View File

@ -60,7 +60,7 @@ static void DecodeXA_ADPCMChunks(const u8* chunk_ptr, s16* samples, s32* last_sa
constexpr u32 NUM_CHUNKS = 18;
constexpr u32 CHUNK_SIZE_IN_BYTES = 128;
constexpr u32 WORDS_PER_CHUNK = 28;
constexpr u32 SAMPLES_PER_CHUNK = 28 * (IS_8BIT ? 4 : 8);
constexpr u32 SAMPLES_PER_CHUNK = WORDS_PER_CHUNK * (IS_8BIT ? 4 : 8);
for (u32 i = 0; i < NUM_CHUNKS; i++)
{

View File

@ -4,11 +4,7 @@
#include <cstring>
#include <type_traits>
#ifdef _MSC_VER
#include <malloc.h> // _aligned_malloc
#else
#include <cstdlib>
#endif
#include <malloc.h> // _aligned_malloc, memalign
template<typename T, u32 CAPACITY>
class FIFOQueue
@ -35,7 +31,7 @@ public:
T& Emplace(Args&&... args)
{
T& ref = PushAndGetReference();
new (&ref) T(std::forward<Args>(args...));
new (&ref) T(std::forward<Args...>(args...));
return ref;
}
@ -157,7 +153,7 @@ template<typename T, u32 CAPACITY>
class InlineFIFOQueue : public FIFOQueue<T, CAPACITY>
{
public:
InlineFIFOQueue() : FIFOQueue<T, CAPACITY>() { m_ptr = m_inline_data; }
InlineFIFOQueue() : FIFOQueue<T, CAPACITY>() { this->m_ptr = m_inline_data; }
private:
T m_inline_data[CAPACITY] = {};
@ -172,20 +168,20 @@ public:
if constexpr (ALIGNMENT > 0)
{
#ifdef _MSC_VER
m_ptr = static_cast<T*>(_aligned_malloc(sizeof(T) * CAPACITY, ALIGNMENT));
this->m_ptr = static_cast<T*>(_aligned_malloc(sizeof(T) * CAPACITY, ALIGNMENT));
#else
m_ptr = static_cast<T*>(memalign(ALIGNMENT, sizeof(T) * CAPACITY));
this->m_ptr = static_cast<T*>(memalign(ALIGNMENT, sizeof(T) * CAPACITY));
#endif
}
else
{
m_ptr = static_cast<T*>(std::malloc(sizeof(T) * CAPACITY));
this->m_ptr = static_cast<T*>(std::malloc(sizeof(T) * CAPACITY));
}
if (!m_ptr)
if (!this->m_ptr)
Panic("Heap allocation failed");
std::memset(m_ptr, 0, sizeof(T) * CAPACITY);
std::memset(this->m_ptr, 0, sizeof(T) * CAPACITY);
}
~HeapFIFOQueue()
@ -193,14 +189,14 @@ public:
if constexpr (ALIGNMENT > 0)
{
#ifdef _MSC_VER
_aligned_free(m_ptr);
_aligned_free(this->m_ptr);
#else
free(m_ptr);
free(this->m_ptr);
#endif
}
else
{
free(m_ptr);
free(this->m_ptr);
}
}
};

View File

@ -74,7 +74,7 @@ public:
if (m_mode == Mode::Read)
{
if (m_error || (m_error |= !m_stream->Read2(value_ptr, sizeof(T))) == true)
*value_ptr = {};
std::memset(value_ptr, 0, sizeof(*value_ptr));
}
else
{