[*] Linux has a pulse...
This commit is contained in:
parent
3205ea8a1f
commit
8fe83de42f
@ -198,8 +198,8 @@ namespace Aurora::Console::ConsoleStd
|
||||
|
||||
#endif
|
||||
|
||||
SysAssert(gInputStream, "Couldn't allocate input stream handler");
|
||||
SysAssert(gOutputStream, "Couldn't allocate output stream handler");
|
||||
SysAssert(gInputStream != DEFAULT_HANDLE_VAL, "Couldn't allocate input stream handler");
|
||||
SysAssert(gOutputStream != DEFAULT_HANDLE_VAL, "Couldn't allocate output stream handler");
|
||||
|
||||
StartLogger();
|
||||
}
|
||||
|
@ -5,3 +5,13 @@
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "ExceptionWatcher.Unix.hpp"
|
||||
|
||||
namespace Aurora::Debug
|
||||
{
|
||||
void PlatformHandleFatal(bool fatal)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -38,19 +38,19 @@ namespace Aurora::IO::FS
|
||||
return IterateDirEntriesSTL(string, false, dirs);
|
||||
}
|
||||
|
||||
AUKN_SYM bool WriteFile(const AuString &path, const void *data, AuUInt length)
|
||||
AUKN_SYM bool WriteFile(const AuString &path, const Memory::MemoryViewRead &blob)
|
||||
{
|
||||
auto file = OpenWriteUnique(path);
|
||||
SysCheckReturn(file, false);
|
||||
|
||||
AuUInt written = length;
|
||||
if (!file->Write(Memory::MemoryViewStreamRead(data, written)))
|
||||
AuUInt written = blob.length;
|
||||
if (!file->Write(Memory::MemoryViewStreamRead(blob, written)))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (written != length)
|
||||
if (written != blob.length)
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return false;
|
||||
@ -59,32 +59,48 @@ namespace Aurora::IO::FS
|
||||
return false;
|
||||
}
|
||||
|
||||
AUKN_SYM bool ReadFile(const AuString &path, AuList<uint8_t> &buffer)
|
||||
AUKN_SYM bool ReadFile(const AuString &path, AuByteBuffer &buffer)
|
||||
{
|
||||
AuUInt read;
|
||||
|
||||
auto file = OpenReadUnique(path);
|
||||
SysCheckReturn(file, false);
|
||||
|
||||
auto len = file->GetLength();
|
||||
|
||||
// NOTE: Linux file systems are such a cluster fuck of unimplemented interface
|
||||
// It's not unusual for these sockets to be unstreamable across NIX-like oses
|
||||
if (len == 0)
|
||||
{
|
||||
if (AuStartsWith(path, "/proc/") ||
|
||||
AuStartsWith(path, "/sys/") ||
|
||||
AuStartsWith(path, "/dev/"))
|
||||
{
|
||||
len = 4096;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!AuTryResize(buffer, len))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
}
|
||||
|
||||
AuUInt read;
|
||||
if (!file->Read(Memory::MemoryViewStreamWrite {buffer, read}))
|
||||
if (!file->Read(Memory::MemoryViewStreamWrite {buffer.begin(), buffer.end(), read}))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (read != buffer.size())
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return false;
|
||||
}
|
||||
// NOTE: File devices love to lie
|
||||
// Do not entertain an arbitrarily large page length provided by non-regular fds
|
||||
|
||||
return false;
|
||||
return AuTryResize(buffer, read);
|
||||
}
|
||||
|
||||
static bool UnixExists(const AuString &path, bool dir)
|
||||
|
@ -294,16 +294,17 @@ namespace Aurora::IO::FS
|
||||
this->bMadeTemporary = true;
|
||||
}
|
||||
|
||||
static IFileStream *OpenNew(const AuString &path, bool read)
|
||||
static IFileStream *OpenNew(const AuString &path, EFileOpenMode openMode, EFileAdvisoryLockLevel lock)
|
||||
{
|
||||
auto pathex = NormalizePathRet(path);
|
||||
|
||||
if (!read)
|
||||
if (openMode != EFileOpenMode::eRead)
|
||||
{
|
||||
CreateDirectories(pathex, true);
|
||||
}
|
||||
|
||||
auto fileHandle = open(pathex.c_str(), read ? O_RDONLY : O_RDWR);
|
||||
auto fileHandle = open(pathex.c_str(),
|
||||
openMode == EFileOpenMode::eRead ? O_RDONLY : O_RDWR);
|
||||
|
||||
if (fileHandle < 0)
|
||||
{
|
||||
@ -315,21 +316,28 @@ namespace Aurora::IO::FS
|
||||
if (!stream)
|
||||
{
|
||||
::close(fileHandle);
|
||||
SysPushErrorMem("{}", path);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!stream->Init(fileHandle, pathex))
|
||||
{
|
||||
delete stream;
|
||||
SysPushErrorGeneric("{}", path);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
AUKN_SYM IFileStream *OpenReadNew(const AuString &path)
|
||||
AUKN_SYM void OpenRelease(IFileStream *that)
|
||||
{
|
||||
return OpenNew(path, true);
|
||||
AuSafeDelete<PosixFileStream *>(that);
|
||||
}
|
||||
|
||||
AUKN_SYM IFileStream *OpenReadNew(const AuString &path, EFileAdvisoryLockLevel level)
|
||||
{
|
||||
return OpenNew(path, EFileOpenMode::eRead, level);
|
||||
}
|
||||
|
||||
AUKN_SYM void OpenReadRelease(IFileStream * that)
|
||||
@ -337,9 +345,9 @@ namespace Aurora::IO::FS
|
||||
AuSafeDelete<PosixFileStream *>(that);
|
||||
}
|
||||
|
||||
AUKN_SYM IFileStream *OpenWriteNew(const AuString &path)
|
||||
AUKN_SYM IFileStream *OpenWriteNew(const AuString &path, EFileAdvisoryLockLevel level)
|
||||
{
|
||||
return OpenNew(path, false);
|
||||
return OpenNew(path, EFileOpenMode::eWrite, level);
|
||||
}
|
||||
|
||||
AUKN_SYM void OpenWriteRelease(IFileStream *that)
|
||||
|
@ -92,9 +92,9 @@ namespace Aurora::Loop
|
||||
return ELoopSource::eSourceEvent;
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<ILSEvent> NewLSEvent()
|
||||
AUKN_SYM AuSPtr<ILSEvent> NewLSEvent(bool triggered, bool atomicRelease, bool permitMultipleTriggers)
|
||||
{
|
||||
auto event = AuMakeShared<LSEvent>();
|
||||
auto event = AuMakeShared<LSEvent>(triggered, atomicRelease, permitMultipleTriggers);
|
||||
if (!event)
|
||||
{
|
||||
return {};
|
||||
|
@ -330,12 +330,25 @@ namespace Aurora::Processes
|
||||
|
||||
void InitUnix()
|
||||
{
|
||||
signal(SIGCHLD, SigChldHandler);
|
||||
gRWLock = AuThreadPrimitives::RWLockUnique();
|
||||
|
||||
struct sigaction action =
|
||||
{
|
||||
.sa_handler = SigChldHandler,
|
||||
.sa_flags = SA_ONSTACK
|
||||
};
|
||||
sigaction(SIGCHLD, &action, nullptr);
|
||||
}
|
||||
|
||||
void DeinitUnix()
|
||||
{
|
||||
struct sigaction action =
|
||||
{
|
||||
.sa_handler = SIG_DFL,
|
||||
.sa_flags = SA_ONSTACK | SA_NOCLDWAIT
|
||||
};
|
||||
sigaction(SIGCHLD, &action, nullptr);
|
||||
|
||||
gRWLock.reset();
|
||||
}
|
||||
}
|
@ -12,26 +12,29 @@
|
||||
|
||||
namespace Aurora::Telemetry
|
||||
{
|
||||
static bool bHasInit {};
|
||||
static AuThreadPrimitives::CriticalSectionUnique_t gGroupLock;
|
||||
|
||||
void BeginBlock()
|
||||
{
|
||||
if (!bHasInit) return;
|
||||
gGroupLock->Lock();
|
||||
}
|
||||
|
||||
void EndBlock()
|
||||
{
|
||||
if (!bHasInit) return;
|
||||
gGroupLock->Unlock();
|
||||
}
|
||||
|
||||
void InsertOSError(const Debug::OSError_t &osError)
|
||||
{
|
||||
|
||||
if (!bHasInit) return;
|
||||
}
|
||||
|
||||
void InsertMsgError(const Debug::LastError &error)
|
||||
{
|
||||
|
||||
if (!bHasInit) return;
|
||||
}
|
||||
|
||||
void InsertCError(AuSInt cError)
|
||||
|
Loading…
Reference in New Issue
Block a user