Extracting cstdio functions

This commit is contained in:
Rodrigo Alfonso 2025-01-12 07:28:57 -03:00
parent b35a5f360c
commit bfa230f697
3 changed files with 26 additions and 11 deletions

View File

@ -49,7 +49,6 @@
#include "_link_common.hpp"
#include <cstdio>
#include "LinkCable.hpp"
#include "LinkWireless.hpp"
@ -567,7 +566,7 @@ class LinkUniversal {
break;
if (!server.isFull() &&
std::strcmp(server.gameName, config.gameName) == 0 &&
LINK_STRCMP(server.gameName, config.gameName) == 0 &&
(LINK_UNIVERSAL_GAME_ID_FILTER == 0 ||
server.gameId == LINK_UNIVERSAL_GAME_ID_FILTER)) {
u32 randomNumber = safeStoi(server.userName);
@ -589,7 +588,7 @@ class LinkUniversal {
serveWait = SERVE_WAIT_FRAMES + _qran_range(1, SERVE_WAIT_FRAMES_RANDOM);
u32 randomNumber = _qran_range(1, MAX_ROOM_NUMBER);
char randomNumberStr[6];
std::snprintf(randomNumberStr, sizeof(randomNumberStr), "%d",
LINK_SNPRINTF(randomNumberStr, sizeof(randomNumberStr), "%d",
randomNumber);
if (!linkWireless.serve(config.gameName, randomNumberStr,
LINK_UNIVERSAL_GAME_ID_FILTER > 0

View File

@ -102,7 +102,7 @@
* For example, in a Makefile-based project, verify that the file is in your
* `SRCDIRS` list.
*/
// #define LINK_WIRELESS_PUT_ISR_IN_IWRAM
#define LINK_WIRELESS_PUT_ISR_IN_IWRAM
#endif
#ifndef LINK_WIRELESS_ENABLE_NESTED_IRQ

View File

@ -5,13 +5,6 @@
#pragma GCC system_header
#endif
/**
* @brief Enable mGBA debug logging.
*/
#ifndef LINK_ENABLE_DEBUG_LOGS
#define LINK_ENABLE_DEBUG_LOGS 0
#endif
/**
* @brief strlen(...) implementation (by default, std::strlen)
*/
@ -20,6 +13,22 @@
#define LINK_STRLEN std::strlen
#endif
/**
* @brief strcmp(...) implementation (by default, std::strcmp)
*/
#ifndef LINK_STRCMP
#include <cstdio>
#define LINK_STRCMP std::strcmp
#endif
/**
* @brief snprintf(...) implementation (by default, std::snprintf)
*/
#ifndef LINK_SNPRINTF
#include <cstdio>
#define LINK_SNPRINTF std::snprintf
#endif
/**
* @brief memcpy(...) implementation (by default, std::memcpy)
*/
@ -28,6 +37,13 @@
#define LINK_MEMCPY std::memcpy
#endif
/**
* @brief Enable mGBA debug logging.
*/
#ifndef LINK_ENABLE_DEBUG_LOGS
#define LINK_ENABLE_DEBUG_LOGS 0
#endif
#if LINK_ENABLE_DEBUG_LOGS != 0
#include <stdarg.h>
#include <stdio.h>