From 324ca5b489076e548258fb7acd9ed3c238406eda Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Fri, 24 Jun 2022 21:19:01 +0300 Subject: Tests/CTestTestFdSetSize: Support plain POSIX When compiling in ISO C mode functions from newer POSIX standards such as usleep() and nanosleep() aren't available. Fortunately select() allows timing out with microsecond precision. --- Tests/CTestTestFdSetSize/sleep.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Tests/CTestTestFdSetSize/sleep.c b/Tests/CTestTestFdSetSize/sleep.c index 2fb6490..d55cec6 100644 --- a/Tests/CTestTestFdSetSize/sleep.c +++ b/Tests/CTestTestFdSetSize/sleep.c @@ -1,7 +1,11 @@ #if defined(_WIN32) # include -#else +#elif _XOPEN_SOURCE >= 500 || defined(_ALL_SOURCE) # include +#else +# include + +# include #endif /* sleeps for 0.1 second */ @@ -9,8 +13,14 @@ int main(int argc, char** argv) { #if defined(_WIN32) Sleep(100); -#else +#elif _XOPEN_SOURCE >= 500 || defined(_ALL_SOURCE) usleep(100 * 1000); +#else + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 100 * 1000; + + select(0, NULL, NULL, NULL, &tv); #endif return 0; } -- cgit v0.12 From 8eb8d16c194afec720d90f98aec46d63d5bbb33a Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Fri, 24 Jun 2022 21:21:17 +0300 Subject: cmSystemTools: Fix unsetenv() fallback The fallback path boils down to putenv(). Calling that with a "=" sets the variable to an empty string. Use cmSystemTools::UnPutEnv() instead, which correctly handles unsetting variables on a variety of systems. --- Source/cmSystemTools.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 55b0df8..3de45bc 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1501,8 +1501,7 @@ std::string cmSystemTools::RelativeIfUnder(std::string const& top, bool cmSystemTools::UnsetEnv(const char* value) { # if !defined(HAVE_UNSETENV) - std::string var = cmStrCat(value, '='); - return cmSystemTools::PutEnv(var); + return cmSystemTools::UnPutEnv(value); # else unsetenv(value); return true; -- cgit v0.12 From 3f7ebf9354173a71a854ee807810fdc42b577204 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Fri, 24 Jun 2022 21:34:06 +0300 Subject: RunCMake/CTestTimeout: Include sched.h for pid_t ISO C modes in Clang don't enable modern POSIX standards. Include sched.h to define pid_t in such modes. --- Tests/RunCMake/CTestTimeout/TestTimeout.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/RunCMake/CTestTimeout/TestTimeout.c b/Tests/RunCMake/CTestTimeout/TestTimeout.c index 5a008a7..0d534fc 100644 --- a/Tests/RunCMake/CTestTimeout/TestTimeout.c +++ b/Tests/RunCMake/CTestTimeout/TestTimeout.c @@ -1,6 +1,7 @@ #if defined(_WIN32) # include #else +# include # include #endif -- cgit v0.12 From e1adddc74e22f93cc30d3d6043ab03d797ead80c Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 25 Jun 2022 10:08:44 +0300 Subject: RunCMake/CXXModules/NoCXX20: Force older standard Compile features ensure a compiler is aware of a standard version, but the one actually used may be newer. The test relies on the standard chosen being pre-C++20, so force C++17 explicitly. This was exposed by a nightly bot that has a compiler defaulting to C++23. The test would've broken anyway in a few years once GCC or Clang upped their default. --- Tests/RunCMake/CXXModules/NoCXX20.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/RunCMake/CXXModules/NoCXX20.cmake b/Tests/RunCMake/CXXModules/NoCXX20.cmake index d502f7c..b7372e8 100644 --- a/Tests/RunCMake/CXXModules/NoCXX20.cmake +++ b/Tests/RunCMake/CXXModules/NoCXX20.cmake @@ -5,6 +5,7 @@ target_sources(nocxx20 PUBLIC FILE_SET fs TYPE CXX_MODULES FILES sources/module.cxx) -target_compile_features(nocxx20 - PRIVATE - cxx_std_17) +set_target_properties(nocxx20 + PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON) -- cgit v0.12