1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +00:00

Apply noreturn attribute where applicable (#1532)

This commit is contained in:
Tharo 2023-09-09 15:24:52 +01:00 committed by GitHub
parent bedf07d541
commit 7235af2249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 30 additions and 18 deletions

12
include/attributes.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef ATTRIBUTES_H
#define ATTRIBUTES_H
#ifndef __GNUC__
#define __attribute__(x)
#endif
#define UNUSED __attribute__((unused))
#define FALLTHROUGH __attribute__((fallthrough))
#define NORETURN __attribute__((noreturn))
#endif

View File

@ -42,8 +42,8 @@ void Fault_Init(void);
// Fatal Errors
void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2);
void Fault_AddHungupAndCrash(const char* file, s32 line);
NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2);
NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line);
// Client Registration

View File

@ -30,13 +30,13 @@ void Locale_ResetRegion(void);
u32 func_80001F48(void);
u32 func_80001F8C(void);
u32 Locale_IsRegionNative(void);
void __assert(const char* exp, const char* file, s32 line);
NORETURN void __assert(const char* exp, const char* file, s32 line);
void isPrintfInit(void);
void osSyncPrintfUnused(const char* fmt, ...);
void osSyncPrintf(const char* fmt, ...);
void rmonPrintf(const char* fmt, ...);
void* is_proutSyncPrintf(void* arg, const char* str, u32 count);
void func_80002384(const char* exp, const char* file, u32 line);
NORETURN void func_80002384(const char* exp, const char* file, u32 line);
OSPiHandle* osDriveRomInit(void);
void Mio0_Decompress(Yaz0Header* hdr, u8* dst);
void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace,
@ -1476,7 +1476,7 @@ u64* SysUcode_GetUCodeBoot(void);
size_t SysUcode_GetUCodeBootSize(void);
u64* SysUcode_GetUCode(void);
u64* SysUcode_GetUCodeData(void);
void func_800D31A0(void);
NORETURN void func_800D31A0(void);
void func_800D31F0(void);
void func_800D3210(void);
void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);

View File

@ -1,19 +1,12 @@
#ifndef MACROS_H
#define MACROS_H
#ifndef __GNUC__
#define __attribute__(x)
#endif
#ifndef AVOID_UB
#define BAD_RETURN(type) type
#else
#define BAD_RETURN(type) void
#endif
#define UNUSED __attribute__((unused))
#define FALLTHROUGH __attribute__((fallthrough))
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))

View File

@ -3,6 +3,7 @@
#include "ultra64.h"
#include "ultra64/gs2dex.h"
#include "attributes.h"
#include "z64save.h"
#include "z64light.h"
#include "z64bgcheck.h"

View File

@ -1,6 +1,6 @@
#include "global.h"
void __assert(const char* exp, const char* file, s32 line) {
NORETURN void __assert(const char* exp, const char* file, s32 line) {
char msg[256];
osSyncPrintf("Assertion failed: %s, file %s, line %d, thread %d\n", exp, file, line, osGetThreadId(NULL));

View File

@ -86,7 +86,7 @@ void* is_proutSyncPrintf(void* arg, const char* str, u32 count) {
return (void*)1;
}
void func_80002384(const char* exp, const char* file, u32 line) {
NORETURN void func_80002384(const char* exp, const char* file, u32 line) {
osSyncPrintf("File:%s Line:%d %s \n", file, line, exp);
while (true) {
;

View File

@ -231,7 +231,7 @@ void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) {
*
* This function does not return.
*/
void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) {
NORETURN void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) {
uintptr_t vrom = req->vromAddr;
void* ram = req->dramAddr;
size_t size = req->size;

View File

@ -3,7 +3,7 @@
u32 gIsCtrlr2Valid = false;
void func_800D31A0(void) {
NORETURN void func_800D31A0(void) {
osSyncPrintf(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST);
while (true) {
Sleep_Msec(1000);

View File

@ -1304,19 +1304,25 @@ void Fault_HungupFaultClient(const char* exp1, const char* exp2) {
* error occurs. The parameters specify two messages detailing the error, one
* or both may be NULL.
*/
void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
FaultClient client;
s32 pad;
Fault_AddClient(&client, Fault_HungupFaultClient, (void*)exp1, (void*)exp2);
*(u32*)0x11111111 = 0; // trigger an exception via unaligned memory access
// Since the above line triggers an exception and transfers execution to the fault handler
// this function does not return and the rest of the function is unreachable.
#ifdef __GNUC__
__builtin_unreachable();
#endif
}
/**
* Like `Fault_AddHungupAndCrashImpl`, however provides a fixed message containing
* filename and line number
*/
void Fault_AddHungupAndCrash(const char* file, s32 line) {
NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line) {
char msg[256];
sprintf(msg, "HungUp %s:%d", file, line);