Skip to content

Commit c4b52e3

Browse files
committed
address compiling problems with POSIX/linux CSystemLinux
Signed-off-by: Michael Pollind <mpollind@gmail.com>
1 parent 27545f2 commit c4b52e3

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

include/nbl/system/ISystemPOSIX.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
namespace nbl::system
77
{
88

9-
#if defined(__unix__)
9+
#if defined(_NBL_PLATFORM_LINUX_) || defined (_NBL_PLATFORM_ANDROID_)
1010
class ISystemPOSIX : public ISystem
1111
{
1212
protected:
1313
class CCaller final : public ISystem::ICaller
1414
{
1515
public:
16-
inline CCaller(ISystemPOSIX* _system) : ICaller(_system) {}
16+
CCaller(ISystemPOSIX* _system) : ICaller(_system) {}
1717

1818
NBL_API2 core::smart_refctd_ptr<ISystemFile> createFile(const std::filesystem::path& filename, const core::bitflag<IFile::E_CREATE_FLAGS> flags) override;
1919
};

src/nbl/system/CSystemLinux.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ using namespace nbl;
44
using namespace nbl::system;
55

66
#ifdef _NBL_PLATFORM_LINUX_
7+
8+
#include <sys/sysinfo.h>
79
ISystem::SystemInfo CSystemLinux::getSystemInfo() const
810
{
911
SystemInfo info;
1012

1113
// TODO
12-
info.cpuFrequencyHz = 3000000000u;
14+
// info.cpuFrequencyHz = 3000000000u;
1315

14-
sysinfo linuxSystemInfo;
16+
struct sysinfo linuxSystemInfo;
1517
sysinfo(&linuxSystemInfo);
1618
info.totalMemory = linuxSystemInfo.totalram;
1719
info.availableMemory = linuxSystemInfo.freeram;

src/nbl/system/ISystemPOSIX.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#include "nbl/system/ISystemPOSIX.h"
22
#include "nbl/system/CFilePOSIX.h"
33

4+
#include "nbl/system/IFile.h"
5+
46
using namespace nbl;
57
using namespace nbl::system;
68

7-
#if defined(__unix__)
9+
#if defined(_NBL_PLATFORM_LINUX_) || defined (_NBL_PLATFORM_ANDROID_)
10+
811
#include <fcntl.h>
912
#include <sys/mman.h>
1013
#include <sys/stat.h>
@@ -13,7 +16,7 @@ core::smart_refctd_ptr<ISystemFile> ISystemPOSIX::CCaller::createFile(const std:
1316
{
1417
const bool writeAccess = flags.value&IFile::ECF_WRITE;
1518
int createFlags = O_LARGEFILE|(writeAccess ? O_CREAT:0);
16-
switch (_flags.value&IFile::ECF_READ_WRITE))
19+
switch (flags.value&IFile::ECF_READ_WRITE)
1720
{
1821
case IFile::ECF_READ:
1922
createFlags |= O_RDONLY;
@@ -30,7 +33,7 @@ core::smart_refctd_ptr<ISystemFile> ISystemPOSIX::CCaller::createFile(const std:
3033
}
3134

3235
CFilePOSIX::native_file_handle_t _native = -1;
33-
auto filenameStream = _filename.string();
36+
auto filenameStream = filename.string();
3437
const char* name_c_str = filenameStream.c_str();
3538
// only create a new file if we're going to be writing
3639
if (writeAccess)
@@ -60,7 +63,7 @@ core::smart_refctd_ptr<ISystemFile> ISystemPOSIX::CCaller::createFile(const std:
6063

6164
// map if needed
6265
void* _mappedPtr = nullptr;
63-
if (_flags.value & ECF_MAPPABLE)
66+
if (flags.value & IFile::ECF_MAPPABLE)
6467
{
6568
const int mappingFlags = ((flags.value&IFile::ECF_READ) ? PROT_READ:0)|(writeAccess ? PROT_WRITE:0);
6669
_mappedPtr = mmap((caddr_t)0, _size, mappingFlags, MAP_PRIVATE, _native, 0);
@@ -71,6 +74,6 @@ core::smart_refctd_ptr<ISystemFile> ISystemPOSIX::CCaller::createFile(const std:
7174
}
7275
}
7376

74-
return core::make_smart_refctd_ptr<CFilePOSIX>(core::smart_refctd_ptr<ISystem>(m_system),filename,flags,_mappedPtr,_size,_native);
77+
return core::make_smart_refctd_ptr<CFilePOSIX>(core::smart_refctd_ptr<ISystem>(m_system),path(filename),flags,_mappedPtr,_size,_native);
7578
}
7679
#endif

0 commit comments

Comments
 (0)