00001
00019 #ifndef COIL_TIME_H
00020 #define COIL_TIME_H
00021
00022 #include <unistd.h>
00023 #include <sys/time.h>
00024 #include <sys/types.h>
00025 #include <time.h>
00026 #include <iostream>
00027 #include <coil/config_coil.h>
00028 #include <coil/TimeValue.h>
00029
00030 namespace coil
00031 {
00032
00033 inline unsigned int sleep(unsigned int seconds)
00034 {
00035 return ::sleep(seconds);
00036 }
00037
00038 inline int sleep(TimeValue interval)
00039 {
00040 timeval tv;
00041 tv.tv_sec = interval.sec();
00042 tv.tv_usec = interval.usec();
00043 return ::select(0, 0, 0, 0, &tv);
00044 }
00045
00046 inline int usleep(useconds_t usec)
00047 {
00048 return ::usleep(usec);
00049 }
00050
00051 inline int gettimeofday(struct timeval *tv, struct timezone *tz)
00052 {
00053 return ::gettimeofday(tv, tz);
00054 }
00055
00056 inline TimeValue gettimeofday()
00057 {
00058 timeval tv;
00059 ::gettimeofday(&tv, 0);
00060 return TimeValue(tv.tv_sec, tv.tv_usec);
00061 }
00062
00063 inline int settimeofday(const struct timeval *tv , const struct timezone *tz)
00064 {
00065 return ::settimeofday(tv, tz);
00066 }
00067
00068
00069 };
00070
00071 #endif // COIL_TIME_H