summaryrefslogtreecommitdiffstats
path: root/src/os_w32exe.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
commit6e9cd6b491267e6dff3e3f3f37d8af5f28e40672 (patch)
tree35661af16c4a0ef2a9a8e225d2d5cc82605ea289 /src/os_w32exe.c
parentAdding upstream version 2:9.1.0496. (diff)
downloadvim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.tar.xz
vim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.zip
Adding upstream version 2:9.1.0698.upstream/2%9.1.0698
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/os_w32exe.c72
1 files changed, 57 insertions, 15 deletions
diff --git a/src/os_w32exe.c b/src/os_w32exe.c
index c4f0294..7aa4ead 100644
--- a/src/os_w32exe.c
+++ b/src/os_w32exe.c
@@ -8,10 +8,10 @@
* See README.txt for an overview of the Vim source code.
*/
/*
- * Windows GUI: main program (EXE) entry point:
+ * Windows GUI/Console: main program (EXE) entry point:
*
- * Ron Aaron <ronaharon@yahoo.com> wrote this and the (now deleted) DLL support
- * code.
+ * Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
+ * Adapted by Ken Takata.
*/
#include "vim.h"
@@ -20,32 +20,74 @@
__declspec(dllimport)
#endif
int VimMain(int argc, char **argv);
-#ifndef VIMDLL
+
+#ifdef VIMDLL
+# define SaveInst(hInst) // Do nothing
+#else
void SaveInst(HINSTANCE hInst);
#endif
-#ifndef PROTO
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
int WINAPI
wWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInst UNUSED,
LPWSTR lpszCmdLine UNUSED,
int nCmdShow UNUSED)
-# else
+{
+ SaveInst(hInstance);
+ return VimMain(0, NULL);
+}
+#else
int
wmain(int argc UNUSED, wchar_t **argv UNUSED)
-# endif
{
-# ifndef VIMDLL
-# ifdef FEAT_GUI
- SaveInst(hInstance);
-# else
SaveInst(GetModuleHandleW(NULL));
-# endif
-# endif
+ 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)
- return 0;
+# 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