@@ -114,13 +114,31 @@ int lookupSymbol(const void *address, SymbolInfo *info);
114114// / \param body A function to invoke. This function attempts to first initialize
115115// / the Debug Help library. The result of that operation is passed to this
116116// / function.
117+ // / \param context A caller-supplied value to pass to \a body.
117118// /
118119// / On Windows, the Debug Help library (DbgHelp.lib) is not thread-safe. All
119120// / calls into it from the Swift runtime and stdlib should route through this
120121// / function.
121122SWIFT_RUNTIME_STDLIB_SPI
122123void _swift_withWin32DbgHelpLibrary (
123- const std::function<void (bool /* isInitialized*/ )>& body);
124+ void (* body)(bool isInitialized, void *context), void *context);
125+
126+ // / Configure the environment to allow calling into the Debug Help library.
127+ // /
128+ // / \param body A function to invoke. This function attempts to first initialize
129+ // / the Debug Help library. The result of that operation is passed to this
130+ // / function.
131+ // /
132+ // / On Windows, the Debug Help library (DbgHelp.lib) is not thread-safe. All
133+ // / calls into it from the Swift runtime and stdlib should route through this
134+ // / function.
135+ static inline void _swift_withWin32DbgHelpLibrary (
136+ const std::function<void (bool /* isInitialized*/ )> &body) {
137+ _swift_withWin32DbgHelpLibrary ([](bool isInitialized, void *context) {
138+ auto bodyp = reinterpret_cast <std::function<void (bool )> *>(context);
139+ (* bodyp)(isInitialized);
140+ }, const_cast <void *>(reinterpret_cast <const void *>(&body)));
141+ }
124142
125143// / Configure the environment to allow calling into the Debug Help library.
126144// /
0 commit comments