-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibCore: Consistently treat file descriptors as handles on Windows
Also: * implement dup and is_socket * implement and call init_crt_and_wsa
- Loading branch information
Showing
6 changed files
with
114 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
/* | ||
* Copyright (c) 2021, Andreas Kling <[email protected]> | ||
* Copyright (c) 2024, stasoid <[email protected]> | ||
* Copyright (c) 2024-2025, stasoid <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibCore/AnonymousBuffer.h> | ||
#include <windows.h> | ||
#include <LibCore/System.h> | ||
|
||
#include <AK/Windows.h> | ||
|
||
namespace Core { | ||
|
||
|
@@ -23,7 +25,7 @@ AnonymousBufferImpl::~AnonymousBufferImpl() | |
VERIFY(UnmapViewOfFile(m_data)); | ||
|
||
if (m_fd != -1) | ||
VERIFY(CloseHandle((HANDLE)(intptr_t)m_fd)); | ||
MUST(System::close(m_fd)); | ||
} | ||
|
||
ErrorOr<NonnullRefPtr<AnonymousBufferImpl>> AnonymousBufferImpl::create(size_t size) | ||
|
@@ -41,7 +43,7 @@ ErrorOr<NonnullRefPtr<AnonymousBufferImpl>> AnonymousBufferImpl::create(int fd, | |
if (!ptr) | ||
return Error::from_windows_error(); | ||
|
||
return adopt_nonnull_ref_or_enomem(new (nothrow) AnonymousBufferImpl(fd, size, ptr)); | ||
return adopt_ref(*new AnonymousBufferImpl(fd, size, ptr)); | ||
} | ||
|
||
ErrorOr<AnonymousBuffer> AnonymousBuffer::create_with_size(size_t size) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Copyright (c) 2023, Andreas Kling <[email protected]> | ||
* Copyright (c) 2024, stasoid <[email protected]> | ||
* Copyright (c) 2024-2025, stasoid <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -180,10 +180,8 @@ void EventLoopManagerWindows::register_notifier(Notifier& notifier) | |
{ | ||
HANDLE event = CreateEvent(NULL, FALSE, FALSE, NULL); | ||
VERIFY(event); | ||
SOCKET socket = _get_osfhandle(notifier.fd()); | ||
VERIFY(socket != INVALID_SOCKET); | ||
int rc = WSAEventSelect(socket, event, notifier_type_to_network_event(notifier.type())); | ||
VERIFY(rc == 0); | ||
int rc = WSAEventSelect(notifier.fd(), event, notifier_type_to_network_event(notifier.type())); | ||
VERIFY(!rc); | ||
|
||
auto& notifiers = ThreadData::the().notifiers; | ||
VERIFY(!notifiers.get(event).has_value()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,5 +180,6 @@ ErrorOr<void> set_resource_limits(int resource, rlim_t limit); | |
#endif | ||
|
||
int getpid(); | ||
bool is_socket(int fd); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters