added yours sincerely for files where I feel that I've made non-trivial contributions.
[fw/openocd] / src / helper / time_support.h
1 /***************************************************************************
2  *   Copyright (C) 2006 by Dominic Rath                                    *
3  *   Dominic.Rath@gmx.de                                                   *
4  *                                                                         *
5  *   Copyright (C) 2007,2008 Ã˜yvind Harboe                                      *
6  *   oyvind.harboe@zylin.com                                               *
7  *                                                                         *
8  *   This program is free software; you can redistribute it and/or modify  *
9  *   it under the terms of the GNU General Public License as published by  *
10  *   the Free Software Foundation; either version 2 of the License, or     *
11  *   (at your option) any later version.                                   *
12  *                                                                         *
13  *   This program is distributed in the hope that it will be useful,       *
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
16  *   GNU General Public License for more details.                          *
17  *                                                                         *
18  *   You should have received a copy of the GNU General Public License     *
19  *   along with this program; if not, write to the                         *
20  *   Free Software Foundation, Inc.,                                       *
21  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
22  ***************************************************************************/
23 #ifndef TIME_SUPPORT_H
24 #define TIME_SUPPORT_H
25
26 #ifdef TIME_WITH_SYS_TIME
27 # include <sys/time.h>
28 # include <time.h>
29 #else
30 # ifdef HAVE_SYS_TIME_H
31 #  include <sys/time.h>
32 # else
33 #  include <time.h>
34 # endif
35 #endif
36
37 extern int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
38 extern int timeval_add(struct timeval *result, struct timeval *x, struct timeval *y);
39 extern int timeval_add_time(struct timeval *result, int sec, int usec);
40 /* gettimeofday() timeval in 64 bit ms */
41 extern long long timeval_ms();
42
43 typedef struct duration_s
44 {
45         struct timeval start;
46         struct timeval duration;
47 } duration_t;
48
49 extern int duration_start_measure(duration_t *duration);
50 extern int duration_stop_measure(duration_t *duration, char **text);
51
52 #endif /* TIME_SUPPORT_H */