mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-27 05:22:07 +00:00
Improve helpers.h
Use C11 standard _Noreturn instead of attributes (except, of course, MSVC) Remove unused helpers Avoid trapping in release builds, in favor of just unreachability Improve shim when __builtin_* are not available
This commit is contained in:
@@ -222,7 +222,7 @@ void error(const char *fmt, ...)
|
||||
nbErrors++;
|
||||
}
|
||||
|
||||
noreturn_ void fatalerror(const char *fmt, ...)
|
||||
_Noreturn void fatalerror(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -250,7 +250,7 @@ void warning(enum WarningID id, char const *fmt, ...)
|
||||
return;
|
||||
|
||||
case WARNING_DEFAULT:
|
||||
trap_;
|
||||
unreachable_();
|
||||
/* Not reached */
|
||||
|
||||
case WARNING_ENABLED:
|
||||
|
||||
8
src/extern/err.c
vendored
8
src/extern/err.c
vendored
@@ -34,7 +34,7 @@ void rgbds_vwarnx(const char *fmt, va_list ap)
|
||||
putc('\n', stderr);
|
||||
}
|
||||
|
||||
noreturn_ void rgbds_verr(int status, const char *fmt, va_list ap)
|
||||
_Noreturn void rgbds_verr(int status, const char *fmt, va_list ap)
|
||||
{
|
||||
fprintf(stderr, "error: ");
|
||||
if (fmt) {
|
||||
@@ -46,7 +46,7 @@ noreturn_ void rgbds_verr(int status, const char *fmt, va_list ap)
|
||||
exit(status);
|
||||
}
|
||||
|
||||
noreturn_ void rgbds_verrx(int status, const char *fmt, va_list ap)
|
||||
_Noreturn void rgbds_verrx(int status, const char *fmt, va_list ap)
|
||||
{
|
||||
fprintf(stderr, "error");
|
||||
if (fmt) {
|
||||
@@ -75,7 +75,7 @@ void rgbds_warnx(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
noreturn_ void rgbds_err(int status, const char *fmt, ...)
|
||||
_Noreturn void rgbds_err(int status, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -84,7 +84,7 @@ noreturn_ void rgbds_err(int status, const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
noreturn_ void rgbds_errx(int status, const char *fmt, ...)
|
||||
_Noreturn void rgbds_errx(int status, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ void assign_AssignSections(void)
|
||||
return;
|
||||
}
|
||||
|
||||
trap_;
|
||||
unreachable_();
|
||||
}
|
||||
|
||||
void assign_Cleanup(void)
|
||||
|
||||
@@ -99,7 +99,7 @@ void error(struct FileStackNode const *where, uint32_t lineNo, char const *fmt,
|
||||
nbErrors++;
|
||||
}
|
||||
|
||||
noreturn_ void fatal(struct FileStackNode const *where, uint32_t lineNo, char const *fmt, ...)
|
||||
_Noreturn void fatal(struct FileStackNode const *where, uint32_t lineNo, char const *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ static void processCommand(enum LinkerScriptCommand command, uint16_t arg,
|
||||
{
|
||||
switch (command) {
|
||||
case COMMAND_INVALID:
|
||||
trap_;
|
||||
unreachable_();
|
||||
|
||||
case COMMAND_ORG:
|
||||
break;
|
||||
@@ -391,12 +391,12 @@ struct SectionPlacement *script_NextSection(void)
|
||||
|
||||
switch (parserState) {
|
||||
case PARSER_FIRSTTIME:
|
||||
trap_;
|
||||
unreachable_();
|
||||
|
||||
case PARSER_LINESTART:
|
||||
switch (token->type) {
|
||||
case TOKEN_INVALID:
|
||||
trap_;
|
||||
unreachable_();
|
||||
|
||||
case TOKEN_EOF:
|
||||
if (!popFile())
|
||||
|
||||
@@ -108,7 +108,7 @@ static void mergeSections(struct Section *target, struct Section *other, enum Se
|
||||
break;
|
||||
|
||||
case SECTION_NORMAL:
|
||||
trap_;
|
||||
unreachable_();
|
||||
}
|
||||
|
||||
other->nextu = target->nextu;
|
||||
|
||||
Reference in New Issue
Block a user