Asserts: break/crash program, fit to style guide; log.h->assert.h
Involves making asserts use printf instead of the log functions (log functions are asynchronous and, as such, the log won't be printed in time) As such, the log type argument was removed (printf obviously can't use it, and it's made obsolete by the file and line printing) Also removed some GEKKO cruft.
This commit is contained in:
parent
168eb27aee
commit
ef24e72b26
88 changed files with 135 additions and 217 deletions
|
@ -32,7 +32,7 @@ bool Event::ShouldWait() {
|
|||
}
|
||||
|
||||
void Event::Acquire() {
|
||||
_assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
|
||||
ASSERT_MSG(!ShouldWait(), "object unavailable!");
|
||||
|
||||
// Release the event if it's not sticky...
|
||||
if (reset_type != RESETTYPE_STICKY)
|
||||
|
|
|
@ -52,7 +52,7 @@ void WaitObject::WakeupAllWaitingThreads() {
|
|||
for (auto thread : waiting_threads_copy)
|
||||
thread->ReleaseWaitObject(this);
|
||||
|
||||
_assert_msg_(Kernel, waiting_threads.empty(), "failed to awaken all waiting threads!");
|
||||
ASSERT_MSG(waiting_threads.empty(), "failed to awaken all waiting threads!");
|
||||
}
|
||||
|
||||
HandleTable::HandleTable() {
|
||||
|
@ -61,7 +61,7 @@ HandleTable::HandleTable() {
|
|||
}
|
||||
|
||||
ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
|
||||
_dbg_assert_(Kernel, obj != nullptr);
|
||||
DEBUG_ASSERT(obj != nullptr);
|
||||
|
||||
u16 slot = next_free_slot;
|
||||
if (slot >= generations.size()) {
|
||||
|
|
|
@ -64,7 +64,7 @@ void Mutex::Acquire() {
|
|||
}
|
||||
|
||||
void Mutex::Acquire(SharedPtr<Thread> thread) {
|
||||
_assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
|
||||
ASSERT_MSG(!ShouldWait(), "object unavailable!");
|
||||
|
||||
// Actually "acquire" the mutex only if we don't already have it...
|
||||
if (lock_count == 0) {
|
||||
|
|
|
@ -36,7 +36,7 @@ bool Semaphore::ShouldWait() {
|
|||
}
|
||||
|
||||
void Semaphore::Acquire() {
|
||||
_assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
|
||||
ASSERT_MSG(!ShouldWait(), "object unavailable!");
|
||||
--available_count;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
}
|
||||
|
||||
void Acquire() override {
|
||||
_assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
|
||||
ASSERT_MSG(!ShouldWait(), "object unavailable!");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ bool Thread::ShouldWait() {
|
|||
}
|
||||
|
||||
void Thread::Acquire() {
|
||||
_assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
|
||||
ASSERT_MSG(!ShouldWait(), "object unavailable!");
|
||||
}
|
||||
|
||||
// Lists all thread ids that aren't deleted/etc.
|
||||
|
@ -144,7 +144,7 @@ void ArbitrateAllThreads(u32 address) {
|
|||
* @param new_thread The thread to switch to
|
||||
*/
|
||||
static void SwitchContext(Thread* new_thread) {
|
||||
_dbg_assert_msg_(Kernel, new_thread->status == THREADSTATUS_READY, "Thread must be ready to become running.");
|
||||
DEBUG_ASSERT_MSG(new_thread->status == THREADSTATUS_READY, "Thread must be ready to become running.");
|
||||
|
||||
Thread* previous_thread = GetCurrentThread();
|
||||
|
||||
|
@ -304,14 +304,12 @@ void Thread::ResumeFromWait() {
|
|||
break;
|
||||
case THREADSTATUS_RUNNING:
|
||||
case THREADSTATUS_READY:
|
||||
LOG_ERROR(Kernel, "Thread with object id %u has already resumed.", GetObjectId());
|
||||
_dbg_assert_(Kernel, false);
|
||||
DEBUG_ASSERT_MSG(false, "Thread with object id %u has already resumed.", GetObjectId());
|
||||
return;
|
||||
case THREADSTATUS_DEAD:
|
||||
// This should never happen, as threads must complete before being stopped.
|
||||
LOG_CRITICAL(Kernel, "Thread with object id %u cannot be resumed because it's DEAD.",
|
||||
DEBUG_ASSERT_MSG(false, "Thread with object id %u cannot be resumed because it's DEAD.",
|
||||
GetObjectId());
|
||||
_dbg_assert_(Kernel, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -387,7 +385,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
|
|||
// TODO(peachum): Remove this. Range checking should be done, and an appropriate error should be returned.
|
||||
static void ClampPriority(const Thread* thread, s32* priority) {
|
||||
if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) {
|
||||
_dbg_assert_msg_(Kernel, false, "Application passed an out of range priority. An error should be returned.");
|
||||
DEBUG_ASSERT_MSG(false, "Application passed an out of range priority. An error should be returned.");
|
||||
|
||||
s32 new_priority = CLAMP(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
|
||||
LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d",
|
||||
|
@ -425,7 +423,7 @@ SharedPtr<Thread> SetupIdleThread() {
|
|||
}
|
||||
|
||||
SharedPtr<Thread> SetupMainThread(u32 stack_size, u32 entry_point, s32 priority) {
|
||||
_dbg_assert_(Kernel, !GetCurrentThread());
|
||||
DEBUG_ASSERT(!GetCurrentThread());
|
||||
|
||||
// Initialize new "main" thread
|
||||
auto thread_res = Thread::Create("main", entry_point, priority, 0,
|
||||
|
|
|
@ -38,7 +38,7 @@ bool Timer::ShouldWait() {
|
|||
}
|
||||
|
||||
void Timer::Acquire() {
|
||||
_assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
|
||||
ASSERT_MSG( !ShouldWait(), "object unavailable!");
|
||||
}
|
||||
|
||||
void Timer::Set(s64 initial, s64 interval) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue