Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / gr-error-correcting-codes / src / lib / libecc / mld / mld_timer.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio.
6  *
7  * Primary Author: Michael Dickens, NCIP Lab, University of Notre Dame
8  * 
9  * GNU Radio is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  * 
14  * GNU Radio is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  * 
19  * You should have received a copy of the GNU General Public License
20  * along with GNU Radio; see the file COPYING.  If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street,
22  * Boston, MA 02110-1301, USA.
23  */
24
25 #include <sys/types.h>
26 #include <mld_timer.h>
27
28 void start_timer (struct timeval *t_tp)
29 {
30   gettimeofday (t_tp, 0);
31 }
32
33 u_long end_timer (struct timeval *g_tp)
34 {
35   struct timeval t_tp;
36   gettimeofday (&t_tp, 0);
37
38   u_long retVal = (t_tp.tv_sec - g_tp->tv_sec);
39   u_long df_usec;
40
41   if (t_tp.tv_usec < g_tp->tv_usec) {
42     retVal -= 1;
43     df_usec = 1000000 - (g_tp->tv_usec - t_tp.tv_usec);
44   } else
45     df_usec = t_tp.tv_usec - g_tp->tv_usec;
46
47   retVal *= 1000000;
48   retVal += df_usec;
49   return (retVal);
50 }