mirror of
https://github.com/shadergz/cosmic-station.git
synced 2024-11-27 00:00:21 +00:00
Providing an exception object and removing unnecessary assert statements
This commit is contained in:
parent
55123258b4
commit
6bef528fc3
BIN
.gitignore
vendored
BIN
.gitignore
vendored
Binary file not shown.
@ -25,7 +25,7 @@ target_include_directories(zenith PRIVATE ${ZENITH_MISC_DIR} ${ZENITH_DIR})
|
||||
|
||||
target_sources(zenith PRIVATE
|
||||
${ZENITH_DIR}/app.cpp
|
||||
${ZENITH_DIR}/paper_logger.cpp
|
||||
${ZENITH_DIR}/logger.cpp
|
||||
${ZENITH_DIR}/eeiv/ee_engine.cpp
|
||||
${ZENITH_DIR}/eeiv/cop0.cpp
|
||||
${ZENITH_DIR}/eeiv/mmu_tlb.cpp
|
||||
|
@ -7,8 +7,8 @@
|
||||
// is started by Java Runtime using System.loadLibrary("zenith")
|
||||
extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
auto desiredVersion{JNI_VERSION_1_6};
|
||||
// Kickstart the user readable log system also called as, PalePaper
|
||||
zenith::userLog = std::make_shared<zenith::PalePaper>();
|
||||
// Kickstart the user readable log system also called as, GlobalLogger
|
||||
zenith::userLog = std::make_shared<zenith::GlobalLogger>();
|
||||
|
||||
zenith::deviceRes = std::make_unique<zenith::java::JvmManager>(vm);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace zenith {
|
||||
std::unique_ptr<java::JvmManager> deviceRes;
|
||||
std::shared_ptr<PalePaper> userLog;
|
||||
std::shared_ptr<GlobalLogger> userLog;
|
||||
std::unique_ptr<CoreApplication> zenithApp;
|
||||
|
||||
CoreApplication::CoreApplication()
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <console/virtual_devices.h>
|
||||
#include <java/device_handler.h>
|
||||
#include <paper_logger.h>
|
||||
#include <logger.h>
|
||||
|
||||
namespace zenith {
|
||||
class CoreApplication {
|
||||
@ -18,5 +18,5 @@ namespace zenith {
|
||||
extern std::unique_ptr<java::JvmManager> deviceRes;
|
||||
extern std::unique_ptr<CoreApplication> zenithApp;
|
||||
|
||||
extern std::shared_ptr<PalePaper> userLog;
|
||||
extern std::shared_ptr<GlobalLogger> userLog;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <cstring>
|
||||
#include <paper_debug.h>
|
||||
#include <verify.h>
|
||||
#include <eeiv/mmu_tlb.h>
|
||||
|
||||
namespace zenith::eeiv {
|
||||
@ -27,7 +27,11 @@ namespace zenith::eeiv {
|
||||
// directly to the table entries
|
||||
for (auto segmentPage{kUnmapStart}; segmentPage != kUnmapEnd; segmentPage += 4096) {
|
||||
auto kVTable{segmentPage / 4096};
|
||||
PaperRtAssert(kVTable < 1024 * 1024, "");
|
||||
|
||||
if (kVTable >= 1024 * 1024) {
|
||||
throw exception::runtime_fault("Kernel TLB table is outside the specified range");
|
||||
}
|
||||
|
||||
kernelVTLB[kVTable] = choiceMemSrc(segmentPage & (0x20000000 - 1));
|
||||
|
||||
if (segmentPage < 0xa0000000)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <paper_debug.h>
|
||||
#include <verify.h>
|
||||
namespace zenith {
|
||||
using u8 = uint8_t;
|
||||
using u16 = uint16_t;
|
||||
@ -27,10 +27,13 @@ namespace zenith {
|
||||
int basicFd;
|
||||
|
||||
void operator=(int fileNativeFd) {
|
||||
PaperRtAssertPersistent(fileNativeFd == invalidFileDescriptor, "");
|
||||
if (fileNativeFd == invalidFileDescriptor) {
|
||||
throw exception::runtime_fault("Corrupted file descriptor being passed without checking");
|
||||
}
|
||||
basicFd = fileNativeFd;
|
||||
|
||||
fstat(basicFd, &lastStates);
|
||||
PaperRtAssert((lastStates.st_mode & S_IFMT) == S_IFREG, "");
|
||||
VerifyRtAssert((lastStates.st_mode & S_IFMT) == S_IFREG);
|
||||
}
|
||||
auto operator*()-> int {
|
||||
return basicFd;
|
||||
|
8
app/src/main/cpp/zenith/logger.cpp
Normal file
8
app/src/main/cpp/zenith/logger.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <logger.h>
|
||||
|
||||
namespace zenith {
|
||||
void verifyRtCheck(bool condition, std::function<void()> func) {
|
||||
[[unlikely]] if (condition)
|
||||
func();
|
||||
}
|
||||
}
|
@ -6,19 +6,19 @@
|
||||
#include <impltypes.h>
|
||||
|
||||
namespace zenith {
|
||||
enum PaleLevel {
|
||||
PaleInfo = ANDROID_LOG_INFO,
|
||||
PaleDebug = ANDROID_LOG_DEBUG,
|
||||
PaleVerbose = ANDROID_LOG_VERBOSE,
|
||||
PaleError = ANDROID_LOG_ERROR,
|
||||
enum LoggerLevel {
|
||||
Info = ANDROID_LOG_INFO,
|
||||
Debug = ANDROID_LOG_DEBUG,
|
||||
Verbose = ANDROID_LOG_VERBOSE,
|
||||
Error = ANDROID_LOG_ERROR,
|
||||
};
|
||||
|
||||
class PalePaper {
|
||||
class GlobalLogger {
|
||||
public:
|
||||
private:
|
||||
ZenFile logFile{};
|
||||
// Don't allow these specific levels to be threaded or printed to the user
|
||||
std::vector<PaleLevel> refuseLevels{};
|
||||
std::vector<LoggerLevel> refuseLevels{};
|
||||
};
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#define PaperRtAssertPersistent(cond, assertMessage)\
|
||||
[[unlikely]] if (!(cond))\
|
||||
assert((cond))
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define PaperRtAssert(cond, assertMessage)\
|
||||
[[unlikely]] if (!(cond))\
|
||||
assert((cond))
|
||||
#else
|
||||
#define PaperRtAssert(cond, assertMessage)\
|
||||
(void)(cond)
|
||||
#endif
|
@ -1,2 +0,0 @@
|
||||
#include <paper_logger.h>
|
||||
namespace zenith {}
|
25
app/src/main/cpp/zenith/verify.h
Normal file
25
app/src/main/cpp/zenith/verify.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
|
||||
namespace zenith {
|
||||
namespace exception {
|
||||
class runtime_fault : public std::runtime_error {
|
||||
public:
|
||||
runtime_fault(const std::string& faultMessage) : std::runtime_error(faultMessage) {}
|
||||
runtime_fault(const char* faultMessage) : std::runtime_error(faultMessage) {}
|
||||
};
|
||||
}
|
||||
void verifyRtCheck(bool condition, std::function<void()> func);
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define VerifyRtAssert(cond)\
|
||||
paperRtCheck(cond, [](){\
|
||||
assert(cond);\
|
||||
})
|
||||
#else
|
||||
#define VerifyRtAssert(cond)\
|
||||
(void)(cond)
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user