summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/CTestConfig.cmake4
-rw-r--r--Source/kwsys/Glob.cxx2
-rw-r--r--Source/kwsys/Glob.hxx.in4
-rw-r--r--Source/kwsys/ProcessUNIX.c6
-rw-r--r--Source/kwsys/SystemInformation.cxx29
-rw-r--r--Source/kwsys/SystemTools.cxx46
-rw-r--r--Source/kwsys/SystemTools.hxx.in9
-rw-r--r--Source/kwsys/testProcess.c11
-rw-r--r--Source/kwsys/testSystemTools.cxx22
9 files changed, 60 insertions, 73 deletions
diff --git a/Source/kwsys/CTestConfig.cmake b/Source/kwsys/CTestConfig.cmake
index 33ea84c..12347b6 100644
--- a/Source/kwsys/CTestConfig.cmake
+++ b/Source/kwsys/CTestConfig.cmake
@@ -3,7 +3,9 @@
set(CTEST_PROJECT_NAME "KWSys")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DROP_METHOD "http")
+if (NOT CTEST_DROP_METHOD STREQUAL "https")
+ set(CTEST_DROP_METHOD "http")
+endif ()
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index 5452f73..c6d4b19 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -27,7 +27,7 @@
#include <cstdio>
#include <cstring>
namespace KWSYS_NAMESPACE {
-#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__APPLE__)
// On Windows and Apple, no difference between lower and upper case
# define KWSYS_GLOB_CASE_INDEPENDENT
#endif
diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in
index b5a34d5..e8474e2 100644
--- a/Source/kwsys/Glob.hxx.in
+++ b/Source/kwsys/Glob.hxx.in
@@ -126,8 +126,8 @@ protected:
bool RecurseListDirs;
private:
- Glob(const Glob&); // Not implemented.
- void operator=(const Glob&); // Not implemented.
+ Glob(const Glob&) = delete;
+ void operator=(const Glob&) = delete;
};
} // namespace @KWSYS_NAMESPACE@
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index cc45529..e1e7721 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -2128,17 +2128,17 @@ static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig,
#endif
#ifdef SIGABRT
case SIGABRT:
- KWSYSPE_CASE(Other, "Child aborted");
+ KWSYSPE_CASE(Other, "Subprocess aborted");
break;
#endif
#ifdef SIGKILL
case SIGKILL:
- KWSYSPE_CASE(Other, "Child killed");
+ KWSYSPE_CASE(Other, "Subprocess killed");
break;
#endif
#ifdef SIGTERM
case SIGTERM:
- KWSYSPE_CASE(Other, "Child terminated");
+ KWSYSPE_CASE(Other, "Subprocess terminated");
break;
#endif
#ifdef SIGHUP
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index ed1cdc0..9c34a56 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -863,7 +863,7 @@ void SystemInformation::RunMemoryCheck()
// Hide implementation details in an anonymous namespace.
namespace {
// *****************************************************************************
-#if defined(__linux) || defined(__APPLE__)
+#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
int LoadLines(FILE* file, std::vector<std::string>& lines)
{
// Load each line in the given file into a the vector.
@@ -893,7 +893,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
return nRead;
}
-# if defined(__linux)
+# if defined(__linux) || defined(__CYGWIN__)
// *****************************************************************************
int LoadLines(const char* fileName, std::vector<std::string>& lines)
{
@@ -926,7 +926,7 @@ int NameValue(std::vector<std::string> const& lines, std::string const& name,
}
#endif
-#if defined(__linux)
+#if defined(__linux) || defined(__CYGWIN__)
// ****************************************************************************
template <typename T>
int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
@@ -3393,7 +3393,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
pos = buffer.find("processor\t", pos + 1);
}
-#ifdef __linux
+#if defined(__linux) || defined(__CYGWIN__)
// Count sockets.
std::set<int> PhysicalIDs;
std::string idc = this->ExtractValueFromCpuInfoFile(buffer, "physical id");
@@ -3414,8 +3414,8 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
this->NumberOfPhysicalCPU =
NumberOfCoresPerSocket * (unsigned int)NumberOfSockets;
-#else // __CYGWIN__
- // does not have "physical id" entries, neither "cpu cores"
+#else
+ // For systems which do not have "physical id" entries, neither "cpu cores"
// this has to be fixed for hyper-threading.
std::string cpucount =
this->ExtractValueFromCpuInfoFile(buffer, "cpu count");
@@ -3597,7 +3597,7 @@ long long SystemInformationImplementation::GetHostMemoryTotal()
GlobalMemoryStatusEx(&statex);
return statex.ullTotalPhys / 1024;
# endif
-#elif defined(__linux)
+#elif defined(__linux) || defined(__CYGWIN__)
long long memTotal = 0;
int ierr = GetFieldFromFile("/proc/meminfo", "MemTotal:", memTotal);
if (ierr) {
@@ -3712,6 +3712,16 @@ long long SystemInformationImplementation::GetHostMemoryUsed()
GlobalMemoryStatusEx(&statex);
return (statex.ullTotalPhys - statex.ullAvailPhys) / 1024;
# endif
+#elif defined(__CYGWIN__)
+ const char* names[3] = { "MemTotal:", "MemFree:", nullptr };
+ long long values[2] = { 0 };
+ int ierr = GetFieldsFromFile("/proc/meminfo", names, values);
+ if (ierr) {
+ return ierr;
+ }
+ long long& memTotal = values[0];
+ long long& memFree = values[1];
+ return memTotal - memFree;
#elif defined(__linux)
// First try to use MemAvailable, but it only works on newer kernels
const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr };
@@ -3773,7 +3783,7 @@ long long SystemInformationImplementation::GetProcMemoryUsed()
return -2;
}
return pmc.WorkingSetSize / 1024;
-#elif defined(__linux)
+#elif defined(__linux) || defined(__CYGWIN__)
long long memUsed = 0;
int ierr = GetFieldFromFile("/proc/self/status", "VmRSS:", memUsed);
if (ierr) {
@@ -3850,7 +3860,8 @@ long long SystemInformationImplementation::GetProcessId()
#if defined(_WIN32)
return GetCurrentProcessId();
#elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \
- defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+ defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
+ defined(__CYGWIN__)
return getpid();
#else
return -1;
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 25705ea..6144d9c 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -96,19 +96,12 @@
# if defined(_MSC_VER) && _MSC_VER >= 1800
# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# endif
-#elif defined(__CYGWIN__)
-# include <windows.h>
-# undef _WIN32
#endif
#if !KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
extern char** environ;
#endif
-#ifdef __CYGWIN__
-# include <sys/cygwin.h>
-#endif
-
// getpwnam doesn't exist on Windows and Cray Xt3/Catamount
// same for TIOCGWINSZ
#if defined(_WIN32) || defined(__LIBCATAMOUNT__) || \
@@ -1290,15 +1283,7 @@ bool SystemTools::PathExists(const std::string& path)
if (path.empty()) {
return false;
}
-#if defined(__CYGWIN__)
- // Convert path to native windows path if possible.
- char winpath[MAX_PATH];
- if (SystemTools::PathCygwinToWin32(path.c_str(), winpath)) {
- return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES);
- }
- struct stat st;
- return lstat(path.c_str(), &st) == 0;
-#elif defined(_WIN32)
+#if defined(_WIN32)
return (GetFileAttributesW(Encoding::ToWindowsExtendedPath(path).c_str()) !=
INVALID_FILE_ATTRIBUTES);
#else
@@ -1320,14 +1305,7 @@ bool SystemTools::FileExists(const std::string& filename)
if (filename.empty()) {
return false;
}
-#if defined(__CYGWIN__)
- // Convert filename to native windows path if possible.
- char winpath[MAX_PATH];
- if (SystemTools::PathCygwinToWin32(filename.c_str(), winpath)) {
- return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES);
- }
- return access(filename.c_str(), R_OK) == 0;
-#elif defined(_WIN32)
+#if defined(_WIN32)
DWORD attr =
GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str());
if (attr == INVALID_FILE_ATTRIBUTES) {
@@ -1433,27 +1411,9 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
#endif
}
-#ifdef __CYGWIN__
-bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
-{
- auto itr = SystemToolsStatics->Cyg2Win32Map.find(path);
- if (itr != SystemToolsStatics->Cyg2Win32Map.end()) {
- strncpy(win32_path, itr->second.c_str(), MAX_PATH);
- } else {
- if (cygwin_conv_path(CCP_POSIX_TO_WIN_A, path, win32_path, MAX_PATH) !=
- 0) {
- win32_path[0] = 0;
- }
- SystemToolsStatics->Cyg2Win32Map.insert(
- SystemToolsStatic::StringMap::value_type(path, win32_path));
- }
- return win32_path[0] != 0;
-}
-#endif
-
bool SystemTools::Touch(const std::string& filename, bool create)
{
- if (!SystemTools::PathExists(filename)) {
+ if (!SystemTools::FileExists(filename)) {
if (create) {
FILE* file = Fopen(filename, "a+b");
if (file) {
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 5dbb726..74dc176 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -331,15 +331,6 @@ public:
static int Stat(const char* path, Stat_t* buf);
static int Stat(const std::string& path, Stat_t* buf);
-/**
- * Converts Cygwin path to Win32 path. Uses dictionary container for
- * caching and calls to cygwin_conv_to_win32_path from Cygwin dll
- * for actual translation. Returns true on success, else false.
- */
-#ifdef __CYGWIN__
- static bool PathCygwinToWin32(const char* path, char* win32_path);
-#endif
-
/**
* Return file length
*/
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index 0c658f5..eed770c 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -450,24 +450,25 @@ static int runChild2(kwsysProcess* kp, const char* cmd[], int state,
printf("The process is still executing.\n");
break;
case kwsysProcess_State_Expired:
- printf("Child was killed when timeout expired.\n");
+ printf("Subprocess was killed when timeout expired.\n");
break;
case kwsysProcess_State_Exited:
- printf("Child exited with value = %d\n", kwsysProcess_GetExitValue(kp));
+ printf("Subprocess exited with value = %d\n",
+ kwsysProcess_GetExitValue(kp));
result = ((exception != kwsysProcess_GetExitException(kp)) ||
(value != kwsysProcess_GetExitValue(kp)));
break;
case kwsysProcess_State_Killed:
- printf("Child was killed by parent.\n");
+ printf("Subprocess was killed by parent.\n");
break;
case kwsysProcess_State_Exception:
- printf("Child terminated abnormally: %s\n",
+ printf("Subprocess terminated abnormally: %s\n",
kwsysProcess_GetExceptionString(kp));
result = ((exception != kwsysProcess_GetExitException(kp)) ||
(value != kwsysProcess_GetExitValue(kp)));
break;
case kwsysProcess_State_Disowned:
- printf("Child was disowned.\n");
+ printf("Subprocess was disowned.\n");
break;
case kwsysProcess_State_Error:
printf("Error in administrating child process: [%s]\n",
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 1d34614..cfa420d 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -422,6 +422,28 @@ static bool CheckFileOperations()
res = false;
}
+#if !defined(_WIN32)
+ std::string const testBadSymlink(testNewDir + "/badSymlink.txt");
+ std::string const testBadSymlinkTgt(testNewDir + "/missing/symlinkTgt.txt");
+ if (!kwsys::SystemTools::CreateSymlink(testBadSymlinkTgt, testBadSymlink)) {
+ std::cerr << "Problem with CreateSymlink for: " << testBadSymlink << " -> "
+ << testBadSymlinkTgt << std::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::Touch(testBadSymlink, false)) {
+ std::cerr << "Problem with Touch (no create) for: " << testBadSymlink
+ << std::endl;
+ res = false;
+ }
+#endif
+
+ if (!kwsys::SystemTools::Touch(testNewDir, false)) {
+ std::cerr << "Problem with Touch (no create) for: " << testNewDir
+ << std::endl;
+ res = false;
+ }
+
kwsys::SystemTools::Touch(testNewFile, true);
if (!kwsys::SystemTools::RemoveADirectory(testNewDir)) {
std::cerr << "Problem with RemoveADirectory for: " << testNewDir