forked from ipasimulator/ipasim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachOInitializer.cpp
More file actions
30 lines (23 loc) · 852 Bytes
/
MachOInitializer.cpp
File metadata and controls
30 lines (23 loc) · 852 Bytes
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
// MachOInitializer.cpp: Contains class `MachOInitializer`.
#define IPASIM_IMPORT extern "C" __declspec(dllimport)
extern "C" char _mh_dylib_header;
IPASIM_IMPORT void ipaSim_register(void *); // From `IpaSimLibrary`
IPASIM_IMPORT void _objc_init(void); // From `objc`
// This ensures that the initializer will run before others. We don't want that
// in `libobjc.dll` itself, though, because we actually want it's globals to be
// initialized before calling `_objc_init`.
#if !defined(BUILDING_OBJC)
#pragma init_seg(lib)
#endif
namespace {
// Ensures the current library is initialized via RAII.
struct MachOInitializer {
MachOInitializer() {
// Register itself within `IpaSimLibrary`.
ipaSim_register(&_mh_dylib_header);
// Initialize the Objective-C runtime.
_objc_init();
}
};
MachOInitializer MI;
} // namespace