From 69da692b0adbd9168d002eaffb02bd59c64044b2 Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: build/msvc: Fix preprocessor parsing Preprocessor directives on the first line of the file were not being parsed. --- src/nvim/generators/gen_declarations.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index 065c043557..c40c37bb3e 100755 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -224,23 +224,15 @@ local static = header local filepattern = '^#%a* (%d+) "([^"]-)/?([^"/]+)"' local curfile -local init = 0 +local init = 1 local curfile = nil local neededfile = fname:match('[^/]+$') local declline = 0 local declendpos = 0 local curdir = nil local is_needed_file = false +local init_is_nl = true while init ~= nil do - init = text:find('[\n;}]', init) - if init == nil then - break - end - local init_is_nl = text:sub(init, init) == '\n' - init = init + 1 - if init_is_nl and is_needed_file then - declline = declline + 1 - end if init_is_nl and text:sub(init, init) == '#' then local line, dir, file = text:match(filepattern, init) if file ~= nil then @@ -293,6 +285,15 @@ while init ~= nil do declendpos = e end end + init = text:find('[\n;}]', init) + if init == nil then + break + end + init_is_nl = text:sub(init, init) == '\n' + init = init + 1 + if init_is_nl and is_needed_file then + declline = declline + 1 + end end non_static = non_static .. footer -- cgit From d520e2590af5e8d22416e6acbcd161ba1601a532 Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: build/msvc: Add mode_t typedef to win_defs.h --- src/nvim/os/win_defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h index 8fd2e51f8b..48607845cc 100644 --- a/src/nvim/os/win_defs.h +++ b/src/nvim/os/win_defs.h @@ -60,6 +60,7 @@ #ifdef _MSC_VER typedef SSIZE_T ssize_t; +typedef int mode_t; #endif #ifndef SSIZE_MAX -- cgit From f04b53aa24f7b6f1f4cdcdf08fcdd600472b0bab Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: build/msvc: Move include into unix_defs.h --- src/nvim/os/os_defs.h | 1 - src/nvim/os/unix_defs.h | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index 87f8d214bd..923a362b41 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h index 5c9daca476..27e64f20cf 100644 --- a/src/nvim/os/unix_defs.h +++ b/src/nvim/os/unix_defs.h @@ -1,9 +1,10 @@ #ifndef NVIM_OS_UNIX_DEFS_H #define NVIM_OS_UNIX_DEFS_H -// Windows doesn't have unistd.h, so we include it here to avoid numerous -// instances of `#ifdef WIN32'. +// Windows doesn't have the following headers, +// so we include them here to avoid numerous instances of `#ifdef WIN32'. #include +#include // POSIX.1-2008 says that NAME_MAX should be in here #include -- cgit From 2c414fbbb1a869a4d9d3dd1076d198945ee74a7e Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: build/msvc: Fix missing restrict keyword MSVC has the __restrict keyword and a marco is defined for it in `win_defs.h`. --- src/nvim/lib/kvec.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h index ee1b890cb9..ad56c9237b 100644 --- a/src/nvim/lib/kvec.h +++ b/src/nvim/lib/kvec.h @@ -41,6 +41,7 @@ #include #include "nvim/memory.h" +#include "nvim/os/os_defs.h" #define kv_roundup32(x) \ ((--(x)), \ -- cgit From 60a341a05f2d2a351a172b36e7f01e579e49ab02 Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: build/msvc: Fix standard IO file number definitions With MSVC, STDOUT_FILENO and STDERR_FILENO are defined as function calls instead of constants, meaning they can't be assigned to enum values. The enum was only used in one file, so it has been removed. A definition for STDIN_FILENO has been added that is consistent with the other two definitions. --- src/nvim/main.c | 8 ++++---- src/nvim/os/os_defs.h | 7 ------- src/nvim/os/win_defs.h | 3 +++ 3 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 4fd55f1491..25fb0f14d8 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -795,7 +795,7 @@ static void command_line_scan(mparm_T *parmp) mch_exit(0); } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) { FileDescriptor fp; - const int fof_ret = file_open_fd(&fp, OS_STDOUT_FILENO, true); + const int fof_ret = file_open_fd(&fp, STDOUT_FILENO, true); msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write); if (fof_ret != 0) { @@ -1256,10 +1256,10 @@ static void check_and_set_isatty(mparm_T *paramp) paramp->err_isatty = os_isatty(fileno(stderr)); #ifndef WIN32 int tty_fd = paramp->input_isatty - ? OS_STDIN_FILENO + ? STDIN_FILENO : (paramp->output_isatty - ? OS_STDOUT_FILENO - : (paramp->err_isatty ? OS_STDERR_FILENO : -1)); + ? STDOUT_FILENO + : (paramp->err_isatty ? STDERR_FILENO : -1)); pty_process_save_termios(tty_fd); #endif TIME_MSG("window checked"); diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index 923a362b41..f81785675e 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -13,13 +13,6 @@ # include "nvim/os/unix_defs.h" #endif -/// File descriptor number used for standard IO streams -enum { - OS_STDIN_FILENO = STDIN_FILENO, - OS_STDOUT_FILENO = STDOUT_FILENO, - OS_STDERR_FILENO = STDERR_FILENO, -}; - #define BASENAMELEN (NAME_MAX - 5) // Use the system path length if it makes sense. diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h index 48607845cc..faee06304c 100644 --- a/src/nvim/os/win_defs.h +++ b/src/nvim/os/win_defs.h @@ -45,6 +45,9 @@ # ifndef restrict # define restrict __restrict # endif +# ifndef STDIN_FILENO +# define STDIN_FILENO _fileno(stdin) +# endif # ifndef STDOUT_FILENO # define STDOUT_FILENO _fileno(stdout) # endif -- cgit From 8f39e96d21d72c103727378ffd8902bed20a2896 Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: build/msvc: Remove unnecessary header include --- src/nvim/spellfile.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index df066e7ad3..f5d5d408a1 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -228,7 +228,6 @@ #include #include #include -#include #include "nvim/vim.h" #include "nvim/spell_defs.h" -- cgit From 01fc02beeee2a4c5ba66e6f93d9fb0d1fd6a4548 Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Sun, 4 Mar 2018 17:44:23 -0600 Subject: build/msvc: Add missing WIN32 macro MSVC predefines `_WIN32`, but not `WIN32`. Also, some unnecessary includes have been removed. --- src/nvim/main.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 25fb0f14d8..4288d7f9d7 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -7,11 +7,6 @@ #include #include -#ifdef WIN32 -# include -# include -#endif - #include #include "nvim/ascii.h" -- cgit From d7ee3233264626de93e0466e0abecbc9dc6bc6ba Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Sun, 4 Mar 2018 17:44:23 -0600 Subject: build/msvc: Fix errors caused by compiler intrinsics --- src/nvim/eval.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 923b4527c2..d69acf4eef 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5936,6 +5936,14 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) } #ifdef INCLUDE_GENERATED_DECLARATIONS + +#ifdef _MSC_VER +// This prevents MSVC from replacing the functions with intrinsics, +// and causing errors when trying to get their addresses in funcs.generated.h +#pragma function (ceil) +#pragma function (floor) +#endif + # include "funcs.generated.h" #endif -- cgit From 353ca83f73dba0c7661a061215cc8508051a1be9 Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Sun, 4 Mar 2018 17:44:23 -0600 Subject: build/msvc: Workaround for compiler optimization bug --- src/nvim/option.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index eff436eb4d..d6903c8db7 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2436,6 +2436,11 @@ static bool valid_filetype(char_u *val) return true; } +#ifdef _MSC_VER +// MSVC optimizations are disabled for this function because it +// incorrectly generates an empty string for SHM_ALL. +#pragma optimize("", off) +#endif /* * Handle string options that need some action to perform when changed. * Returns NULL for success, or an error message for an error. @@ -3305,6 +3310,9 @@ did_set_string_option ( return errmsg; } +#ifdef _MSC_VER +#pragma optimize("", on) +#endif /* * Simple int comparison function for use with qsort() -- cgit From fb3667cd16adfb1564ccbe36973f8874afc1524f Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Sun, 4 Mar 2018 17:44:23 -0600 Subject: build/msvc: Remove confusing comment --- src/nvim/os/unix_defs.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h index 27e64f20cf..60a2dfa882 100644 --- a/src/nvim/os/unix_defs.h +++ b/src/nvim/os/unix_defs.h @@ -1,8 +1,6 @@ #ifndef NVIM_OS_UNIX_DEFS_H #define NVIM_OS_UNIX_DEFS_H -// Windows doesn't have the following headers, -// so we include them here to avoid numerous instances of `#ifdef WIN32'. #include #include -- cgit