Skip to content

Commit

Permalink
exception: Make libndsCrash() the same on ARM7 and ARM9
Browse files Browse the repository at this point in the history
The implementation is in source/common/exception/exceptions.c
  • Loading branch information
AntonioND committed Dec 22, 2024
1 parent c082903 commit 505d1db
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
9 changes: 0 additions & 9 deletions source/arm7/libnds_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,4 @@ typedef struct {
*/
libnds_touchMeasurementFilterResult libnds_touchMeasurementFilter(u16 values[5]);

// In the ARM7 we can't really print anything without adding a lot of additional
// code, so just crash in a controlled way.
__attribute__((always_inline, noreturn))
THUMB_CODE static inline void libndsCrash(__attribute__((unused)) const char *message)
{
asm volatile("udf #0" ::: "memory");
while (1);
}

#endif // ARM7_LIBNDS_INTERNAL_H__
4 changes: 0 additions & 4 deletions source/arm9/libnds_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ extern ConsoleOutFn libnds_stdout_write, libnds_stderr_write;

void setTransferInputData(touchPosition *touch, u16 buttons);

// In the ARM9, this function will cause an exception that will print the
// provided message.
__attribute__((noreturn)) void libndsCrash(const char *message);

extern time_t *punixTime;

#endif // ARM9_LIBNDS_INTERNAL_H__
6 changes: 1 addition & 5 deletions source/common/libc/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

#include <sys/lock.h>

#ifdef ARM9
#include "arm9/libnds_internal.h"
#else
#include "arm7/libnds_internal.h"
#endif
#include "common/libnds_internal.h"

void *__aeabi_read_tp(void);

Expand Down
5 changes: 4 additions & 1 deletion source/common/libnds_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileNotice: Modified from the original version by the BlocksDS project.
//
// Copyright (C) 2005-2008 Dave Murphy (WinterMute)
// Copyright (c) 2023 Antonio Niño Díaz
// Copyright (c) 2023-2024 Antonio Niño Díaz

// Internal variables for libnds

Expand Down Expand Up @@ -87,4 +87,7 @@ void __libnds_exit(int rc);
int nocash_putc_buffered(char c, FILE *file);
ssize_t nocash_write(const char *ptr, size_t len);

// This function will cause an exception that will print the provided message.
__attribute__((noreturn)) void libndsCrash(const char *message);

#endif // COMMON_LIBNDS_INTERNAL_H__

0 comments on commit 505d1db

Please sign in to comment.