3ds: Various fixes, mostly for compiler warnings

- Move all devkitpro includes before the Rockbox ones so that the macros which are both conflicting and unused can be undef'd
- Remove unused result variables
- Exclude an unused function from being compiled for this target
- Fix hex number formatting
- Fix the return value of dummy functions
- Fix macro redefinition in the plugins keypad config
- Remove duplicate button mapping
- Turn off -Wchar-subscripts as it's already handled in Rockbox's ctype.h

Change-Id: I3f5a3d492c585f233277a380feaea5fe877a044f
This commit is contained in:
Vencislav Atanasov 2026-03-12 17:41:13 +02:00 committed by Solomon Peachy
parent 6246e9b4d3
commit a77c5d2219
19 changed files with 93 additions and 60 deletions

View file

@ -310,7 +310,8 @@
(CONFIG_KEYPAD != ONDAVX777_PAD) && \
(CONFIG_KEYPAD != CREATIVE_ZENXFI2_PAD) && \
(CONFIG_KEYPAD != SHANLING_Q1_PAD) && \
(CONFIG_KEYPAD != HIBY_R3PROII_PAD)
(CONFIG_KEYPAD != HIBY_R3PROII_PAD) && \
(CONFIG_KEYPAD != CTRU_PAD)
#define BTN_FIRE BUTTON_BOTTOMLEFT
#define BTN_PAUSE BUTTON_TOPLEFT
#endif

View file

@ -28,7 +28,7 @@ PLUGIN_HEADER
#ifdef CTRU
/* dummy undefined symbols to build plugins for ctru */
void __aeabi_unwind_cpp_pr0(void) {}
struct _reent * _EXFUN(__getreent, (void)) {}
struct _reent * _EXFUN(__getreent, (void)) { return NULL; }
#endif
/*

View file

@ -231,7 +231,7 @@ void format_thread_name(char *buf, size_t bufsize,
snprintf(buf, bufsize, fmt, name, thread->id);
}
#ifndef HAVE_SDL_THREADS
#if !defined(HAVE_SDL_THREADS) && !defined(CTRU)
/*---------------------------------------------------------------------------
* Returns the maximum percentage of the stack ever used during runtime.
*---------------------------------------------------------------------------
@ -252,7 +252,7 @@ static unsigned int stack_usage(uintptr_t *stackptr, size_t stack_size)
return usage;
}
#endif /* HAVE_SDL_THREADS */
#endif /* !defined(HAVE_SDL_THREADS) && !defined(CTRU) */
#if NUM_CORES > 1
int core_get_debug_info(unsigned int core, struct core_debug_info *infop)

View file

@ -23,6 +23,10 @@
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <3ds/services/gsplcd.h>
#include <3ds/result.h>
#include "config.h"
#include "backlight-target.h"
#include "sysfs.h"
@ -30,8 +34,6 @@
#include "lcd.h"
#include "debug.h"
#include <3ds/services/gsplcd.h>
#include <3ds/result.h>
#include "luminance-ctru.h"
/* TODO: To use calibrated values in rockbox,

View file

@ -22,6 +22,13 @@
#include <math.h>
#include <stdlib.h> /* EXIT_SUCCESS */
#include <stdio.h>
#include <3ds/types.h>
#include <3ds/services/apt.h>
#include <3ds/services/hid.h>
#include <3ds/services/mcuhwc.h>
#include <3ds/services/dsp.h>
#include "config.h"
#include "button.h"
#include "kernel.h"
@ -38,12 +45,6 @@
#include "touchscreen.h"
#include <3ds/types.h>
#include <3ds/services/apt.h>
#include <3ds/services/hid.h>
#include <3ds/services/mcuhwc.h>
#include <3ds/services/dsp.h>
static u8 old_slider_level = 0;
static int last_y, last_x;
@ -136,9 +137,6 @@ int button_read_device(int* data)
if (kDown & KEY_DDOWN) {
key |= BUTTON_DOWN;
}
if (kDown & KEY_START) {
key |= BUTTON_POWER;
}
touchPosition touch;
hidTouchRead(&touch);

View file

