Commit ae8f6e85 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Get rid of all static_asserts

parent d70d1dbb
......@@ -103,8 +103,6 @@ static INLINE T MDFN_deXsb(const void* ptr)
if(isbigendian != -1 && isbigendian != (int)MDFN_IS_BIGENDIAN)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Gummy penguins.");
if(sizeof(T) == 8)
return MDFN_bswap64(tmp);
else if(sizeof(T) == 4)
......@@ -212,8 +210,6 @@ static INLINE void MDFN_enXsb(void* ptr, T value)
if(isbigendian != -1 && isbigendian != (int)MDFN_IS_BIGENDIAN)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Gummy penguins.");
if(sizeof(T) == 8)
tmp = MDFN_bswap64(value);
else if(sizeof(T) == 4)
......@@ -338,9 +334,6 @@ static INLINE uintptr_t neX_ptr_le(uintptr_t const base, const size_t byte_offse
template<typename T, typename BT>
static INLINE void ne16_wbo_be(BT base, const size_t byte_offset, const T value)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint16*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_be<T, uint16>((uintptr_t)base, byte_offset);
if(sizeof(T) == 4)
......@@ -357,9 +350,6 @@ static INLINE void ne16_wbo_be(BT base, const size_t byte_offset, const T value)
template<typename T, typename BT>
static INLINE T ne16_rbo_be(BT base, const size_t byte_offset)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint16*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_be<T, uint16>((uintptr_t)base, byte_offset);
if(sizeof(T) == 4)
......@@ -392,9 +382,6 @@ static INLINE void ne16_rwbo_be(BT base, const size_t byte_offset, T* value)
template<typename T, typename BT>
static INLINE void ne16_wbo_le(BT base, const size_t byte_offset, const T value)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint16*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_le<T, uint16>((uintptr_t)base, byte_offset);
if(sizeof(T) == 4)
......@@ -411,9 +398,6 @@ static INLINE void ne16_wbo_le(BT base, const size_t byte_offset, const T value)
template<typename T, typename BT>
static INLINE T ne16_rbo_le(BT base, const size_t byte_offset)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint16*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_le<T, uint16>((uintptr_t)base, byte_offset);
if(sizeof(T) == 4)
......@@ -446,9 +430,6 @@ static INLINE void ne16_rwbo_le(BT base, const size_t byte_offset, T* value)
template<typename T, typename BT>
static INLINE void ne64_wbo_be(BT base, const size_t byte_offset, const T value)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint64*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_be<T, uint64>((uintptr_t)base, byte_offset);
memcpy(MDFN_ASSUME_ALIGNED((void*)ptr, alignof(T)), &value, sizeof(T));
......@@ -457,9 +438,6 @@ static INLINE void ne64_wbo_be(BT base, const size_t byte_offset, const T value)
template<typename T, typename BT>
static INLINE T ne64_rbo_be(BT base, const size_t byte_offset)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint64*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_be<T, uint64>((uintptr_t)base, byte_offset);
T ret;
......@@ -482,9 +460,6 @@ static INLINE void ne64_rwbo_be(BT base, const size_t byte_offset, T* value)
template<typename T, typename BT>
static INLINE void ne64_wbo_le(BT base, const size_t byte_offset, const T value)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint64*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_le<T, uint64>((uintptr_t)base, byte_offset);
memcpy(MDFN_ASSUME_ALIGNED((void*)ptr, alignof(T)), &value, sizeof(T));
......@@ -493,9 +468,6 @@ static INLINE void ne64_wbo_le(BT base, const size_t byte_offset, const T value)
template<typename T, typename BT>
static INLINE T ne64_rbo_le(BT base, const size_t byte_offset)
{
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint64*>::value, "Wrong base type");
uintptr_t const ptr = neX_ptr_le<T, uint64>((uintptr_t)base, byte_offset);
T ret;
......
......@@ -219,8 +219,6 @@ static INLINE /*constexpr*/ InputDeviceInputInfoStruct IDIIS_Switch(const char*
{
InputDeviceInputInfoStruct ret = { sname, name, co, IDIT_SWITCH, (uint8)(undoc_defpos_setting ? IDIT_FLAG_AUX_SETTINGS_UNDOC : 0), 0, 0 };
static_assert(defpos < spn_count, "Invalid default switch position!");
ret.Switch.Pos = spn;
ret.Switch.NumPos = spn_count;
ret.Switch.DefPos = defpos;
......
......@@ -65,7 +65,6 @@ static INLINE constexpr uint8 sha1_cton2(char c, char d)
static INLINE constexpr sha1_digest operator "" _sha1(const char *s, std::size_t sz)
{
//static_assert(sz == 41, "Malformed SHA-1 string.");
return /*(sz == 41 ? (void)0 : abort()),*/ sha1_digest({{ sha1_cton2(s[0], s[1]), sha1_cton2(s[2], s[3]), sha1_cton2(s[4], s[5]), sha1_cton2(s[6], s[7]),
sha1_cton2(s[8], s[9]), sha1_cton2(s[10], s[11]), sha1_cton2(s[12], s[13]), sha1_cton2(s[14], s[15]),
sha1_cton2(s[16], s[17]), sha1_cton2(s[18], s[19]), sha1_cton2(s[20], s[21]), sha1_cton2(s[22], s[23]),
......
......@@ -97,7 +97,6 @@ static INLINE constexpr uint8 sha256_cton2(char c, char d)
static INLINE constexpr sha256_digest operator "" _sha256(const char *s, std::size_t sz)
{
//static_assert(sz == 65, "Malformed SHA-256 string.");
return /*(sz == 65 ? (void)0 : abort()),*/ sha256_digest({{ sha256_cton2(s[0], s[1]), sha256_cton2(s[2], s[3]), sha256_cton2(s[4], s[5]), sha256_cton2(s[6], s[7]),
sha256_cton2(s[8], s[9]), sha256_cton2(s[10], s[11]), sha256_cton2(s[12], s[13]), sha256_cton2(s[14], s[15]),
sha256_cton2(s[16], s[17]), sha256_cton2(s[18], s[19]), sha256_cton2(s[20], s[21]), sha256_cton2(s[22], s[23]),
......
......@@ -265,8 +265,6 @@ static bool InitializeModules(void)
&EmulatedVB,
#endif
};
static_assert(MEDNAFEN_VERSION_NUMERIC >= 0x00102200, "Bad MEDNAFEN_VERSION_NUMERIC");
for(unsigned int i = 0; i < sizeof(InternalSystems) / sizeof(MDFNGI *); i++)
AddSystem(InternalSystems[i]);
......
......@@ -328,8 +328,6 @@ static INLINE void Instr_Branch(uint32 instr)
const bool bsub = opcode & 0x20;
bool cond;
static_assert(((opcode >> 2) & 0x7) >= 0x2 && ((opcode >> 2) & 0x7) <= 0x6, "bad opcode");
switch((opcode >> 2) & 0x7)
{
case 0x2:
......
......@@ -320,7 +320,6 @@ static INLINE uint8 DecompByte(void)
template<unsigned T_offs>
static DEFWRITE(SDD1_Write_43xx)
{
static_assert(T_offs == 0 || T_offs == 2 || T_offs == 3 || T_offs == 4 || T_offs == 5 || T_offs == 6, "wrong offs");
switch(T_offs)
{
case 0: DMA_Write_43x0(A, V); break;
......
......@@ -280,13 +280,6 @@ static struct
};
} linebuf;
#ifndef _MSC_VER
static_assert(linebuf.main == linebuf.bg[0], "linebuf structure malformed.");
static_assert(linebuf.main == linebuf.bghr[0], "linebuf structure malformed.");
static_assert(linebuf.sub == linebuf.bg[2], "linebuf structure malformed.");
static_assert(linebuf.sub == linebuf.bghr[1], "linebuf structure malformed.");
#endif
template<bool size16, bool mode4 = false>
static MDFN_HOT MDFN_FASTCALL void GetOPTStrip(const unsigned n)
{
......@@ -466,7 +459,6 @@ static MDFN_HOT MDFN_FASTCALL void DrawBG(const unsigned n, const unsigned y, ui
const uint32* subtarg_bound = target + (h_flip ? 8 : -1);
uint32* subtarg = target + (h_flip ? 0 : 7);
static_assert(bpp == 2 || bpp == 4 || bpp == 8, "wrong bpp");
if(bpp == 2)
{
uint32 tmp[4] =
......@@ -786,8 +778,6 @@ static MDFN_HOT MDFN_FASTCALL void DoWindow(unsigned layernum, uint32* MDFN_REST
bool W0Enabled, W1Enabled;
bool W0Invert, W1Invert;
static_assert(!cwin || !hires, "DoWindow() template arg error.");
//if(mask_settings)
// printf("Layer: %u, mask_settings = 0x%02x\n", layernum, mask_settings);
......@@ -1324,8 +1314,6 @@ static MDFN_HOT void MixLayersSub(void)
{
uint32 main_back, sub_back;
static_assert(hrop != 1 || (mix_bg0 && mix_bg1 && !mix_bg2 && !mix_bg3), "hrop mix_bg* mismatch.");
main_back = (CGRAM[0] << 16) | ((CGADSUB >> 5) & 1) | 2 | 0x808;
//
......@@ -1915,7 +1903,6 @@ static INLINE void RenderCommon_Init(void)
memcpy(PPU.inctab, inctab_init, sizeof(PPU.inctab));
memcpy(PPU.ttab, ttab_init, sizeof(PPU.ttab));
static_assert(sizeof(PPU.Sprite_WHTab) == sizeof(Sprite_WHTab_Init) && sizeof(inctab_init) == sizeof(PPU.inctab) && sizeof(ttab_init) == sizeof(PPU.ttab), "size mismatch");
//
//
//
......
......@@ -53,28 +53,11 @@ static INLINE uint32* SF_FORCE_A32(uint32* p) { return p; }
static INLINE int64* SF_FORCE_A64(int64* p) { return p; }
static INLINE uint64* SF_FORCE_A64(uint64* p) { return p; }
template<typename T>
static INLINE void SF_FORCE_ANY(typename std::enable_if<!std::is_enum<T>::value>::type* = nullptr)
{
static_assert( std::is_same<T, bool>::value ||
std::is_same<T, int8>::value || std::is_same<T, uint8>::value ||
std::is_same<T, int16>::value || std::is_same<T, uint16>::value ||
std::is_same<T, int32>::value || std::is_same<T, uint32>::value || std::is_same<T, float>::value ||
std::is_same<T, int64>::value || std::is_same<T, uint64>::value || std::is_same<T, double>::value, "Unsupported type");
}
template<typename T>
static INLINE void SF_FORCE_ANY(typename std::enable_if<std::is_enum<T>::value>::type* = nullptr)
{
SF_FORCE_ANY<typename std::underlying_type<T>::type>();
}
template<typename IT>
static INLINE SFORMAT SFBASE_(IT* const iv, uint32 icount, const uint32 totalcount, const size_t repstride, void* repbase, const char* const name)
{
typedef typename std::remove_all_extents<IT>::type T;
uint32 count = icount * (sizeof(IT) / sizeof(T));
SF_FORCE_ANY<T>();
//
//
SFORMAT ret;
......@@ -121,8 +104,6 @@ static INLINE SFORMAT SFCONDVAR_(const bool cond, const SFORMAT sf)
#define SFCONDVAR(cond, x, ...) SFCONDVAR_(cond, SFVAR(x, ## __VA_ARGS__))
#endif
static_assert(sizeof(double) == 8, "sizeof(double) != 8");
#define SFPTR8N(x, ...) SFBASE_(SF_FORCE_A8(x), __VA_ARGS__)
#define SFPTR8(x, ...) SFBASE_(SF_FORCE_A8(x), __VA_ARGS__, #x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment