mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
Kernel+LibC+UE: Implement usleep() via sys$clock_nanosleep()
This doesn't need to be its own syscall. Thanks @BenWiederhake for the idea. :^)
This commit is contained in:
parent
95ed363b15
commit
f857f3ce4c
Notes:
sideshowbarker
2024-07-19 03:00:22 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f857f3ce4cf
@ -272,8 +272,6 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
||||
return virt$ioctl(arg1, arg2, arg3);
|
||||
case SC_get_dir_entries:
|
||||
return virt$get_dir_entries(arg1, arg2, arg3);
|
||||
case SC_usleep:
|
||||
return virt$usleep(arg1);
|
||||
case SC_shbuf_create:
|
||||
return virt$shbuf_create(arg1, arg2);
|
||||
case SC_shbuf_allow_pid:
|
||||
@ -384,11 +382,6 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
||||
}
|
||||
}
|
||||
|
||||
int Emulator::virt$usleep(useconds_t us)
|
||||
{
|
||||
return syscall(SC_usleep, us);
|
||||
}
|
||||
|
||||
int Emulator::virt$shbuf_create(int size, FlatPtr buffer)
|
||||
{
|
||||
u8* host_data = nullptr;
|
||||
|
@ -85,7 +85,6 @@ private:
|
||||
int virt$stat(FlatPtr);
|
||||
int virt$realpath(FlatPtr);
|
||||
int virt$gethostname(FlatPtr, ssize_t);
|
||||
int virt$usleep(useconds_t);
|
||||
int virt$shbuf_create(int size, FlatPtr buffer);
|
||||
int virt$shbuf_allow_pid(int, pid_t peer_pid);
|
||||
int virt$shbuf_allow_all(int);
|
||||
|
@ -117,7 +117,6 @@ namespace Kernel {
|
||||
S(poll) \
|
||||
S(rmdir) \
|
||||
S(chmod) \
|
||||
S(usleep) \
|
||||
S(socket) \
|
||||
S(bind) \
|
||||
S(accept) \
|
||||
@ -241,7 +240,7 @@ struct ImmutableBufferArgument {
|
||||
};
|
||||
|
||||
struct StringListArgument {
|
||||
Userspace<StringArgument*> strings { };
|
||||
Userspace<StringArgument*> strings {};
|
||||
size_t length { 0 };
|
||||
};
|
||||
|
||||
|
@ -29,17 +29,6 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$usleep(useconds_t usec)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
if (!usec)
|
||||
return 0;
|
||||
u64 wakeup_time = Thread::current()->sleep(usec * TimeManagement::the().ticks_per_second() / 1000000);
|
||||
if (wakeup_time > g_uptime)
|
||||
return -EINTR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$sleep(unsigned seconds)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user