summaryrefslogtreecommitdiff
path: root/Libraries/LibC
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-30 10:43:15 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-30 10:45:51 +0200
commitf857f3ce4cfc3fca4bbaca3aae67a04897dc911f (patch)
tree3f96ccca1d01873263bbcf2676f0bffab88c34c4 /Libraries/LibC
parent95ed363b1559384911ad4d41e2df305cd1f8a7fb (diff)
downloadserenity-f857f3ce4cfc3fca4bbaca3aae67a04897dc911f.zip
Kernel+LibC+UE: Implement usleep() via sys$clock_nanosleep()
This doesn't need to be its own syscall. Thanks @BenWiederhake for the idea. :^)
Diffstat (limited to 'Libraries/LibC')
-rw-r--r--Libraries/LibC/unistd.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp
index 796006a572..c7aee64815 100644
--- a/Libraries/LibC/unistd.cpp
+++ b/Libraries/LibC/unistd.cpp
@@ -42,6 +42,7 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <termios.h>
+#include <time.h>
#include <unistd.h>
extern "C" {
@@ -336,7 +337,8 @@ int sleep(unsigned seconds)
int usleep(useconds_t usec)
{
- return syscall(SC_usleep, usec);
+ struct timespec ts = { (long)(usec / 1000000), (long)(usec % 1000000) * 1000 };
+ return clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, nullptr);
}
int gethostname(char* buffer, size_t size)