@ -24,6 +24,9 @@
#include <stdio.h>
#include <errno.h>
#include <utime.h>
#include <3ds/archive.h>
#include "config.h"
#include "system.h"
#include "file.h"
@ -33,8 +36,6 @@
#include "pathfuncs.h"
#include "string-extra.h"
#include <3ds/archive.h>
void paths_init(void)
{
/* is this needed in 3DS? */

View file

@ -19,9 +19,15 @@
*
****************************************************************************/
#define RB_FILESYSTEM_OS
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
/* this is part of CTRDL and includes 3ds.h */
#include <dlfcn.h>
#ifdef RGB565
#undef RGB565
#endif
#include "system.h"
#include "load_code.h"
#include "filesystem-ctru.h"

View file

@ -22,17 +22,22 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <3ds/gfx.h>
#ifdef RGB565
#undef RGB565
#endif
#include <3ds/allocator/linear.h>
#include <3ds/console.h>
#include <3ds/services/cfgu.h>
#include "debug.h"
#include "system.h"
#include "button-ctru.h"
#include "screendump.h"
#include "lcd-target.h"
#include <3ds/gfx.h>
#include <3ds/allocator/linear.h>
#include <3ds/console.h>
#include <3ds/services/cfgu.h>
/*#define LOGF_ENABLE*/
#include "logf.h"
@ -186,7 +191,7 @@ void lcd_init_device(void)
/* hidInit(); */
u16 fb_width, fb_height;
u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &fb_width, &fb_height);
gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &fb_width, &fb_height);
u32 bufsize = fb_width * fb_height * 2;
dev_fb = (fb_data *) linearAlloc(bufsize);

View file

@ -10,6 +10,10 @@
#include <math.h>
#include <3ds/gfx.h>
#ifdef RGB565
#undef RGB565
#endif
#include <3ds/svc.h>
#include <3ds/types.h>
#include <3ds/thread.h>

View file

@ -19,19 +19,22 @@
*
****************************************************************************/
#define DIRFUNCTIONS_DEFINED
#include "config.h"
#include <errno.h>
#include <string.h>
#include "fs_defines.h"
#include <3ds/archive.h>
#include <3ds/util/utf.h>
/* this includes a couple of 3ds headers */
#include "sys_file.h"
#include "config.h"
#include "debug.h"
#include "dir.h"
#include "pathfuncs.h"
#include "timefuncs.h"
#include "system.h"
#include "fs_defines.h"
#include "sys_file.h"
#include <3ds/archive.h>
#include <3ds/util/utf.h>
/* This file is based on firmware/common/dir.c */

View file

@ -18,19 +18,22 @@
* KIND, either express or implied.
*
****************************************************************************/
#define RB_FILESYSTEM_OS
#include "config.h"
#include "system.h"
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <utime.h>
#include "fs_defines.h"
/* this includes a couple of 3ds headers */
#include "sys_file.h"
#define RB_FILESYSTEM_OS
#include "config.h"
#include "system.h"
#include "file.h"
#include "debug.h"
#include "string-extra.h"
#include "fs_defines.h"
#include "sys_file.h"
/* This file is based on firmware/common/file.c */

View file

@ -22,12 +22,12 @@
#ifndef __SYSTHREAD_H__
#define __SYSTHREAD_H__
#include "thread.h"
#include <3ds/synchronization.h>
#include <3ds/thread.h>
#include <3ds/services/apt.h>
#include "thread.h"
/* Complementary atomic operations */
bool _AtomicCAS(u32 *ptr, int oldval, int newval);
#define AtomicGet(ptr) __atomic_load_n((u32*)(ptr), __ATOMIC_SEQ_CST)

View file

@ -24,13 +24,15 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "debug.h"
#include "logf.h"
#include <3ds/os.h>
/* these include a couple of 3ds headers */
#include "sys_thread.h"
#include "sys_timer.h"
#include "debug.h"
#include "logf.h"
#define CACHELINE_SIZE 128
static bool ticks_started = false;
@ -283,7 +285,7 @@ void sys_timer_quit(void)
/* Shutdown the timer thread */
if (data->thread) {
LightSemaphore_Release(&data->sem, 1);
Result res = threadJoin(data->thread, U64_MAX);
threadJoin(data->thread, U64_MAX);
threadFree(data->thread);
data->thread = NULL;
}

