tree-wide: standardize header names across src/fundamental, src/basic and src/shared

Drop the -fundamental suffix from src/fundamental/ headers in favor of names
that match their src/basic/ or src/shared/ counterparts (e.g.
macro-fundamental.h -> macro.h, assert-fundamental.h -> assert-util.h,
cleanup-fundamental.h -> cleanup-util.h). Rename src/basic/{btrfs,label}.{c,h}
to use the -util suffix to match the existing shared/btrfs-util and
shared/label-util siblings. Rename src/shared/mkdir-label.{c,h} to mkdir.{c,h}
and src/shared/tmpfile-util-label.{c,h} to tmpfile-util.{c,h} to match the
corresponding src/basic names.

This saves us from having to come up with separate names for files that do
the same thing across tiers, and it makes it easier to move stuff between
src/fundamental, src/basic and src/shared: consumers just #include "foo.h"
and pick up whichever tier their -I path resolves to first, so call sites
don't need to be updated when an API moves between layers.

Where a higher-tier wrapper exists (e.g. src/basic/macro.h wrapping
src/fundamental/macro.h), the wrapper uses an explicit "../fundamental/foo.h"
or "../basic/foo.h" relative include for the lower-tier header. We can't use
GCC's #include_next directive for this — when the wrapper is reachable both
via same-dir-as-source lookup and via -I (e.g. -Isrc/shared) for the
directory it lives in, #include_next advances by exactly one slot in libcpp's
internal directory chain and lands on the same physical directory it was
already in, never reaching the lower-tier sibling (see make_cpp_dir() in
gcc/libcpp/files.cc:1986).

To make sure the right headers are always picked up, the include directories
are reordered so that e.g. src/shared always takes priority over src/basic and
similar for the other directories.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Daan De Meyer
2026-05-21 10:33:03 +09:00
committed by Yu Watanabe
parent 7e77105988
commit 74d392ed1b
166 changed files with 219 additions and 212 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "assert-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/assert-util.h" /* IWYU pragma: export */
/* Logging for various assertions */
+2 -1
View File
@@ -17,7 +17,8 @@
#include "assert-util.h" /* IWYU pragma: export */
#include "cleanup-util.h" /* IWYU pragma: export */
#include "macro.h" /* IWYU pragma: export */
#include "string-table-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/string-table.h" /* IWYU pragma: export */
/* Generic types */
+1 -1
View File
@@ -5,7 +5,7 @@
#include <sys/stat.h>
#include "alloc-util.h"
#include "btrfs.h"
#include "btrfs-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fs-util.h"
+2 -2
View File
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "assert-fundamental.h"
#include "cleanup-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/assert-util.h"
#include "../fundamental/cleanup-util.h" /* IWYU pragma: export */
typedef void (*free_func_t)(void *p);
typedef void* (*mfree_func_t)(void *p);
-1
View File
@@ -8,7 +8,6 @@
#include <unistd.h>
#include "confidential-virt.h"
#include "confidential-virt-fundamental.h"
#include "errno-util.h" /* IWYU pragma: keep */
#include "fd-util.h"
#include "fileio.h" /* IWYU pragma: keep */
+2
View File
@@ -3,6 +3,8 @@
#include "basic-forward.h"
#include "../fundamental/confidential-virt.h" /* IWYU pragma: export */
typedef enum ConfidentialVirtualization {
CONFIDENTIAL_VIRTUALIZATION_NONE = 0,
+1 -1
View File
@@ -5,7 +5,7 @@
#include "sd-id128.h"
#include "efivars-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/efivars.h" /* IWYU pragma: export */
#define EFI_VENDOR_LOADER SD_ID128_MAKE(4a,67,b0,82,0a,4c,41,cf,b6,c7,44,0b,29,bb,8c,4f)
#define EFI_VENDOR_LOADER_STR SD_ID128_MAKE_UUID_STR(4a,67,b0,82,0a,4c,41,cf,b6,c7,44,0b,29,bb,8c,4f)
+1 -1
View File
@@ -10,7 +10,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "label.h"
#include "label-util.h"
#include "log.h"
#include "string-util.h"
#include "strv.h"
+1 -1
View File
@@ -16,7 +16,7 @@
#include "hexdecoct.h"
#include "io-util.h"
#include "iovec-util.h"
#include "label.h"
#include "label-util.h"
#include "log.h"
#include "mkdir.h"
#include "nulstr-util.h"
+2 -2
View File
@@ -7,14 +7,14 @@
#include <unistd.h>
#include "alloc-util.h"
#include "btrfs.h"
#include "btrfs-util.h"
#include "chattr-util.h"
#include "dirent-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "label.h"
#include "label-util.h"
#include "lock-util.h"
#include "log.h"
#include "mkdir.h"
+2 -1
View File
@@ -4,7 +4,8 @@
#include <sys/uio.h> /* IWYU pragma: export */
#include "basic-forward.h"
#include "iovec-util-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/iovec-util.h" /* IWYU pragma: export */
extern const struct iovec iovec_nul_byte; /* Points to a single NUL byte */
extern const struct iovec iovec_empty; /* Points to an empty, but valid (i.e. non-NULL) pointer */
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "label.h"
#include "label-util.h"
static const LabelOps *label_ops = NULL;
+1 -1
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "macro-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/macro.h" /* IWYU pragma: export */
#if !defined(HAS_FEATURE_MEMORY_SANITIZER)
# if defined(__has_feature)
+2 -1
View File
@@ -4,7 +4,8 @@
#include <string.h>
#include "basic-forward.h"
#include "memory-util-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/memory-util.h" /* IWYU pragma: export */
size_t page_size(void) _pure_;
#define PAGE_ALIGN(l) ALIGN_TO(l, page_size())
+2 -2
View File
@@ -10,7 +10,7 @@ basic_sources = files(
'arphrd-util.c',
'assert-util.c',
'audit-util.c',
'btrfs.c',
'btrfs-util.c',
'build.c',
'build-path.c',
'bus-label.c',
@@ -57,7 +57,7 @@ basic_sources = files(
'iovec-util.c',
'iovec-wrapper.c',
'keyring-util.c',
'label.c',
'label-util.c',
'limits-util.c',
'locale-util.c',
'lock-util.c',
+1 -1
View File
@@ -3,7 +3,7 @@
#include <unistd.h>
#include "alloc-util.h"
#include "btrfs.h"
#include "btrfs-util.h"
#include "chase.h"
#include "errno-util.h"
#include "fd-util.h"
+2 -1
View File
@@ -3,7 +3,8 @@
#pragma once
#include "basic-forward.h"
#include "sha256-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/sha256.h" /* IWYU pragma: export */
int sha256_fd(int fd, uint64_t max_size, uint8_t ret[static SHA256_DIGEST_SIZE]);
+2 -1
View File
@@ -5,7 +5,8 @@
#include "alloc-util.h"
#include "basic-forward.h"
#include "string-util-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/string-util.h" /* IWYU pragma: export */
static inline char* strstr_ptr_internal(const char *haystack, const char *needle) {
if (!haystack || !needle)
+2 -1
View File
@@ -2,7 +2,8 @@
#pragma once
#include "basic-forward.h"
#include "strv-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/strv.h" /* IWYU pragma: export */
char* strv_find(char * const *l, const char *name) _pure_;
char* strv_find_case(char * const *l, const char *name) _pure_;
+2 -1
View File
@@ -4,7 +4,8 @@
#include <endian.h>
#include "basic-forward.h"
#include "unaligned-fundamental.h" /* IWYU pragma: export */
#include "../fundamental/unaligned.h" /* IWYU pragma: export */
/* BE */