Commit 2c4e9fa1 authored by Kitware Robot's avatar Kitware Robot Committed by Brad King

KWSys 2016-06-30 (96f06c8e)

Code extracted from:

    http://public.kitware.com/KWSys.git

at commit 96f06c8e93d2b5e0395c9f413d1649563a2015d8 (master).

Upstream Shortlog
-----------------

Ben Boeckel (3):
      069a6b37 windows: check for _WIN32 rather than WIN32
      f6867bb7 SystemTools: flip junction deletion around
      3392da1d SystemTools: add buffer around preproc conditions

Brad King (1):
      96f06c8e Drop the auto_ptr.hxx component of KWSys

Felix Geyer (1):
      b51abb30 SystemInformation: Fix spelling typos in comments

Mariusz Pluciński (1):
      6b60c184 SystemInformation: Fix compilation on VS Clang/C2 toolset

Zack Galbreath (1):
      36d8666f Process: Add function to reset the start time of a process
parent bc53d3db
Pipeline #18309 passed with stage
......@@ -663,7 +663,6 @@ SET(KWSYS_CLASSES)
SET(KWSYS_H_FILES Configure SharedForward)
SET(KWSYS_HXX_FILES Configure String
hashtable hash_fun hash_map hash_set
auto_ptr
)
# Add selected C++ classes.
......@@ -903,7 +902,6 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
# C++ tests
IF(NOT WATCOM)
SET(KWSYS_CXX_TESTS
testAutoPtr
testHashSTL
)
ENDIF()
......
......@@ -77,6 +77,7 @@
# define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit)
# define kwsysProcess_Interrupt kwsys_ns(Process_Interrupt)
# define kwsysProcess_Kill kwsys_ns(Process_Kill)
# define kwsysProcess_ResetStartTime kwsys_ns(Process_ResetStartTime)
#endif
#if defined(__cplusplus)
......@@ -392,6 +393,11 @@ kwsysEXPORT void kwsysProcess_Interrupt(kwsysProcess* cp);
*/
kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
/**
* Reset the start time of the child process to the current time.
*/
kwsysEXPORT void kwsysProcess_ResetStartTime(kwsysProcess* cp);
#if defined(__cplusplus)
} /* extern "C" */
#endif
......@@ -456,6 +462,7 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
# undef kwsysProcess_WaitForExit
# undef kwsysProcess_Interrupt
# undef kwsysProcess_Kill
# undef kwsysProcess_ResetStartTime
# endif
#endif
......
......@@ -3058,3 +3058,14 @@ static void kwsysProcessesSignalHandler(int signum
errno = old_errno;
}
/*--------------------------------------------------------------------------*/
void kwsysProcess_ResetStartTime(kwsysProcess* cp)
{
if(!cp)
{
return;
}
/* Reset start time. */
cp->StartTime = kwsysProcessTimeGetCurrent();
}
......@@ -3017,3 +3017,14 @@ static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType)
/* Continue on to default Ctrl handler (which calls ExitProcess). */
return FALSE;
}
/*--------------------------------------------------------------------------*/
void kwsysProcess_ResetStartTime(kwsysProcess* cp)
{
if(!cp)
{
return;
}
/* Reset start time. */
cp->StartTime = kwsysProcessTimeGetCurrent();
}
......@@ -376,7 +376,7 @@ bool RegularExpression::compile (const char* exp) {
}
// Allocate space.
//#ifndef WIN32
//#ifndef _WIN32
if (this->program != 0) delete [] this->program;
//#endif
this->program = new char[regsize];
......
......@@ -333,7 +333,7 @@ inline RegularExpression::RegularExpression (const std::string& s)
*/
inline RegularExpression::~RegularExpression ()
{
//#ifndef WIN32
//#ifndef _WIN32
delete [] this->program;
//#endif
}
......@@ -396,7 +396,7 @@ inline bool RegularExpression::is_valid () const
inline void RegularExpression::set_invalid ()
{
//#ifndef WIN32
//#ifndef _WIN32
delete [] this->program;
//#endif
this->program = 0;
......
......@@ -200,13 +200,13 @@ typedef struct rlimit ResourceLimitType;
# endif
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64)
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) && !defined(__clang__)
#define USE_ASM_INSTRUCTIONS 1
#else
#define USE_ASM_INSTRUCTIONS 0
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__)
#include <intrin.h>
#define USE_CPUID_INTRINSICS 1
#else
......@@ -1583,7 +1583,7 @@ SystemInformationImplementation::~SystemInformationImplementation()
void SystemInformationImplementation::RunCPUCheck()
{
#ifdef WIN32
#ifdef _WIN32
// Check to see if this processor supports CPUID.
bool supportsCPUID = DoesCPUSupportCPUID();
......@@ -2056,7 +2056,7 @@ bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature)
void SystemInformationImplementation::Delay(unsigned int uiMS)
{
#ifdef WIN32
#ifdef _WIN32
LARGE_INTEGER Frequency, StartCounter, EndCounter;
__int64 x;
......@@ -2339,7 +2339,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails()
case 13: TLBCacheUnit = ((TLBCacheData[3] & 0x00FF0000) >> 16); break;
case 14: TLBCacheUnit = ((TLBCacheData[3] & 0xFF000000) >> 24); break;
// Default case - an error has occured.
// Default case - an error has occurred.
default: return false;
}
......@@ -2401,7 +2401,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails()
case 0x96: STORE_TLBCACHE_INFO (TLBCode, 262144); break; // <-- FIXME: IA-64 Only
case 0x9b: STORE_TLBCACHE_INFO (TLBCode, 262144); break; // <-- FIXME: IA-64 Only
// Default case - an error has occured.
// Default case - an error has occurred.
default: return false;
}
}
......
......@@ -2855,6 +2855,7 @@ static bool DeleteJunction(const std::wstring& source)
return false;
#endif
}
#endif
bool SystemTools::RemoveFile(const std::string& source)
......@@ -2884,9 +2885,9 @@ bool SystemTools::RemoveFile(const std::string& source)
SetLastError(err);
return false;
}
if (IsJunction(ws) && !DeleteJunction(ws))
if (IsJunction(ws) && DeleteJunction(ws))
{
return false;
return true;
}
if (DeleteFileW(ws.c_str()) ||
GetLastError() == ERROR_FILE_NOT_FOUND ||
......
/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef @KWSYS_NAMESPACE@_auto_ptr_hxx
#define @KWSYS_NAMESPACE@_auto_ptr_hxx
#include <@KWSYS_NAMESPACE@/Configure.hxx>
// The HP compiler and VS6 cannot handle the conversions necessary to use
// auto_ptr_ref to pass an auto_ptr returned from one function
// directly to another function as in use_auto_ptr(get_auto_ptr()).
// We instead use const_cast to achieve the syntax on those platforms.
// We do not use const_cast on other platforms to maintain the C++
// standard design and guarantee that if an auto_ptr is bound
// to a reference-to-const then ownership will be maintained.
#if defined(__HP_aCC) || (defined(_MSC_VER) && _MSC_VER <= 1200)
# define @KWSYS_NAMESPACE@_AUTO_PTR_REF 0
# define @KWSYS_NAMESPACE@_AUTO_PTR_CONST const
# define @KWSYS_NAMESPACE@_AUTO_PTR_CAST(a) cast(a)
#else
# define @KWSYS_NAMESPACE@_AUTO_PTR_REF 1
# define @KWSYS_NAMESPACE@_AUTO_PTR_CONST
# define @KWSYS_NAMESPACE@_AUTO_PTR_CAST(a) a
#endif
// In C++11, clang will warn about using dynamic exception specifications
// as they are deprecated. But as this class is trying to faithfully
// mimic std::auto_ptr, we want to keep the 'throw()' decorations below.
// So we suppress the warning.
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wdeprecated")
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated"
# endif
#endif
namespace @KWSYS_NAMESPACE@
{
template <class X> class auto_ptr;
#if @KWSYS_NAMESPACE@_AUTO_PTR_REF
namespace detail
{
// The auto_ptr_ref template is supposed to be a private member of
// auto_ptr but Borland 5.8 cannot handle it. Instead put it in
// a private namespace.
template <class Y> struct auto_ptr_ref
{
Y* p_;
// The extra constructor argument prevents implicit conversion to
// auto_ptr_ref from auto_ptr through the constructor. Normally
// this should be done with the explicit keyword but Borland 5.x
// generates code in the conversion operator to call itself
// infinately.
auto_ptr_ref(Y* p, int): p_(p) {}
};
}
#endif
/** C++98 Standard Section 20.4.5 - Template class auto_ptr. */
template <class X>
class auto_ptr
{
#if !@KWSYS_NAMESPACE@_AUTO_PTR_REF
template <typename Y>
static inline auto_ptr<Y>& cast(auto_ptr<Y> const& a)
{ return const_cast<auto_ptr<Y>&>(a); }
#endif
/** The pointer to the object held. */
X* x_;
public:
/** The type of object held by the auto_ptr. */
typedef X element_type;
/** Construct from an auto_ptr holding a compatible object. This
transfers ownership to the newly constructed auto_ptr. */
template <class Y>
auto_ptr(auto_ptr<Y> @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw():
x_(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release())
{
}
/** Assign from an auto_ptr holding a compatible object. This
transfers ownership to the left-hand-side of the assignment. */
template <class Y>
auto_ptr& operator=(auto_ptr<Y> @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw()
{
this->reset(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release());
return *this;
}
/**
* Explicitly construct from a raw pointer. This is typically
* called with the result of operator new. For example:
*
* auto_ptr<X> ptr(new X());
*/
explicit auto_ptr(X* p=0) throw(): x_(p)
{
}
/** Construct from another auto_ptr holding an object of the same
type. This transfers ownership to the newly constructed
auto_ptr. */
auto_ptr(auto_ptr @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw():
x_(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release())
{
}
/** Assign from another auto_ptr holding an object of the same type.
This transfers ownership to the newly constructed auto_ptr. */
auto_ptr& operator=(auto_ptr @KWSYS_NAMESPACE@_AUTO_PTR_CONST& a) throw()
{
this->reset(@KWSYS_NAMESPACE@_AUTO_PTR_CAST(a).release());
return *this;
}
/** Destruct and delete the object held. */
~auto_ptr() throw()
{
// Assume object destructor is nothrow.
delete this->x_;
}
/** Dereference and return a reference to the object held. */
X& operator*() const throw()
{
return *this->x_;
}
/** Return a pointer to the object held. */
X* operator->() const throw()
{
return this->x_;
}
/** Return a pointer to the object held. */
X* get() const throw()
{
return this->x_;
}
/** Return a pointer to the object held and reset to hold no object.
This transfers ownership to the caller. */
X* release() throw()
{
X* x = this->x_;
this->x_ = 0;
return x;
}
/** Assume ownership of the given object. The object previously
held is deleted. */
void reset(X* p=0) throw()
{
if(this->x_ != p)
{
// Assume object destructor is nothrow.
delete this->x_;
this->x_ = p;
}
}
/** Convert to an auto_ptr holding an object of a compatible type.
This transfers ownership to the returned auto_ptr. */
template <class Y> operator auto_ptr<Y>() throw()
{
return auto_ptr<Y>(this->release());
}
#if @KWSYS_NAMESPACE@_AUTO_PTR_REF
/** Construct from an auto_ptr_ref. This is used when the
constructor argument is a call to a function returning an
auto_ptr. */
auto_ptr(detail::auto_ptr_ref<X> r) throw(): x_(r.p_)
{
}
/** Assign from an auto_ptr_ref. This is used when a function
returning an auto_ptr is passed on the right-hand-side of an
assignment. */
auto_ptr& operator=(detail::auto_ptr_ref<X> r) throw()
{
this->reset(r.p_);
return *this;
}
/** Convert to an auto_ptr_ref. This is used when a function
returning an auto_ptr is the argument to the constructor of
another auto_ptr. */
template <class Y> operator detail::auto_ptr_ref<Y>() throw()
{
return detail::auto_ptr_ref<Y>(this->release(), 1);
}
#endif
};
} // namespace @KWSYS_NAMESPACE@
// Undo warning suppression.
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wdeprecated")
# pragma clang diagnostic pop
# endif
#endif
#endif
/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifdef __BORLANDC__
# pragma warn -8027 /* 'for' not inlined. */
# pragma warn -8026 /* exception not inlined. */
#endif
#include "kwsysPrivate.h"
#include KWSYS_HEADER(auto_ptr.hxx)
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "auto_ptr.hxx.in"
#endif
#include <stdio.h>
#define ASSERT(x,y) if (!(x)) { printf("FAIL: " y "\n"); status = 1; }
int instances = 0; // don't declare as static
struct A
{
A() { ++instances; }
~A() { --instances; }
A* self() {return this; }
};
struct B: public A {};
static int function_call(kwsys::auto_ptr<A> a)
{
return a.get()? 1:0;
}
static A* get_A(A& a) { return &a; }
static kwsys::auto_ptr<A> generate_auto_ptr_A()
{
return kwsys::auto_ptr<A>(new A);
}
static kwsys::auto_ptr<B> generate_auto_ptr_B()
{
return kwsys::auto_ptr<B>(new B);
}
int testAutoPtr(int, char*[])
{
int status = 0;
// Keep everything in a subscope so we can detect leaks.
{
kwsys::auto_ptr<A> pa0;
kwsys::auto_ptr<A> pa1(new A());
kwsys::auto_ptr<B> pb1(new B());
kwsys::auto_ptr<B> pb2(new B());
kwsys::auto_ptr<A> pa2(new B());
A* ptr = get_A(*pa1);
ASSERT(ptr == pa1.get(),
"auto_ptr does not return correct object when dereferenced");
ptr = pa1->self();
ASSERT(ptr == pa1.get(),
"auto_ptr does not return correct pointer from operator->");
A* before = pa0.get();
pa0.reset(new A());
ASSERT(pa0.get() && pa0.get() != before,
"auto_ptr empty after reset(new A())");
before = pa0.get();
pa0.reset(new B());
ASSERT(pa0.get() && pa0.get() != before,
"auto_ptr empty after reset(new B())");
delete pa0.release();
ASSERT(!pa0.get(), "auto_ptr holds an object after release()");
kwsys::auto_ptr<A> pa3(pb1);
ASSERT(!pb1.get(),
"auto_ptr full after being used to construct another");
ASSERT(pa3.get(),
"auto_ptr empty after construction from another");
{
kwsys::auto_ptr<A> pa;
pa = pa3;
ASSERT(!pa3.get(),
"auto_ptr full after assignment to another");
ASSERT(pa.get(),
"auto_ptr empty after assignment from another");
}
{
kwsys::auto_ptr<A> pa;
pa = pb2;
ASSERT(!pb2.get(),
"auto_ptr full after assignment to compatible");
ASSERT(pa.get(),
"auto_ptr empty after assignment from compatible");
}
{
int receive = function_call(pa2);
ASSERT(receive,
"auto_ptr did not receive ownership in called function");
ASSERT(!pa2.get(),
"auto_ptr did not release ownership to called function");
}
{
int received = function_call(generate_auto_ptr_A());
ASSERT(received,
"auto_ptr in called function did not take ownership "
"from factory function");
}
#if 0
// Is this allowed by the standard?
{
int received = function_call(generate_auto_ptr_B());
ASSERT(received,
"auto_ptr in called function did not take ownership "
"from factory function with conversion");
}
#endif
{
kwsys::auto_ptr<A> pa(generate_auto_ptr_A());
ASSERT(pa.get(),
"auto_ptr empty after construction from factory function");
}
{
kwsys::auto_ptr<A> pa;
pa = generate_auto_ptr_A();
ASSERT(pa.get(),
"auto_ptr empty after assignment from factory function");
}
{
kwsys::auto_ptr<A> pa(generate_auto_ptr_B());
ASSERT(pa.get(),
"auto_ptr empty after construction from compatible factory function");
}
{
kwsys::auto_ptr<A> pa;
pa = generate_auto_ptr_B();
ASSERT(pa.get(),
"auto_ptr empty after assignment from compatible factory function");
}
}
ASSERT(instances == 0, "auto_ptr leaked an object");
return status;
}
......@@ -120,7 +120,7 @@ static int testRobustEncoding()
ret++;
}
#ifdef WIN32
#ifdef _WIN32
// 16 bit wchar_t - we make an invalid surrogate pair
wchar_t cwstr[] = {0xD801, 0xDA00, 0};
// this conversion could fail
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment