From 778cb660d09bf1aef411b88a0d5a57ddeddc6f86 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Thu, 14 May 2026 12:18:34 +0000 Subject: [PATCH] common/types: drop , add explicit includes at the 41 callers types.h carried for transitive purposes only - the header itself never references std::memcpy / std::memset / std::strlen etc. 41 TUs across the tree used those C-string functions while relying on types.h to supply the declaration. Add an explicit '#include ' to each of those files and drop it from types.h. The headers that also use cstring functions (error.h, jit_code_buffer.h are not in the list because they already include directly, or use the C-namespace already in scope) are unaffected. Files getting an explicit : src/common: cd_image.cpp, cd_image_ecm.cpp, cd_image_mds.cpp, cd_image_memory.cpp, cd_image_pbp.cpp, cd_image_ppf.cpp, cd_subchannel_replacement.cpp, cue_parser.cpp, d3d12/shader_cache.cpp, d3d12/staging_texture.cpp, d3d12/texture.cpp, d3d12/util.cpp, iso_reader.cpp, jit_code_buffer.cpp, md5_digest.cpp, vulkan/shader_cache.cpp, vulkan/staging_texture.cpp src/core: bios.cpp, bios.h, bus.cpp, cdrom.cpp, cheats.cpp, cpu_code_cache.cpp, cpu_recompiler_code_generator.cpp, cpu_recompiler_register_cache.cpp, dma.cpp, gpu.cpp, gpu_hw.cpp, gpu_hw.h, gpu_hw_d3d11.cpp, gpu_hw_d3d12.cpp, gpu_hw_opengl.cpp, gpu_hw_vulkan.cpp, gpu_sw.cpp, gte.cpp, mdec.cpp, memory_card_image.cpp, pgxp.cpp, spu.cpp, system.cpp src/libretro: libretro_host_display.cpp Most files get one '#include ' added into the existing system-include block, sorted alphabetically. A handful of files (system.cpp, memory_card_image.cpp, d3d12/shader_cache.cpp) had pre-existing blank-line separations between the stdlib include block and libretro third-party headers (, ); those separations are preserved. Build: Makefile.libretro platform=unix - clean, no warnings. swanstation_libretro.so size unchanged (8026128 bytes). retro_* exports: 25 (unchanged). types.h now only includes , , and - the three headers it actually needs for its own contents. --- src/common/cd_image.cpp | 1 + src/common/cd_image_ecm.cpp | 1 + src/common/cd_image_mds.cpp | 1 + src/common/cd_image_memory.cpp | 1 + src/common/cd_image_pbp.cpp | 1 + src/common/cd_image_ppf.cpp | 1 + src/common/cd_subchannel_replacement.cpp | 1 + src/common/cue_parser.cpp | 1 + src/common/d3d12/shader_cache.cpp | 1 + src/common/d3d12/staging_texture.cpp | 1 + src/common/d3d12/texture.cpp | 1 + src/common/d3d12/util.cpp | 1 + src/common/iso_reader.cpp | 1 + src/common/jit_code_buffer.cpp | 2 +- src/common/md5_digest.cpp | 1 + src/common/types.h | 1 - src/common/vulkan/shader_cache.cpp | 2 +- src/common/vulkan/staging_texture.cpp | 1 + src/core/bios.cpp | 2 +- src/core/bios.h | 2 +- src/core/bus.cpp | 2 +- src/core/cdrom.cpp | 2 +- src/core/cheats.cpp | 1 + src/core/cpu_code_cache.cpp | 1 + src/core/cpu_recompiler_code_generator.cpp | 1 + src/core/cpu_recompiler_register_cache.cpp | 2 +- src/core/dma.cpp | 1 + src/core/gpu.cpp | 2 +- src/core/gpu_hw.cpp | 2 +- src/core/gpu_hw.h | 2 +- src/core/gpu_hw_d3d11.cpp | 2 +- src/core/gpu_hw_d3d12.cpp | 1 + src/core/gpu_hw_opengl.cpp | 1 + src/core/gpu_hw_vulkan.cpp | 1 + src/core/gpu_sw.cpp | 2 +- src/core/gte.cpp | 2 +- src/core/mdec.cpp | 1 + src/core/memory_card_image.cpp | 1 + src/core/pgxp.cpp | 2 +- src/core/spu.cpp | 2 +- src/core/system.cpp | 1 + src/libretro/libretro_host_display.cpp | 4 ++-- 42 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/common/cd_image.cpp b/src/common/cd_image.cpp index 72efc9a8..3881bf03 100644 --- a/src/common/cd_image.cpp +++ b/src/common/cd_image.cpp @@ -3,6 +3,7 @@ #include "log.h" #include "string_util.h" #include +#include Log_SetChannel(CDImage); CDImage::CDImage(OpenFlags open_flags) : m_open_flags(open_flags) {} diff --git a/src/common/cd_image_ecm.cpp b/src/common/cd_image_ecm.cpp index e7111644..4363ebb0 100644 --- a/src/common/cd_image_ecm.cpp +++ b/src/common/cd_image_ecm.cpp @@ -5,6 +5,7 @@ #include "log.h" #include #include +#include #include Log_SetChannel(CDImageEcm); diff --git a/src/common/cd_image_mds.cpp b/src/common/cd_image_mds.cpp index a9104e7a..8dc6b3cf 100644 --- a/src/common/cd_image_mds.cpp +++ b/src/common/cd_image_mds.cpp @@ -4,6 +4,7 @@ #include "file_system.h" #include "log.h" #include +#include #include Log_SetChannel(CDImageMds); diff --git a/src/common/cd_image_memory.cpp b/src/common/cd_image_memory.cpp index 2fe965f1..15cf274e 100644 --- a/src/common/cd_image_memory.cpp +++ b/src/common/cd_image_memory.cpp @@ -3,6 +3,7 @@ #include "file_system.h" #include "log.h" #include +#include #include Log_SetChannel(CDImageMemory); diff --git a/src/common/cd_image_pbp.cpp b/src/common/cd_image_pbp.cpp index 03942dac..0a2f0587 100644 --- a/src/common/cd_image_pbp.cpp +++ b/src/common/cd_image_pbp.cpp @@ -9,6 +9,7 @@ #include "miniz.h" #include #include +#include #include Log_SetChannel(CDImagePBP); diff --git a/src/common/cd_image_ppf.cpp b/src/common/cd_image_ppf.cpp index 3b7ad69b..4d4ec317 100644 --- a/src/common/cd_image_ppf.cpp +++ b/src/common/cd_image_ppf.cpp @@ -4,6 +4,7 @@ #include "log.h" #include #include +#include #include #include Log_SetChannel(CDImagePPF); diff --git a/src/common/cd_subchannel_replacement.cpp b/src/common/cd_subchannel_replacement.cpp index 1a8ef402..c95c3efa 100644 --- a/src/common/cd_subchannel_replacement.cpp +++ b/src/common/cd_subchannel_replacement.cpp @@ -2,6 +2,7 @@ #include "file_system.h" #include "log.h" #include +#include #include Log_SetChannel(CDSubChannelReplacement); diff --git a/src/common/cue_parser.cpp b/src/common/cue_parser.cpp index 88a4e28f..a3e3100a 100644 --- a/src/common/cue_parser.cpp +++ b/src/common/cue_parser.cpp @@ -3,6 +3,7 @@ #include "log.h" #include "string_util.h" #include +#include #include Log_SetChannel(CueParser); diff --git a/src/common/d3d12/shader_cache.cpp b/src/common/d3d12/shader_cache.cpp index 415a7efc..3b4381df 100644 --- a/src/common/d3d12/shader_cache.cpp +++ b/src/common/d3d12/shader_cache.cpp @@ -3,6 +3,7 @@ #include "../file_system.h" #include "../log.h" #include "../md5_digest.h" +#include #include #include diff --git a/src/common/d3d12/staging_texture.cpp b/src/common/d3d12/staging_texture.cpp index 9ecd4e72..6926d141 100644 --- a/src/common/d3d12/staging_texture.cpp +++ b/src/common/d3d12/staging_texture.cpp @@ -3,6 +3,7 @@ #include "context.h" #include "util.h" +#include namespace D3D12 { StagingTexture::StagingTexture() : m_width(0), m_height(0) {} diff --git a/src/common/d3d12/texture.cpp b/src/common/d3d12/texture.cpp index b4b8d315..f5092a54 100644 --- a/src/common/d3d12/texture.cpp +++ b/src/common/d3d12/texture.cpp @@ -5,6 +5,7 @@ #include "stream_buffer.h" #include "util.h" +#include namespace D3D12 { Texture::Texture() = default; diff --git a/src/common/d3d12/util.cpp b/src/common/d3d12/util.cpp index 9aaa402e..d909f79c 100644 --- a/src/common/d3d12/util.cpp +++ b/src/common/d3d12/util.cpp @@ -5,6 +5,7 @@ #include "context.h" #include "shader_cache.h" #include +#include #include Log_SetChannel(D3D12); diff --git a/src/common/iso_reader.cpp b/src/common/iso_reader.cpp index 42d3e515..bac906fc 100644 --- a/src/common/iso_reader.cpp +++ b/src/common/iso_reader.cpp @@ -2,6 +2,7 @@ #include "cd_image.h" #include "log.h" #include +#include Log_SetChannel(ISOReader); static bool FilenamesEqual(const char* a, const char* b, u32 length) diff --git a/src/common/jit_code_buffer.cpp b/src/common/jit_code_buffer.cpp index 394d078e..4568b21e 100644 --- a/src/common/jit_code_buffer.cpp +++ b/src/common/jit_code_buffer.cpp @@ -2,7 +2,7 @@ #include "align.h" #include "platform.h" #include - +#include #if defined(_WIN32) #include "windows_headers.h" #else diff --git a/src/common/md5_digest.cpp b/src/common/md5_digest.cpp index 2f413532..2127f9fe 100644 --- a/src/common/md5_digest.cpp +++ b/src/common/md5_digest.cpp @@ -1,5 +1,6 @@ #include "md5_digest.h" +#include // Plumb's reference MD5 needs to know the host endianness. The // algorithm operates on 32-bit longwords; on a big-endian host the // raw input bytes need to be byte-reversed before the per-block diff --git a/src/common/types.h b/src/common/types.h index a27471c0..c1a62476 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include #include // Force inline helper diff --git a/src/common/vulkan/shader_cache.cpp b/src/common/vulkan/shader_cache.cpp index 08276e5c..83390527 100644 --- a/src/common/vulkan/shader_cache.cpp +++ b/src/common/vulkan/shader_cache.cpp @@ -6,8 +6,8 @@ #include "shader_compiler.h" #include "util.h" +#include #include - Log_SetChannel(Vulkan::ShaderCache); // TODO: store the driver version and stuff in the shader header diff --git a/src/common/vulkan/staging_texture.cpp b/src/common/vulkan/staging_texture.cpp index 11e65bbb..2f964d2f 100644 --- a/src/common/vulkan/staging_texture.cpp +++ b/src/common/vulkan/staging_texture.cpp @@ -7,6 +7,7 @@ #include "context.h" #include "util.h" +#include namespace Vulkan { StagingTexture::StagingTexture() = default; diff --git a/src/core/bios.cpp b/src/core/bios.cpp index ebb1e080..7341a555 100644 --- a/src/core/bios.cpp +++ b/src/core/bios.cpp @@ -4,7 +4,7 @@ #include #include #include - +#include namespace BIOS { static constexpr Hash MakeHashFromString(const char str[]) { diff --git a/src/core/bios.h b/src/core/bios.h index f1fd3867..9d40d15b 100644 --- a/src/core/bios.h +++ b/src/core/bios.h @@ -1,9 +1,9 @@ #pragma once #include "types.h" +#include #include #include #include - namespace BIOS { inline constexpr u32 BIOS_BASE = 0x1FC00000, BIOS_SIZE = 0x80000, BIOS_SIZE_PS2 = 0x400000, BIOS_SIZE_PS3 = 0x3E66F0; diff --git a/src/core/bus.cpp b/src/core/bus.cpp index 506d0922..0bd38a22 100644 --- a/src/core/bus.cpp +++ b/src/core/bus.cpp @@ -16,9 +16,9 @@ #include "spu.h" #include "timers.h" #include +#include #include #include - // Disable MSVC unreachable code warnings for code that actually get reached #ifdef _MSC_VER #pragma warning(push) diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index b20ed077..679a3ae2 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -8,7 +8,7 @@ #include "spu.h" #include "system.h" #include - +#include #if defined(CPU_X64) #include #endif diff --git a/src/core/cheats.cpp b/src/core/cheats.cpp index 16eba365..df75f3e1 100644 --- a/src/core/cheats.cpp +++ b/src/core/cheats.cpp @@ -10,6 +10,7 @@ #include "host_interface.h" #include "system.h" #include +#include #include #include #include diff --git a/src/core/cpu_code_cache.cpp b/src/core/cpu_code_cache.cpp index af3b9dab..2a4a2579 100644 --- a/src/core/cpu_code_cache.cpp +++ b/src/core/cpu_code_cache.cpp @@ -6,6 +6,7 @@ #include "settings.h" #include "system.h" #include "timing_event.h" +#include Log_SetChannel(CPU::CodeCache); #ifdef WITH_RECOMPILER diff --git a/src/core/cpu_recompiler_code_generator.cpp b/src/core/cpu_recompiler_code_generator.cpp index a7d66ca8..ea54a158 100644 --- a/src/core/cpu_recompiler_code_generator.cpp +++ b/src/core/cpu_recompiler_code_generator.cpp @@ -5,6 +5,7 @@ #include "gte.h" #include "pgxp.h" #include "settings.h" +#include Log_SetChannel(CPU::Recompiler); // TODO: Turn load+sext/zext into a single signed/unsigned load diff --git a/src/core/cpu_recompiler_register_cache.cpp b/src/core/cpu_recompiler_register_cache.cpp index 92375fed..d61b882f 100644 --- a/src/core/cpu_recompiler_register_cache.cpp +++ b/src/core/cpu_recompiler_register_cache.cpp @@ -1,7 +1,7 @@ #include "cpu_recompiler_register_cache.h" #include "cpu_recompiler_code_generator.h" #include - +#include namespace CPU::Recompiler { Value::Value() = default; diff --git a/src/core/dma.cpp b/src/core/dma.cpp index ae71f003..73f2b7da 100644 --- a/src/core/dma.cpp +++ b/src/core/dma.cpp @@ -12,6 +12,7 @@ #include "spu.h" #include "system.h" +#include static u32 GetAddressMask() { return Bus::g_ram_mask & 0xFFFFFFFCu; diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 725f89c1..a8231a92 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -10,7 +10,7 @@ #include "system.h" #include "timers.h" #include - +#include std::unique_ptr g_gpu; const GPU::GP0CommandHandlerTable GPU::s_GP0_command_handler_table = GPU::GenerateGP0CommandHandlerTable(); diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index c7bb8c8e..a68f59c5 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -6,9 +6,9 @@ #include "settings.h" #include "system.h" #include +#include #include #include - #define IS_POW2(value) (((value) & ((value) - 1)) == 0) template diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index a886e198..d967d749 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -2,12 +2,12 @@ #include "common/heap_array.h" #include "gpu.h" #include "host_display.h" +#include #include #include #include #include #include - class GPU_SW_Backend; struct GPUBackendCommand; struct GPUBackendDrawCommand; diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index 03b265cf..bf706c4a 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -15,8 +15,8 @@ Log_SetChannel(GPU_HW_D3D11); #define HAVE_D3D11 +#include #include - class LibretroD3D11HostDisplayTexture : public HostDisplayTexture { public: diff --git a/src/core/gpu_hw_d3d12.cpp b/src/core/gpu_hw_d3d12.cpp index 697ddca8..b9f63ca9 100644 --- a/src/core/gpu_hw_d3d12.cpp +++ b/src/core/gpu_hw_d3d12.cpp @@ -12,6 +12,7 @@ #include "host_display.h" #include "host_interface.h" #include "system.h" +#include Log_SetChannel(GPU_HW_D3D12); GPU_HW_D3D12::GPU_HW_D3D12() = default; diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 0cb067ed..3c0e4033 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -7,6 +7,7 @@ #include "host_display.h" #include "shader_cache_version.h" #include "core/host_interface.h" +#include #include #include "system.h" #include "texture_replacements.h" diff --git a/src/core/gpu_hw_vulkan.cpp b/src/core/gpu_hw_vulkan.cpp index 759fc00d..b653da9b 100644 --- a/src/core/gpu_hw_vulkan.cpp +++ b/src/core/gpu_hw_vulkan.cpp @@ -15,6 +15,7 @@ #include "core/host_interface.h" #include "system.h" #include "vulkan_loader.h" +#include Log_SetChannel(GPU_HW_Vulkan); class LibretroVulkanHostDisplayTexture : public HostDisplayTexture diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index 8a35ccc5..b8a71068 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -5,7 +5,7 @@ #include "host_display.h" #include "system.h" #include - +#include #if defined(CPU_X64) #include #elif defined(CPU_AARCH64) diff --git a/src/core/gte.cpp b/src/core/gte.cpp index b045b781..174a1181 100644 --- a/src/core/gte.cpp +++ b/src/core/gte.cpp @@ -10,8 +10,8 @@ #include "timing_event.h" #include #include +#include #include - namespace GTE { static constexpr s64 MAC0_MIN_VALUE = -(INT64_C(1) << 31); diff --git a/src/core/mdec.cpp b/src/core/mdec.cpp index 93d69e31..7f6abd7d 100644 --- a/src/core/mdec.cpp +++ b/src/core/mdec.cpp @@ -6,6 +6,7 @@ #include "interrupt_controller.h" #include "system.h" +#include MDEC g_mdec; MDEC::MDEC() = default; diff --git a/src/core/memory_card_image.cpp b/src/core/memory_card_image.cpp index 5ccd65d8..a5235cd6 100644 --- a/src/core/memory_card_image.cpp +++ b/src/core/memory_card_image.cpp @@ -7,6 +7,7 @@ #include "system.h" #include #include +#include #include #include diff --git a/src/core/pgxp.cpp b/src/core/pgxp.cpp index 4055256e..a5436bf7 100644 --- a/src/core/pgxp.cpp +++ b/src/core/pgxp.cpp @@ -24,7 +24,7 @@ #include "settings.h" #include #include - +#include namespace PGXP { inline constexpr u32 VERTEX_CACHE_WIDTH = 0x800 * 2, VERTEX_CACHE_HEIGHT = 0x800 * 2, diff --git a/src/core/spu.cpp b/src/core/spu.cpp index 2b7cad18..090a41de 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -6,8 +6,8 @@ #include "host_interface.h" #include "interrupt_controller.h" #include "system.h" +#include #include - #define SPU_TriggerRAMIRQ() \ m_SPUSTAT.irq9_flag = true; \ g_interrupt_controller.InterruptRequest(InterruptController::IRQ::SPU) diff --git a/src/core/system.cpp b/src/core/system.cpp index 389c5b56..5411a695 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libretro/libretro_host_display.cpp b/src/libretro/libretro_host_display.cpp index 5edf9cb8..a4f268b7 100644 --- a/src/libretro/libretro_host_display.cpp +++ b/src/libretro/libretro_host_display.cpp @@ -1,10 +1,10 @@ #include "libretro_host_display.h" #include "common/align.h" #include "core/host_interface.h" -#include #include +#include +#include #include - static retro_pixel_format GetRetroPixelFormat(HostDisplayPixelFormat format) { switch (format)