ITotalJustice / notorious_beeg

gba emulator written in c++23
https://notorious-beeg.netlify.app/
GNU General Public License v3.0
41 stars 4 forks source link

fix stuff for emscripten port #81

Closed ITotalJustice closed 2 years ago

ITotalJustice commented 2 years ago

reason being is libc++ support for ranges is pretty poor. this means i cannot build my emulator for the web using emscripten.

i could write a wrapper for ranges, and use that instead for clang builds, but they may involve too much work, though i'd rather this option because then once libc++ has full support for ranges, i can simply delete the wrapper.

ITotalJustice commented 2 years ago

something like this seems to build fine (added to fwd.hpp)

#ifdef EMSCRIPTEN
#include <ranges>

namespace std::ranges {

constexpr auto fill(auto& array, auto value) -> void
{
    for (auto& entry : array)
    {
        entry = value;
    }
}

constexpr auto copy(auto& src, auto& dst) -> void
{
    constexpr auto src_size = sizeof(src);
    constexpr auto dst_size = sizeof(dst);

    for (std::size_t i = 0; i < src_size && i < dst_size; i++)
    {
        dst[i] = src[i];
    }
}

} // namespace std::ranges

namespace std {

[[noreturn]] inline void unreachable()
{
    __builtin_unreachable();
}

} // namespace std
#endif // EMSCRIPTEN

obvs this isnt have copy or fill should be impl, but for the places that i use it, this works fine.

ITotalJustice commented 2 years ago

fixed in https://github.com/ITotalJustice/notorious_beeg/commit/b0a4ad19645b2280429397973f6861000add9254