ROHC compression/decompression library
rohc_time.h
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 2 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * This program is distributed in the hope that it will be useful,
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  * GNU General Public License for more details.
00011  *
00012  * You should have received a copy of the GNU General Public License
00013  * along with this program; if not, write to the Free Software
00014  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  */
00016 
00017 /**
00018  * @file    rohc_time.h
00019  * @brief   ROHC functions and definitions related to time
00020  * @author  Didier Barvaux <didier.barvaux@toulouse.viveris.com>
00021  * @author  Thales Communications
00022  */
00023 
00024 #ifndef ROHC_TIME_H
00025 #define ROHC_TIME_H
00026 
00027 #ifndef __KERNEL__
00028 #       include <sys/time.h>
00029 #endif
00030 
00031 #ifndef __KERNEL__
00032 
00033 /**
00034  * @brief Get the current time in milliseconds
00035  *
00036  * @return The current time in milliseconds
00037  */
00038 static inline unsigned int get_milliseconds(void)
00039 {
00040         struct timeval tv;
00041         gettimeofday(&tv, NULL);
00042         return tv.tv_sec * 1000 + tv.tv_usec / 1000;
00043 }
00044  
00045 #else /* __KERNEL__ */
00046 
00047 /**
00048  * @brief Get the current time in milliseconds
00049  *
00050  * @return The current time in milliseconds
00051  */
00052 static inline unsigned int get_milliseconds(void)
00053 {
00054         struct timespec ts;
00055         ktime_get_ts(&ts);
00056         return ts.tv_sec * MSEC_PER_SEC + ts.tv_nsec / NSEC_PER_MSEC;
00057 }
00058 
00059 #endif /* __KERNEL__ */
00060 
00061 #endif
00062