00001 #include <grass/config.h>
00002
00003 #ifdef HAVE_SYS_TYPES_H
00004 #include <sys/types.h>
00005 #endif
00006
00007 #ifdef HAVE_SYS_TIMEB_H
00008 #include <sys/timeb.h>
00009 #endif
00010
00011 #ifdef HAVE_UNISTD_H
00012 #include <unistd.h>
00013 #endif
00014
00015 #if TIME_WITH_SYS_TIME
00016 #include <sys/time.h>
00017 #include <time.h>
00018 #else
00019 #if HAVE_SYS_TIME_H
00020 #include <sys/time.h>
00021 #else
00022 #include <time.h>
00023 #endif
00024 #endif
00025 #include <grass/gis.h>
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 long sleep_ltp( double tm)
00038 {
00039 double finish;
00040 double check;
00041
00042 time_ltp(&check);
00043 for(finish = check + tm; check <= finish; time_ltp(&check))
00044 G_sleep(0);
00045
00046 return(0);
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifdef HAVE_GETTIMEOFDAY
00060
00061 int time_ltp( double *time)
00062 {
00063 struct timeval tstruct;
00064
00065 gettimeofday (&tstruct, NULL);
00066 *time = tstruct.tv_sec + tstruct.tv_usec / 1000000.0;
00067 return(0);
00068 }
00069
00070 #else
00071
00072 #ifdef HAVE_FTIME
00073
00074 int time_ltp( double *time)
00075 {
00076 struct timeb tstruct;
00077
00078 ftime(&tstruct);
00079 *time = tstruct.time + tstruct.millitm / 1000.0;
00080 return(0);
00081 }
00082
00083 #else
00084
00085 #ifdef HAVE_TIME
00086
00087 int time_ltp(double *time)
00088 {
00089 time_t tloc;
00090
00091 time(&tloc);
00092 *time = tloc;
00093 return(0);
00094 }
00095
00096 #endif
00097 #endif
00098 #endif
00099
00100
00101 unsigned int G_sleep (unsigned int seconds)
00102 {
00103 #ifdef __MINGW32__
00104
00105 return 0;
00106 #else
00107 return sleep(seconds);
00108 #endif
00109 }
00110