Merge branch 'development' of https://github.com/o3de/o3de into carlitosan/development
This commit is contained in:
@@ -28,6 +28,7 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
inline static constexpr char FilePathsRootKey[] = "/Amazon/AzCore/Runtime/FilePaths";
|
||||
inline static constexpr char FilePathKey_BinaryFolder[] = "/Amazon/AzCore/Runtime/FilePaths/BinaryFolder";
|
||||
inline static constexpr char FilePathKey_EngineRootFolder[] = "/Amazon/AzCore/Runtime/FilePaths/EngineRootFolder";
|
||||
inline static constexpr char FilePathKey_InstalledBinaryFolder[] = "/Amazon/AzCore/Runtime/FilePaths/InstalledBinariesFolder";
|
||||
|
||||
//! Stores the absolute path to root of a project's cache. No asset platform in this path, this is where the asset database file lives.
|
||||
//! i.e. <ProjectPath>/Cache
|
||||
|
||||
@@ -21,7 +21,18 @@ namespace AZStd
|
||||
{
|
||||
// alias std::pointer_traits into the AZStd::namespace
|
||||
using std::pointer_traits;
|
||||
|
||||
//! Bring the names of uninitialized_default_construct and
|
||||
//! uninitialized_default_construct_n into the AZStd namespace
|
||||
using std::uninitialized_default_construct;
|
||||
using std::uninitialized_default_construct_n;
|
||||
|
||||
//! uninitialized_value_construct and uninitialized_value_construct_n
|
||||
//! are now brought into scope of the AZStd namespace
|
||||
using std::uninitialized_value_construct;
|
||||
using std::uninitialized_value_construct_n;
|
||||
}
|
||||
|
||||
namespace AZStd::Internal
|
||||
{
|
||||
template <typename T, typename = void>
|
||||
@@ -223,107 +234,6 @@ namespace AZStd
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
//! C++20 implementation of uninitialized_default_construct
|
||||
//! Initializes objects by default-initialization via placement new
|
||||
//! Ex. `new(declval<void*>()) T` - Notice no parenthesis after T
|
||||
//! This performs default initialization instead of value initialization
|
||||
//! Default initialization performs the following actions
|
||||
//! # If T is a class type it considers constructors which can be invoked
|
||||
//! with an empty argument list. The selected constructor is invoked
|
||||
//! to provide the initial value of the object
|
||||
//! # If T is an array type, then default initialization is performed
|
||||
//! on each array element
|
||||
//! # Otherwise nothing is done and objects with automatic storage duration(i.e scope)
|
||||
//! are initialized with indeterminate values
|
||||
//! For example given the following struct
|
||||
//! struct Foo
|
||||
//! {
|
||||
//! int mint;
|
||||
//! double bubble;
|
||||
//! };
|
||||
//! Invoking uninitialized_default_construct(FooPtr, FooPtr + 1)
|
||||
//! Will default initialize the FooPtr object (Foo has an implicitly-defined default constructor)
|
||||
//! The values of mint and bubble are indeterminate
|
||||
template <typename ForwardIt>
|
||||
constexpr auto uninitialized_default_construct(ForwardIt first, ForwardIt last)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, void>
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type;
|
||||
}
|
||||
}
|
||||
// C++20 implementation of uninitialized_default_construct_n
|
||||
// Constructs "n" objects starting at first via default-initialization
|
||||
template <typename ForwardIt, typename Size>
|
||||
constexpr auto uninitialized_default_construct_n(ForwardIt first, Size numElements)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, ForwardIt>
|
||||
{
|
||||
for (; numElements > 0; ++first, --numElements)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type;
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
//! C++20 implementation of uninitialized_value_construct
|
||||
//! Initializes objects by value-initialization via placement new
|
||||
//! Ex. `new(declval<void*>()) T()` - Notice parenthesis are here after T
|
||||
//! value-initialization of an object performs different rules depending
|
||||
//! on the type of T
|
||||
//! Value initialization performs the following actions
|
||||
//! # If T is a class type with no default constructor or with a user-provided
|
||||
//! constructor or a deleted default constructor, then default-initialization
|
||||
//! is performed
|
||||
//! # If T is a class type with a default constructor that is neither
|
||||
//! user-provided nor deleted(i.e a class with an implicitly-defined or defaulted
|
||||
//! default constructor), then the object is zero-initialized and then it is
|
||||
//! default-initialized if it has a non-trivial default constructor
|
||||
//! # If T is an array type, then value initialization is performed
|
||||
//! on each array element
|
||||
//! # Otherwise the object is zero-initialized
|
||||
//! (i.e sets arithmetic and enum objects to 0, bool objects to false, pointers to nullptr)
|
||||
//! For example given the following struct
|
||||
//! struct Foo
|
||||
//! {
|
||||
//! int mint;
|
||||
//! double bubble;
|
||||
//! };
|
||||
//! Invoking uninitialized_default_construct(FooPtr, FooPtr + 1)
|
||||
//! Will value-initialize the FooPtr object.
|
||||
//! The Foo has an implicitly-defined default constructor.
|
||||
//! For aggregates such as int and double this will perform zero-initialization
|
||||
//! which will set their values to 0
|
||||
//! Therefore The values of mint will be 0 and and bubble 0.0
|
||||
template <typename ForwardIt>
|
||||
constexpr auto uninitialized_value_construct(ForwardIt first, ForwardIt last)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, void>
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type();
|
||||
}
|
||||
}
|
||||
// C++20 implementation of uninitialized_default_construct_n
|
||||
// Constructs "n" objects starting at the first via by value-initialization
|
||||
template <typename ForwardIt, typename Size>
|
||||
constexpr auto uninitialized_value_construct_n(ForwardIt first, Size numElements)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, ForwardIt>
|
||||
{
|
||||
for (; numElements > 0; ++first, --numElements)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type();
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd::Internal
|
||||
{
|
||||
|
||||
@@ -25,29 +25,7 @@ namespace AZStd
|
||||
AZStd::sys_time_t GetTimeNowTicks()
|
||||
{
|
||||
AZStd::sys_time_t timeNow;
|
||||
struct timespec ts;
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
kern_return_t ret = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ret = clock_get_time(cclock, &mts);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ts.tv_sec = mts.tv_sec;
|
||||
ts.tv_nsec = mts.tv_nsec;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
timeNow = ts.tv_sec * GetTimeTicksPerSecond() + ts.tv_nsec;
|
||||
timeNow = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
|
||||
return timeNow;
|
||||
}
|
||||
|
||||
@@ -62,29 +40,7 @@ namespace AZStd
|
||||
AZStd::sys_time_t GetTimeNowSecond()
|
||||
{
|
||||
AZStd::sys_time_t timeNowSecond;
|
||||
struct timespec ts;
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
kern_return_t ret = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ret = clock_get_time(cclock, &mts);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ts.tv_sec = mts.tv_sec;
|
||||
ts.tv_nsec = mts.tv_nsec;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
timeNowSecond = ts.tv_sec;
|
||||
timeNowSecond = GetTimeNowTicks()/GetTimeTicksPerSecond();
|
||||
return timeNowSecond;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,4 +134,48 @@ namespace UnitTest
|
||||
EXPECT_FLOAT_EQ(4.0f, resultAddress->m_floatValue);
|
||||
AZStd::destroy_at(resultAddress);
|
||||
}
|
||||
|
||||
TEST(CreateDestroy, UninitializedDefaultConstruct_IsAbleToConstructMultipleElements_Succeeds)
|
||||
{
|
||||
struct RefWrapper
|
||||
{
|
||||
RefWrapper()
|
||||
{}
|
||||
int m_intValue{ 2 };
|
||||
};
|
||||
constexpr size_t ArraySize = 2;
|
||||
AZStd::aligned_storage_for_t<RefWrapper> testArray[ArraySize];
|
||||
RefWrapper(&uninitializedAddress)[2] = reinterpret_cast<RefWrapper(&)[2]>(testArray);
|
||||
AZStd::uninitialized_default_construct(AZStd::begin(uninitializedAddress), AZStd::end(uninitializedAddress));
|
||||
|
||||
|
||||
EXPECT_EQ(2, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(2, uninitializedAddress[1].m_intValue);
|
||||
// Reset uninitializedAddress to Debug pattern
|
||||
memset(uninitializedAddress, 0xCD, ArraySize * sizeof(RefWrapper));
|
||||
AZStd::uninitialized_default_construct_n(AZStd::data(uninitializedAddress), AZStd::size(uninitializedAddress));
|
||||
EXPECT_EQ(2, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(2, uninitializedAddress[1].m_intValue);
|
||||
}
|
||||
|
||||
TEST(CreateDestroy, UninitializedValueConstruct_IsAbleToConstructMultipleElements_Succeeds)
|
||||
{
|
||||
struct RefWrapper
|
||||
{
|
||||
int m_intValue;
|
||||
};
|
||||
constexpr size_t ArraySize = 2;
|
||||
AZStd::aligned_storage_for_t<RefWrapper> testArray[ArraySize];
|
||||
RefWrapper(&uninitializedAddress)[2] = reinterpret_cast<RefWrapper(&)[2]>(testArray);
|
||||
AZStd::uninitialized_value_construct(AZStd::begin(uninitializedAddress), AZStd::end(uninitializedAddress));
|
||||
|
||||
|
||||
EXPECT_EQ(0, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(0, uninitializedAddress[1].m_intValue);
|
||||
// Reset uninitializedAddress to Debug pattern
|
||||
memset(uninitializedAddress, 0xCD, ArraySize * sizeof(RefWrapper));
|
||||
AZStd::uninitialized_value_construct_n(AZStd::data(uninitializedAddress), AZStd::size(uninitializedAddress));
|
||||
EXPECT_EQ(0, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(0, uninitializedAddress[1].m_intValue);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-23
@@ -24,7 +24,9 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/resource.h> // for iopolicy
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern char **environ;
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
@@ -45,7 +47,7 @@ namespace AzFramework
|
||||
// result == 0 means child PID is still running, nothing to check
|
||||
if (result == -1)
|
||||
{
|
||||
AZ_TracePrintf("ProcessWatcher", "IsChildProcessDone could not determine child process status (waitpid errno %d). assuming process either failed to launch or terminated unexpectedly\n", errno);
|
||||
AZ_TracePrintf("ProcessWatcher", "IsChildProcessDone could not determine child process status (waitpid errno %d(%s)). assuming process either failed to launch or terminated unexpectedly\n", errno, strerror(errno));
|
||||
exitCode = 0;
|
||||
}
|
||||
else if (result == childProcessId)
|
||||
@@ -274,28 +276,27 @@ namespace AzFramework
|
||||
azstrcat(commandAndArgs[i], token.size(), token.c_str());
|
||||
}
|
||||
commandAndArgs[commandTokens.size()] = nullptr;
|
||||
|
||||
char** environmentVariables = nullptr;
|
||||
int numEnvironmentVars = 0;
|
||||
|
||||
constexpr int MaxEnvVariables = 128;
|
||||
using EnvironmentVariableContainer = AZStd::fixed_vector<char*, MaxEnvVariables>;
|
||||
EnvironmentVariableContainer environmentVariables;
|
||||
for (char **env = ::environ; *env; env++)
|
||||
{
|
||||
environmentVariables.push_back(*env);
|
||||
}
|
||||
if (processLaunchInfo.m_environmentVariables)
|
||||
{
|
||||
const int numEnvironmentVars = processLaunchInfo.m_environmentVariables->size();
|
||||
// Adding one more as exec expects the array to have a nullptr as the last element
|
||||
environmentVariables = new char*[numEnvironmentVars + 1];
|
||||
for (int i = 0; i < numEnvironmentVars; i++)
|
||||
for (AZStd::string& processLaunchEnv : *processLaunchInfo.m_environmentVariables)
|
||||
{
|
||||
const AZStd::string& envVarString = processLaunchInfo.m_environmentVariables->at(i);
|
||||
environmentVariables[i] = new char[envVarString.size() + 1];
|
||||
environmentVariables[i][0] = '\0';
|
||||
azstrcat(environmentVariables[i], envVarString.size(), envVarString.c_str());
|
||||
environmentVariables.push_back(processLaunchEnv.data());
|
||||
}
|
||||
environmentVariables[numEnvironmentVars] = NULL;
|
||||
}
|
||||
environmentVariables.push_back(nullptr);
|
||||
|
||||
pid_t child_pid = fork();
|
||||
if (IsIdChildProcess(child_pid))
|
||||
{
|
||||
ExecuteCommandAsChild(commandAndArgs, environmentVariables, processLaunchInfo, processData.m_startupInfo);
|
||||
ExecuteCommandAsChild(commandAndArgs, environmentVariables.data(), processLaunchInfo, processData.m_startupInfo);
|
||||
}
|
||||
|
||||
processData.m_childProcessId = child_pid;
|
||||
@@ -303,15 +304,6 @@ namespace AzFramework
|
||||
// Close these handles as they are only to be used by the child process
|
||||
processData.m_startupInfo.CloseAllHandles();
|
||||
|
||||
if (processLaunchInfo.m_environmentVariables)
|
||||
{
|
||||
for (int i = 0; i < numEnvironmentVars; i++)
|
||||
{
|
||||
delete [] environmentVariables[i];
|
||||
}
|
||||
delete [] environmentVariables;
|
||||
}
|
||||
|
||||
for (int i = 0; i < commandTokens.size(); i++)
|
||||
{
|
||||
delete [] commandAndArgs[i];
|
||||
|
||||
Reference in New Issue
Block a user