mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
Kernel+LibC: Use uintptr_t as the main type in the syscall interface
This commit is contained in:
parent
583bfa04e2
commit
65cdac1a5b
Notes:
sideshowbarker
2024-07-19 01:55:38 +09:00
Author: https://github.com/awesomekling
Commit: 65cdac1a5b
5 changed files with 25 additions and 19 deletions
|
@ -244,13 +244,13 @@ struct StringListArgument {
|
|||
};
|
||||
|
||||
struct SC_mmap_params {
|
||||
uint32_t addr;
|
||||
uint32_t size;
|
||||
uint32_t alignment;
|
||||
uintptr_t addr;
|
||||
size_t size;
|
||||
size_t alignment;
|
||||
int32_t prot;
|
||||
int32_t flags;
|
||||
int32_t fd;
|
||||
int32_t offset; // FIXME: 64-bit off_t?
|
||||
ssize_t offset;
|
||||
StringArgument name;
|
||||
};
|
||||
|
||||
|
@ -435,9 +435,9 @@ struct SC_ptrace_peek_params {
|
|||
void initialize();
|
||||
int sync();
|
||||
|
||||
inline u32 invoke(Function function)
|
||||
inline uintptr_t invoke(Function function)
|
||||
{
|
||||
u32 result;
|
||||
uintptr_t result;
|
||||
asm volatile("int $0x82"
|
||||
: "=a"(result)
|
||||
: "a"(function)
|
||||
|
@ -446,34 +446,34 @@ inline u32 invoke(Function function)
|
|||
}
|
||||
|
||||
template<typename T1>
|
||||
inline u32 invoke(Function function, T1 arg1)
|
||||
inline uintptr_t invoke(Function function, T1 arg1)
|
||||
{
|
||||
u32 result;
|
||||
uintptr_t result;
|
||||
asm volatile("int $0x82"
|
||||
: "=a"(result)
|
||||
: "a"(function), "d"((u32)arg1)
|
||||
: "a"(function), "d"((uintptr_t)arg1)
|
||||
: "memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline u32 invoke(Function function, T1 arg1, T2 arg2)
|
||||
inline uintptr_t invoke(Function function, T1 arg1, T2 arg2)
|
||||
{
|
||||
u32 result;
|
||||
uintptr_t result;
|
||||
asm volatile("int $0x82"
|
||||
: "=a"(result)
|
||||
: "a"(function), "d"((u32)arg1), "c"((u32)arg2)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "c"((uintptr_t)arg2)
|
||||
: "memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
inline u32 invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
|
||||
inline uintptr_t invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
|
||||
{
|
||||
u32 result;
|
||||
uintptr_t result;
|
||||
asm volatile("int $0x82"
|
||||
: "=a"(result)
|
||||
: "a"(function), "d"((u32)arg1), "c"((u32)arg2), "b"((u32)arg3)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "c"((uintptr_t)arg2), "b"((uintptr_t)arg3)
|
||||
: "memory");
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ extern "C" {
|
|||
|
||||
void* serenity_mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset, size_t alignment, const char* name)
|
||||
{
|
||||
Syscall::SC_mmap_params params { (u32)addr, size, alignment, prot, flags, fd, offset, { name, name ? strlen(name) : 0 } };
|
||||
int rc = syscall(SC_mmap, ¶ms);
|
||||
Syscall::SC_mmap_params params { (uintptr_t)addr, size, alignment, prot, flags, fd, offset, { name, name ? strlen(name) : 0 } };
|
||||
ssize_t rc = syscall(SC_mmap, ¶ms);
|
||||
if (rc < 0 && -rc < EMAXERRNO) {
|
||||
errno = -rc;
|
||||
return MAP_FAILED;
|
||||
|
|
|
@ -93,7 +93,7 @@ int perf_event(int type, uintptr_t arg1, FlatPtr arg2)
|
|||
|
||||
void* shbuf_get(int shbuf_id, size_t* size)
|
||||
{
|
||||
int rc = syscall(SC_shbuf_get, shbuf_id, size);
|
||||
ssize_t rc = syscall(SC_shbuf_get, shbuf_id, size);
|
||||
if (rc < 0 && -rc < EMAXERRNO) {
|
||||
errno = -rc;
|
||||
return (void*)-1;
|
||||
|
|
|
@ -72,6 +72,7 @@ int perf_event(int type, uintptr_t arg1, uintptr_t arg2);
|
|||
|
||||
int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size);
|
||||
|
||||
#ifdef __i386__
|
||||
ALWAYS_INLINE void send_secret_data_to_userspace_emulator(uintptr_t data1, uintptr_t data2, uintptr_t data3)
|
||||
{
|
||||
asm volatile(
|
||||
|
@ -88,5 +89,10 @@ ALWAYS_INLINE void send_secret_data_to_userspace_emulator(uintptr_t data1, uintp
|
|||
"c"(data2), "d"(data3)
|
||||
: "memory");
|
||||
}
|
||||
#elif __x86_64__
|
||||
ALWAYS_INLINE void send_secret_data_to_userspace_emulator(uintptr_t, uintptr_t, uintptr_t)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -103,7 +103,7 @@ ssize_t recvfrom(int sockfd, void* buffer, size_t buffer_length, int flags, stru
|
|||
|
||||
sockaddr_storage internal_addr;
|
||||
iovec iov = { buffer, buffer_length };
|
||||
msghdr msg = { addr ? &internal_addr : nullptr, addr ? sizeof(internal_addr) : 0, &iov, 1, nullptr, 0, 0 };
|
||||
msghdr msg = { addr ? &internal_addr : nullptr, addr ? (socklen_t)sizeof(internal_addr) : 0, &iov, 1, nullptr, 0, 0 };
|
||||
ssize_t rc = recvmsg(sockfd, &msg, flags);
|
||||
if (rc >= 0 && addr) {
|
||||
memcpy(addr, &internal_addr, min(*addr_length, msg.msg_namelen));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue