Merge branch 'fixf'
[wrf-fire-matlab.git] / femwind / fortran / msleep.c
blobab58bc744fd540ba320680181a31dbbc4d38295f
1 #include <time.h>
2 #include <errno.h>
4 int msleep(long msec) {
5 /* wait msec miliseconds */
6 struct timespec ts;
7 int res;
9 if (msec < 0) {
10 errno = EINVAL;
11 return -1;
14 ts.tv_sec = msec / 1000;
15 ts.tv_nsec = (msec % 1000) * 1000000;
17 do {
18 res = nanosleep(&ts, &ts);
19 } while (res && errno == EINTR);
21 return res;