Skip to content

Commit

Permalink
Optimize Net module for Android (#4517)
Browse files Browse the repository at this point in the history
* epoll is available on Android

* <ifaddrs.h> is introduced in android-24
  • Loading branch information
zhuzeitou authored Apr 2, 2024
1 parent ece3603 commit 3496e47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Net/include/Poco/Net/Net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions Net/src/NetworkInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3496e47

Please sign in to comment.