TSP: The Transport Sample Protocol



Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

tsp_time.c

Go to the documentation of this file.
00001 
00038 #include "tsp_sys_headers.h"
00039 #include <time.h>
00040 
00041 #include "tsp_time.h"
00042 
00043 
00044 tsp_hrtime_t tsp_gethrtime(void)
00045 {
00046 #ifdef TSP_SYSTEM_HAVE_GETHRTIME
00047   return gethrtime();
00048 #else
00049   struct timeval tp;
00050   gettimeofday(&tp, (void*)NULL);
00051    return ((tsp_hrtime_t)tp.tv_sec *  TSP_INT64_CONSTANT(1000000000)
00052            + (tsp_hrtime_t)tp.tv_usec*TSP_INT64_CONSTANT(1000));
00053 #endif
00054 }
00055 
00056 
00057 int tsp_usleep(int useconds)
00058 {
00059 
00060 #ifdef TSP_SYSTEM_HAVE_NANOSLEEP
00061   struct timespec ts;
00062   ts.tv_sec = useconds / 1000000;
00063   ts.tv_nsec = (useconds % 1000000) * 1000;
00064   return nanosleep(&ts, NULL);
00065 #else
00066 
00067 #ifdef TSP_SYSTEM_HAVE_THREADSAFE_USLEEP
00068   return usleep(useconds);
00069 #else
00070   ERROR__you_should_try_to_find_some_kind_of_wait_function
00071 #endif /*TSP_SYSTEM_HAVE_THREADSAFE_USLEEP*/
00072 
00073 #endif /*TSP_SYSTEM_HAVE_NANOSLEEP*/
00074 
00075 }
00076 
Framework Home Page.

Beware !! TSP wave is coming...