patch 9.1.0630: MS-Windows: build fails with VIMDLL and mzscheme
Problem: MS-Windows: build fails with VIMDLL and mzscheme
Solution: define scheme_register_tls_space() inside gvim.exe
and refer to it from the dll (Ken Takata).
`scheme_register_tls_space()` doesn't support a thread-local variable in
a DLL:
https://docs.racket-lang.org/inside/im_memoryalloc.html#%28cpp._scheme_register_tls_space%29
closes: #15363
Signed-off-by: Ken Takata <kentkt@csc.jp>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/os_w32exe.c b/src/os_w32exe.c
index 85bbfbc..7aa4ead 100644
--- a/src/os_w32exe.c
+++ b/src/os_w32exe.c
@@ -70,3 +70,24 @@
}
# endif
#endif // USE_OWNSTARTUP
+
+
+#if defined(VIMDLL) && defined(FEAT_MZSCHEME)
+
+# if defined(_MSC_VER)
+static __declspec(thread) void *tls_space;
+extern intptr_t _tls_index;
+# elif defined(__MINGW32__)
+static __thread void *tls_space;
+extern intptr_t _tls_index;
+# endif
+
+// Get TLS information that is needed for if_mzsch.
+ __declspec(dllexport) void
+get_tls_info(void ***ptls_space, intptr_t *ptls_index)
+{
+ *ptls_space = &tls_space;
+ *ptls_index = _tls_index;
+ return;
+}
+#endif