0
0
mirror of https://github.com/vim/vim.git synced 2025-10-18 07:54:29 -04:00

patch 9.1.1721: Defining a global gettimeofday() function

Problem:  Defining a global gettimeofday() function causes conflicts if
          gettimeofday() is already defined.
Solution: Revert globalized gettimeofday() function (Hirohito Higashi).

fixes: #18162
fixes: #18161
fixes: #18170
closes: #18173

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito Higashi
2025-08-31 19:43:23 +02:00
committed by Christian Brabandt
parent 6278f1a10a
commit bf91eb7620
3 changed files with 16 additions and 18 deletions

View File

@@ -20,9 +20,6 @@ void f_timer_pause(typval_T *argvars, typval_T *rettv);
void f_timer_start(typval_T *argvars, typval_T *rettv);
void f_timer_stop(typval_T *argvars, typval_T *rettv);
void f_timer_stopall(typval_T *argvars, typval_T *rettv);
#if (defined(MSWIN) || defined(__MINGW32__)) && !defined(FEAT_RUBY)
int gettimeofday(struct timeval *tv, char *dummy);
#endif
void time_push(void *tv_rel, void *tv_start);
void time_pop(void *tp);
void time_msg(char *mesg, void *tv_start);

View File

@@ -127,21 +127,6 @@ get_ctime(time_t thetime, int add_newline)
return buf;
}
// Ruby has its own version of gettimeofday
#if (defined(MSWIN) || defined(__MINGW32__)) && !defined(FEAT_RUBY)
/*
* Windows doesn't have gettimeofday(), although it does have struct timeval.
*/
int
gettimeofday(struct timeval *tv, char *dummy UNUSED)
{
long t = clock();
tv->tv_sec = t / CLOCKS_PER_SEC;
tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
return 0;
}
#endif
#if defined(FEAT_EVAL) || defined(PROTO)
#if defined(MACOS_X)
@@ -962,6 +947,20 @@ f_timer_stopall(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
# if defined(STARTUPTIME) || defined(PROTO)
static struct timeval prev_timeval;
# ifdef MSWIN
/*
* Windows doesn't have gettimeofday(), although it does have struct timeval.
*/
static int
gettimeofday(struct timeval *tv, char *dummy UNUSED)
{
long t = clock();
tv->tv_sec = t / CLOCKS_PER_SEC;
tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
return 0;
}
# endif
/*
* Save the previous time before doing something that could nest.
* set "*tv_rel" to the time elapsed so far.

View File

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