From e421c10735cd4b14afd2ddd2738617bec4c3a8c3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 27 Feb 2019 00:02:01 +0100 Subject: [PATCH] More compat work towards porting vim. It now builds and runs in the small-featureset configuration. :^) --- Applications/Terminal/Terminal.cpp | 8 ++++++++ Applications/Terminal/Terminal.h | 1 + Kernel/FileDescriptor.cpp | 8 +++++++- Kernel/Process.cpp | 15 ++++++++++++--- Kernel/Process.h | 1 + Kernel/Syscall.cpp | 2 ++ LibC/stdint.h | 4 ++++ LibC/stdlib.cpp | 10 +++++++++- 8 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp index a5cfa60002..b18b5e3579 100644 --- a/Applications/Terminal/Terminal.cpp +++ b/Applications/Terminal/Terminal.cpp @@ -190,6 +190,13 @@ void Terminal::escape$u(const Vector&) set_cursor(m_saved_cursor_row, m_saved_cursor_column); } +void Terminal::escape$t(const Vector& params) +{ + if (params.size() < 1) + return; + dbgprintf("escape$t: Ps: %u\n", params[0]); +} + void Terminal::escape$H(const Vector& params) { unsigned row = 1; @@ -380,6 +387,7 @@ void Terminal::execute_escape_sequence(byte final) case 'm': escape$m(params); break; case 's': escape$s(params); break; case 'u': escape$u(params); break; + case 't': escape$t(params); break; default: dbgprintf("Terminal::execute_escape_sequence: Unhandled final '%c'\n", final); break; diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h index 67e453bc5a..55e3ad207d 100644 --- a/Applications/Terminal/Terminal.h +++ b/Applications/Terminal/Terminal.h @@ -53,6 +53,7 @@ private: void escape$m(const Vector&); void escape$s(const Vector&); void escape$u(const Vector&); + void escape$t(const Vector&); void clear(); diff --git a/Kernel/FileDescriptor.cpp b/Kernel/FileDescriptor.cpp index 084e22f0de..97405e502a 100644 --- a/Kernel/FileDescriptor.cpp +++ b/Kernel/FileDescriptor.cpp @@ -393,7 +393,13 @@ Region* FileDescriptor::mmap(Process& process, LinearAddress laddr, size_t offse ASSERT(m_inode); // FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec. - auto region_name = absolute_path(); + String region_name; +#if 0 + // FIXME: I would like to do this, but it would instantiate all the damn inodes. + region_name = absolute_path(); +#else + region_name = "Memory-mapped file"; +#endif InterruptDisabler disabler; // FIXME: Implement mapping at a client-specified address. Most of the support is already in plcae. ASSERT(laddr.as_ptr() == nullptr); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 67d09899cb..252bed6945 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -313,7 +313,12 @@ int Process::do_exec(String path, Vector arguments, Vector envir ProcessPagingScope paging_scope(*this); auto vmo = VMObject::create_file_backed(descriptor->inode()); +#if 0 + // FIXME: I would like to do this, but it would instantiate all the damn inodes. vmo->set_name(descriptor->absolute_path()); +#else + vmo->set_name("ELF image"); +#endif RetainPtr region = allocate_region_with_vmo(LinearAddress(), descriptor->metadata().size, vmo.copy_ref(), 0, "executable", true, false); // FIXME: Should we consider doing on-demand paging here? Is it actually useful? @@ -1547,6 +1552,7 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options) return reaped_pid; } else { ASSERT(waitee > 0); // FIXME: Implement other PID specs. + InterruptDisabler disabler; auto* waitee_process = Process::from_pid(waitee); if (!waitee_process) return -ECHILD; @@ -1967,9 +1973,7 @@ int Process::sys$select(const Syscall::SC_select_params* params) auto* timeout = params->timeout; // FIXME: Implement exceptfds support. - //ASSERT(!exceptfds); - if (exceptfds) - kprintf("%s(%u): FIXME: select() with exceptfds\n", name().characters(), pid()); + (void)exceptfds; if (timeout) { m_select_timeout = *timeout; @@ -2006,6 +2010,9 @@ int Process::sys$select(const Syscall::SC_select_params* params) error = transfer_fds(readfds, m_select_read_fds); if (error) return error; + error = transfer_fds(readfds, m_select_exceptional_fds); + if (error) + return error; #ifdef DEBUG_IO dbgprintf("%s<%u> selecting on (read:%u, write:%u), wakeup_req:%u, timeout=%p\n", name().characters(), pid(), m_select_read_fds.size(), m_select_write_fds.size(), m_wakeup_requested, timeout); @@ -2047,6 +2054,8 @@ int Process::sys$select(const Syscall::SC_select_params* params) } } + // FIXME: Check for exceptional conditions. + return markedfds; } diff --git a/Kernel/Process.h b/Kernel/Process.h index 8c5cd4eaeb..08e6d85f99 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -353,6 +353,7 @@ private: int m_blocked_fd { -1 }; Vector m_select_read_fds; Vector m_select_write_fds; + Vector m_select_exceptional_fds; timeval m_select_timeout; bool m_select_has_timeout { false }; size_t m_max_open_file_descriptors { 16 }; diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index ec6e21ff18..37f8b8976d 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -231,5 +231,7 @@ void syscall_trap_entry(RegisterDump& regs) dword arg2 = regs.ecx; dword arg3 = regs.ebx; regs.eax = Syscall::handle(regs, function, arg1, arg2, arg3); + if (function == Syscall::SC_mkdir) + dbgprintf("->%d\n", regs.eax); } diff --git a/LibC/stdint.h b/LibC/stdint.h index ad56feaded..e5f84a5b79 100644 --- a/LibC/stdint.h +++ b/LibC/stdint.h @@ -50,12 +50,16 @@ typedef __INTMAX_TYPE__ intmax_t; #define INT8_MIN (-128) #define INT16_MIN (-32767-1) #define INT32_MIN (-2147483647-1) +#define INT64_MIN (-9223372036854775807LL-1LL) #define INT8_MAX (127) #define INT16_MAX (32767) #define INT32_MAX (2147483647) +#define INT64_MAX (9223372036854775807LL) #define UINT8_MAX (255) #define UINT16_MAX (65535) #define UINT32_MAX (4294967295U) +#define UINT64_MAX (18446744073709551615ULL) + #define INT64_C(x) x##LL #define UINT64_C(x) x##ULL diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp index 37078f4986..8d0b9aa153 100644 --- a/LibC/stdlib.cpp +++ b/LibC/stdlib.cpp @@ -33,7 +33,7 @@ struct MallocFooter { uint32_t xorcheck; }; -#define CHUNK_SIZE 16 +#define CHUNK_SIZE 32 #define POOL_SIZE 4 * 1048576 static const size_t malloc_budget = POOL_SIZE; @@ -250,6 +250,14 @@ int putenv(char* new_var) return 0; } +double strtod(const char* str, char** endptr) +{ + (void)str; + (void)endptr; + dbgprintf("LibC: strtod: '%s'\n", str); + assert(false); +} + double atof(const char* str) { dbgprintf("LibC: atof: '%s'\n", str);