LibCore+Everywhere: Make Windows's System::ioctl consistent with POSIX
Passing the option by value on Windows where it's a pointer on all other platforms seems like it may cause some unnecessary ifdef soup.
This commit is contained in:
parent
de47fe86ba
commit
8eda26c5cf
6 changed files with 11 additions and 9 deletions
|
|
@ -59,7 +59,7 @@ bool LocalServer::listen(ByteString const& address)
|
|||
|
||||
m_fd = MUST(Core::System::socket(AF_LOCAL, SOCK_STREAM, 0));
|
||||
int option = 1;
|
||||
MUST(Core::System::ioctl(m_fd, FIONBIO, option));
|
||||
MUST(Core::System::ioctl(m_fd, FIONBIO, &option));
|
||||
auto const ret = SetHandleInformation(to_handle(m_fd), HANDLE_FLAG_INHERIT, 0);
|
||||
VERIFY(ret != 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
|
||||
* Copyright (c) 2024-2025, stasoid <stasoid@yahoo.com>
|
||||
* Copyright (c) 2025, ayeteadoe <ayeteadoe@gmail.com>
|
||||
* Copyright (c) 2026, Gregory Bertilson <gregory@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -99,9 +100,9 @@ ErrorOr<void> ioctl(int fd, unsigned request, ...)
|
|||
{
|
||||
va_list ap;
|
||||
va_start(ap, request);
|
||||
u_long arg = va_arg(ap, FlatPtr);
|
||||
u_long* arg = va_arg(ap, u_long*);
|
||||
va_end(ap);
|
||||
if (::ioctlsocket(fd, request, &arg) == SOCKET_ERROR)
|
||||
if (::ioctlsocket(fd, request, arg) == SOCKET_ERROR)
|
||||
return Error::from_windows_error();
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ ErrorOr<NonnullRefPtr<TCPServer>> TCPServer::try_create()
|
|||
} };
|
||||
|
||||
int option = 1;
|
||||
TRY(Core::System::ioctl(fd, FIONBIO, option));
|
||||
TRY(Core::System::ioctl(fd, FIONBIO, &option));
|
||||
TRY(Core::System::setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &option, sizeof(option)));
|
||||
if (SetHandleInformation(to_handle(fd), HANDLE_FLAG_INHERIT, 0) == 0)
|
||||
return Error::from_windows_error();
|
||||
|
|
@ -72,7 +72,8 @@ ErrorOr<void> TCPServer::set_blocking(bool const blocking)
|
|||
// NOTE: Blocking does not seem to be supported. Error code returned is WSAEINVAL
|
||||
if (!blocking)
|
||||
return Error::from_string_literal("Core::TCPServer: WinSock2 does not support blocking");
|
||||
TRY(Core::System::ioctl(m_fd, FIONBIO, 1));
|
||||
int option = 1;
|
||||
TRY(Core::System::ioctl(m_fd, FIONBIO, &option));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ UDPServer::UDPServer()
|
|||
{
|
||||
m_fd = MUST(Core::System::socket(AF_INET, SOCK_DGRAM, 0));
|
||||
int option = 1;
|
||||
MUST(Core::System::ioctl(m_fd, FIONBIO, option));
|
||||
MUST(Core::System::ioctl(m_fd, FIONBIO, &option));
|
||||
auto const ret = SetHandleInformation(to_handle(m_fd), HANDLE_FLAG_INHERIT, 0);
|
||||
VERIFY(ret != 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ ErrorOr<int> Process::create_ipc_socket(ByteString const& socket_path)
|
|||
#if defined(AK_OS_WINDOWS)
|
||||
auto socket_fd = TRY(Core::System::socket(AF_LOCAL, SOCK_STREAM, 0));
|
||||
int option = 1;
|
||||
TRY(Core::System::ioctl(socket_fd, FIONBIO, option));
|
||||
TRY(Core::System::ioctl(socket_fd, FIONBIO, &option));
|
||||
if (SetHandleInformation(to_handle(socket_fd), HANDLE_FLAG_INHERIT, 0) == 0)
|
||||
return Error::from_windows_error();
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ ErrorOr<RequestPipe> RequestPipe::create()
|
|||
int socket_fds[2] {};
|
||||
TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds));
|
||||
int option = 1;
|
||||
TRY(Core::System::ioctl(socket_fds[0], FIONBIO, option));
|
||||
TRY(Core::System::ioctl(socket_fds[1], FIONBIO, option));
|
||||
TRY(Core::System::ioctl(socket_fds[0], FIONBIO, &option));
|
||||
TRY(Core::System::ioctl(socket_fds[1], FIONBIO, &option));
|
||||
return RequestPipe(socket_fds[0], socket_fds[1]);
|
||||
#else
|
||||
auto fds = TRY(Core::System::pipe2(O_NONBLOCK));
|
||||
|
|
|
|||
Loading…
Reference in a new issue