Merge bitcoin/bitcoin#32405: build: replace header checks with __has_include

e1f543823b build: replace header checks with __has_include (fanquake)

Pull request description:

  Replace the checks in CMake, with the equivalent functionality provided by the standard library (since C++17).
  See https://en.cppreference.com/w/cpp/preprocessor/include.

  Guix Build:
  ```bash
  66d71c866bd111ffe65bc03b9e1653a95eb678f0b04451759c56af868bfc03d5  guix-build-e1f543823b30/output/aarch64-linux-gnu/SHA256SUMS.part
  1a4130d801620a63d86c3069b1fbca39ebc963e610101451d3f48b1c191ca4b3  guix-build-e1f543823b30/output/aarch64-linux-gnu/bitcoin-e1f543823b30-aarch64-linux-gnu-debug.tar.gz
  745adbc7767344a8cd0ebe1e7592239614d89f949558c9b6a2ae58f7b2602a32  guix-build-e1f543823b30/output/aarch64-linux-gnu/bitcoin-e1f543823b30-aarch64-linux-gnu.tar.gz
  cb69d205a20715ee58a324cc2b8475c2bae0443a062f5de2820baa45f822292c  guix-build-e1f543823b30/output/arm-linux-gnueabihf/SHA256SUMS.part
  081774dd903256dafa187ee47a569cd44b01eb16adc9dbfeb54b721abc39e944  guix-build-e1f543823b30/output/arm-linux-gnueabihf/bitcoin-e1f543823b30-arm-linux-gnueabihf-debug.tar.gz
  1dd857fe6b9e75fae746e73fbfc6b77302b4dbb13685baebb10e9686da7bad01  guix-build-e1f543823b30/output/arm-linux-gnueabihf/bitcoin-e1f543823b30-arm-linux-gnueabihf.tar.gz
  e035ba959da69263de2f29282328d4e5b455f94a800a15891801f26ba3b8b325  guix-build-e1f543823b30/output/arm64-apple-darwin/SHA256SUMS.part
  ebf973e0e44be688ea5e1ebae804dfce6e71b7ca8aaca5d8249a14d130f37c3f  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-codesigning.tar.gz
  3ea687b53032b30d7c4a0760f8a35d19e2f60a8cb3f1f5e2c5cba05897f04e43  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-unsigned.tar.gz
  ebb6a935f2fbc75167f5e61a039d13f231621f7eb0cbd1292616425f7677739c  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-unsigned.zip
  9e77422977506f0c3f0373ee19d24c3ad86cbaf3a97cfcf5db202d4fff9c3ae4  guix-build-e1f543823b30/output/dist-archive/bitcoin-e1f543823b30.tar.gz
  62d7c8f63a3702b066f88498f829b2c371baa06c596b71b6d8969f638cc2d356  guix-build-e1f543823b30/output/powerpc64-linux-gnu/SHA256SUMS.part
  60c00fc85dea24548c212330e5fa097020f17bb74f511e7e764b8b33224afce0  guix-build-e1f543823b30/output/powerpc64-linux-gnu/bitcoin-e1f543823b30-powerpc64-linux-gnu-debug.tar.gz
  97b1aa4dc967c9a3767476a262a503900ea77e15b4b292928c6cdddf306cafc9  guix-build-e1f543823b30/output/powerpc64-linux-gnu/bitcoin-e1f543823b30-powerpc64-linux-gnu.tar.gz
  ed67fbb0768ce7b1d4d053de2ba0ea3b2798d01a276adf6430c4a2a413461ee2  guix-build-e1f543823b30/output/riscv64-linux-gnu/SHA256SUMS.part
  83f7b4e6c244d97caa2eb41b67cdef2bfa71f2f3ef1cfa378fae32db18fc8e25  guix-build-e1f543823b30/output/riscv64-linux-gnu/bitcoin-e1f543823b30-riscv64-linux-gnu-debug.tar.gz
  c8ca7793fdfac2346a21d5fc8f6e00f1feb6556d048896fef8148ac614921050  guix-build-e1f543823b30/output/riscv64-linux-gnu/bitcoin-e1f543823b30-riscv64-linux-gnu.tar.gz
  a3e99dd3369aa97cad2437fc1b29f84a8950327fd0f0a1c0a8a3e7ce49369f1a  guix-build-e1f543823b30/output/x86_64-apple-darwin/SHA256SUMS.part
  1c22d2967c72a5b901d54b9914d243aaf8f52216e48399f09bf17f34455369ec  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-codesigning.tar.gz
  28c731d91d84f41a0b94cfb420474f150edd2bd33db1e9c38d52c9452e44b3f1  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-unsigned.tar.gz
  f6b74d1756af4de4a7e250c11f0a48a93fafc67139951afc4a55888ce24dc01a  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-unsigned.zip
  16d7a33003e89f53b3d8ce31a121250a4f836c83482f39b0c40721a2dd32faca  guix-build-e1f543823b30/output/x86_64-linux-gnu/SHA256SUMS.part
  d17606b3fec3c045d84dadff4b107186cc6e51daa80a16588de4e213585a98cd  guix-build-e1f543823b30/output/x86_64-linux-gnu/bitcoin-e1f543823b30-x86_64-linux-gnu-debug.tar.gz
  52ee77c9ff6bbe6965100165847d107c4e3ddcf8c2a960746f663ade074295a5  guix-build-e1f543823b30/output/x86_64-linux-gnu/bitcoin-e1f543823b30-x86_64-linux-gnu.tar.gz
  daeba27cb9ce21e3a6a01b9487ef81738eec0c84ad80ca0ba1287412c0d4eeda  guix-build-e1f543823b30/output/x86_64-w64-mingw32/SHA256SUMS.part
  38ccc35fe32895688f4fc0f22ed8a03233d06636a487b49de74a215fc6b67002  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-codesigning.tar.gz
  22863abb1a4d1fed1e4753e602f33a743296caf297bdc7ed9330010f5d3f79f3  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-debug.zip
  1cbc8ae43899d96664e75fa2c3fce2efbb2cfac34b279fe1e240a616646cb3e9  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-setup-unsigned.exe
  b6d22f62c083aca24dc788df1676bfc2ce0abc85a796a4823e5802d71482082c  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-unsigned.zip
  ```

