Optimize Net module for Android (#4517)

* epoll is available on Android

* <ifaddrs.h> is introduced in android-24
This commit is contained in:
zhuzeitou 2024-04-03 01:03:41 +08:00 committed by GitHub
parent ece360393f
commit 3496e47475
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -134,7 +134,7 @@ POCO_NET_FORCE_SYMBOL(pocoNetworkInitializer)
#endif
#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_WINDOWS_NT)
#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_WINDOWS_NT) || (POCO_OS == POCO_OS_ANDROID)
#define POCO_HAVE_FD_EPOLL 1
#endif

View File

@ -1486,7 +1486,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
#include <sys/types.h>
#if POCO_OS != POCO_OS_ANDROID // Android doesn't have <ifaddrs.h>
#if POCO_OS != POCO_OS_ANDROID || __ANDROID_API__ >= 24 // old Android doesn't have <ifaddrs.h>
#include <ifaddrs.h>
#endif
#include <net/if.h>
@ -1521,7 +1521,7 @@ static NetworkInterface::Type fromNative(unsigned arphrd)
}
}
#if (POCO_OS != POCO_OS_ANDROID) && !defined(POCO_EMSCRIPTEN)
#if (POCO_OS != POCO_OS_ANDROID || __ANDROID_API__ >= 24) && !defined(POCO_EMSCRIPTEN)
void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
{
@ -1580,7 +1580,7 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
{
#if (POCO_OS != POCO_OS_ANDROID) && !defined(POCO_EMSCRIPTEN)
#if (POCO_OS != POCO_OS_ANDROID || __ANDROID_API__ >= 24) && !defined(POCO_EMSCRIPTEN)
FastMutex::ScopedLock lock(_mutex);
Map result;
unsigned ifIndex = 0;