mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-01 15:26:01 +00:00
Apply noreturn attribute where applicable (#1532)
This commit is contained in:
parent
bedf07d541
commit
7235af2249
10 changed files with 30 additions and 18 deletions
12
include/attributes.h
Normal file
12
include/attributes.h
Normal 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
|
|
@ -42,8 +42,8 @@ void Fault_Init(void);
|
||||||
|
|
||||||
// Fatal Errors
|
// Fatal Errors
|
||||||
|
|
||||||
void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2);
|
NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2);
|
||||||
void Fault_AddHungupAndCrash(const char* file, s32 line);
|
NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line);
|
||||||
|
|
||||||
// Client Registration
|
// Client Registration
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,13 @@ void Locale_ResetRegion(void);
|
||||||
u32 func_80001F48(void);
|
u32 func_80001F48(void);
|
||||||
u32 func_80001F8C(void);
|
u32 func_80001F8C(void);
|
||||||
u32 Locale_IsRegionNative(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 isPrintfInit(void);
|
||||||
void osSyncPrintfUnused(const char* fmt, ...);
|
void osSyncPrintfUnused(const char* fmt, ...);
|
||||||
void osSyncPrintf(const char* fmt, ...);
|
void osSyncPrintf(const char* fmt, ...);
|
||||||
void rmonPrintf(const char* fmt, ...);
|
void rmonPrintf(const char* fmt, ...);
|
||||||
void* is_proutSyncPrintf(void* arg, const char* str, u32 count);
|
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);
|
OSPiHandle* osDriveRomInit(void);
|
||||||
void Mio0_Decompress(Yaz0Header* hdr, u8* dst);
|
void Mio0_Decompress(Yaz0Header* hdr, u8* dst);
|
||||||
void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace,
|
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);
|
size_t SysUcode_GetUCodeBootSize(void);
|
||||||
u64* SysUcode_GetUCode(void);
|
u64* SysUcode_GetUCode(void);
|
||||||
u64* SysUcode_GetUCodeData(void);
|
u64* SysUcode_GetUCodeData(void);
|
||||||
void func_800D31A0(void);
|
NORETURN void func_800D31A0(void);
|
||||||
void func_800D31F0(void);
|
void func_800D31F0(void);
|
||||||
void func_800D3210(void);
|
void func_800D3210(void);
|
||||||
void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);
|
void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);
|
||||||
|
|
|
@ -1,19 +1,12 @@
|
||||||
#ifndef MACROS_H
|
#ifndef MACROS_H
|
||||||
#define MACROS_H
|
#define MACROS_H
|
||||||
|
|
||||||
#ifndef __GNUC__
|
|
||||||
#define __attribute__(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef AVOID_UB
|
#ifndef AVOID_UB
|
||||||
#define BAD_RETURN(type) type
|
#define BAD_RETURN(type) type
|
||||||
#else
|
#else
|
||||||
#define BAD_RETURN(type) void
|
#define BAD_RETURN(type) void
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UNUSED __attribute__((unused))
|
|
||||||
#define FALLTHROUGH __attribute__((fallthrough))
|
|
||||||
|
|
||||||
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
|
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
|
||||||
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
|
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "ultra64.h"
|
#include "ultra64.h"
|
||||||
#include "ultra64/gs2dex.h"
|
#include "ultra64/gs2dex.h"
|
||||||
|
#include "attributes.h"
|
||||||
#include "z64save.h"
|
#include "z64save.h"
|
||||||
#include "z64light.h"
|
#include "z64light.h"
|
||||||
#include "z64bgcheck.h"
|
#include "z64bgcheck.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "global.h"
|
#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];
|
char msg[256];
|
||||||
|
|
||||||
osSyncPrintf("Assertion failed: %s, file %s, line %d, thread %d\n", exp, file, line, osGetThreadId(NULL));
|
osSyncPrintf("Assertion failed: %s, file %s, line %d, thread %d\n", exp, file, line, osGetThreadId(NULL));
|
||||||
|
|
|
@ -86,7 +86,7 @@ void* is_proutSyncPrintf(void* arg, const char* str, u32 count) {
|
||||||
return (void*)1;
|
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);
|
osSyncPrintf("File:%s Line:%d %s \n", file, line, exp);
|
||||||
while (true) {
|
while (true) {
|
||||||
;
|
;
|
||||||
|
|
|
@ -231,7 +231,7 @@ void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) {
|
||||||
*
|
*
|
||||||
* This function does not return.
|
* 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;
|
uintptr_t vrom = req->vromAddr;
|
||||||
void* ram = req->dramAddr;
|
void* ram = req->dramAddr;
|
||||||
size_t size = req->size;
|
size_t size = req->size;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
u32 gIsCtrlr2Valid = false;
|
u32 gIsCtrlr2Valid = false;
|
||||||
|
|
||||||
void func_800D31A0(void) {
|
NORETURN void func_800D31A0(void) {
|
||||||
osSyncPrintf(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST);
|
osSyncPrintf(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST);
|
||||||
while (true) {
|
while (true) {
|
||||||
Sleep_Msec(1000);
|
Sleep_Msec(1000);
|
||||||
|
|
|
@ -1304,19 +1304,25 @@ void Fault_HungupFaultClient(const char* exp1, const char* exp2) {
|
||||||
* error occurs. The parameters specify two messages detailing the error, one
|
* error occurs. The parameters specify two messages detailing the error, one
|
||||||
* or both may be NULL.
|
* 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;
|
FaultClient client;
|
||||||
s32 pad;
|
s32 pad;
|
||||||
|
|
||||||
Fault_AddClient(&client, Fault_HungupFaultClient, (void*)exp1, (void*)exp2);
|
Fault_AddClient(&client, Fault_HungupFaultClient, (void*)exp1, (void*)exp2);
|
||||||
*(u32*)0x11111111 = 0; // trigger an exception via unaligned memory access
|
*(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
|
* Like `Fault_AddHungupAndCrashImpl`, however provides a fixed message containing
|
||||||
* filename and line number
|
* filename and line number
|
||||||
*/
|
*/
|
||||||
void Fault_AddHungupAndCrash(const char* file, s32 line) {
|
NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line) {
|
||||||
char msg[256];
|
char msg[256];
|
||||||
|
|
||||||
sprintf(msg, "HungUp %s:%d", file, line);
|
sprintf(msg, "HungUp %s:%d", file, line);
|
||||||
|
|
Loading…
Reference in a new issue