Spicy
init.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 namespace hilti::rt {
6 
7 struct Context;
8 
13 extern void init();
14 
19 extern void done();
20 
22 extern bool isInitialized();
23 
25 extern void executeManualPreInits();
26 
27 namespace detail {
28 
31 struct HiltiModule {
32  const char* name{};
33  const char* id = nullptr;
34  void (*init_module)() = nullptr;
37  nullptr;
38  unsigned int* globals_idx =
39  nullptr;
40 };
41 
43 extern void registerModule(HiltiModule module);
44 
51 #ifdef HILTI_MANUAL_PREINIT
52 #define HILTI_PRE_INIT(func) static ::hilti::rt::detail::RegisterManualPreInit __pre_init_##__COUNTER__(func);
53 #else
54 #define HILTI_PRE_INIT(func) static ::hilti::rt::detail::ExecutePreInit __pre_init_##__COUNTER__(func);
55 #endif
56 
59 public:
60  ExecutePreInit(void (*f)()) { (*f)(); }
61 };
62 
65 public:
66  RegisterManualPreInit(void (*f)());
67 };
68 
69 } // namespace detail
70 
71 } // namespace hilti::rt
void init()
Definition: init.cc:22
void(* init_module)()
Definition: init.h:34
Definition: init.h:31
unsigned int * globals_idx
Definition: init.h:38
Definition: any.h:7
void(* init_globals)(hilti::rt::Context *ctx)
Definition: init.h:36
void done()
Definition: init.cc:64
void executeManualPreInits()
Definition: init.cc:111
bool isInitialized()
Definition: init.cc:81
const char * name
Definition: init.h:32
Definition: context.h:24