From 7dece41990e835859f16d28ea4897df42bab7aee Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sat, 26 Jul 2025 09:43:13 +0200 Subject: [PATCH] Fix includes in source/lib Make include-what-you-use happy with some files in source/lib and fix what needs to be fixed. Ref: #8086 Signed-off-by: Ralph Sennhauser --- source/lib/allocators/shared_ptr.h | 2 +- .../lib/allocators/tests/test_DynamicArena.h | 3 +- source/lib/allocators/tests/test_allocators.h | 3 +- source/lib/file/common/tests/test_trace.h | 8 ++- source/lib/file/file_system.h | 1 - source/lib/file/vfs/vfs_lookup.cpp | 1 - source/lib/file/vfs/vfs_tree.h | 2 + source/lib/file/vfs/vfs_util.cpp | 1 - source/lib/file/vfs/vfs_util.h | 1 - source/lib/ogl.cpp | 14 ++-- source/lib/pch/pch_stdlib.h | 6 +- source/lib/posix/posix_pthread.h | 3 +- source/lib/posix/posix_types.h | 12 ---- source/lib/posix/tests/test_posix.h | 5 +- source/lib/precompiled.h | 4 ++ source/lib/status.cpp | 6 +- source/lib/status.h | 3 +- source/lib/sysdep/arch/amd64/amd64.h | 4 +- source/lib/sysdep/arch/x86_x64/apic.cpp | 9 ++- source/lib/sysdep/arch/x86_x64/simd.cpp | 4 +- source/lib/sysdep/arch/x86_x64/x86_x64.cpp | 23 ++++--- source/lib/sysdep/arch/x86_x64/x86_x64.h | 4 ++ source/lib/sysdep/cpu.cpp | 10 ++- source/lib/sysdep/cpu.h | 2 +- source/lib/sysdep/dir_watch.h | 3 +- .../lib/sysdep/os/linux/dir_watch_inotify.cpp | 20 +++++- source/lib/sysdep/os/linux/lcpu.cpp | 10 +++ source/lib/sysdep/os/linux/ldbg.cpp | 11 ++- source/lib/sysdep/os/linux/linux.cpp | 9 ++- source/lib/sysdep/os/unix/udbg.cpp | 17 +++-- source/lib/sysdep/os/unix/ufilesystem.cpp | 15 +++- source/lib/sysdep/os/unix/unix.cpp | 18 +++-- .../os/unix/unix_executable_pathname.cpp | 12 +++- source/lib/sysdep/os/unix/unuma.cpp | 5 ++ source/lib/sysdep/os/unix/uvm.cpp | 9 ++- source/lib/sysdep/os_cpu.cpp | 6 +- source/lib/sysdep/rtl/gcc/gcc.cpp | 7 +- source/lib/sysdep/smbios.h | 69 +++++++++++++++++++ source/lib/sysdep/sysdep.h | 8 ++- source/lib/sysdep/tests/test_sysdep.h | 14 +++- source/lib/tests/test_adts.h | 5 +- source/lib/tests/test_fnv_hash.h | 3 +- source/lib/tex/tex.cpp | 9 ++- source/lib/tex/tex.h | 12 +++- source/lib/tex/tex_bmp.cpp | 11 ++- source/lib/tex/tex_codec.cpp | 13 ++-- source/lib/tex/tex_codec.h | 14 +++- source/lib/tex/tex_internal.h | 6 +- source/lib/timer.cpp | 17 ++--- source/lib/timer.h | 12 ++-- source/lib/types.h | 4 +- source/maths/tests/test_Bound.h | 6 +- source/ps/Profiler2.h | 1 + .../tests/test_ScriptConversions.h | 4 +- 54 files changed, 353 insertions(+), 128 deletions(-) diff --git a/source/lib/allocators/shared_ptr.h b/source/lib/allocators/shared_ptr.h index be6dcc7025..5afbdbc53d 100644 --- a/source/lib/allocators/shared_ptr.h +++ b/source/lib/allocators/shared_ptr.h @@ -24,7 +24,7 @@ #define INCLUDED_ALLOCATORS_SHARED_PTR #include "lib/alignment.h" -#include "lib/debug.h" +#include "lib/status.h" #include "lib/sysdep/rtl.h" // rtl_AllocateAligned #include "lib/types.h" diff --git a/source/lib/allocators/tests/test_DynamicArena.h b/source/lib/allocators/tests/test_DynamicArena.h index c2ac13bd6b..16c706236d 100644 --- a/source/lib/allocators/tests/test_DynamicArena.h +++ b/source/lib/allocators/tests/test_DynamicArena.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,6 +23,7 @@ #include "lib/self_test.h" #include "lib/allocators/DynamicArena.h" +#include "lib/types.h" class TestDynamicArena : public CxxTest::TestSuite { diff --git a/source/lib/allocators/tests/test_allocators.h b/source/lib/allocators/tests/test_allocators.h index 4a324e5dd8..14c5528dfe 100644 --- a/source/lib/allocators/tests/test_allocators.h +++ b/source/lib/allocators/tests/test_allocators.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,7 +23,6 @@ #include "lib/self_test.h" #include "lib/allocators/dynarray.h" -#include "lib/byte_order.h" class TestAllocators : public CxxTest::TestSuite { diff --git a/source/lib/file/common/tests/test_trace.h b/source/lib/file/common/tests/test_trace.h index cfed6c73c8..02e59ebc13 100644 --- a/source/lib/file/common/tests/test_trace.h +++ b/source/lib/file/common/tests/test_trace.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,6 +23,12 @@ #include "lib/self_test.h" #include "lib/file/common/trace.h" +#include "lib/os_path.h" +#include "lib/path.h" + +#include +#include +#include class TestTraceEntry : public CxxTest::TestSuite { diff --git a/source/lib/file/file_system.h b/source/lib/file/file_system.h index fd39af90ab..457d41d2c3 100644 --- a/source/lib/file/file_system.h +++ b/source/lib/file/file_system.h @@ -28,7 +28,6 @@ #define INCLUDED_FILE_SYSTEM #include "lib/os_path.h" -#include "lib/path.h" #include "lib/posix/posix_filesystem.h" #include "lib/posix/posix_types.h" #include "lib/status.h" diff --git a/source/lib/file/vfs/vfs_lookup.cpp b/source/lib/file/vfs/vfs_lookup.cpp index 5f48acd311..5535cabbc7 100644 --- a/source/lib/file/vfs/vfs_lookup.cpp +++ b/source/lib/file/vfs/vfs_lookup.cpp @@ -38,7 +38,6 @@ #include "lib/os_path.h" #include "lib/path.h" #include "lib/posix/posix_filesystem.h" -#include "lib/posix/posix_types.h" #include "lib/sysdep/filesystem.h" #include diff --git a/source/lib/file/vfs/vfs_tree.h b/source/lib/file/vfs/vfs_tree.h index b78505ee74..04eeabd79f 100644 --- a/source/lib/file/vfs/vfs_tree.h +++ b/source/lib/file/vfs/vfs_tree.h @@ -32,8 +32,10 @@ #include "lib/file/common/file_loader.h" // PIFileLoader #include "lib/file/common/real_directory.h" // PRealDirectory #include "lib/file/vfs/vfs_path.h" +#include "lib/path.h" #include +#include #include class VfsFile diff --git a/source/lib/file/vfs/vfs_util.cpp b/source/lib/file/vfs/vfs_util.cpp index 88ca3137ae..1f259ca56b 100644 --- a/source/lib/file/vfs/vfs_util.cpp +++ b/source/lib/file/vfs/vfs_util.cpp @@ -32,7 +32,6 @@ #include "lib/path.h" #include "lib/regex.h" #include "lib/secure_crt.h" -#include "lib/sysdep/filesystem.h" #include #include diff --git a/source/lib/file/vfs/vfs_util.h b/source/lib/file/vfs/vfs_util.h index ea7bc84f4d..18628d9a56 100644 --- a/source/lib/file/vfs/vfs_util.h +++ b/source/lib/file/vfs/vfs_util.h @@ -30,7 +30,6 @@ #include "lib/file/file_system.h" #include "lib/file/vfs/vfs.h" #include "lib/file/vfs/vfs_path.h" -#include "lib/os_path.h" #include "lib/status.h" #include diff --git a/source/lib/ogl.cpp b/source/lib/ogl.cpp index 2ff28ca4c4..4808bf37a7 100644 --- a/source/lib/ogl.cpp +++ b/source/lib/ogl.cpp @@ -22,34 +22,30 @@ #include "precompiled.h" -#include "lib/ogl.h" +#include "ogl.h" #include "lib/config2.h" #include "lib/debug.h" -#include "lib/external_libraries/libsdl.h" #include "ps/CLogger.h" -#if !CONFIG2_GLES +#include +#include +#if !CONFIG2_GLES # if OS_WIN # include # elif !OS_MACOSX # include # if defined(SDL_VIDEO_DRIVER_X11) +# include # include # endif # if defined(SDL_VIDEO_DRIVER_WAYLAND) # include # endif # endif - #endif // !CONFIG2_GLES -#include -#include -#include - - //---------------------------------------------------------------------------- // extensions //---------------------------------------------------------------------------- diff --git a/source/lib/pch/pch_stdlib.h b/source/lib/pch/pch_stdlib.h index 6066181e03..3acb01a2cf 100644 --- a/source/lib/pch/pch_stdlib.h +++ b/source/lib/pch/pch_stdlib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,6 +23,8 @@ #ifndef INCLUDED_PCH_STDLIB #define INCLUDED_PCH_STDLIB +// IWYU pragma: begin_keep + #if !MINIMAL_PCH // all new-form C library headers #include @@ -90,4 +92,6 @@ #include #endif // !MINIMAL_PCH +// IWYU pragma: end_keep + #endif // #ifndef INCLUDED_PCH_STDLIB diff --git a/source/lib/posix/posix_pthread.h b/source/lib/posix/posix_pthread.h index 9701e2770f..a9ac617dd0 100644 --- a/source/lib/posix/posix_pthread.h +++ b/source/lib/posix/posix_pthread.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -24,5 +24,6 @@ # include "lib/sysdep/os/win/wposix/wpthread.h" #else # include +# include # include #endif diff --git a/source/lib/posix/posix_types.h b/source/lib/posix/posix_types.h index 834a9ecf25..05227b0716 100644 --- a/source/lib/posix/posix_types.h +++ b/source/lib/posix/posix_types.h @@ -39,19 +39,7 @@ # include "lib/sysdep/os/win/wposix/wposix_types.h" #else -// unix/linux/glibc/gcc says that this macro has to be defined when including -// stdint.h from C++ for stdint.h to define SIZE_MAX and friends -# ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS -# endif - -# include -# include # include -# include -# include -# include - # include #endif // #if !OS_WIN diff --git a/source/lib/posix/tests/test_posix.h b/source/lib/posix/tests/test_posix.h index ae62261cb7..e7d0ff96b2 100644 --- a/source/lib/posix/tests/test_posix.h +++ b/source/lib/posix/tests/test_posix.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -22,7 +22,8 @@ #include "lib/self_test.h" -#include "lib/posix/posix.h" +#include +#include class TestPosix : public CxxTest::TestSuite { diff --git a/source/lib/precompiled.h b/source/lib/precompiled.h index c6f132842e..b13ab433c1 100644 --- a/source/lib/precompiled.h +++ b/source/lib/precompiled.h @@ -36,6 +36,8 @@ # define MINIMAL_PCH 0 #endif +// IWYU pragma: begin_keep + #include "lib/config.h" // CONFIG_ENABLE_PCH #include "lib/sysdep/compiler.h" // MSC_VERSION @@ -100,4 +102,6 @@ #include "ps/CLogger.h" #include "ps/Profile.h" +// IWYU pragma: end_keep + #endif // #if CONFIG_ENABLE_PCH diff --git a/source/lib/status.cpp b/source/lib/status.cpp index 21a0d779f9..049ba153cf 100644 --- a/source/lib/status.cpp +++ b/source/lib/status.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -30,9 +30,9 @@ #include "status.h" +#include "lib/secure_crt.h" + #include -#include -#include static StatusDefinitionBucket* buckets; diff --git a/source/lib/status.h b/source/lib/status.h index 399d33820b..251e01c93e 100644 --- a/source/lib/status.h +++ b/source/lib/status.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -161,6 +161,7 @@ To summarize: +/-1SHHCC (S=subsystem, HH=header, CC=code number) #ifndef INCLUDED_STATUS #define INCLUDED_STATUS +#include "lib/code_annotation.h" #include "lib/types.h" #include diff --git a/source/lib/sysdep/arch/amd64/amd64.h b/source/lib/sysdep/arch/amd64/amd64.h index 66549d4969..4b2605314a 100644 --- a/source/lib/sysdep/arch/amd64/amd64.h +++ b/source/lib/sysdep/arch/amd64/amd64.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -27,6 +27,8 @@ #ifndef INCLUDED_AMD64 #define INCLUDED_AMD64 +#include "lib/sysdep/arch.h" + #if !ARCH_AMD64 #error "including amd64.h without ARCH_AMD64=1" #endif diff --git a/source/lib/sysdep/arch/x86_x64/apic.cpp b/source/lib/sysdep/arch/x86_x64/apic.cpp index 8b8d90e1fb..15ca58c905 100644 --- a/source/lib/sysdep/arch/x86_x64/apic.cpp +++ b/source/lib/sysdep/arch/x86_x64/apic.cpp @@ -21,15 +21,20 @@ */ #include "precompiled.h" -#include "lib/sysdep/arch/x86_x64/apic.h" + +#include "apic.h" #include "lib/bits.h" +#include "lib/code_annotation.h" +#include "lib/debug.h" #include "lib/module_init.h" +#include "lib/status.h" +#include "lib/sysdep/arch/x86_x64/x86_x64.h" #include "lib/sysdep/cpu.h" // ERR::CPU_FEATURE_MISSING #include "lib/sysdep/os_cpu.h" -#include "lib/sysdep/arch/x86_x64/x86_x64.h" #include +#include ApicId GetApicId() { diff --git a/source/lib/sysdep/arch/x86_x64/simd.cpp b/source/lib/sysdep/arch/x86_x64/simd.cpp index a374ea17cc..e7d2dbe98e 100644 --- a/source/lib/sysdep/arch/x86_x64/simd.cpp +++ b/source/lib/sysdep/arch/x86_x64/simd.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,8 +25,6 @@ #include "lib/sysdep/arch/x86_x64/simd.h" #if COMPILER_HAS_SSE -#include "lib/code_generation.h" -#include "lib/debug.h" #include "lib/sysdep/arch.h" #if ARCH_X86_X64 diff --git a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp index 4fa6eb343a..2b4f544d5b 100644 --- a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp +++ b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,20 +25,23 @@ */ #include "precompiled.h" -#include "lib/sysdep/arch/x86_x64/x86_x64.h" -#include -#include -#include -#include -#include +#include "x86_x64.h" -#include "lib/posix/posix_pthread.h" #include "lib/bits.h" -#include "lib/timer.h" +#include "lib/code_annotation.h" +#include "lib/debug.h" +#include "lib/lib.h" #include "lib/module_init.h" +#include "lib/posix/posix_pthread.h" +#include "lib/secure_crt.h" +#include "lib/status.h" #include "lib/sysdep/cpu.h" -#include "lib/sysdep/os_cpu.h" +#include "lib/timer.h" + +#include +#include +#include #if MSC_VERSION # include // __rdtsc diff --git a/source/lib/sysdep/arch/x86_x64/x86_x64.h b/source/lib/sysdep/arch/x86_x64/x86_x64.h index 92287140e2..6e0659e464 100644 --- a/source/lib/sysdep/arch/x86_x64/x86_x64.h +++ b/source/lib/sysdep/arch/x86_x64/x86_x64.h @@ -28,6 +28,10 @@ #define INCLUDED_X86_X64 #include "lib/sysdep/arch.h" +#include "lib/sysdep/compiler.h" +#include "lib/types.h" + +#include #if !ARCH_X86_X64 #error "including x86_x64.h without ARCH_X86_X64=1" diff --git a/source/lib/sysdep/cpu.cpp b/source/lib/sysdep/cpu.cpp index fed1dacd84..daa284a13d 100644 --- a/source/lib/sysdep/cpu.cpp +++ b/source/lib/sysdep/cpu.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,7 +25,13 @@ */ #include "precompiled.h" -#include "lib/sysdep/cpu.h" + +#include "cpu.h" + +#include "lib/code_annotation.h" +#include "lib/types.h" + +#include static const StatusDefinition cpuStatusDefinitions[] = { { ERR::CPU_FEATURE_MISSING, L"This CPU doesn't support a required feature" }, diff --git a/source/lib/sysdep/cpu.h b/source/lib/sysdep/cpu.h index daeaa51e49..56646d26bd 100644 --- a/source/lib/sysdep/cpu.h +++ b/source/lib/sysdep/cpu.h @@ -28,9 +28,9 @@ #define INCLUDED_CPU #include "lib/status.h" +#include "lib/sysdep/arch.h" #include "lib/sysdep/compiler.h" - namespace ERR { const Status CPU_FEATURE_MISSING = -130000; diff --git a/source/lib/sysdep/dir_watch.h b/source/lib/sysdep/dir_watch.h index 449da3810c..d1d655d7db 100644 --- a/source/lib/sysdep/dir_watch.h +++ b/source/lib/sysdep/dir_watch.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -28,6 +28,7 @@ #define INCLUDED_DIR_WATCH #include "lib/os_path.h" +#include "lib/status.h" #include #include diff --git a/source/lib/sysdep/os/linux/dir_watch_inotify.cpp b/source/lib/sysdep/os/linux/dir_watch_inotify.cpp index f9b5306129..915cbe9d3a 100644 --- a/source/lib/sysdep/os/linux/dir_watch_inotify.cpp +++ b/source/lib/sysdep/os/linux/dir_watch_inotify.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,13 +23,27 @@ #include "precompiled.h" #include "lib/sysdep/dir_watch.h" -#include "lib/sysdep/sysdep.h" + +#include "lib/debug.h" +#include "lib/os_path.h" +#include "lib/path.h" +#include "lib/posix/posix_pthread.h" +#include "lib/posix/posix_types.h" +#include "lib/status.h" #include "ps/CLogger.h" +#include +#include +#include +#include +#include #include +#include #include #include - +#include +#include +#include struct NotificationEvent { diff --git a/source/lib/sysdep/os/linux/lcpu.cpp b/source/lib/sysdep/os/linux/lcpu.cpp index 572b56d6b5..c34029446b 100644 --- a/source/lib/sysdep/os/linux/lcpu.cpp +++ b/source/lib/sysdep/os/linux/lcpu.cpp @@ -23,10 +23,20 @@ #include "precompiled.h" #include "lib/sysdep/os_cpu.h" + #include "lib/alignment.h" #include "lib/bits.h" #include "lib/config2.h" +#include "lib/debug.h" #include "lib/module_init.h" +#include "lib/posix/posix_pthread.h" +#include "lib/posix/posix_types.h" +#include "lib/status.h" +#include "lib/sysdep/os.h" + +#include +#include +#include #if CONFIG2_VALGRIND # include "valgrind.h" diff --git a/source/lib/sysdep/os/linux/ldbg.cpp b/source/lib/sysdep/os/linux/ldbg.cpp index 8fb6e4fd38..88e1fc9dcc 100644 --- a/source/lib/sysdep/os/linux/ldbg.cpp +++ b/source/lib/sysdep/os/linux/ldbg.cpp @@ -30,11 +30,20 @@ #include "precompiled.h" -#include "lib/sysdep/sysdep.h" #include "lib/debug.h" +#include "lib/code_annotation.h" +#include "lib/posix/posix_types.h" +#include "lib/secure_crt.h" +#include "lib/status.h" +#include "lib/sysdep/os.h" + #include +#include +#include #include +#include +#include #include #if OS_ANDROID diff --git a/source/lib/sysdep/os/linux/linux.cpp b/source/lib/sysdep/os/linux/linux.cpp index b8f23c9f95..44e9afc61b 100644 --- a/source/lib/sysdep/os/linux/linux.cpp +++ b/source/lib/sysdep/os/linux/linux.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -22,8 +22,13 @@ #include "precompiled.h" -#include "lib/sysdep/sysdep.h" +#include "lib/os_path.h" +#include "lib/posix/posix_types.h" #include "lib/sysdep/os/unix/unix_executable_pathname.h" +#include "lib/sysdep/sysdep.h" + +#include +#include static bool getPathFromProc(char* buffer, size_t length) { diff --git a/source/lib/sysdep/os/unix/udbg.cpp b/source/lib/sysdep/os/unix/udbg.cpp index 94b32ce084..fde14a7382 100644 --- a/source/lib/sysdep/os/unix/udbg.cpp +++ b/source/lib/sysdep/os/unix/udbg.cpp @@ -29,14 +29,17 @@ symbol lookups and backtraces) #include "precompiled.h" -#include -#include -#include - -#include "lib/timer.h" -#include "lib/sysdep/sysdep.h" #include "lib/debug.h" -#include "lib/utf8.h" + +#include "lib/posix/posix_types.h" +#include "lib/status.h" +#include "lib/sysdep/os.h" + +#include + +#ifndef NDEBUG +# include +#endif Status debug_CaptureContext(void* /*context*/) diff --git a/source/lib/sysdep/os/unix/ufilesystem.cpp b/source/lib/sysdep/os/unix/ufilesystem.cpp index 2f2b719c0c..0fca66f263 100644 --- a/source/lib/sysdep/os/unix/ufilesystem.cpp +++ b/source/lib/sysdep/os/unix/ufilesystem.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,11 +25,22 @@ */ #include "precompiled.h" + #include "lib/sysdep/filesystem.h" -#include "lib/path.h" +#include "lib/code_annotation.h" +#include "lib/debug.h" +#include "lib/os_path.h" +#include "lib/posix/posix_filesystem.h" +#include "lib/posix/posix_types.h" +#include "lib/secure_crt.h" +#include "lib/sysdep/os.h" +#include #include +#include +#include +#include struct WDIR { diff --git a/source/lib/sysdep/os/unix/unix.cpp b/source/lib/sysdep/os/unix/unix.cpp index ecf5f0bf1e..347aa666d4 100644 --- a/source/lib/sysdep/os/unix/unix.cpp +++ b/source/lib/sysdep/os/unix/unix.cpp @@ -22,19 +22,25 @@ #include "precompiled.h" -#include -#include -#include - #include "lib/code_annotation.h" -#include "lib/utf8.h" +#include "lib/debug.h" +#include "lib/os_path.h" +#include "lib/posix/posix_types.h" +#include "lib/secure_crt.h" +#include "lib/status.h" +#include "lib/sysdep/os.h" #include "lib/sysdep/os/unix/udbg.h" #include "lib/sysdep/sysdep.h" +#include "lib/types.h" +#include "lib/utf8.h" #include +#include +#include +#include +#include #define GNU_SOURCE -#include #include diff --git a/source/lib/sysdep/os/unix/unix_executable_pathname.cpp b/source/lib/sysdep/os/unix/unix_executable_pathname.cpp index fc4acb140a..5dc779583b 100644 --- a/source/lib/sysdep/os/unix/unix_executable_pathname.cpp +++ b/source/lib/sysdep/os/unix/unix_executable_pathname.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -24,12 +24,18 @@ #include "lib/sysdep/sysdep.h" +#include "lib/os_path.h" +#include "lib/posix/posix_dlfcn.h" + +#include +#include +#include +#include + #define GNU_SOURCE #include "mocks/dlfcn.h" #include "mocks/unistd.h" -#include - OsPath unix_ExecutablePathname() { // Find the executable's filename diff --git a/source/lib/sysdep/os/unix/unuma.cpp b/source/lib/sysdep/os/unix/unuma.cpp index 2755e40a42..80085cfc79 100644 --- a/source/lib/sysdep/os/unix/unuma.cpp +++ b/source/lib/sysdep/os/unix/unuma.cpp @@ -21,11 +21,16 @@ */ #include "precompiled.h" + #include "lib/sysdep/numa.h" #include "lib/bits.h" +#include "lib/debug.h" #include "lib/sysdep/os_cpu.h" +#include +#include + size_t numa_NumNodes() { return 1; diff --git a/source/lib/sysdep/os/unix/uvm.cpp b/source/lib/sysdep/os/unix/uvm.cpp index 5704afe1ba..41d0b9264a 100644 --- a/source/lib/sysdep/os/unix/uvm.cpp +++ b/source/lib/sysdep/os/unix/uvm.cpp @@ -21,9 +21,16 @@ */ #include "precompiled.h" + #include "lib/sysdep/vm.h" -#include "lib/alignment.h" +#include "lib/debug.h" +#include "lib/posix/posix_mman.h" +#include "lib/status.h" + +#include +#include +#include // "anonymous" effectively means mapping /dev/zero, but is more efficient. // MAP_ANONYMOUS is not in SUSv3, but is a very common extension. diff --git a/source/lib/sysdep/os_cpu.cpp b/source/lib/sysdep/os_cpu.cpp index 1c9d8f4932..d516184a91 100644 --- a/source/lib/sysdep/os_cpu.cpp +++ b/source/lib/sysdep/os_cpu.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,10 +25,14 @@ */ #include "precompiled.h" + #include "lib/sysdep/os_cpu.h" #include "lib/alignment.h" +#include "lib/code_annotation.h" +#include "lib/sysdep/os.h" #include "lib/sysdep/smbios.h" +#include "lib/types.h" #if OS_WIN # include "lib/sysdep/os/win/wcpu.h" diff --git a/source/lib/sysdep/rtl/gcc/gcc.cpp b/source/lib/sysdep/rtl/gcc/gcc.cpp index e7172719a1..6ce1eae137 100644 --- a/source/lib/sysdep/rtl/gcc/gcc.cpp +++ b/source/lib/sysdep/rtl/gcc/gcc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -22,8 +22,11 @@ #include "precompiled.h" -#include "lib/sysdep/rtl.h" #include "lib/bits.h" +#include "lib/sysdep/os.h" +#include "lib/sysdep/rtl.h" + +#include // Linux glibc has posix_memalign and (obsolete) memalign // Android libc has only memalign diff --git a/source/lib/sysdep/smbios.h b/source/lib/sysdep/smbios.h index ec258b56f0..898c1b94df 100644 --- a/source/lib/sysdep/smbios.h +++ b/source/lib/sysdep/smbios.h @@ -29,8 +29,77 @@ #include "lib/types.h" +#include #include +namespace SMBIOS { struct Baseboard; } +namespace SMBIOS { struct BaseboardFlags; } +namespace SMBIOS { struct BaseboardType; } +namespace SMBIOS { struct Bios; } +namespace SMBIOS { struct BiosFlags1; } +namespace SMBIOS { struct BiosFlags2; } +namespace SMBIOS { struct BiosFlags; } +namespace SMBIOS { struct Cache; } +namespace SMBIOS { struct CacheAssociativity; } +namespace SMBIOS { struct CacheConfigurationFlags; } +namespace SMBIOS { struct CacheFlags; } +namespace SMBIOS { struct CacheLocation; } +namespace SMBIOS { struct CacheMode; } +namespace SMBIOS { struct CacheType; } +namespace SMBIOS { struct Chassis; } +namespace SMBIOS { struct ChassisSecurityStatus; } +namespace SMBIOS { struct ChassisType; } +namespace SMBIOS { struct CoolingDevice; } +namespace SMBIOS { struct CoolingDeviceType; } +namespace SMBIOS { struct ECC; } +namespace SMBIOS { struct ManagementDevice; } +namespace SMBIOS { struct ManagementDeviceAddressType; } +namespace SMBIOS { struct ManagementDeviceComponent; } +namespace SMBIOS { struct ManagementDeviceThreshold; } +namespace SMBIOS { struct ManagementDeviceType; } +namespace SMBIOS { struct MemoryArray; } +namespace SMBIOS { struct MemoryArrayLocation; } +namespace SMBIOS { struct MemoryArrayMappedAddress; } +namespace SMBIOS { struct MemoryArrayUse; } +namespace SMBIOS { struct MemoryDevice; } +namespace SMBIOS { struct MemoryDeviceFormFactor; } +namespace SMBIOS { struct MemoryDeviceMappedAddress; } +namespace SMBIOS { struct MemoryDeviceType; } +namespace SMBIOS { struct MemoryDeviceTypeFlags; } +namespace SMBIOS { struct OnBoardDeviceType; } +namespace SMBIOS { struct OnBoardDevices; } +namespace SMBIOS { struct OnboardDevices2; } +namespace SMBIOS { struct PortConnector; } +namespace SMBIOS { struct PortConnectorType; } +namespace SMBIOS { struct PortType; } +namespace SMBIOS { struct PortableBattery; } +namespace SMBIOS { struct PortableBatteryChemistry; } +namespace SMBIOS { struct Processor; } +namespace SMBIOS { struct ProcessorFlags; } +namespace SMBIOS { struct ProcessorStatus; } +namespace SMBIOS { struct ProcessorType; } +namespace SMBIOS { struct ProcessorUpgrade; } +namespace SMBIOS { struct State; } +namespace SMBIOS { struct System; } +namespace SMBIOS { struct SystemBoot; } +namespace SMBIOS { struct SystemBootStatus; } +namespace SMBIOS { struct SystemPowerSupply; } +namespace SMBIOS { struct SystemPowerSupplyCharacteristics; } +namespace SMBIOS { struct SystemPowerSupplyInputSwitching; } +namespace SMBIOS { struct SystemPowerSupplyType; } +namespace SMBIOS { struct SystemSlot; } +namespace SMBIOS { struct SystemSlotBusWidth; } +namespace SMBIOS { struct SystemSlotFlags1; } +namespace SMBIOS { struct SystemSlotFlags2; } +namespace SMBIOS { struct SystemSlotLength; } +namespace SMBIOS { struct SystemSlotType; } +namespace SMBIOS { struct SystemSlotUsage; } +namespace SMBIOS { struct SystemWakeUpType; } +namespace SMBIOS { struct TemperatureProbe; } +namespace SMBIOS { struct TemperatureProbeLocation; } +namespace SMBIOS { struct VoltageProbe; } +namespace SMBIOS { struct VoltageProbeLocation; } + namespace SMBIOS { // to introduce another enumeration: diff --git a/source/lib/sysdep/sysdep.h b/source/lib/sysdep/sysdep.h index 869354a54b..1135ab78ff 100644 --- a/source/lib/sysdep/sysdep.h +++ b/source/lib/sysdep/sysdep.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -33,6 +33,12 @@ #include "lib/debug.h" // ErrorReactionInternal #include "lib/os_path.h" +#include "lib/status.h" +#include "lib/sysdep/os.h" +#include "lib/types.h" + +#include +#include // diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h index 3fcdf21189..5ed9b1f8cc 100644 --- a/source/lib/sysdep/tests/test_sysdep.h +++ b/source/lib/sysdep/tests/test_sysdep.h @@ -22,10 +22,22 @@ #include "lib/self_test.h" -#include "lib/lib.h" +#include "lib/code_annotation.h" +#include "lib/os_path.h" +#include "lib/posix/posix_dlfcn.h" +#include "lib/posix/posix_filesystem.h" +#include "lib/posix/posix_types.h" #include "lib/secure_crt.h" #include "lib/sysdep/filesystem.h" +#include "lib/sysdep/os.h" #include "lib/sysdep/sysdep.h" +#include "lib/types.h" + +#include +#include +#include +#include +#include #if OS_BSD || OS_LINUX # include "lib/sysdep/os/unix/unix_executable_pathname.h" diff --git a/source/lib/tests/test_adts.h b/source/lib/tests/test_adts.h index c6a05530e0..596314fe47 100644 --- a/source/lib/tests/test_adts.h +++ b/source/lib/tests/test_adts.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -24,6 +24,9 @@ #include "lib/adts/ring_buf.h" +#include +#include +#include #include class TestRingbuf : public CxxTest::TestSuite diff --git a/source/lib/tests/test_fnv_hash.h b/source/lib/tests/test_fnv_hash.h index 88673744e6..9ba77dcee0 100644 --- a/source/lib/tests/test_fnv_hash.h +++ b/source/lib/tests/test_fnv_hash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,6 +23,7 @@ #include "lib/self_test.h" #include "lib/fnv_hash.h" +#include "lib/types.h" class TestFnvHash : public CxxTest::TestSuite { diff --git a/source/lib/tex/tex.cpp b/source/lib/tex/tex.cpp index cdd8b27bda..21c727b667 100644 --- a/source/lib/tex/tex.cpp +++ b/source/lib/tex/tex.cpp @@ -24,15 +24,18 @@ #include "tex.h" +#include "lib/alignment.h" +#include "lib/allocators/dynarray.h" #include "lib/allocators/shared_ptr.h" #include "lib/bits.h" -#include "lib/sysdep/cpu.h" +#include "lib/debug.h" +#include "lib/posix/posix_types.h" #include "lib/tex/tex_codec.h" #include "lib/timer.h" #include -#include -#include +#include +#include static const StatusDefinition texStatusDefinitions[] = { diff --git a/source/lib/tex/tex.h b/source/lib/tex/tex.h index bffd481dad..313aff5af2 100644 --- a/source/lib/tex/tex.h +++ b/source/lib/tex/tex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -104,12 +104,18 @@ library and IO layer. Read and write are zero-copy. #ifndef INCLUDED_TEX #define INCLUDED_TEX -#include "lib/os_path.h" +#include "lib/code_annotation.h" #include "lib/file/vfs/vfs_path.h" -#include "lib/allocators/dynarray.h" +#include "lib/os_path.h" +#include "lib/status.h" +#include "lib/types.h" +#include +#include #include +struct DynArray; + namespace ERR { const Status TEX_UNKNOWN_FORMAT = -120100; diff --git a/source/lib/tex/tex_bmp.cpp b/source/lib/tex/tex_bmp.cpp index 00ff6cacee..d2fe26dc61 100644 --- a/source/lib/tex/tex_bmp.cpp +++ b/source/lib/tex/tex_bmp.cpp @@ -26,9 +26,18 @@ #include "precompiled.h" -#include "lib/byte_order.h" #include "tex_codec.h" +#include "lib/byte_order.h" +#include "lib/code_annotation.h" +#include "lib/debug.h" +#include "lib/os_path.h" +#include "lib/status.h" +#include "lib/tex/tex.h" +#include "lib/types.h" + +#include + #pragma pack(push, 1) struct BmpHeader diff --git a/source/lib/tex/tex_codec.cpp b/source/lib/tex/tex_codec.cpp index 255e5002e1..c994f57007 100644 --- a/source/lib/tex/tex_codec.cpp +++ b/source/lib/tex/tex_codec.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,13 +25,14 @@ */ #include "precompiled.h" + #include "tex_codec.h" -#include -#include - -#include "lib/allocators/shared_ptr.h" // ArrayDeleter -#include "tex.h" +#include "lib/allocators/dynarray.h" +#include "lib/debug.h" +#include "lib/posix/posix_types.h" +#include "lib/tex/tex.h" +#include "lib/tex/tex_internal.h" // Statically allocate all of the codecs... TexCodecDds DdsCodec; diff --git a/source/lib/tex/tex_codec.h b/source/lib/tex/tex_codec.h index b756f09a77..6bd4e80f22 100644 --- a/source/lib/tex/tex_codec.h +++ b/source/lib/tex/tex_codec.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -27,8 +27,16 @@ #ifndef INCLUDED_TEX_CODEC #define INCLUDED_TEX_CODEC -#include "tex.h" -#include "tex_internal.h" // for codec's convenience +#include "lib/code_annotation.h" +#include "lib/os_path.h" +#include "lib/status.h" +#include "lib/types.h" + +#include +#include + +class Tex; +struct DynArray; /** * virtual method table for TexCodecs. diff --git a/source/lib/tex/tex_internal.h b/source/lib/tex/tex_internal.h index 227381facf..c68a641258 100644 --- a/source/lib/tex/tex_internal.h +++ b/source/lib/tex/tex_internal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -28,7 +28,9 @@ #define INCLUDED_TEX_INTERNAL #include "lib/allocators/dynarray.h" -#include "lib/file/io/io.h" // io::Allocate +#include "lib/status.h" + +#include /** * check if the given texture format is acceptable: 8bpp grey, diff --git a/source/lib/timer.cpp b/source/lib/timer.cpp index 81fba01a68..7ed7cae230 100644 --- a/source/lib/timer.cpp +++ b/source/lib/timer.cpp @@ -25,17 +25,18 @@ */ #include "precompiled.h" -#include "lib/timer.h" -#include -#include -#include -#include -#include -#include // std::stringstream +#include "timer.h" #include "lib/module_init.h" -#include "lib/sysdep/cpu.h" +#include "lib/posix/posix_types.h" +#include "lib/status.h" +#include "lib/sysdep/os.h" + +#include +#include +#include +#include #if OS_WIN #include "lib/sysdep/os/win/win.h" diff --git a/source/lib/timer.h b/source/lib/timer.h index 194d69ee06..e6af2da934 100644 --- a/source/lib/timer.h +++ b/source/lib/timer.h @@ -27,18 +27,20 @@ #ifndef INCLUDED_TIMER #define INCLUDED_TIMER +#include "lib/code_annotation.h" #include "lib/config2.h" // CONFIG2_TIMER_ALLOW_RDTSC +#include "lib/debug.h" #include "lib/sysdep/arch.h" +#include "lib/utf8.h" + +#include +#include + #if ARCH_X86_X64 && CONFIG2_TIMER_ALLOW_RDTSC # include "lib/sysdep/os_cpu.h" // os_cpu_ClockFrequency # include "lib/sysdep/arch/x86_x64/x86_x64.h" // x86_x64::rdtsc #endif -#include "lib/debug.h" -#include "lib/utf8.h" - -#include - /** * timer_Time will subsequently return values relative to the current time. **/ diff --git a/source/lib/types.h b/source/lib/types.h index 9e5ded3c52..db36ed2abf 100644 --- a/source/lib/types.h +++ b/source/lib/types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ #ifndef INCLUDED_TYPES #define INCLUDED_TYPES -#include "lib/posix/posix_types.h" +#include typedef int8_t i8; typedef int16_t i16; diff --git a/source/maths/tests/test_Bound.h b/source/maths/tests/test_Bound.h index 14c4c02d05..b9959dfdab 100644 --- a/source/maths/tests/test_Bound.h +++ b/source/maths/tests/test_Bound.h @@ -205,9 +205,9 @@ public: CBoundingBoxOriented result; flatAabb.Transform(transform, result); - TS_ASSERT(!isnan(result.m_Basis[0].X) && !isnan(result.m_Basis[0].Y) && !isnan(result.m_Basis[0].Z)); - TS_ASSERT(!isnan(result.m_Basis[1].X) && !isnan(result.m_Basis[1].Y) && !isnan(result.m_Basis[1].Z)); - TS_ASSERT(!isnan(result.m_Basis[2].X) && !isnan(result.m_Basis[2].Y) && !isnan(result.m_Basis[2].Z)); + TS_ASSERT(!std::isnan(result.m_Basis[0].X) && !std::isnan(result.m_Basis[0].Y) && !std::isnan(result.m_Basis[0].Z)); + TS_ASSERT(!std::isnan(result.m_Basis[1].X) && !std::isnan(result.m_Basis[1].Y) && !std::isnan(result.m_Basis[1].Z)); + TS_ASSERT(!std::isnan(result.m_Basis[2].X) && !std::isnan(result.m_Basis[2].Y) && !std::isnan(result.m_Basis[2].Z)); } void test_point_visibility() diff --git a/source/ps/Profiler2.h b/source/ps/Profiler2.h index 64d565d220..d10a07a092 100644 --- a/source/ps/Profiler2.h +++ b/source/ps/Profiler2.h @@ -82,6 +82,7 @@ #include "ps/ThreadUtil.h" #include +#include #include #include #include diff --git a/source/scriptinterface/tests/test_ScriptConversions.h b/source/scriptinterface/tests/test_ScriptConversions.h index 98ce6c08d2..61c3cfd1dc 100644 --- a/source/scriptinterface/tests/test_ScriptConversions.h +++ b/source/scriptinterface/tests/test_ScriptConversions.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -208,7 +208,7 @@ public: JS::RootedValue testNANVal(rq.cx); Script::ToJSVal(rq, &testNANVal, NAN); TS_ASSERT(Script::FromJSVal(rq, testNANVal, f)); - TS_ASSERT(isnan(f)); + TS_ASSERT(std::isnan(f)); } // NOTE: fixed and vector conversions are defined in simulation2/scripting/EngineScriptConversions.cpp