From 33aa9315414dca1218b3c88b0c5ffc89d4379974 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 28 Aug 2008 17:45:30 +0000 Subject: Support OS X by moving to gettimeofday(2) and adding poll compat from OpenSSH. --- tty-keys.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index 6ee4e935..69c52b95 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1,4 +1,4 @@ -/* $Id: tty-keys.c,v 1.9 2008-07-24 21:42:40 nicm Exp $ */ +/* $Id: tty-keys.c,v 1.10 2008-08-28 17:45:28 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -17,9 +17,9 @@ */ #include +#include #include -#include #include "tmux.h" @@ -299,7 +299,7 @@ tty_keys_next(struct tty *tty, int *code) { struct tty_key *tk; size_t size; - struct timespec ts; + struct timeval tv; size = BUFFER_USED(tty->in); if (size == 0) @@ -324,20 +324,20 @@ tty_keys_next(struct tty *tty, int *code) /* Escape but no key string. If the timer isn't started, start it. */ if (!(tty->flags & TTY_ESCAPE)) { - ts.tv_sec = 0; - ts.tv_nsec = 500 * 1000000L; - if (clock_gettime(CLOCK_REALTIME, &tty->key_timer) != 0) - fatal("clock_gettime"); - timespecadd(&tty->key_timer, &ts, &tty->key_timer); + tv.tv_sec = 0; + tv.tv_usec = 500 * 1000L; + if (gettimeofday(&tty->key_timer, NULL) != 0) + fatal("gettimeofday"); + timeradd(&tty->key_timer, &tv, &tty->key_timer); tty->flags |= TTY_ESCAPE; return (1); } /* Otherwise, if the timer hasn't expired, wait. */ - if (clock_gettime(CLOCK_REALTIME, &ts) != 0) - fatal("clock_gettime"); - if (!timespeccmp(&tty->key_timer, &ts, >)) + if (gettimeofday(&tv, NULL) != 0) + fatal("gettimeofday"); + if (!timercmp(&tty->key_timer, &tv, >)) return (1); tty->flags &= ~TTY_ESCAPE; -- cgit