Meson: Set _WIN32_WINNT to 0x0601 (Windows 7)

We want to set _WIN32_WINNT so that functions will be properly found in
the headers, to target the NT6.1+ (Windows 7+) APIs.

Also improve the checks for if_nametoindex() and if_indextoname() on
Windows as they are supported in Windows Vista+, but they have
to be checked by linking against iphlpapi.lib (or -liphlpapi).  On other
platforms, they are still checked as they were before.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
This commit is contained in:
Chun-wei Fan 2017-07-18 22:19:54 +08:00
parent ea6ac5f71e
commit 54aee1f627
3 changed files with 27 additions and 4 deletions

View File

@ -768,7 +768,7 @@
/* Define for large files, on AIX-style hosts. */
#mesondefine _LARGE_FILES
/* Target the Windows XP API */
/* Target the Windows 7 API */
#mesondefine _WIN32_WINNT
/* Needed to get declarations for msg_control and msg_controllen on Solaris */

View File

@ -369,7 +369,7 @@ if host_system == 'windows'
contenttype_sources += ['gcontenttype-win32.c']
platform_deps += [cc.find_library('shlwapi'),
cc.find_library('dnsapi'),
cc.find_library('iphlpapi'),
iphlpapi_dep,
winsock2]
win32_sources += [
'gwin32registrykey.c',

View File

@ -255,6 +255,11 @@ foreach m : struct_members
endif
endforeach
# Windows Support (Vista+)
if host_system == 'windows'
glib_conf.set('_WIN32_WINNT', '0x0601')
endif
functions = [
'alloca',
'mmap',
@ -311,8 +316,6 @@ functions = [
'kqueue',
'kevent',
'endservent',
'if_indextoname',
'if_nametoindex',
'sendmmsg',
'recvmmsg',
]
@ -328,6 +331,25 @@ else
have_func_statfs = false
endif
if host_system == 'windows'
iphlpapi_dep = cc.find_library('iphlpapi')
iphlpapi_funcs = ['if_nametoindex', 'if_indextoname']
foreach ifunc : iphlpapi_funcs
if cc.has_function(ifunc,
prefix : '#define _WIN32_WINNT 0x0601\n#include <winsock2.h>\n#include <iphlpapi.h>',
dependencies : iphlpapi_dep)
idefine = 'HAVE_' + ifunc.underscorify().to_upper()
glib_conf.set(idefine, 1)
glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(idefine)
set_variable('have_func_' + ifunc, true)
else
set_variable('have_func_' + ifunc, false)
endif
endforeach
else
functions += ['if_indextoname', 'if_nametoindex']
endif
# AIX splice is something else
if host_system != 'aix'
functions += ['splice']
@ -674,6 +696,7 @@ endif
# AC_FUNC_PRINTF_UNIX98
# Nothing uses HAVE_UNIX98_PRINTF
# Check for nl_langinfo and CODESET
# FIXME: Check for HAVE_BIND_TEXTDOMAIN_CODESET
if cc.links('''#include <langinfo.h>