Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/common/fastjmp.h
4211 views
1
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: 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 = 216;
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
}
36
37