diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-03 10:35:25 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-03 10:35:25 -0300 |
commit | cb86eca91f9bdffe8b0214664169093d41902415 (patch) | |
tree | 8ba097bb2f3f8c03ac924b47decdfe7ec5f3e6b4 /src | |
parent | 41f1678767071b037e0097e7c46eeecbe6bd6df4 (diff) | |
parent | cc34c90df7dd24c2b5319863fa8a39e4aff4ad32 (diff) | |
download | rneovim-cb86eca91f9bdffe8b0214664169093d41902415.tar.gz rneovim-cb86eca91f9bdffe8b0214664169093d41902415.tar.bz2 rneovim-cb86eca91f9bdffe8b0214664169093d41902415.zip |
Merge PR #1603 'Small refactoring and dependencies update'
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/diff.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 4 | ||||
-rw-r--r-- | src/nvim/os/shell.h | 15 | ||||
-rw-r--r-- | src/nvim/os/time.c | 37 |
4 files changed, 26 insertions, 32 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 18e30f8587..b557753bff 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -918,7 +918,7 @@ void ex_diffpatch(exarg_T *eap) #endif // ifdef UNIX // Avoid ShellCmdPost stuff block_autocmds(); - (void)call_shell(buf, kShellOptFilter | kShellOptCooked, NULL); + (void)call_shell(buf, kShellOptFilter, NULL); unblock_autocmds(); } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 44caa67847..5ae03c6be3 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1097,7 +1097,7 @@ do_filter ( */ if (call_shell( cmd_buf, - kShellOptFilter | kShellOptCooked | shell_flags, + kShellOptFilter | shell_flags, NULL )) { redraw_later_clear(); @@ -1253,7 +1253,7 @@ do_shell ( if (!swapping_screen()) windgoto(msg_row, msg_col); cursor_on(); - (void)call_shell(cmd, kShellOptCooked | flags, NULL); + (void)call_shell(cmd, flags, NULL); did_check_timestamps = FALSE; need_check_timestamps = TRUE; diff --git a/src/nvim/os/shell.h b/src/nvim/os/shell.h index a4c588d7a3..64e7c79ba7 100644 --- a/src/nvim/os/shell.h +++ b/src/nvim/os/shell.h @@ -5,14 +5,13 @@ // Flags for mch_call_shell() second argument typedef enum { - kShellOptFilter = 1, ///< filtering text - kShellOptExpand = 2, ///< expanding wildcards - kShellOptCooked = 4, ///< set term to cooked mode - kShellOptDoOut = 8, ///< redirecting output - kShellOptSilent = 16, ///< don't print error returned by command - kShellOptRead = 32, ///< read lines and insert into buffer - kShellOptWrite = 64, ///< write lines from buffer - kShellOptHideMess = 128, ///< previously a global variable from os_unix.c + kShellOptFilter = 1, ///< filtering text + kShellOptExpand = 2, ///< expanding wildcards + kShellOptDoOut = 4, ///< redirecting output + kShellOptSilent = 8, ///< don't print error returned by command + kShellOptRead = 16, ///< read lines and insert into buffer + kShellOptWrite = 32, ///< write lines from buffer + kShellOptHideMess = 64, ///< previously a global variable from os_unix.c } ShellOpts; #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 3794e813d2..810ddea82b 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -54,7 +54,22 @@ void os_delay(uint64_t milliseconds, bool ignoreinput) /// @param microseconds Number of microseconds to sleep void os_microdelay(uint64_t microseconds) { - microdelay(microseconds); + uint64_t elapsed = 0; + uint64_t ns = microseconds * 1000; // convert to nanoseconds + uint64_t base = uv_hrtime(); + + uv_mutex_lock(&delay_mutex); + + while (elapsed < ns) { + if (uv_cond_timedwait(&delay_cond, &delay_mutex, ns - elapsed) + == UV_ETIMEDOUT) + break; + uint64_t now = uv_hrtime(); + elapsed += now - base; + base = now; + } + + uv_mutex_unlock(&delay_mutex); } /// Portable version of POSIX localtime_r() @@ -88,23 +103,3 @@ struct tm *os_get_localtime(struct tm *result) FUNC_ATTR_NONNULL_ALL time_t rawtime = time(NULL); return os_localtime_r(&rawtime, result); } - -static void microdelay(uint64_t microseconds) -{ - uint64_t elapsed = 0; - uint64_t ns = microseconds * 1000; // convert to nanoseconds - uint64_t base = uv_hrtime(); - - uv_mutex_lock(&delay_mutex); - - while (elapsed < ns) { - if (uv_cond_timedwait(&delay_cond, &delay_mutex, ns - elapsed) - == UV_ETIMEDOUT) - break; - uint64_t now = uv_hrtime(); - elapsed += now - base; - base = now; - } - - uv_mutex_unlock(&delay_mutex); -} |