Mac/iOS fixes
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -29,20 +29,19 @@ namespace AZ
|
||||
return errno;
|
||||
}
|
||||
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
void ComposeName(char* dest, size_t length, const char* name, const char* suffix)
|
||||
{
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
|
||||
// sem_open doesn't support paths bigger than 31, so call it s_Mtx.
|
||||
// While this is enough for Profiler, maybe the code should be smarter
|
||||
// and trim the name instead
|
||||
azsnprintf(dest, length, "/tmp/%s_Mtx", name);
|
||||
azsnprintf(dest, length, "/tmp/%s_%s", name, suffix);
|
||||
}
|
||||
|
||||
SharedMemory_Common::CreateResult SharedMemory_Mac::Create(const char* name, unsigned int size, bool openIfCreated)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Mtx");
|
||||
|
||||
m_globalMutex = sem_open(fullName, O_CREAT | O_EXCL, 0600, 1);
|
||||
int error = errno;
|
||||
@@ -59,7 +58,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Create the file mapping.
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Data");
|
||||
m_mapHandle = shm_open(fullName, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
error = errno;
|
||||
if (error == EEXIST)
|
||||
@@ -80,7 +79,8 @@ namespace AZ
|
||||
bool SharedMemory_Mac::Open(const char* name)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Mtx");
|
||||
|
||||
m_globalMutex = sem_open(fullName, 0);
|
||||
AZ_Warning("AZSystem", m_globalMutex != nullptr, "Failed to open OS mutex [%s]\n", m_name);
|
||||
@@ -90,7 +90,7 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Data");
|
||||
m_mapHandle = shm_open(fullName, O_RDWR, 0600);
|
||||
if (m_mapHandle == -1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user