1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:57:45 +00:00

Everywhere: Make the codebase more architecture aware

This commit is contained in:
Undefine 2022-07-22 20:48:24 +02:00 committed by Brian Gianforcaro
parent 6c4b5775e1
commit 97cc33ca47
22 changed files with 108 additions and 36 deletions

View file

@ -149,10 +149,12 @@ static ErrorOr<FlatPtr> make_userspace_context_for_main_thread([[maybe_unused]]
push_on_new_stack(envp);
push_on_new_stack(argv);
push_on_new_stack(argv_entries.size());
#else
#elif ARCH(X86_64)
regs.rdi = argv_entries.size();
regs.rsi = argv;
regs.rdx = envp;
#else
# error Unknown architecture
#endif
VERIFY(new_sp % 16 == 0);

View file

@ -89,7 +89,7 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
dbgln_if(FORK_DEBUG, "fork: child will begin executing at {:#04x}:{:p} with stack {:#04x}:{:p}, kstack {:#04x}:{:p}",
child_regs.cs, child_regs.eip, child_regs.ss, child_regs.esp, child_regs.ss0, child_regs.esp0);
#else
#elif ARCH(X86_64)
auto& child_regs = child_first_thread->m_regs;
child_regs.rax = 0; // fork() returns 0 in the child :^)
child_regs.rbx = regs.rbx;
@ -113,6 +113,8 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
dbgln_if(FORK_DEBUG, "fork: child will begin executing at {:#04x}:{:p} with stack {:p}, kstack {:p}",
child_regs.cs, child_regs.rip, child_regs.rsp, child_regs.rsp0);
#else
# error Unknown architecture
#endif
{

View file

@ -19,8 +19,12 @@ ErrorOr<FlatPtr> Process::sys$uname(Userspace<utsname*> user_buf)
memcpy(buf.version, "FIXME", 6);
#if ARCH(I386)
memcpy(buf.machine, "i686", 5);
#else
#elif ARCH(X86_64)
memcpy(buf.machine, "x86_64", 7);
#elif ARCH(AARCH64)
memcpy(buf.machine, "AArch64", 7);
#else
# error Unknown architecture
#endif
hostname().with_shared([&](auto const& name) {