diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-02-14 21:24:22 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-02-14 21:24:22 +0100 |
| commit | f6a960c09c9593af72ff6da2c3ed501e01a0f429 (patch) | |
| tree | 783c452486c2528fe0df25d76f49d1d4f20c1d47 /common/helper.c | |
| parent | adbe9cdb61e5d12299b8872b2ac27a48036bc95d (diff) | |
| download | philosophers-f6a960c09c9593af72ff6da2c3ed501e01a0f429.tar.gz philosophers-f6a960c09c9593af72ff6da2c3ed501e01a0f429.tar.bz2 philosophers-f6a960c09c9593af72ff6da2c3ed501e01a0f429.zip | |
philo one working (with what may be a hack)
Diffstat (limited to 'common/helper.c')
| -rw-r--r-- | common/helper.c | 14 |
1 files changed, 11 insertions, 3 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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)); +} |
