@@ -376,21 +376,6 @@ mch_write(char_u *s, int len)
376376 RealWaitForChar (read_cmd_fd , p_wd , NULL , NULL );
377377}
378378
379- #if defined(HAVE_GETTIMEOFDAY ) && defined(HAVE_SYS_TIME_H )
380- /*
381- * Return time in msec since "start_tv".
382- */
383- static long
384- elapsed (struct timeval * start_tv )
385- {
386- struct timeval now_tv ;
387-
388- gettimeofday (& now_tv , NULL );
389- return (now_tv .tv_sec - start_tv -> tv_sec ) * 1000L
390- + (now_tv .tv_usec - start_tv -> tv_usec ) / 1000L ;
391- }
392- #endif
393-
394379/*
395380 * mch_inchar(): low level input function.
396381 * Get a characters from the keyboard.
@@ -411,10 +396,10 @@ mch_inchar(
411396 int did_start_blocking = FALSE;
412397 long wait_time ;
413398 long elapsed_time = 0 ;
414- #if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
415- struct timeval start_tv ;
399+ #ifdef ELAPSED_FUNC
400+ ELAPSED_TYPE start_tv ;
416401
417- gettimeofday ( & start_tv , NULL );
402+ ELAPSED_INIT ( start_tv );
418403#endif
419404
420405 /* repeat until we got a character or waited long enough */
@@ -438,8 +423,8 @@ mch_inchar(
438423 else
439424 /* going to block after p_ut */
440425 wait_time = p_ut ;
441- #if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
442- elapsed_time = elapsed ( & start_tv );
426+ #ifdef ELAPSED_FUNC
427+ elapsed_time = ELAPSED_FUNC ( start_tv );
443428#endif
444429 wait_time -= elapsed_time ;
445430 if (wait_time < 0 )
@@ -1554,18 +1539,16 @@ mch_input_isatty(void)
15541539
15551540#ifdef FEAT_X11
15561541
1557- # if defined(HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H ) \
1542+ # if defined(ELAPSED_TIMEVAL ) \
15581543 && (defined(FEAT_XCLIPBOARD ) || defined(FEAT_TITLE ))
15591544
1560- static void xopen_message (struct timeval * start_tv );
1561-
15621545/*
15631546 * Give a message about the elapsed time for opening the X window.
15641547 */
15651548 static void
1566- xopen_message (struct timeval * start_tv )
1549+ xopen_message (long elapsed_msec )
15671550{
1568- smsg ((char_u * )_ ("Opening the X display took %ld msec" ), elapsed ( start_tv ) );
1551+ smsg ((char_u * )_ ("Opening the X display took %ld msec" ), elapsed_msec );
15691552}
15701553# endif
15711554#endif
@@ -1864,11 +1847,11 @@ get_x11_windis(void)
18641847#endif
18651848 if (x11_display != NULL )
18661849 {
1867- # if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
1850+ # ifdef ELAPSED_FUNC
18681851 if (p_verbose > 0 )
18691852 {
18701853 verbose_enter ();
1871- xopen_message (& start_tv );
1854+ xopen_message (ELAPSED_FUNC ( start_tv ) );
18721855 verbose_leave ();
18731856 }
18741857# endif
@@ -4630,8 +4613,8 @@ mch_call_shell(
46304613 ga_init2 (& ga , 1 , BUFLEN );
46314614
46324615 noread_cnt = 0 ;
4633- # if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
4634- gettimeofday ( & start_tv , NULL );
4616+ # ifdef ELAPSED_FUNC
4617+ ELAPSED_INIT ( start_tv );
46354618# endif
46364619 for (;;)
46374620 {
@@ -4666,8 +4649,8 @@ mch_call_shell(
46664649 /* Get extra characters when we don't have any.
46674650 * Reset the counter and timer. */
46684651 noread_cnt = 0 ;
4669- # if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
4670- gettimeofday ( & start_tv , NULL );
4652+ # ifdef ELAPSED_FUNC
4653+ ELAPSED_INIT ( start_tv );
46714654# endif
46724655 len = ui_inchar (ta_buf , BUFLEN , 10L , 0 );
46734656 }
@@ -4886,10 +4869,10 @@ mch_call_shell(
48864869 if (got_int )
48874870 break ;
48884871
4889- # if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
4872+ # ifdef ELAPSED_FUNC
48904873 if (wait_pid == 0 )
48914874 {
4892- long msec = elapsed ( & start_tv );
4875+ long msec = ELAPSED_FUNC ( start_tv );
48934876
48944877 /* Avoid that we keep looping here without
48954878 * checking for a CTRL-C for a long time. Don't
@@ -5632,15 +5615,14 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
56325615 /* May retry getting characters after an event was handled. */
56335616# define MAY_LOOP
56345617
5635- # if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
5618+ # ifdef ELAPSED_FUNC
56365619 /* Remember at what time we started, so that we know how much longer we
56375620 * should wait after being interrupted. */
5638- # define USE_START_TV
56395621 long start_msec = msec ;
5640- struct timeval start_tv ;
5622+ ELAPSED_TYPE start_tv ;
56415623
56425624 if (msec > 0 )
5643- gettimeofday ( & start_tv , NULL );
5625+ ELAPSED_INIT ( start_tv );
56445626# endif
56455627
56465628 /* Handle being called recursively. This may happen for the session
@@ -5947,9 +5929,9 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
59475929 /* We're going to loop around again, find out for how long */
59485930 if (msec > 0 )
59495931 {
5950- # ifdef USE_START_TV
5932+ # ifdef ELAPSED_FUNC
59515933 /* Compute remaining wait time. */
5952- msec = start_msec - elapsed ( & start_tv );
5934+ msec = start_msec - ELAPSED_FUNC ( start_tv );
59535935# else
59545936 /* Guess we got interrupted halfway. */
59555937 msec = msec / 2 ;
@@ -7046,11 +7028,11 @@ setup_term_clip(void)
70467028#if defined(HAVE_SETJMP_H )
70477029 int (* oldIOhandler )();
70487030#endif
7049- # if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
7050- struct timeval start_tv ;
7031+ # ifdef ELAPSED_FUNC
7032+ ELAPSED_TYPE start_tv ;
70517033
70527034 if (p_verbose > 0 )
7053- gettimeofday ( & start_tv , NULL );
7035+ ELAPSED_INIT ( start_tv );
70547036# endif
70557037
70567038 /* Ignore X errors while opening the display */
@@ -7092,11 +7074,11 @@ setup_term_clip(void)
70927074 /* Catch terminating error of the X server connection. */
70937075 (void )XSetIOErrorHandler (x_IOerror_handler );
70947076
7095- # if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
7077+ # ifdef ELAPSED_FUNC
70967078 if (p_verbose > 0 )
70977079 {
70987080 verbose_enter ();
7099- xopen_message (& start_tv );
7081+ xopen_message (ELAPSED_FUNC ( start_tv ) );
71007082 verbose_leave ();
71017083 }
71027084# endif
0 commit comments