Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update kwsys #3765

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions thirdparty/KWSys/adios2sys/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.git* export-ignore
# import off
.gitattributes -export-ignore
.hooks* export-ignore

# Custom attribute to mark sources as using the kwsys C code style.
[attr]kwsys-c-style whitespace=tab-in-indent format.clang-format=15

/GitSetup export-ignore
/*.sh export-ignore eol=lf
/*.bash export-ignore eol=lf
/.clang-format export-ignore
# import on

*.c kwsys-c-style
*.c.in kwsys-c-style
*.cxx kwsys-c-style
*.h kwsys-c-style
*.h.in kwsys-c-style
*.hxx kwsys-c-style
*.hxx.in kwsys-c-style

*.cmake whitespace=tab-in-indent
*.rst whitespace=tab-in-indent conflict-marker-size=79
*.txt whitespace=tab-in-indent
38 changes: 9 additions & 29 deletions thirdparty/KWSys/adios2sys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,7 @@
# any outside mailing list and no documentation of the change will be
# written.

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
foreach(p
CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature.
CMP0063 # CMake 3.3, Honor visibility properties for all target types.
CMP0067 # CMake 3.8, Honor language standard in try_compile source-file signature.
CMP0069 # CMake 3.9, INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
)
if(POLICY ${p})
cmake_policy(SET ${p} NEW)
endif()
endforeach()
cmake_minimum_required(VERSION 3.9...3.22 FATAL_ERROR)

# Some configure checks depend upon the deployment target. Clear checks when
# the deployment target changes.
Expand Down Expand Up @@ -211,11 +201,7 @@ endif()

# Enable testing if building standalone.
if(KWSYS_STANDALONE)
include(Dart)
mark_as_advanced(BUILD_TESTING DART_ROOT TCL_TCLSH)
if(BUILD_TESTING)
enable_testing()
endif()
include(CTest)
endif()

# Choose default shared/static build if not specified.
Expand Down Expand Up @@ -640,8 +626,8 @@ endif()
# Build a list of classes and headers we need to implement the
# selected components. Initialize with required components.
set(KWSYS_CLASSES)
set(KWSYS_H_FILES Configure SharedForward)
set(KWSYS_HXX_FILES Configure String)
set(KWSYS_H_FILES Configure)
set(KWSYS_HXX_FILES Configure)

# Add selected C++ classes.
set(cppclasses
Expand Down Expand Up @@ -1048,6 +1034,10 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE})
target_link_libraries(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_TARGET_LINK})
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx APPEND PROPERTY COMPILE_DEFINITIONS BUILD_CONFIG="$<CONFIG>")
endif()

set(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
Expand Down Expand Up @@ -1111,7 +1101,7 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
# Some Apple compilers produce bad optimizations in this source.
if(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$")
set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -O0")
elseif(CMAKE_C_COMPILER_ID STREQUAL "XL")
elseif(CMAKE_C_COMPILER_ID MATCHES "^(XL|XLClang)$")
# Tell IBM XL not to warn about our test infinite loop
if(CMAKE_SYSTEM MATCHES "Linux.*ppc64le"
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "16.1.0"
Expand All @@ -1128,16 +1118,6 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
endif()
set_property(SOURCE testProcess.c PROPERTY COMPILE_FLAGS "${testProcess_COMPILE_FLAGS}")

# Test SharedForward
configure_file(${PROJECT_SOURCE_DIR}/testSharedForward.c.in
${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE)
add_executable(${KWSYS_NAMESPACE}TestSharedForward
${PROJECT_BINARY_DIR}/testSharedForward.c)
set_property(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE})
add_dependencies(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_TARGET_C_LINK})
add_test(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1)
set_property(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST})

# Configure some test properties.
if(KWSYS_STANDALONE)
# We expect test to fail
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/KWSys/adios2sys/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ copies of KWSys within dependent projects can be updated to get the changes.
Code Style
==========

We use `clang-format`_ version **6.0** to define our style for C++ code in
We use `clang-format`_ version **15** to define our style for C++ code in
the KWSys source tree. See the `.clang-format`_ configuration file for
our style settings. Use the `clang-format.bash`_ script to format source
code. It automatically runs ``clang-format`` on the set of source files
Expand Down
15 changes: 7 additions & 8 deletions thirdparty/KWSys/adios2sys/CommandLineArguments.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
#include KWSYS_HEADER(CommandLineArguments.hxx)

#include KWSYS_HEADER(Configure.hxx)
#include KWSYS_HEADER(String.hxx)

// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "CommandLineArguments.hxx.in"
# include "Configure.hxx.in"
# include "String.hxx.in"
#endif

#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#include <cstdio>
Expand Down Expand Up @@ -52,14 +51,14 @@ struct CommandLineArgumentsCallbackStructure
const char* Help;
};

class CommandLineArgumentsVectorOfStrings : public std::vector<kwsys::String>
class CommandLineArgumentsVectorOfStrings : public std::vector<std::string>
{
};
class CommandLineArgumentsSetOfStrings : public std::set<kwsys::String>
class CommandLineArgumentsSetOfStrings : public std::set<std::string>
{
};
class CommandLineArgumentsMapOfStrucs
: public std::map<kwsys::String, CommandLineArgumentsCallbackStructure>
: public std::map<std::string, CommandLineArgumentsCallbackStructure>
{
};

Expand All @@ -70,7 +69,7 @@ class CommandLineArgumentsInternal

using VectorOfStrings = CommandLineArgumentsVectorOfStrings;
using CallbacksMap = CommandLineArgumentsMapOfStrucs;
using String = kwsys::String;
using String = std::string;
using SetOfStrings = CommandLineArgumentsSetOfStrings;

VectorOfStrings Argv;
Expand Down Expand Up @@ -306,7 +305,7 @@ void CommandLineArguments::GetUnusedArguments(int* argc, char*** argv)

// Copy everything after the LastArgument, since that was not parsed.
for (cc = 0; cc < this->Internals->UnusedArguments.size(); cc++) {
kwsys::String& str = this->Internals->UnusedArguments[cc];
std::string& str = this->Internals->UnusedArguments[cc];
args[cnt] = new char[str.size() + 1];
strcpy(args[cnt], str.c_str());
cnt++;
Expand All @@ -319,7 +318,7 @@ void CommandLineArguments::DeleteRemainingArguments(int argc, char*** argv)
{
int cc;
for (cc = 0; cc < argc; ++cc) {
delete[](*argv)[cc];
delete[] (*argv)[cc];
}
delete[] * argv;
}
Expand Down
39 changes: 20 additions & 19 deletions thirdparty/KWSys/adios2sys/Directory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class DirectoryInternals
{
std::string Name;
#if defined(_WIN32) && !defined(__CYGWIN__)
_wfinddata_t FindData;
WIN32_FIND_DATAW FindData;
#endif
FileData(std::string name
#if defined(_WIN32) && !defined(__CYGWIN__)
,
_wfinddata_t data
WIN32_FIND_DATAW data
#endif
)
: Name(std::move(name))
Expand Down Expand Up @@ -115,8 +115,8 @@ std::string Directory::GetFilePath(std::size_t i) const
bool Directory::FileIsDirectory(std::size_t i) const
{
#if defined(_WIN32) && !defined(__CYGWIN__)
_wfinddata_t const& data = this->Internal->Files[i].FindData;
return (data.attrib & FILE_ATTRIBUTE_DIRECTORY) != 0;
auto const& data = this->Internal->Files[i].FindData;
return (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
#else
std::string const& path = this->GetFilePath(i);
return kwsys::SystemTools::FileIsDirectory(path);
Expand All @@ -127,9 +127,9 @@ bool Directory::FileIsSymlink(std::size_t i) const
{
std::string const& path = this->GetFilePath(i);
#if defined(_WIN32) && !defined(__CYGWIN__)
_wfinddata_t const& data = this->Internal->Files[i].FindData;
auto const& data = this->Internal->Files[i].FindData;
return kwsys::SystemTools::FileIsSymlinkWithAttr(
Encoding::ToWindowsExtendedPath(path), data.attrib);
Encoding::ToWindowsExtendedPath(path), data.dwFileAttributes);
#else
return kwsys::SystemTools::FileIsSymlink(path);
#endif
Expand Down Expand Up @@ -157,7 +157,7 @@ namespace KWSYS_NAMESPACE {
Status Directory::Load(std::string const& name, std::string* errorMessage)
{
this->Clear();
intptr_t srchHandle;
HANDLE srchHandle;
char* buf;
size_t bufLength;
size_t n = name.size();
Expand All @@ -176,14 +176,14 @@ Status Directory::Load(std::string const& name, std::string* errorMessage)
snprintf(buf, bufLength, "%s/*", name.c_str());
}
}
struct _wfinddata_t data; // data of current file
WIN32_FIND_DATAW data; // data of current file

// Now put them into the file array
srchHandle =
_wfindfirst((wchar_t*)Encoding::ToWindowsExtendedPath(buf).c_str(), &data);
FindFirstFileW(Encoding::ToWindowsExtendedPath(buf).c_str(), &data);
delete[] buf;

if (srchHandle == -1) {
if (srchHandle == INVALID_HANDLE_VALUE) {
Status status = Status::POSIX_errno();
if (errorMessage) {
*errorMessage = status.GetString();
Expand All @@ -193,10 +193,11 @@ Status Directory::Load(std::string const& name, std::string* errorMessage)

// Loop through names
do {
this->Internal->Files.emplace_back(Encoding::ToNarrow(data.name), data);
} while (_wfindnext(srchHandle, &data) != -1);
this->Internal->Files.emplace_back(Encoding::ToNarrow(data.cFileName),
data);
} while (FindNextFileW(srchHandle, &data));
this->Internal->Path = name;
if (_findclose(srchHandle) == -1) {
if (!FindClose(srchHandle)) {
Status status = Status::POSIX_errno();
if (errorMessage) {
*errorMessage = status.GetString();
Expand All @@ -209,7 +210,7 @@ Status Directory::Load(std::string const& name, std::string* errorMessage)
unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
std::string* errorMessage)
{
intptr_t srchHandle;
HANDLE srchHandle;
char* buf;
size_t bufLength;
size_t n = name.size();
Expand All @@ -222,13 +223,13 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
buf = new char[n + 2 + 1];
snprintf(buf, bufLength, "%s/*", name.c_str());
}
struct _wfinddata_t data; // data of current file
WIN32_FIND_DATAW data; // data of current file

// Now put them into the file array
srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
srchHandle = FindFirstFileW(Encoding::ToWide(buf).c_str(), &data);
delete[] buf;

if (srchHandle == -1) {
if (srchHandle == INVALID_HANDLE_VALUE) {
if (errorMessage) {
if (unsigned int errorId = GetLastError()) {
LPSTR message = nullptr;
Expand All @@ -250,8 +251,8 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
unsigned long count = 0;
do {
count++;
} while (_wfindnext(srchHandle, &data) != -1);
_findclose(srchHandle);
} while (FindNextFileW(srchHandle, &data));
FindClose(srchHandle);
return count;
}

Expand Down
4 changes: 2 additions & 2 deletions thirdparty/KWSys/adios2sys/Glob.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
#endif
// Handle drive letters on Windows
if (expr[1] == ':' && expr[0] != '/') {
skip = 2;
}
skip = 2;
}
}

if (skip > 0) {
Expand Down
17 changes: 17 additions & 0 deletions thirdparty/KWSys/adios2sys/ProcessUNIX.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__OpenBSD__)
/* NOLINTNEXTLINE(bugprone-reserved-identifier) */
# define _XOPEN_SOURCE 600
#endif
#include "kwsysPrivate.h"
#include KWSYS_HEADER(Process.h)
#include KWSYS_HEADER(System.h)
Expand Down Expand Up @@ -2007,6 +2011,14 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
return 0;
}

