time.cc
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           WMPSNIFFER          --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         V7.0B  11/05/10
00005  *
00006  *
00007  *  File: time.cc
00008  *  Authors: Danilo Tardioli
00009  *  ----------------------------------------------------------------------
00010  *  Copyright (C) 2000-2012, Universidad de Zaragoza, SPAIN
00011  *
00012  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00013  *
00014  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00015  *  under the terms of the GNU General Public License  as published by the
00016  *  Free Software Foundation;  either  version 2, or (at  your option) any
00017  *  later version.
00018  *
00019  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00020  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00021  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00022  *  General Public License for more details.
00023  *
00024  *  You should have received  a  copy of  the  GNU General Public  License
00025  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00026  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00027  *  02111-1307, USA.
00028  *
00029  *  As a  special exception, if you  link this  unit  with other  files to
00030  *  produce an   executable,   this unit  does  not  by  itself cause  the
00031  *  resulting executable to be covered by the  GNU General Public License.
00032  *  This exception does  not however invalidate  any other reasons why the
00033  *  executable file might be covered by the GNU Public License.
00034  *
00035  *----------------------------------------------------------------------*/
00036 
00037 #include <time.h>
00038 #include <sys/time.h>
00039 
00040 static unsigned int initialized = 0, timeZero = 0;
00041 
00042 unsigned long getActualTimeus() {
00043     long timer = 0;
00044     if (!initialized) {
00045         initialized = 1;
00046         struct timeval tv;
00047         gettimeofday(&tv, 0);
00048         unsigned long long tmp = (tv.tv_sec)*1000000LL;
00049         tmp += tv.tv_usec;
00050         timeZero = tmp;
00051     }
00052     struct timeval tv;
00053     gettimeofday(&tv, 0);
00054     unsigned long long tmp = (tv.tv_sec)*1000000LL;
00055     tmp += tv.tv_usec;
00056     tmp = tmp - timeZero;
00057     timer = (long) (tmp);
00058     return timer;
00059 }
00060 #include <stdio.h>
00061 #include <time.h>
00062 
00063 #include <linux/sched.h>
00064 unsigned long long getRawActualTimeus() {
00065     struct timeval tv;
00066     gettimeofday(&tv, 0);
00067     unsigned long long tim1=tv.tv_sec;
00068     tim1*=1000000;
00069     tim1+=tv.tv_usec;
00070     return tim1;
00071 }


ros_rt_wmp_sniffer
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:08:32