summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-03-20 06:05:48 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-03-20 06:05:48 +0100
commitf23980100d12f4d707a585d5222f680850cc4e8c (patch)
treeca41953d9adf09f32e8a33d09448191652d9eab5 /compat
parent4fa2108094cb137ec7b2a6b44a9c13b554b4c1f9 (diff)
compat/sleep: guard against signed -> unsigned wraparound
Diffstat (limited to 'compat')
-rw-r--r--compat/sleep.hpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/compat/sleep.hpp b/compat/sleep.hpp
index fab27286..4cd7a397 100644
--- a/compat/sleep.hpp
+++ b/compat/sleep.hpp
@@ -9,14 +9,16 @@
namespace portable
{
#ifdef _WIN32
- inline void sleep(unsigned milliseconds)
+ inline void sleep(int milliseconds)
{
- Sleep(milliseconds);
+ if (milliseconds > 0)
+ Sleep(milliseconds);
}
#else
- inline void sleep(unsigned milliseconds)
+ inline void sleep(int milliseconds)
{
- usleep(milliseconds * 1000U); // takes microseconds
+ if (milliseconds > 0)
+ usleep(unsigned(milliseconds) * 1000U); // takes microseconds
}
#endif
}