1
0
forked from aniani/vim

patch 8.2.5131: timeout implementation is not optimal

Problem:    Timeout implementation is not optimal.
Solution:   Further improvements for timeouts.  Add a test for searchpair()
            timeout. (partly by Paul Ollis)
This commit is contained in:
Bram Moolenaar
2022-06-19 17:05:47 +01:00
parent c5382b667a
commit e530395c2c
5 changed files with 60 additions and 23 deletions

6
src/auto/configure vendored
View File

@@ -4769,6 +4769,8 @@ rm -f core conftest.err conftest.$ac_objext \
MACOS_X_DARWIN=yes
OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
$as_echo "#define HAVE_TIMER_CREATE 1" >>confdefs.h
CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
@@ -13044,7 +13046,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#include<signal.h>
#include<time.h>
static void set_flag(union sigval) {}
static void set_flag(union sigval sv) {}
int
main ()
@@ -13073,7 +13075,7 @@ else
#include<signal.h>
#include<time.h>
static void set_flag(union sigval) {}
static void set_flag(union sigval sv) {}
int
main ()

View File

@@ -287,6 +287,8 @@ if test "$vim_cv_uname_output" = Darwin; then
MACOS_X_DARWIN=yes
OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
dnl os_macosx.m implements timer_create() and friends
AC_DEFINE(HAVE_TIMER_CREATE)
dnl TODO: use -arch i386 on Intel machines
dnl Removed -no-cpp-precomp, only for very old compilers.
CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
@@ -3809,7 +3811,7 @@ LIBS="$LIBS -lrt"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include<signal.h>
#include<time.h>
static void set_flag(union sigval) {}
static void set_flag(union sigval sv) {}
], [
struct timespec ts;
struct sigevent action = {0};
@@ -3824,7 +3826,7 @@ static void set_flag(union sigval) {}
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include<signal.h>
#include<time.h>
static void set_flag(union sigval) {}
static void set_flag(union sigval sv) {}
], [
struct timespec ts;
struct sigevent action = {0};

View File

@@ -37,7 +37,7 @@ endfunc
func Test_hlsearch_hangs()
CheckFunction reltimefloat
" So, it turns out the Windows 7 implements TimerQueue timers differently
" So, it turns out that Windows 7 implements TimerQueue timers differently
" and they can expire *before* the requested time has elapsed. So allow for
" the timeout occurring after 80 ms (5 * 16 (the typical clock tick)).
if has("win32")

View File

@@ -355,6 +355,37 @@ func Test_searchpair_timeout()
bwipe!
endfunc
func SearchpairSkip()
let id = synID(line('.'), col('.'), 0)
let attr = synIDattr(id, 'name')
return attr !~ 'comment'
endfunc
func Test_searchpair_timeout_with_skip()
let g:test_is_flaky = 1
edit ../evalfunc.c
if has('win32')
" Windows timeouts are rather coarse grained, about 16ms.
let ms = 20
let min_time = 0.016
let max_time = min_time * 10.0
else
let ms = 1
let min_time = 0.001
let max_time = min_time * 10.0
if GetVimCommand() =~ 'valgrind.*--log-file='
let max_time += 0.04 " this can be slow with valgrind
endif
endif
let start = reltime()
let found = searchpair('(', '', ')', 'crnm', 'SearchpairSkip()', 0, ms)
let elapsed = reltimefloat(reltime(start))
call assert_inrange(min_time, max_time, elapsed)
bwipe!
endfunc
func Test_searchpairpos()
new
call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])

View File

@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
5131,
/**/
5130,
/**/