ACKs for top commit:
  shahsb:
    ACK e1f543823b
  purpleKarrot:
    ACK e1f543823b
  TheCharlatan:
    ACK e1f543823b
  hebasto:
    ACK e1f543823b, I have reviewed the code and it looks OK.

Tree-SHA512: d4bcbc37d431113f0e6367e8f61e71ab9d9ef8a08c38a2db961d9f9cc8473636124f5f2bd4d66cbb3e5032f9d5f978d7d286033d80f7e148f9d571ff09f005ff
This commit is contained in:
Hennadii Stepanov 2025-05-05 15:19:08 +01:00
commit baa848b8d3
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F
4 changed files with 4 additions and 24 deletions

View File

@ -108,18 +108,6 @@
/* Define to 1 if std::system or ::wsystem is available. */
#cmakedefine HAVE_SYSTEM 1
/* Define to 1 if you have the <sys/prctl.h> header file. */
#cmakedefine HAVE_SYS_PRCTL_H 1
/* Define to 1 if you have the <sys/resources.h> header file. */
#cmakedefine HAVE_SYS_RESOURCES_H 1
/* Define to 1 if you have the <sys/vmmeter.h> header file. */
#cmakedefine HAVE_SYS_VMMETER_H 1
/* Define to 1 if you have the <vm/vm_param.h> header file. */
#cmakedefine HAVE_VM_VM_PARAM_H 1
/* Define to the address where bug reports for this package should be sent. */
#define CLIENT_BUGREPORT "@CLIENT_BUGREPORT@"

View File

@ -6,12 +6,6 @@ include(CheckCXXSourceCompiles)
include(CheckCXXSymbolExists)
include(CheckIncludeFileCXX)
# The following HAVE_{HEADER}_H variables go to the bitcoin-build-config.h header.
check_include_file_cxx(sys/prctl.h HAVE_SYS_PRCTL_H)
check_include_file_cxx(sys/resources.h HAVE_SYS_RESOURCES_H)
check_include_file_cxx(sys/vmmeter.h HAVE_SYS_VMMETER_H)
check_include_file_cxx(vm/vm_param.h HAVE_VM_VM_PARAM_H)
check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
check_cxx_symbol_exists(fork "unistd.h" HAVE_DECL_FORK)

View File

@ -43,13 +43,13 @@
#endif
#ifdef HAVE_SYSCTL
#include <sys/sysctl.h>
#ifdef HAVE_VM_VM_PARAM_H
#if __has_include(<vm/vm_param.h>)
#include <vm/vm_param.h>
#endif
#ifdef HAVE_SYS_RESOURCES_H
#if __has_include(<sys/resources.h>)
#include <sys/resources.h>
#endif
#ifdef HAVE_SYS_VMMETER_H
#if __has_include(<sys/vmmeter.h>)
#include <sys/vmmeter.h>
#endif
#endif

View File

@ -2,8 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bitcoin-build-config.h> // IWYU pragma: keep
#include <cstring>
#include <string>
#include <thread>
@ -16,7 +14,7 @@
#include <util/threadnames.h>
#ifdef HAVE_SYS_PRCTL_H
#if __has_include(<sys/prctl.h>)
#include <sys/prctl.h>
#endif