diff --git a/.github/workflows/uwp.yml b/.github/workflows/uwp.yml new file mode 100644 index 00000000..80b461bc --- /dev/null +++ b/.github/workflows/uwp.yml @@ -0,0 +1,29 @@ +# Copyright (C) The c-ares project and its contributors +# SPDX-License-Identifier: MIT +name: Windows UWP (Store) +on: + push: + pull_request: + +concurrency: + group: ${{ github.ref }}-uwp + cancel-in-progress: true + +jobs: + build: + runs-on: windows-latest + name: Windows UWP (Store) + steps: + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + uwp: true + - name: Checkout c-ares + uses: actions/checkout@v4 + - name: Build c-ares + run: | + mkdir build + cmake -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON "-DCMAKE_SYSTEM_VERSION=10.0" -DCMAKE_SYSTEM_NAME=WindowsStore -A x64 -Bbuild + cmake --build build --config Debug + +# -DCMAKE_SYSTEM_VERSION=10.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 84186824..f075a7ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -425,6 +425,10 @@ CHECK_SYMBOL_EXISTS (if_indextoname "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_INDE CHECK_SYMBOL_EXISTS (if_nametoindex "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_NAMETOINDEX) CHECK_SYMBOL_EXISTS (ConvertInterfaceIndexToLuid "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONVERTINTERFACEINDEXTOLUID) CHECK_SYMBOL_EXISTS (ConvertInterfaceLuidToNameA "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONVERTINTERFACELUIDTONAMEA) +CHECK_SYMBOL_EXISTS (NotifyIpInterfaceChange "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_NOTIFYIPINTERFACECHANGE) +CHECK_SYMBOL_EXISTS (RegisterWaitForSingleObject "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_REGISTERWAITFORSINGLEOBJECT) + + CHECK_SYMBOL_EXISTS (inet_net_pton "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_NET_PTON) IF (NOT WIN32) # Disabled on Windows, because these functions are only really supported on Windows diff --git a/configure.ac b/configure.ac index 60afc358..1b449bc4 100644 --- a/configure.ac +++ b/configure.ac @@ -585,6 +585,8 @@ AC_CHECK_DECL(kqueue, [AC_DEFINE([HAVE_KQUEUE], 1, [Define t AC_CHECK_DECL(epoll_create1, [AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if you have `epoll_{create1,ctl,wait}`])], [], $cares_all_includes) AC_CHECK_DECL(ConvertInterfaceIndexToLuid, [AC_DEFINE([HAVE_CONVERTINTERFACEINDEXTOLUID], 1, [Define to 1 if you have `ConvertInterfaceIndexToLuid`])], [], $cares_all_includes) AC_CHECK_DECL(ConvertInterfaceLuidToNameA, [AC_DEFINE([HAVE_CONVERTINTERFACELUIDTONAMEA], 1, [Define to 1 if you have `ConvertInterfaceLuidToNameA`])], [], $cares_all_includes) +AC_CHECK_DECL(NotifyIpInterfaceChange, [AC_DEFINE([HAVE_NOTIFYIPINTERFACECHANGE], 1, [Define to 1 if you have `NotifyIpInterfaceChange`] )], [], $cares_all_includes) +AC_CHECK_DECL(RegisterWaitForSingleObject, [AC_DEFINE([HAVE_REGISTERWAITFORSINGLEOBJECT], 1, [Define to 1 if you have `RegisterWaitForSingleObject`])], [], $cares_all_includes) AC_CHECK_DECL(__system_property_get, [AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], 1, [Define to 1 if you have `__system_property_get`] )], [], $cares_all_includes) diff --git a/src/lib/ares_config.h.cmake b/src/lib/ares_config.h.cmake index b3f91699..da738671 100644 --- a/src/lib/ares_config.h.cmake +++ b/src/lib/ares_config.h.cmake @@ -148,6 +148,12 @@ /* Define to 1 if you have the `ConvertInterfaceLuidToNameA' function. */ #cmakedefine HAVE_CONVERTINTERFACELUIDTONAMEA 1 +/* Define to 1 if you have the `NotifyIpInterfaceChange' function. */ +#cmakedefine HAVE_NOTIFYIPINTERFACECHANGE 1 + +/* Define to 1 if you have the `RegisterWaitForSingleObject' function. */ +#cmakedefine HAVE_REGISTERWAITFORSINGLEOBJECT 1 + /* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ #cmakedefine HAVE_INET_NET_PTON 1 diff --git a/src/lib/config-win32.h b/src/lib/config-win32.h index da5c7483..b9c4ec17 100644 --- a/src/lib/config-win32.h +++ b/src/lib/config-win32.h @@ -352,6 +352,9 @@ # define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 #endif +/* Define to 1 if you have the `RegisterWaitForSingleObject' function. */ +#define HAVE_REGISTERWAITFORSINGLEOBJECT 1 + #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \ !defined(__WATCOMC__) && !defined(WATT32) /* Define if you have if_nametoindex() */ @@ -362,6 +365,8 @@ # define HAVE_CONVERTINTERFACEINDEXTOLUID 1 /* Define to 1 if you have the `ConvertInterfaceLuidToNameA' function. */ # define HAVE_CONVERTINTERFACELUIDTONAMEA 1 +/* Define to 1 if you have the `NotifyIpInterfaceChange' function. */ +# define HAVE_NOTIFYIPINTERFACECHANGE 1 #endif /* ---------------------------------------------------------------- */ diff --git a/src/lib/event/ares_event_configchg.c b/src/lib/event/ares_event_configchg.c index 7a29001a..030c76c6 100644 --- a/src/lib/event/ares_event_configchg.c +++ b/src/lib/event/ares_event_configchg.c @@ -195,13 +195,14 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) return; } -# ifndef __WATCOMC__ +# ifdef HAVE_NOTIFYIPINTERFACECHANGE if (configchg->ifchg_hnd != NULL) { CancelMibChangeNotify2(configchg->ifchg_hnd); configchg->ifchg_hnd = NULL; } # endif +# ifdef HAVE_REGISTERWAITFORSINGLEOBJECT if (configchg->regip4_wait != NULL) { UnregisterWait(configchg->regip4_wait); configchg->regip4_wait = NULL; @@ -231,12 +232,13 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) CloseHandle(configchg->regip6_event); configchg->regip6_event = NULL; } +# endif ares_free(configchg); } -# ifndef __WATCOMC__ +# ifdef HAVE_NOTIFYIPINTERFACECHANGE static void NETIOAPI_API_ ares_event_configchg_ip_cb(PVOID CallerContext, PMIB_IPINTERFACE_ROW Row, MIB_NOTIFICATION_TYPE NotificationType) @@ -251,9 +253,10 @@ static void NETIOAPI_API_ static ares_bool_t ares_event_configchg_regnotify(ares_event_configchg_t *configchg) { -# if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) -# define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L -# endif +# ifdef HAVE_REGISTERWAITFORSINGLEOBJECT +# if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) +# define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L +# endif DWORD flags = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_THREAD_AGNOSTIC; @@ -266,7 +269,9 @@ static ares_bool_t configchg->regip6_event, TRUE) != ERROR_SUCCESS) { return ARES_FALSE; } - +# else + (void)configchg; +# endif return ARES_TRUE; } @@ -296,7 +301,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, c->e = e; -# ifndef __WATCOMC__ +# ifdef HAVE_NOTIFYIPINTERFACECHANGE /* NOTE: If a user goes into the control panel and changes the network * adapter DNS addresses manually, this will NOT trigger a notification. * We've also tried listening on NotifyUnicastIpAddressChange(), but @@ -309,6 +314,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, } # endif +# ifdef HAVE_REGISTERWAITFORSINGLEOBJECT /* Monitor HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces * and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces * for changes via RegNotifyChangeKeyValue() */ @@ -353,6 +359,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, status = ARES_ESERVFAIL; goto done; } +# endif if (!ares_event_configchg_regnotify(c)) { status = ARES_ESERVFAIL;