Skip to content

Commit 94c8849

Browse files
committed
Async: Fix warnings generated by clangd (IWYU)
1 parent 82f2b08 commit 94c8849

File tree

6 files changed

+39
-32
lines changed

6 files changed

+39
-32
lines changed

Libraries/Async/Async.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright (c) Stefano Cristiano
22
// SPDX-License-Identifier: MIT
3-
#include "../Containers/Internal/IntrusiveDoubleLinkedList.inl"
3+
#include "../Containers/Internal/IntrusiveDoubleLinkedList.inl" // IWYU pragma: keep
44
#include "../Foundation/Platform.h"
5-
#include "../Socket/Socket.h"
65

76
#include <string.h> // strncpy
87

Libraries/Async/Internal/AsyncInternal.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@ struct SC::AsyncEventLoop::Internal
1313
struct KernelEventsIoURing;
1414
struct KernelQueue;
1515
struct KernelEvents;
16+
17+
struct KernelQueue
18+
{
19+
AlignedStorage<320> storage;
20+
21+
bool isEpoll = true;
22+
23+
KernelQueue();
24+
~KernelQueue();
25+
KernelQueueIoURing& getUring();
26+
KernelQueuePosix& getPosix();
27+
28+
// On io_uring it doesn't make sense to run operations in a thread pool
29+
[[nodiscard]] bool makesSenseToRunInThreadPool(AsyncRequest&) { return isEpoll; }
30+
31+
Result close();
32+
Result createEventLoop(AsyncEventLoop::Options options);
33+
Result createSharedWatchers(AsyncEventLoop&);
34+
Result wakeUpFromExternalThread();
35+
36+
static Result associateExternallyCreatedSocket(SocketDescriptor&) { return Result(true); }
37+
static Result associateExternallyCreatedFileDescriptor(FileDescriptor&) { return Result(true); }
38+
static Result removeAllAssociationsFor(SocketDescriptor&) { return Result(true); }
39+
static Result removeAllAssociationsFor(FileDescriptor&) { return Result(true); }
40+
};
1641
#elif SC_PLATFORM_APPLE
1742
struct KernelQueuePosix;
1843
struct KernelEventsPosix;

Libraries/Async/Internal/AsyncLinux.inl

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@
99
#include <sys/syscall.h> // SYS_pidfd_open
1010
#include <sys/wait.h> // waitpid
1111

12-
struct SC::AsyncEventLoop::Internal::KernelQueue
13-
{
14-
AlignedStorage<320> storage;
15-
16-
bool isEpoll = true;
17-
18-
KernelQueue();
19-
~KernelQueue();
20-
KernelQueueIoURing& getUring();
21-
KernelQueuePosix& getPosix();
22-
23-
// On io_uring it doesn't make sense to run operations in a thread pool
24-
[[nodiscard]] bool makesSenseToRunInThreadPool(AsyncRequest&) { return isEpoll; }
25-
26-
Result close();
27-
Result createEventLoop(AsyncEventLoop::Options options);
28-
Result createSharedWatchers(AsyncEventLoop&);
29-
Result wakeUpFromExternalThread();
30-
31-
static Result associateExternallyCreatedSocket(SocketDescriptor&) { return Result(true); }
32-
static Result associateExternallyCreatedFileDescriptor(FileDescriptor&) { return Result(true); }
33-
static Result removeAllAssociationsFor(SocketDescriptor&) { return Result(true); }
34-
static Result removeAllAssociationsFor(FileDescriptor&) { return Result(true); }
35-
};
36-
3712
struct SC::AsyncEventLoop::Internal::KernelEvents
3813
{
3914
bool isEpoll = true;
@@ -73,7 +48,6 @@ struct SC::AsyncEventLoop::Internal::KernelEvents
7348
// clang-format on
7449
};
7550

76-
#define SC_ASYNC_USE_EPOLL 1 // uses epoll
7751
#include "AsyncPosix.inl"
7852

7953
#include "AsyncLinuxAPI.h"

Libraries/Async/Internal/AsyncLinuxAPI.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#include <dlfcn.h>
2+
#include <stdint.h>
3+
#include <string.h>
4+
#include <sys/uio.h> // for iovec
5+
#include <unistd.h>
26

37
struct AsyncLinuxAPI
48
{
@@ -148,7 +152,6 @@ struct AsyncLinuxLibURingLoader : public AsyncLinuxAPI
148152
//
149153
// TODO: Use the liburing-ffi supplied functions if they're available on the system
150154

151-
#include <errno.h> // errno
152155
#include <linux/io_uring.h> // io_uring
153156
#include <linux/time_types.h> // __kernel_timespec
154157

Libraries/Async/Internal/AsyncPosix.inl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
// Copyright (c) Stefano Cristiano
22
// SPDX-License-Identifier: MIT
3-
43
#include "AsyncInternal.h"
54

5+
#include "../../Foundation/Assert.h"
66
#include "../../Foundation/Deferred.h"
7+
#include "../../Socket/Socket.h"
8+
9+
#if SC_PLATFORM_LINUX
10+
#define SC_ASYNC_USE_EPOLL 1 // uses epoll
11+
#endif
712

813
#if SC_ASYNC_USE_EPOLL
914

@@ -15,6 +20,7 @@
1520
#include <sys/socket.h> // For socket-related functions
1621
#include <sys/stat.h> // fstat
1722
#include <sys/uio.h> // writev, pwritev
23+
#include <sys/wait.h> // waitpid / WIFEXITED / WEXITSTATUS
1824

1925
#else
2026

@@ -189,8 +195,7 @@ struct SC::AsyncEventLoop::Internal::KernelQueuePosix
189195
struct signalfd_siginfo siginfo;
190196
FileDescriptor::Handle sigHandle;
191197

192-
const KernelQueuePosix& kernelQueue = result.eventLoop.internal.kernelQueue.get().getPosix();
193-
Result res = kernelQueue.signalProcessExitDescriptor.get(sigHandle, Result::Error("Invalid signal handle"));
198+
Result res = signalProcessExitDescriptor.get(sigHandle, Result::Error("Invalid signal handle"));
194199
if (not res)
195200
{
196201
return;

Libraries/Async/Internal/AsyncWindows.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <Ws2tcpip.h> // sockadd_in6
99

1010
#include "../../Foundation/Deferred.h"
11+
#include "../../Socket/Socket.h"
1112
#include "AsyncInternal.h"
1213
#include "AsyncWindows.h"
1314
#include "AsyncWindowsAPI.h"

0 commit comments

Comments
 (0)