From f6a960c09c9593af72ff6da2c3ed501e01a0f429 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 14 Feb 2020 21:24:22 +0100 Subject: philo one working (with what may be a hack) --- common/helper.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'common/helper.c') diff --git a/common/helper.c b/common/helper.c index afdb7f3..2826ceb 100644 --- a/common/helper.c +++ b/common/helper.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 23:22:49 by cacharle #+# #+# */ -/* Updated: 2020/02/14 01:37:31 by cacharle ### ########.fr */ +/* Updated: 2020/02/14 21:07:54 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -74,7 +74,15 @@ t_time h_timeval_to_time(struct timeval *tp) { t_time t; - t = tp->tv_sec * 1000; - t += tp->tv_usec / 1000; + t = tp->tv_sec * 1000 + tp->tv_usec / 1000; return (t); } + +t_time h_time_now(void) +{ + struct timeval tv; + + if (gettimeofday(&tv, NULL) == -1) + return (-1); + return (h_timeval_to_time(&tv)); +} -- cgit