return Scalar(ts.tv_sec - reference) + Scalar(ts.tv_nsec) / 1000000000.0;
}
+void sleep(Scalar seconds, bool absolute)
+{
+ struct timespec ts;
+ int ret;
+
+ if (absolute) seconds -= getTicks();
+ ts.tv_sec = time_t(seconds);
+ ts.tv_nsec = long((seconds - Scalar(ts.tv_sec)) * 1000000000.0);
+
+ do
+ {
+ ret = nanosleep(&ts, &ts);
+ }
+ while (ret == -1 && errno == EINTR);
+}
+
#else // ! HAVE_CLOCK_GETTIME
return Scalar(ms / 1000) + Scalar(ms % 1000) / 1000.0;
}
-
-#endif // HAVE_CLOCK_GETTIME
-
-
void sleep(Scalar seconds, bool absolute)
{
- struct timespec ts;
- int ret;
-
if (absolute) seconds -= getTicks();
- ts.tv_sec = time_t(seconds);
- ts.tv_nsec = long((seconds - Scalar(ts.tv_sec)) * 1000000000.0);
- do
- {
- ret = nanosleep(&ts, &ts);
- }
- while (ret == -1 && errno == EINTR);
+ SDL_Delay(Uint32(seconds * 1000.0));
}
+#endif // HAVE_CLOCK_GETTIME
+
} // namespace Mf