mirror of
https://github.com/vim/vim
synced 2025-03-16 06:47:52 +01:00
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>
93 lines
2.1 KiB
C
93 lines
2.1 KiB
C
/* vi:set ts=8 sts=4 sw=4 noet:
|
|
*
|
|
* VIM - Vi IMproved by Bram Moolenaar
|
|
* GUI support by Robert Webb
|
|
*
|
|
* Do ":help uganda" in Vim to read copying and usage conditions.
|
|
* Do ":help credits" in Vim to see a list of people who contributed.
|
|
* See README.txt for an overview of the Vim source code.
|
|
*/
|
|
/*
|
|
* Windows GUI/Console: main program (EXE) entry point:
|
|
*
|
|
* Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
|
|
* Adapted by Ken Takata.
|
|
*/
|
|
#include "vim.h"
|
|
|
|
// cproto doesn't create a prototype for VimMain()
|
|
#ifdef VIMDLL
|
|
__declspec(dllimport)
|
|
#endif
|
|
int VimMain(int argc, char **argv);
|
|
|
|
#ifdef VIMDLL
|
|
# define SaveInst(hInst) // Do nothing
|
|
#else
|
|
void SaveInst(HINSTANCE hInst);
|
|
#endif
|
|
|
|
#ifdef FEAT_GUI
|
|
int WINAPI
|
|
wWinMain(
|
|
HINSTANCE hInstance,
|
|
HINSTANCE hPrevInst UNUSED,
|
|
LPWSTR lpszCmdLine UNUSED,
|
|
int nCmdShow UNUSED)
|
|
{
|
|
SaveInst(hInstance);
|
|
return VimMain(0, NULL);
|
|
}
|
|
#else
|
|
int
|
|
wmain(int argc UNUSED, wchar_t **argv UNUSED)
|
|
{
|
|
SaveInst(GetModuleHandleW(NULL));
|
|
return VimMain(0, NULL);
|
|
}
|
|
#endif
|
|
|
|
#ifdef USE_OWNSTARTUP
|
|
// Use our own entry point and don't use the default CRT startup code to
|
|
// reduce the size of (g)vim.exe. This works only when VIMDLL is defined.
|
|
//
|
|
// For MSVC, the /GS- compiler option is needed to avoid the undefined symbol
|
|
// error. (It disables the security check. However, it affects only this
|
|
// function and doesn't have any effect on Vim itself.)
|
|
// For MinGW, the -nostdlib compiler option and the --entry linker option are
|
|
// needed.
|
|
# ifdef FEAT_GUI
|
|
void WINAPI
|
|
wWinMainCRTStartup(void)
|
|
{
|
|
VimMain(0, NULL);
|
|
}
|
|
# else
|
|
void
|
|
wmainCRTStartup(void)
|
|
{
|
|
VimMain(0, NULL);
|
|
}
|
|
# 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
|