View file

@ -27,6 +27,13 @@
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <3ds/ndsp/ndsp.h>
#include <3ds/ndsp/channel.h>
#include <3ds/services/dsp.h>
#include <3ds/synchronization.h>
#include <3ds/allocator/linear.h>
#include "config.h"
#include "debug.h"
#include "sound.h"
@ -47,12 +54,6 @@
#include "pcm_mixer.h"
#include "pcm_sink.h"
#include <3ds/ndsp/ndsp.h>
#include <3ds/ndsp/channel.h>
#include <3ds/services/dsp.h>
#include <3ds/synchronization.h>
#include <3ds/allocator/linear.h>
/*#define LOGF_ENABLE*/
#include "logf.h"

View file

@ -22,6 +22,11 @@
#include <unistd.h>
#include <stdbool.h>
#include <3ds/types.h>
#include <3ds/result.h>
#include <3ds/services/mcuhwc.h>
#include <3ds/services/ptmu.h>
#include "config.h"
#include "kernel.h"
#include "powermgmt.h"
@ -30,11 +35,6 @@
#include "system.h"
#include "debug.h"
#include <3ds/types.h>
#include <3ds/result.h>
#include <3ds/services/mcuhwc.h>
#include <3ds/services/ptmu.h>
void mcuhwc_init(void)
{
Result result = mcuHwcInit();

View file

@ -23,6 +23,14 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
/* this includes a couple of 3ds headers */
#include "bfile.h"
#include <3ds/types.h>
#include <3ds/allocator/linear.h>
#include <3ds/services/cfgu.h>
#include "system.h"
#include "kernel.h"
#include "thread-ctru.h"
@ -32,11 +40,6 @@
#include "panic.h"
#include "debug.h"
#include <3ds/types.h>
#include <3ds/allocator/linear.h>
#include <3ds/services/cfgu.h>
#include "bfile.h"
const char *audiodev = NULL;
#ifdef DEBUG
@ -94,7 +97,7 @@ void system_init(void)
svcGetThreadPriority(&main_thread_priority, CUR_THREAD_HANDLE);
if (main_thread_priority != 0x30) {
DEBUGF("warning, main_thread_priority = 0x%x\n", main_thread_priority);
DEBUGF("warning, main_thread_priority = 0x%lx\n", main_thread_priority);
}
/* check for New 3DS model */

View file

@ -23,12 +23,16 @@
#include <stdbool.h>
#include <stdbool.h>
#include "config.h"
#include "gcc_extensions.h"
#include <3ds/types.h>
#include <3ds/svc.h>
#include "sys_timer.h"
#ifdef BIT
#undef BIT
#endif
#include "config.h"
#include "gcc_extensions.h"
#define HIGHEST_IRQ_LEVEL 1

View file

@ -34,7 +34,7 @@ int _start(void) {return 0;}
#ifdef CTRU
/* dummy undefined symbols */
void __aeabi_unwind_cpp_pr0(void) {}
struct _reent * _EXFUN(__getreent, (void)) {}
struct _reent * _EXFUN(__getreent, (void)) { return NULL; }
#endif
enum codec_status codec_start(enum codec_entry_call_reason reason)

2
tools/configure vendored
View file

@ -939,7 +939,7 @@ devkitarmcc () {
GCCOPTS=`echo $GCCOPTS | sed -e s/\ -Os/\ -Og/`
fi
GCCOPTS="$GCCOPTS -fno-builtin -g -Wno-unused-result"
GCCOPTS="$GCCOPTS -fno-builtin -g -Wno-unused-result -Wno-char-subscripts"
GCCOPTS="$GCCOPTS -I$DEVKITPRO/libctru/include -I$DEVKITPRO/portlibs/3ds/include"
GCCOPTS="$GCCOPTS -mword-relocations -ffunction-sections -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft"
GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -D_REENTRANT -masm-syntax-unified"