Repairing Windows build.
This commit is contained in:
parent
877d96462d
commit
a95439d419
12 changed files with 144 additions and 55 deletions
|
@ -2,11 +2,13 @@
|
|||
|
||||
#include "RandomUtils.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
void SharedMemory::allocate(const std::string& namePrefix, std::size_t size)
|
||||
{
|
||||
|
@ -17,6 +19,7 @@ void SharedMemory::allocate(const std::string& namePrefix, std::size_t size)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
int ret{-1};
|
||||
do {
|
||||
ret = ftruncate(mFileDescriptor, size);
|
||||
|
@ -27,6 +30,7 @@ void SharedMemory::allocate(const std::string& namePrefix, std::size_t size)
|
|||
close(mFileDescriptor);
|
||||
mIsValid = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int SharedMemory::getFileDescriptor() const
|
||||
|
@ -41,6 +45,7 @@ bool SharedMemory::isValid() const
|
|||
|
||||
void SharedMemory::createFile(const std::string& namePrefix)
|
||||
{
|
||||
#ifdef __linux__
|
||||
unsigned retries = 100;
|
||||
do {
|
||||
const auto name = getRandomName(namePrefix);
|
||||
|
@ -55,6 +60,7 @@ void SharedMemory::createFile(const std::string& namePrefix)
|
|||
break;
|
||||
}
|
||||
} while (retries > 0 && errno == EEXIST);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string SharedMemory::getRandomName(const std::string& namePrefix) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue