mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-07 07:21:18 +12:00
Proper fix for static asserts
This commit is contained in:
parent
723fd8cbef
commit
2767373098
5 changed files with 40 additions and 13 deletions
|
@ -77,7 +77,7 @@ void ih264d_init_function_ptr(dec_struct_t *ps_codec)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#ifndef __WIN32
|
||||
#include <cpuid.h>
|
||||
|
||||
void __cpuid2(signed int* cpuInfo, unsigned int level)
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
#include "Cafe/IOSU/legacy/iosu_crypto.h"
|
||||
#include "Common/filestream.h"
|
||||
|
||||
#ifndef __WIN32
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#endif
|
||||
|
||||
std::vector<Account> Account::s_account_list;
|
||||
|
||||
Account::Account(uint32 persistent_id)
|
||||
|
@ -65,7 +69,15 @@ Account::Account(uint32 persistent_id, std::wstring_view mii_name)
|
|||
|
||||
static std::random_device s_random_device;
|
||||
static std::mt19937 s_mte(s_random_device());
|
||||
|
||||
//Use boost library to escape static asserts in Linux Builds
|
||||
//TODO: Look for fix in libstdc++
|
||||
#ifndef __WIN32
|
||||
boost::random::uniform_int_distribution<uint16> dist(std::numeric_limits<uint8>::min(), std::numeric_limits<uint8>::max());
|
||||
#else
|
||||
std::uniform_int_distribution<uint16> dist(std::numeric_limits<uint8>::min(), std::numeric_limits<uint8>::max());
|
||||
#endif
|
||||
|
||||
std::generate(m_uuid.begin(), m_uuid.end(), [&]() { return (uint8)dist(s_mte); });
|
||||
|
||||
// 1000004 or 2000004 | lower uint32 from uuid from uuid
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
#include<bitset>
|
||||
#include<random>
|
||||
|
||||
#ifndef __WIN32
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#endif
|
||||
|
||||
void swap(unsigned char *a, unsigned char *b)
|
||||
{
|
||||
int tmp = *a;
|
||||
|
@ -111,7 +115,13 @@ void releasePRUDPPort(uint16 port)
|
|||
}
|
||||
|
||||
std::mt19937_64 prudpRG(GetTickCount());
|
||||
//Workaround for static asserts when using uniform_int_distribution
|
||||
//TODO: Look for fix in libstdc++
|
||||
#ifdef __WIN32
|
||||
std::uniform_int_distribution<int> prudpDis8(0, 0xFF);
|
||||
#else
|
||||
boost::random::uniform_int_distribution<int> prudpDis8(0, 0xFF);
|
||||
#endif
|
||||
|
||||
uint8 prudp_generateRandomU8()
|
||||
{
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
//Temporary Workaround for static_assert related errors in libstdc++12
|
||||
//TODO: Make a proper fix
|
||||
#ifdef __clang__
|
||||
#define static_assert(...) static_assert(true, "")
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h> // for size_t
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
|
||||
#include "config/ActiveSettings.h"
|
||||
|
||||
#ifndef __WIN32
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#include <TlHelp32.h>
|
||||
#endif
|
||||
|
@ -426,7 +431,13 @@ std::string GenerateRandomString(size_t length, std::string_view characters)
|
|||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
//Workaround for static asserts using boost
|
||||
//TODO: Wait for fix in libstdc++
|
||||
#ifdef __WIN32
|
||||
std::uniform_int_distribution<decltype(characters.size())> index_dist(0, characters.size() - 1);
|
||||
#else
|
||||
boost::random::uniform_int_distribution<decltype(characters.size())> index_dist(0, characters.size() - 1);
|
||||
#endif
|
||||
for (uint32_t i = 0; i < length; ++i)
|
||||
{
|
||||
result << characters[index_dist(gen)];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue