duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

fastjmp.h (951B)


      1 // SPDX-FileCopyrightText: 2021 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
      3 
      4 #pragma once
      5 
      6 #include "types.h"
      7 
      8 #include <cstddef>
      9 #include <cstdint>
     10 
     11 struct fastjmp_buf
     12 {
     13 #if defined(_WIN32) && defined(_M_AMD64)
     14   static constexpr std::size_t BUF_SIZE = 240;
     15 #elif defined(_M_ARM64) || defined(__aarch64__)
     16   static constexpr std::size_t BUF_SIZE = 168;
     17 #elif defined(_M_ARM) || defined(__arm__)
     18   static constexpr std::size_t BUF_SIZE = 112;
     19 #elif defined(__x86_64__)
     20   static constexpr std::size_t BUF_SIZE = 64;
     21 #elif defined(_M_IX86) || defined(__i386__)
     22   static constexpr std::size_t BUF_SIZE = 24;
     23 #elif defined(__riscv) && __riscv_xlen == 64
     24   static constexpr std::size_t BUF_SIZE = 208;
     25 #else
     26 #error Unknown architecture.
     27 #endif
     28 
     29   alignas(16) std::uint8_t buf[BUF_SIZE];
     30 };
     31 
     32 extern "C" {
     33 int fastjmp_set(fastjmp_buf* buf);
     34 [[noreturn]] void fastjmp_jmp(const fastjmp_buf* buf, int ret);
     35 }