#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wshorten-64-to-32")
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wshorten-64-to-32"
# define KWSYSPE_CLANG_DIAG_WSHORTEN
# endif
#endif

/* Get the length of time before the given timeout time arrives.
Returns 1 if the time has already arrived, and 0 otherwise. */
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
Expand Down Expand Up @@ -2057,6 +2069,11 @@ static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
return current;
}

#if defined(KWSYSPE_CLANG_DIAG_WSHORTEN)
# undef KWSYSPE_CLANG_DIAG_WSHORTEN
# pragma clang diagnostic pop
#endif

static double kwsysProcessTimeToDouble(kwsysProcessTime t)
{
return (double)t.tv_sec + (double)(t.tv_usec) * 0.000001;
Expand Down
5 changes: 3 additions & 2 deletions thirdparty/KWSys/adios2sys/ProcessWin32.c
Original file line number Diff line number Diff line change
Expand Up @@ -2406,8 +2406,9 @@ static int kwsysProcess_List__Next_NT4(kwsysProcess_List* self)
{
if (self->CurrentInfo) {
if (self->CurrentInfo->NextEntryDelta > 0) {
self->CurrentInfo = ((PSYSTEM_PROCESS_INFORMATION)(
(char*)self->CurrentInfo + self->CurrentInfo->NextEntryDelta));
self->CurrentInfo =
((PSYSTEM_PROCESS_INFORMATION)((char*)self->CurrentInfo +
self->CurrentInfo->NextEntryDelta));
return 1;
}
self->CurrentInfo = 0;
Expand Down
Loading
Loading