summaryrefslogtreecommitdiffstats
path: root/third_party/rlbox_wasm2c_sandbox/include/rlbox_wasm2c_tls.hpp
blob: b87ac7bf5faedf4780ec4f2dee2fda275bb971fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <stdint.h>

namespace rlbox {

class rlbox_wasm2c_sandbox;

struct rlbox_wasm2c_sandbox_thread_data
{
  rlbox_wasm2c_sandbox* sandbox;
  uint32_t last_callback_invoked;
};

#ifdef RLBOX_EMBEDDER_PROVIDES_TLS_STATIC_VARIABLES

rlbox_wasm2c_sandbox_thread_data* get_rlbox_wasm2c_sandbox_thread_data();

#  define RLBOX_WASM2C_SANDBOX_STATIC_VARIABLES()                              \
    thread_local rlbox::rlbox_wasm2c_sandbox_thread_data                       \
      rlbox_wasm2c_sandbox_thread_info{ 0, 0 };                                \
                                                                               \
    namespace rlbox {                                                          \
      rlbox_wasm2c_sandbox_thread_data* get_rlbox_wasm2c_sandbox_thread_data() \
      {                                                                        \
        return &rlbox_wasm2c_sandbox_thread_info;                              \
      }                                                                        \
    }                                                                          \
    static_assert(true, "Enforce semi-colon")

#endif

} // namespace rlbox