move socket_ready to header for inlining

This commit is contained in:
J. Nick Koston
2026-03-01 14:31:44 -10:00
parent 10ec8afbb2
commit 9abb52f485
2 changed files with 5 additions and 9 deletions
+1 -7
View File
@@ -8,13 +8,7 @@
namespace esphome::socket {
#ifdef USE_LWIP_FAST_SELECT
// Shared ready() implementation for fd-based socket implementations (BSD and LWIP sockets).
// Uses cached lwip_sock pointer for direct rcvevent read — no fd lookup overhead.
bool socket_ready(struct lwip_sock *cached_sock, bool loop_monitored) {
return !loop_monitored || (cached_sock != nullptr && esphome_lwip_socket_has_data(cached_sock));
}
#elif defined(USE_SOCKET_SELECT_SUPPORT)
#if defined(USE_SOCKET_SELECT_SUPPORT) && !defined(USE_LWIP_FAST_SELECT)
// Shared ready() implementation for fd-based socket implementations (BSD and LWIP sockets).
// Checks if the Application's select() loop has marked this fd as ready.
bool socket_ready_fd(int fd, bool loop_monitored) { return !loop_monitored || App.is_socket_ready_(fd); }
+4 -2
View File
@@ -7,7 +7,7 @@
#include "headers.h"
#ifdef USE_LWIP_FAST_SELECT
struct lwip_sock;
#include "esphome/core/lwip_fast_select.h"
#endif
#if defined(USE_SOCKET_IMPL_LWIP_TCP) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS)
@@ -42,7 +42,9 @@ using ListenSocket = LWIPRawListenImpl;
#ifdef USE_LWIP_FAST_SELECT
/// Shared ready() helper using cached lwip_sock pointer for direct rcvevent read.
bool socket_ready(struct lwip_sock *cached_sock, bool loop_monitored);
inline bool socket_ready(struct lwip_sock *cached_sock, bool loop_monitored) {
return !loop_monitored || (cached_sock != nullptr && esphome_lwip_socket_has_data(cached_sock));
}
#elif defined(USE_SOCKET_SELECT_SUPPORT)
/// Shared ready() helper for fd-based socket implementations.
/// Checks if the Application's select() loop has marked this fd as ready.