0
0
mirror of https://github.com/vim/vim.git synced 2025-10-23 08:44:20 -04:00

patch 8.2.5057: using gettimeofday() for timeout is very inefficient

Problem:    Using gettimeofday() for timeout is very inefficient.
Solution:   Set a platform dependent timer. (Paul Ollis, closes #10505)
This commit is contained in:
Paul Ollis
2022-06-05 16:55:54 +01:00
committed by Bram Moolenaar
parent 1d97db3d98
commit 6574577cac
29 changed files with 811 additions and 242 deletions

View File

@@ -6,6 +6,9 @@
* Do ":help credits" in Vim to see a list of people who contributed.
*/
#ifndef OS_MAC__H
#define OS_MAC__H
// Before Including the MacOS specific files,
// let's set the OPAQUE_TOOLBOX_STRUCTS to 0 so we
// can access the internal structures.
@@ -266,3 +269,52 @@
// A Mac constant causing big problem to syntax highlighting
#define UNKNOWN_CREATOR '\?\?\?\?'
#ifdef FEAT_RELTIME
# include <dispatch/dispatch.h>
# if !defined(MAC_OS_X_VERSION_10_12) || \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12)
typedef int clockid_t;
# endif
# ifndef CLOCK_REALTIME
# define CLOCK_REALTIME 0
# endif
# ifndef CLOCK_MONOTONIC
# define CLOCK_MONOTONIC 1
# endif
struct itimerspec
{
struct timespec it_interval; // timer period
struct timespec it_value; // initial expiration
};
struct sigevent;
struct macos_timer
{
dispatch_queue_t tim_queue;
dispatch_source_t tim_timer;
void (*tim_func)(union sigval);
void *tim_arg;
};
typedef struct macos_timer *timer_t;
extern int timer_create(
clockid_t clockid,
struct sigevent *sevp,
timer_t *timerid);
extern int timer_delete(timer_t timerid);
extern int timer_settime(
timer_t timerid, int flags,
const struct itimerspec *new_value,
struct itimerspec *unused);
#endif // FEAT_RELTIME
#endif // OS_MAC__H