From 4c165dd20850b738ef6724a9a008bd768263b853 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Wed, 18 Jun 2025 20:34:57 +0200 Subject: [PATCH] Update some includes for iwyu part 1 First batch of fixes to please include-what-you-use. Ref: #8086 Signed-off-by: Ralph Sennhauser --- source/lib/allocators/dynarray.h | 7 +++++-- source/lib/allocators/freelist.h | 4 +++- source/lib/allocators/page_aligned.h | 8 ++++++-- source/lib/allocators/pool.h | 11 +++++++++-- source/lib/allocators/shared_ptr.h | 7 ++++++- source/lib/bits.h | 10 +++++++++- source/lib/byte_order.h | 5 ++++- source/lib/debug_stl.h | 6 +++++- source/lib/file/archive/archive.h | 12 ++++++++++-- source/lib/file/archive/codec.h | 8 +++++++- source/lib/file/archive/stream.h | 8 +++++++- source/lib/file/common/file_loader.h | 7 ++++++- source/lib/file/common/file_stats.h | 6 ++++-- source/lib/file/common/real_directory.h | 9 ++++++++- source/lib/file/common/trace.h | 8 +++++++- source/lib/file/io/io.cpp | 3 ++- source/lib/file/io/io.h | 19 ++++++++++++++----- source/lib/file/io/write_buffer.h | 8 +++++++- source/lib/file/vfs/vfs.h | 10 +++++++++- source/lib/file/vfs/vfs_lookup.h | 5 ++++- source/lib/file/vfs/vfs_path.h | 3 ++- source/ps/SavedGame.cpp | 3 ++- 22 files changed, 136 insertions(+), 31 deletions(-) diff --git a/source/lib/allocators/dynarray.h b/source/lib/allocators/dynarray.h index 4957a2b728..9ede27d7d9 100644 --- a/source/lib/allocators/dynarray.h +++ b/source/lib/allocators/dynarray.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 @@ -27,7 +27,10 @@ #ifndef INCLUDED_ALLOCATORS_DYNARRAY #define INCLUDED_ALLOCATORS_DYNARRAY -#include "lib/posix/posix_mman.h" // PROT_* +#include "lib/debug.h" +#include "lib/types.h" + +#include /** * provides a memory range that can be expanded but doesn't waste diff --git a/source/lib/allocators/freelist.h b/source/lib/allocators/freelist.h index 96e291892d..52d86d8148 100644 --- a/source/lib/allocators/freelist.h +++ b/source/lib/allocators/freelist.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 @@ -23,6 +23,8 @@ #ifndef INCLUDED_ALLOCATORS_FREELIST #define INCLUDED_ALLOCATORS_FREELIST +#include "lib/debug.h" + #include // "freelist" is a pointer to the first unused element or a sentinel. diff --git a/source/lib/allocators/page_aligned.h b/source/lib/allocators/page_aligned.h index 87b79e9146..75afee2e88 100644 --- a/source/lib/allocators/page_aligned.h +++ b/source/lib/allocators/page_aligned.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 @@ -23,7 +23,11 @@ #ifndef INCLUDED_ALLOCATORS_PAGE_ALIGNED #define INCLUDED_ALLOCATORS_PAGE_ALIGNED -#include "lib/posix/posix_mman.h" // PROT_* +#include "lib/posix/posix_mman.h" // PROT_* +#include "lib/debug.h" +#include "lib/types.h" + +#include // very thin wrapper on top of sys/mman.h that makes the intent more obvious // (its commit/decommit semantics are difficult to tell apart) diff --git a/source/lib/allocators/pool.h b/source/lib/allocators/pool.h index dad77b6ff6..312f5e64c9 100644 --- a/source/lib/allocators/pool.h +++ b/source/lib/allocators/pool.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 @@ -27,8 +27,15 @@ #ifndef INCLUDED_ALLOCATORS_POOL #define INCLUDED_ALLOCATORS_POOL -#include "lib/bits.h" // ROUND_UP #include "lib/allocators/allocator_policies.h" +#include "lib/allocators/freelist.h" +#include "lib/bits.h" // ROUND_UP +#include "lib/code_annotation.h" +#include "lib/debug.h" +#include "lib/status.h" + +#include +#include namespace Allocators { diff --git a/source/lib/allocators/shared_ptr.h b/source/lib/allocators/shared_ptr.h index 06db683383..be6dcc7025 100644 --- a/source/lib/allocators/shared_ptr.h +++ b/source/lib/allocators/shared_ptr.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 @@ -24,7 +24,12 @@ #define INCLUDED_ALLOCATORS_SHARED_PTR #include "lib/alignment.h" +#include "lib/debug.h" #include "lib/sysdep/rtl.h" // rtl_AllocateAligned +#include "lib/types.h" + +#include +#include struct DummyDeleter { diff --git a/source/lib/bits.h b/source/lib/bits.h index e4f2aae2ec..cb85763af2 100644 --- a/source/lib/bits.h +++ b/source/lib/bits.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,14 @@ #ifndef INCLUDED_BITS #define INCLUDED_BITS +#include "lib/code_annotation.h" +#include "lib/debug.h" +#include "lib/status.h" + +#include +#include +#include + /** * value of bit number \. * diff --git a/source/lib/byte_order.h b/source/lib/byte_order.h index 7f25d0cf36..ba4fb1697b 100644 --- a/source/lib/byte_order.h +++ b/source/lib/byte_order.h @@ -27,7 +27,10 @@ #ifndef INCLUDED_BYTE_ORDER #define INCLUDED_BYTE_ORDER -#include "lib/sysdep/cpu.h" +#include "lib/sysdep/compiler.h" +#include "lib/types.h" + +#include // detect byte order via predefined macros. #ifndef BYTE_ORDER diff --git a/source/lib/debug_stl.h b/source/lib/debug_stl.h index fec210a0a6..9e448bc9df 100644 --- a/source/lib/debug_stl.h +++ b/source/lib/debug_stl.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,10 @@ #ifndef INCLUDED_DEBUG_STL #define INCLUDED_DEBUG_STL +#include "lib/status.h" +#include "lib/types.h" + +#include namespace ERR { diff --git a/source/lib/file/archive/archive.h b/source/lib/file/archive/archive.h index 9ab1dd290e..85d5e51d07 100644 --- a/source/lib/file/archive/archive.h +++ b/source/lib/file/archive/archive.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 @@ -27,9 +27,17 @@ #ifndef INCLUDED_ARCHIVE #define INCLUDED_ARCHIVE -#include "lib/file/file_system.h" // FileInfo #include "lib/file/common/file_loader.h" +#include "lib/file/file_system.h" // FileInfo #include "lib/file/vfs/vfs_path.h" +#include "lib/os_path.h" +#include "lib/path.h" +#include "lib/status.h" +#include "lib/types.h" + +#include +#include +#include // rationale: this module doesn't build a directory tree of the entries // within an archive. that task is left to the VFS; here, we are only diff --git a/source/lib/file/archive/codec.h b/source/lib/file/archive/codec.h index 5aaa7d89c8..b187f89d2f 100644 --- a/source/lib/file/archive/codec.h +++ b/source/lib/file/archive/codec.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 @@ -29,6 +29,12 @@ #ifndef INCLUDED_CODEC #define INCLUDED_CODEC +#include "lib/status.h" +#include "lib/types.h" + +#include +#include + #define CODEC_COMPUTE_CHECKSUM 1 struct ICodec diff --git a/source/lib/file/archive/stream.h b/source/lib/file/archive/stream.h index 3f07f93938..a30e534921 100644 --- a/source/lib/file/archive/stream.h +++ b/source/lib/file/archive/stream.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 @@ -27,7 +27,13 @@ #ifndef INCLUDED_STREAM #define INCLUDED_STREAM +#include "lib/code_annotation.h" +#include "lib/debug.h" #include "lib/file/archive/codec.h" +#include "lib/types.h" + +#include +#include // note: this is similar in function to std::vector, but we don't need // iterators etc. and would prefer to avoid initializing each byte. diff --git a/source/lib/file/common/file_loader.h b/source/lib/file/common/file_loader.h index de7c06450d..1627597375 100644 --- a/source/lib/file/common/file_loader.h +++ b/source/lib/file/common/file_loader.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,11 @@ #define INCLUDED_FILE_LOADER #include "lib/os_path.h" +#include "lib/status.h" +#include "lib/types.h" + +#include +#include struct IFileLoader { diff --git a/source/lib/file/common/file_stats.h b/source/lib/file/common/file_stats.h index a090c9fc92..d35405fd78 100644 --- a/source/lib/file/common/file_stats.h +++ b/source/lib/file/common/file_stats.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,9 @@ #ifndef INCLUDED_FILE_STATS #define INCLUDED_FILE_STATS -#include "lib/posix/posix_aio.h" // LIO_READ, LIO_WRITE +#include "lib/code_annotation.h" + +#include #define FILE_STATS_ENABLED 0 diff --git a/source/lib/file/common/real_directory.h b/source/lib/file/common/real_directory.h index a5a1208a02..99e57471ea 100644 --- a/source/lib/file/common/real_directory.h +++ b/source/lib/file/common/real_directory.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,8 +23,15 @@ #ifndef INCLUDED_REAL_DIRECTORY #define INCLUDED_REAL_DIRECTORY +#include "lib/code_annotation.h" #include "lib/file/common/file_loader.h" +#include "lib/os_path.h" +#include "lib/status.h" #include "lib/sysdep/dir_watch.h" +#include "lib/types.h" + +#include +#include class RealDirectory : public IFileLoader { diff --git a/source/lib/file/common/trace.h b/source/lib/file/common/trace.h index 9f2c54530b..aae5412950 100644 --- a/source/lib/file/common/trace.h +++ b/source/lib/file/common/trace.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 @@ -35,7 +35,13 @@ #ifndef INCLUDED_TRACE #define INCLUDED_TRACE +#include "lib/debug.h" #include "lib/os_path.h" +#include "lib/path.h" + +#include +#include +#include // stores information about an IO event. class TraceEntry diff --git a/source/lib/file/io/io.cpp b/source/lib/file/io/io.cpp index afd01608a3..2d981e1ce6 100644 --- a/source/lib/file/io/io.cpp +++ b/source/lib/file/io/io.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 @@ -23,6 +23,7 @@ #include "precompiled.h" #include "lib/file/io/io.h" +#include "lib/config2.h" #include "lib/sysdep/rtl.h" static const StatusDefinition ioStatusDefinitions[] = { diff --git a/source/lib/file/io/io.h b/source/lib/file/io/io.h index 8260314cda..2340cac834 100644 --- a/source/lib/file/io/io.h +++ b/source/lib/file/io/io.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,14 +28,23 @@ #ifndef INCLUDED_IO #define INCLUDED_IO -#include "lib/config2.h" #include "lib/alignment.h" #include "lib/bits.h" -#include "lib/timer.h" +#include "lib/code_annotation.h" +#include "lib/debug.h" #include "lib/file/file.h" -#include "lib/sysdep/rtl.h" -#include "lib/sysdep/filesystem.h" // wtruncate +#include "lib/lib.h" +#include "lib/os_path.h" #include "lib/posix/posix_aio.h" // LIO_READ, LIO_WRITE +#include "lib/sysdep/filesystem.h" // wtruncate +#include "lib/sysdep/os.h" +#include "lib/sysdep/rtl.h" +#include "lib/types.h" + +#include +#include +#include +#include namespace ERR { diff --git a/source/lib/file/io/write_buffer.h b/source/lib/file/io/write_buffer.h index 3da4b6aeaa..dd66c39cf9 100644 --- a/source/lib/file/io/write_buffer.h +++ b/source/lib/file/io/write_buffer.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,7 +23,13 @@ #ifndef INCLUDED_WRITE_BUFFER #define INCLUDED_WRITE_BUFFER +#include "lib/code_annotation.h" +#include "lib/debug.h" #include "lib/file/file.h" +#include "lib/types.h" + +#include +#include class WriteBuffer { diff --git a/source/lib/file/vfs/vfs.h b/source/lib/file/vfs/vfs.h index 7f9a56bde2..01e426e6fe 100644 --- a/source/lib/file/vfs/vfs.h +++ b/source/lib/file/vfs/vfs.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,8 +28,16 @@ #ifndef INCLUDED_VFS #define INCLUDED_VFS +#include "lib/debug.h" #include "lib/file/file_system.h" // CFileInfo #include "lib/file/vfs/vfs_path.h" +#include "lib/os_path.h" +#include "lib/types.h" + +#include +#include +#include +#include constexpr size_t VFS_MIN_PRIORITY = 0; constexpr size_t VFS_MAX_PRIORITY = std::numeric_limits::max(); diff --git a/source/lib/file/vfs/vfs_lookup.h b/source/lib/file/vfs/vfs_lookup.h index 5ec82fdcf7..a13f004ed8 100644 --- a/source/lib/file/vfs/vfs_lookup.h +++ b/source/lib/file/vfs/vfs_lookup.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 @@ -27,8 +27,11 @@ #ifndef INCLUDED_VFS_LOOKUP #define INCLUDED_VFS_LOOKUP +#include "lib/debug.h" #include "lib/file/vfs/vfs_path.h" +#include + class VfsFile; class VfsDirectory; diff --git a/source/lib/file/vfs/vfs_path.h b/source/lib/file/vfs/vfs_path.h index e1e0a52640..e50b8459c3 100644 --- a/source/lib/file/vfs/vfs_path.h +++ b/source/lib/file/vfs/vfs_path.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 @@ -25,6 +25,7 @@ #include "lib/path.h" +#include #include /** diff --git a/source/ps/SavedGame.cpp b/source/ps/SavedGame.cpp index 2a1cda1d1c..745f0888d5 100644 --- a/source/ps/SavedGame.cpp +++ b/source/ps/SavedGame.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 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 @@ -25,6 +25,7 @@ #include "lib/file/archive/archive_zip.h" #include "lib/file/io/io.h" #include "lib/utf8.h" +#include "lib/timer.h" #include "maths/Vector3D.h" #include "ps/CLogger.h" #include "ps/Filesystem.h"