set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+# keep in sync with check_headers in meson.build
check_include_files("winsock2.h;afunix.h" HAVE_AFUNIX_H)
check_include_file(alloca.h HAVE_ALLOCA_H)
check_include_file(byteswap.h HAVE_BYTESWAP_H)
check_include_file(locale.h HAVE_LOCALE_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(stdio.h HAVE_STDIO_H) # dbus-sysdeps.h
-check_include_file(syslog.h HAVE_SYSLOG_H)
check_include_files("stdint.h;sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H)
+check_include_file(sys/inotify.h DBUS_BUS_ENABLE_INOTIFY)
+check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H)
check_include_file(sys/random.h HAVE_SYS_RANDOM_H)
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_file(sys/syscall.h HAVE_SYS_SYSCALL_H)
-check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c
check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
-check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c
+check_include_file(syslog.h HAVE_SYSLOG_H)
check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c
-check_include_file(sys/inotify.h DBUS_BUS_ENABLE_INOTIFY)
+check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c
find_package(Backtrace) # dbus-sysdeps.c, dbus-sysdeps-win.c
set(HAVE_BACKTRACE ${Backtrace_FOUND})
+# keep in sync with check_functions in meson.build
+check_symbol_exists(LOG_PERROR "syslog.h" HAVE_DECL_LOG_PERROR)
+check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_DECL_MSG_NOSIGNAL)
+check_symbol_exists(SCM_RIGHTS "sys/types.h;sys/socket.h;sys/un.h" HAVE_UNIX_FD_PASSING)
+check_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
+check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c
+check_symbol_exists(close_range "unistd.h" HAVE_CLOSE_RANGE) # dbus-sysdeps-unix.c
+check_symbol_exists(closefrom "unistd.h" HAVE_CLOSEFROM) # dbus-sysdeps-unix.c
+check_symbol_exists(environ "unistd.h" HAVE_DECL_ENVIRON)
+check_symbol_exists(fstatfs "sys/vfs.h" HAVE_FSTATFS)
check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c
check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c
-check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c
check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_GETPWNAM_R) # dbus-sysdeps-util-unix.c
-check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c
-check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c
-check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c
-check_symbol_exists(closefrom "unistd.h" HAVE_CLOSEFROM) # dbus-sysdeps-unix.c
-check_symbol_exists(close_range "unistd.h" HAVE_CLOSE_RANGE) # dbus-sysdeps-unix.c
-check_symbol_exists(writev "sys/uio.h" HAVE_WRITEV) # dbus-sysdeps.c, dbus-sysdeps-win.c
-check_symbol_exists(setrlimit "sys/resource.h" HAVE_SETRLIMIT) # dbus-sysdeps.c, dbus-sysdeps-win.c, test/test-segfault.c
-check_symbol_exists(socketpair "sys/socket.h" HAVE_SOCKETPAIR) # dbus-sysdeps.c
-check_symbol_exists(setlocale "locale.h" HAVE_SETLOCALE) # dbus-test-main.c
+check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
+check_symbol_exists(getresuid "unistd.h" HAVE_GETRESUID)
+check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT)
+check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
check_symbol_exists(localeconv "locale.h" HAVE_LOCALECONV) # dbus-sysdeps.c
-check_symbol_exists(poll "poll.h" HAVE_POLL) # dbus-sysdeps-unix.c
+check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c
check_symbol_exists(pipe2 "fcntl.h;unistd.h" HAVE_PIPE2)
-check_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
-check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
-check_symbol_exists(SCM_RIGHTS "sys/types.h;sys/socket.h;sys/un.h" HAVE_UNIX_FD_PASSING)
+check_symbol_exists(poll "poll.h" HAVE_POLL) # dbus-sysdeps-unix.c
check_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL)
-check_symbol_exists(raise "signal.h" HAVE_RAISE)
-check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
-check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT)
check_symbol_exists(prlimit "sys/resource.h;sys/time.h" HAVE_PRLIMIT)
-check_symbol_exists(setrlimit "sys/resource.h;sys/time.h" HAVE_SETRLIMIT)
-check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_DECL_MSG_NOSIGNAL)
-check_symbol_exists(environ "unistd.h" HAVE_DECL_ENVIRON)
-check_symbol_exists(LOG_PERROR "syslog.h" HAVE_DECL_LOG_PERROR)
+check_symbol_exists(raise "signal.h" HAVE_RAISE)
+check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c
+check_symbol_exists(setlocale "locale.h" HAVE_SETLOCALE) # dbus-test-main.c
check_symbol_exists(setresuid "unistd.h" HAVE_SETRESUID)
-check_symbol_exists(getresuid "unistd.h" HAVE_GETRESUID)
-check_symbol_exists(fstatfs "sys/vfs.h" HAVE_FSTATFS)
+check_symbol_exists(setrlimit "sys/resource.h" HAVE_SETRLIMIT) # dbus-sysdeps.c, dbus-sysdeps-win.c, test/test-segfault.c
+check_symbol_exists(setrlimit "sys/resource.h;sys/time.h" HAVE_SETRLIMIT)
+check_symbol_exists(socketpair "sys/socket.h" HAVE_SOCKETPAIR) # dbus-sysdeps.c
+check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c
+check_symbol_exists(writev "sys/uio.h" HAVE_WRITEV) # dbus-sysdeps.c, dbus-sysdeps-win.c
check_struct_member(cmsgcred cmcred_pid "sys/types.h;sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c