From 0a0a1fd330bb09981dba0ee070d63d88357a4705 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Mon, 28 Feb 2022 19:11:28 +0000 Subject: [PATCH] Use __has_include() instead of check_include_file() Allows removing some CMake checks config-kwin.h contents. This is supported by all compilers and required for C++17. While touching those lines I also cleaned up an unnecessary HAVE_UNISTD_H check (glibc always has it and and incorrect use of HAVE_SYS_PROCCTL_H. --- CMakeLists.txt | 4 ---- src/config-kwin.h.cmake | 7 ------- src/main.cpp | 12 ++++-------- src/main_x11.cpp | 4 ++-- src/session_consolekit.cpp | 2 +- src/session_logind.cpp | 2 +- src/xwl/xwayland.cpp | 5 +---- 7 files changed, 9 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87d9b1c6f4..24de2a4212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -355,10 +355,6 @@ set(HAVE_X11_XCB ${X11_XCB_FOUND}) include(CheckIncludeFile) include(CheckIncludeFiles) include(CheckSymbolExists) -check_include_files(unistd.h HAVE_UNISTD_H) -check_include_files(malloc.h HAVE_MALLOC_H) - -check_include_file("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H) check_symbol_exists(SCHED_RESET_ON_FORK "sched.h" HAVE_SCHED_RESET_ON_FORK) add_feature_info("SCHED_RESET_ON_FORK" diff --git a/src/config-kwin.h.cmake b/src/config-kwin.h.cmake index d2fd99107b..c5aa0d66b6 100644 --- a/src/config-kwin.h.cmake +++ b/src/config-kwin.h.cmake @@ -18,7 +18,6 @@ #cmakedefine01 HAVE_X11_XINPUT #cmakedefine01 HAVE_GBM_BO_GET_FD_FOR_PLANE #cmakedefine01 HAVE_WAYLAND_EGL -#cmakedefine01 HAVE_SYS_SYSMACROS_H #cmakedefine01 HAVE_BREEZE_DECO #cmakedefine01 HAVE_LIBCAP #cmakedefine01 HAVE_SCHED_RESET_ON_FORK @@ -27,12 +26,6 @@ #define BREEZE_KDECORATION_PLUGIN_ID "${BREEZE_KDECORATION_PLUGIN_ID}" #endif -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MALLOC_H 1 - #cmakedefine XCB_ICCCM_FOUND 1 #ifndef XCB_ICCCM_FOUND #define XCB_ICCCM_WM_STATE_WITHDRAWN 0 diff --git a/src/main.cpp b/src/main.cpp index 102186e866..bb29025d9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,13 +47,13 @@ #include // system -#ifdef HAVE_UNISTD_H +#if __has_include() #include -#endif // HAVE_UNISTD_H +#endif -#ifdef HAVE_MALLOC_H +#ifdef __has_include() #include -#endif // HAVE_MALLOC_H +#endif // xcb #include @@ -255,11 +255,7 @@ void Application::setupMalloc() // due to fragmentation especially if we use the raster graphicssystem. On the // otherside if the threshold is too low, free() starts to permanently ask the kernel // about shrinking the heap. -#ifdef HAVE_UNISTD_H const int pagesize = sysconf(_SC_PAGESIZE); -#else - const int pagesize = 4*1024; -#endif // HAVE_UNISTD_H mallopt(M_TRIM_THRESHOLD, 5*pagesize); #endif // M_TRIM_THRESHOLD } diff --git a/src/main_x11.cpp b/src/main_x11.cpp index 7b506043e5..5cc4734a59 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -42,9 +42,9 @@ #include // system -#ifdef HAVE_UNISTD_H +#if __has_include() #include -#endif // HAVE_UNISTD_H +#endif #include Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtWarningMsg) diff --git a/src/session_consolekit.cpp b/src/session_consolekit.cpp index e642327a5e..89c5165232 100644 --- a/src/session_consolekit.cpp +++ b/src/session_consolekit.cpp @@ -21,7 +21,7 @@ #include #include -#if HAVE_SYS_SYSMACROS_H +#if __has_include() #include #endif diff --git a/src/session_logind.cpp b/src/session_logind.cpp index 818a96620b..135e5d72ef 100644 --- a/src/session_logind.cpp +++ b/src/session_logind.cpp @@ -21,7 +21,7 @@ #include #include -#if HAVE_SYS_SYSMACROS_H +#if __has_include() #include #endif diff --git a/src/xwl/xwayland.cpp b/src/xwl/xwayland.cpp index 93245ac70f..b7a7b64230 100644 --- a/src/xwl/xwayland.cpp +++ b/src/xwl/xwayland.cpp @@ -43,10 +43,7 @@ #include // system -#ifdef HAVE_UNISTD_H -#include -#endif -#if HAVE_SYS_PROCCTL_H +#if __has_include() #include #endif