rockbox/firmware/target/hosted/ctru/lc-ctru.c
Vencislav Atanasov a77c5d2219 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
2026-03-13 10:24:36 -04:00

80 lines
2.4 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2025 Mauricio G.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#define RB_FILESYSTEM_OS
#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"
#include "debug.h"
extern u32 __ctrl_code_allocator_pages;
void* programResolver(const char* sym, void *userData);
void * lc_open(const char *filename, unsigned char *buf, size_t buf_size)
{
DEBUGF("dlopen(path=\"%s\")\n", filename);
/* We need to increase __ctrl_code_allocator_pages value to 8 MB
to enable big plugins */
__ctrl_code_allocator_pages = 2048;
/* note: the 3ds dlopen implementation needs a custom resolver
for the unresolved symbols in shared objects */
/* void *handle = dlopen(filename, RTLD_NOW | RTLD_LOCAL); */
void *handle = ctrdlOpen(filename,
RTLD_NOW | RTLD_LOCAL,
programResolver,
NULL);
if (handle == NULL)
{
DEBUGF("%s(\"%s\") failed\n", __func__, filename);
DEBUGF(" lc_open error '%s'\n", dlerror());
}
DEBUGF("handle = %p\n", handle);
return handle;
(void) buf; (void) buf_size;
}
void * lc_get_header(void *handle)
{
void *symbol = dlsym(handle, "__header");
if (!symbol) {
symbol = dlsym(handle, "___header");
}
return symbol;
}
void lc_close(void *handle)
{
if (handle) {
dlclose(handle);
}
}