Commit Graph

25 Commits

Author SHA1 Message Date
ayeteadoe
7683f1285f AK: Expose helpers to invoke Windows runtime config directly in main()
When shutting down helper processes, PosixSocketHelper::close() in
SocketWindows when trying to close the socket fd with
WSANOTINITIALISED. This was due to us initiating WinSock2 during static
initialization and presumably also not terminating WinSock2 properly.

Similar to WinSock2 initiation, calling CRT during static
initialization is considered dangerous given the CRT DLL itself may not
yet be initialized.

Because of the above, we move to perform this Windows-specific
runtime setup/teardown calls into the main() functions.
2025-10-29 21:07:52 -06:00
Timothy Flynn
e433dee543 LibCore: Add a system wrapper to pipe a file
This uses splice on Linux and mmap+write elsewhere to transfer a file to
a pipe. Note we cannot use sendfile because (at least on macOS) the
receiving fd must be a socket.
2025-10-14 13:40:33 +02:00
ayeteadoe
69e92f69a7 LibCore: Implement SIGTERM-based kill() on Windows
There is no direct Win32 API equivalent, but calling WM_CLOSE on
the top-level windows allows for a graceful shutdown where resources
are able to clean themselves up properly
2025-09-15 09:19:52 +02:00
ayeteadoe
904f736b95 LibCore: Implement UDPServer on Windows 2025-08-06 20:24:38 -06:00
ayeteadoe
cc3cabc768 LibCore: Implement TCPServer on Windows 2025-08-06 20:24:38 -06:00
ayeteadoe
9d7971c111 Tests/LibCore: Enable several tests in Windows CI
These are the set of tests that were already building and passing
with little to no modifications required.
2025-08-06 20:24:38 -06:00
stasoid
c14e6473d6 LibCore: Add Windows impl of System::socket, getaddrinfo, connect 2025-06-23 18:58:01 -06:00
R-Goc
6c8623320f LibCore: Implement chdir on Windows
This commit adds a wrapper around chdir in LibCore.

Co-authored-by: Andrew Kaster <andrew@ladybird.org>
2025-06-05 22:00:55 -06:00
Timothy Flynn
dceed08058 AK+LibCore: Avoid double-negation of syscall error values
This is a remnant from SerenityOS. Let's avoid confusion as to why we
negate errno when we call Error::from_syscall just to negate it again
when we store the error code.
2025-05-10 21:19:46 -04:00
stasoid
2ac53794c3 LibCore: Implement System::isatty on Windows
Also fixes a bug introduced in 642b7b6a5e: Core::System functions
expect a handle now, so we have to use _get_osfhandle in STD*_FILENO.
2025-04-13 10:19:23 -06:00
stasoid
2abc792938 LibCore: Implement System::set_close_on_exec 2025-03-19 20:25:24 -06:00
stasoid
10db20a537 LibCore: Implement System::current_executable_path on Windows 2025-03-19 20:25:24 -06:00
stasoid
4ae3522b10 LibCore: Implement System::socketpair on Windows 2025-02-14 09:38:59 -07:00
stasoid
6b86d8a44d LibCore: Implement System::physical_memory_bytes on Windows 2025-02-12 18:42:05 -07:00
stasoid
f143a9b971 LibCore: Implement System::hardware_concurrency on Windows 2025-02-11 04:07:24 -07:00
stasoid
a291a7f770 LibCore: Add System::sleep_ms 2025-02-06 15:16:50 -07:00
stasoid
b77016cc34 LibCore: Consistently treat file descriptors as handles on Windows
Also:
 * implement dup and is_socket
 * implement and call init_crt_and_wsa
2025-02-05 19:27:47 -07:00
stasoid
259cd70c1b LibCore: Simplify System::open
_O_OBTAIN_DIR flag makes _open use FILE_FLAG_BACKUP_SEMANTICS in
CreateFile call.

FILE_FLAG_BACKUP_SEMANTICS is required to open directory handles.

For ordinary files FILE_FLAG_BACKUP_SEMANTICS overrides file security
checks when the process has SE_BACKUP_NAME and SE_RESTORE_NAME
privileges, see https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea
2025-02-05 19:27:47 -07:00
stasoid
870cce9d11 AK: Add Error::from_windows_error(void)
Also slightly improve Error::from_windows_error(int)
2025-02-05 19:27:47 -07:00
stasoid
212cea4535 LibCore: Add System::getpid 2024-12-17 11:07:53 +01:00
stasoid
67db10f26e LibCore/System: Do not translate \n <-> \r\n when reading/writing files
on Windows
2024-11-29 10:50:59 +01:00
stasoid
3f7affa825 LibCore/System: Add mmap, munmap for Windows 2024-11-26 10:00:11 +01:00
stasoid
77d205571d LibCore/System: Add mkdir, openat (stub), fstatat (stub) for Windows
Also support directories in open().
2024-11-19 22:07:01 -07:00
stasoid
a828a0e158 LibCore/System: Port getcwd, stat, rmdir, unlink to Windows 2024-11-19 14:35:52 -07:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00