summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-20 14:36:56 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-20 14:36:56 +0000
commitbd83c8ab8d8c65c3a18f449ede7ba2abef6d1c33 (patch)
tree0d2a84cb3f0ff31372af99337ec596b7f10c07a6 /libstdc++-v3/src
parent960a9b56d6ddfdfa9f6ec747b263e8a6dec80bcd (diff)
downloadppe42-gcc-bd83c8ab8d8c65c3a18f449ede7ba2abef6d1c33.tar.gz
ppe42-gcc-bd83c8ab8d8c65c3a18f449ede7ba2abef6d1c33.zip
PR libstdc++/55741
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Check for Sleep. * config.h.in: Regenerate. * configure: Regenerate. * src/c++11/thread.cc (__sleep_for): Use Sleep if available. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194635 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/c++11/thread.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
index fa86a1bd34e..b04e6dc36e3 100644
--- a/libstdc++-v3/src/c++11/thread.cc
+++ b/libstdc++-v3/src/c++11/thread.cc
@@ -61,6 +61,8 @@ static inline int get_nprocs()
#ifndef _GLIBCXX_USE_NANOSLEEP
# ifdef _GLIBCXX_HAVE_SLEEP
# include <unistd.h>
+# elif defined(_GLIBCXX_HAVE_WIN32_SLEEP)
+# include <windows.h>
# else
# error "No sleep function known for this target"
# endif
@@ -170,9 +172,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static_cast<long>(__ns.count())
};
::nanosleep(&__ts, 0);
-#else
-# ifdef _GLIBCXX_HAVE_SLEEP
-# ifdef _GLIBCXX_HAVE_USLEEP
+#elif defined(_GLIBCXX_HAVE_SLEEP)
+# ifdef _GLIBCXX_HAVE_USLEEP
::sleep(__s.count());
if (__ns.count() > 0)
{
@@ -181,10 +182,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__us = 1;
::usleep(__us);
}
-# else
+# else
::sleep(__s.count() + (__ns >= 1000000));
-# endif
# endif
+#elif defined(_GLIBCXX_HAVE_WIN32_SLEEP)
+ unsigned long ms = __ns.count() / 1000000;
+ if (__ns.count() > 0 && ms == 0)
+ ms = 1;
+ ::Sleep(chrono::milliseconds(__s).count() + ms);
#endif
}
OpenPOWER on IntegriCloud