ipdbg: fix double free of virtual-ir data
[openocd.git] / src / helper / time_support_common.c
blob9d17a315bf30db929ab3476dcc8d1fdf68c02af7
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /***************************************************************************
4 * Copyright (C) 2006 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
6 * *
7 * Copyright (C) 2007,2008 Øyvind Harboe *
8 * oyvind.harboe@zylin.com *
9 * *
10 * Copyright (C) 2008 by Spencer Oliver *
11 * spen@spen-soft.co.uk *
12 ***************************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include "config.h"
16 #endif
18 #include "time_support.h"
20 /* simple and low overhead fetching of ms counter. Use only
21 * the difference between ms counters returned from this fn.
23 int64_t timeval_ms(void)
25 struct timeval now;
26 int retval = gettimeofday(&now, NULL);
27 if (retval < 0)
28 return retval;
29 return (int64_t)now.tv_sec * 1000 + now.tv_usec / 1000;