Split out of #37344.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include "af-list.h"
-#include "macro.h"
#include "string-util.h"
static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "macro.h"
+#include "forward.h"
const char* af_to_name(int id) _const_;
int af_from_name(const char *name) _pure_;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <malloc.h>
-#include <stdint.h>
-#include <string.h>
#include "alloc-util.h"
-#include "macro.h"
void* memdup(const void *p, size_t l) {
void *ret;
void *expand_to_usable(void *ptr, size_t newsize _unused_) {
return ptr;
}
+
+size_t malloc_sizeof_safe(void **xp) {
+ if (_unlikely_(!xp || !*xp))
+ return 0;
+
+ size_t sz = malloc_usable_size(*xp);
+ *xp = expand_to_usable(*xp, sz);
+ /* GCC doesn't see the _returns_nonnull_ when built with ubsan, so yet another hint to make it doubly
+ * clear that expand_to_usable won't return NULL.
+ * See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79265 */
+ if (!*xp)
+ assert_not_reached();
+ return sz;
+}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <alloca.h>
-#include <malloc.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "assert-util.h"
-#include "cleanup-util.h"
-#include "macro.h"
+#include <stdlib.h>
+
+#include "forward.h"
#include "memory-util.h"
#if HAS_FEATURE_MEMORY_SANITIZER
* See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503 */
void *expand_to_usable(void *p, size_t newsize) _alloc_(2) _returns_nonnull_ _noinline_;
-static inline size_t malloc_sizeof_safe(void **xp) {
- if (_unlikely_(!xp || !*xp))
- return 0;
-
- size_t sz = malloc_usable_size(*xp);
- *xp = expand_to_usable(*xp, sz);
- /* GCC doesn't see the _returns_nonnull_ when built with ubsan, so yet another hint to make it doubly
- * clear that expand_to_usable won't return NULL.
- * See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79265 */
- if (!*xp)
- assert_not_reached();
- return sz;
-}
+size_t malloc_sizeof_safe(void **xp);
/* This returns the number of usable bytes in a malloc()ed region as per malloc_usable_size(), which may
* return a value larger than the size that was actually allocated. Access to that additional memory is
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <stdlib.h>
+
#include "ansi-color.h"
#include "log.h"
#include "process-util.h"
#include "string-table.h"
+#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-
-#include "macro.h"
+#include "forward.h"
/* Limits the use of ANSI colors to a subset. */
typedef enum ColorMode {
#include <sys/utsname.h>
#include "architecture.h"
-#include "macro.h"
#include "string-table.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <endian.h>
-#include <errno.h>
+#include <endian.h> /* IWYU pragma: keep */
-#include "macro.h"
+#include "forward.h"
/* A cleaned up architecture definition. We don't want to get lost in
* processor features, models, generations or even ABIs. Hence we
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <sched.h>
+#include <stdlib.h>
#include <sys/mman.h>
#include <sys/prctl.h>
-#include <unistd.h>
#include "argv-util.h"
#include "capability-util.h"
int saved_argc = 0;
char **saved_argv = NULL;
+void save_argc_argv(int argc, char **argv) {
+ /* Protect against CVE-2021-4034 style attacks */
+ assert_se(argc > 0);
+ assert_se(argv);
+ assert_se(argv[0]);
+
+ saved_argc = argc;
+ saved_argv = argv;
+}
+
bool invoked_as(char *argv[], const char *token) {
if (!argv || isempty(argv[0]))
return false;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
extern int saved_argc;
extern char **saved_argv;
-static inline void save_argc_argv(int argc, char **argv) {
- /* Protect against CVE-2021-4034 style attacks */
- assert_se(argc > 0);
- assert_se(argv);
- assert_se(argv[0]);
-
- saved_argc = argc;
- saved_argv = argv;
-}
+void save_argc_argv(int argc, char **argv);
bool invoked_as(char *argv[], const char *token);
bool invoked_by_systemd(void);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <linux/if_arp.h>
#include <linux/if_infiniband.h>
#include <netinet/in.h>
#include <string.h>
#include "arphrd-util.h"
-#include "assert-util.h"
-#include "macro.h"
static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <stddef.h>
+#include "forward.h"
const char* arphrd_to_name(int id);
int arphrd_from_name(const char *name);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <limits.h>
#include <stdio.h>
+#include <stdlib.h>
#include "assert-util.h"
#include "errno-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "assert-fundamental.h"
-#include "macro.h"
+#include "assert-fundamental.h" /* IWYU pragma: export */
/* Logging for various assertions */
#include "audit-util.h"
#include "fileio.h"
#include "parse-util.h"
+#include "pidref.h"
#include "process-util.h"
#include "stat-util.h"
#include "user-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "pidref.h"
+#include "forward.h"
#define AUDIT_SESSION_INVALID UINT32_MAX
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "macro.h"
+#include "forward.h"
/* Bit index (0-based) to mask of specified type. Assertion failure if index is out of range. */
#define _INDEX_TO_MASK(type, i, uniq) \
#include <linux/btrfs.h>
#include <sys/ioctl.h>
+#include <sys/stat.h>
#include "alloc-util.h"
#include "btrfs.h"
#include "errno-util.h"
#include "fd-util.h"
-#include "fs-util.h"
#include "path-util.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <fcntl.h>
+#include "forward.h"
int btrfs_validate_subvolume_name(const char *name);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <elf.h>
+#include <fcntl.h>
#include <link.h>
#include <stdlib.h>
#include <sys/auxv.h>
+#include "alloc-util.h"
#include "build-path.h"
-#include "errno-list.h"
-#include "errno-util.h"
-#include "fd-util.h"
-#include "macro.h"
#include "path-util.h"
#include "process-util.h"
+#include "string-util.h"
#include "unistd.h"
static int get_runpath_from_dynamic(const ElfW(Dyn) *d, ElfW(Addr) bias, const char **ret) {
#include "build.h"
#include "extract-word.h"
#include "log.h"
-#include "macro.h"
#include "string-util.h"
-#include "terminal-util.h"
#include "version.h"
const char* const systemd_features =
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "forward.h"
+
extern const char* const systemd_features;
int version(void);
#include "alloc-util.h"
#include "bus-label.h"
#include "hexdecoct.h"
-#include "macro.h"
+#include "string-util.h"
char* bus_label_escape(const char *s) {
char *r, *t;
assert_return(f, NULL);
+ if (l == SIZE_MAX)
+ l = strlen(f);
+
/* Special case for the empty string */
if (l == 1 && *f == '_')
return strdup("");
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stddef.h>
-#include <stdlib.h>
-
-#include "string-util.h"
+#include "forward.h"
char* bus_label_escape(const char *s);
char* bus_label_unescape_n(const char *f, size_t l);
static inline char* bus_label_unescape(const char *f) {
- return bus_label_unescape_n(f, strlen_ptr(f));
+ return bus_label_unescape_n(f, SIZE_MAX);
}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <string.h>
+#include <stdio.h>
#include "alloc-util.h"
#include "bitfield.h"
#include "capability-util.h"
#include "extract-word.h"
#include "log.h"
-#include "macro.h"
#include "parse-util.h"
-#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
+#include "forward.h"
/* Space for capability_to_string() in case we write out a numeric capability because we don't know the name
* for it. "0x3e" is the largest string we might output, in both sensese of the word "largest": two chars for
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <linux/prctl.h>
#include <stdatomic.h>
#include <stdio.h>
-#include <stdlib.h>
#include <sys/prctl.h>
-#include <threads.h>
#include <unistd.h>
#include "alloc-util.h"
#include "fileio.h"
#include "log.h"
#include "logarithm.h"
-#include "macro.h"
#include "parse-util.h"
#include "pidref.h"
#include "process-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/capability.h>
-#include <sys/types.h>
+#include <sys/capability.h> /* IWYU pragma: export */
-#include "macro.h"
-#include "pidref.h"
+#include "forward.h"
/* Special marker used when storing a capabilities mask as "unset". This would need to be updated as soon as
* Linux learns more than 63 caps. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-
#include "alloc-util.h"
#include "capsule-util.h"
#include "path-util.h"
+#include "string-util.h"
#include "user-util.h"
int capsule_name_is_valid(const char *name) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "forward.h"
+
int capsule_name_is_valid(const char *name);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <limits.h>
#include <signal.h>
-#include <stddef.h>
#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
#include <sys/xattr.h>
#include <threads.h>
#include <unistd.h>
#include "alloc-util.h"
#include "capsule-util.h"
#include "cgroup-util.h"
-#include "constants.h"
#include "dirent-util.h"
#include "errno-util.h"
#include "extract-word.h"
#include "fs-util.h"
#include "log.h"
#include "login-util.h"
-#include "macro.h"
#include "missing_fs.h"
#include "missing_magic.h"
-#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pidref.h"
#include "process-util.h"
#include "set.h"
#include "special.h"
#include "stat-util.h"
-#include "stdio-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
#include "xattr-util.h"
+/* The structure to pass to name_to_handle_at() on cgroupfs2 */
+typedef union {
+ struct file_handle file_handle;
+ uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
+} cg_file_handle;
+
+#define CG_FILE_HANDLE_INIT \
+ (cg_file_handle) { \
+ .file_handle.handle_bytes = sizeof(uint64_t), \
+ .file_handle.handle_type = FILEID_KERNFS, \
+ }
+
+#define CG_FILE_HANDLE_CGROUPID(fh) (*CAST_ALIGN_PTR(uint64_t, (fh).file_handle.f_handle))
+
int cg_path_open(const char *controller, const char *path) {
_cleanup_free_ char *fs = NULL;
int r;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <sys/statfs.h>
-#include <sys/types.h>
-
-#include "constants.h"
-#include "pidref.h"
-#include "set.h"
+#include "forward.h"
#define SYSTEMD_CGROUP_CONTROLLER_LEGACY "name=systemd"
#define SYSTEMD_CGROUP_CONTROLLER_HYBRID "name=unified"
const char* managed_oom_preference_to_string(ManagedOOMPreference a) _const_;
ManagedOOMPreference managed_oom_preference_from_string(const char *s) _pure_;
-
-/* The structure to pass to name_to_handle_at() on cgroupfs2 */
-typedef union {
- struct file_handle file_handle;
- uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
-} cg_file_handle;
-
-#define CG_FILE_HANDLE_INIT \
- (cg_file_handle) { \
- .file_handle.handle_bytes = sizeof(uint64_t), \
- .file_handle.handle_type = FILEID_KERNFS, \
- }
-
-#define CG_FILE_HANDLE_CGROUPID(fh) (*CAST_ALIGN_PTR(uint64_t, (fh).file_handle.f_handle))
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/magic.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "chase.h"
#include "glyph-util.h"
#include "log.h"
#include "path-util.h"
+#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <dirent.h>
-#include <stdio.h>
-
-#include "stat-util.h"
+#include "forward.h"
typedef enum ChaseFlags {
CHASE_PREFIX_ROOT = 1 << 0, /* The specified path will be prefixed by the specified root before beginning the iteration */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include "fd-util.h"
#include "fs-util.h"
#include "log.h"
-#include "macro.h"
#include "string-util.h"
int chattr_full(
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-
+#include "forward.h"
#include "missing_fs.h"
/* The chattr() flags to apply when creating a new file *before* writing to it. In particular, flags such as
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <inttypes.h>
-#include <malloc.h>
-#include <stdlib.h>
+#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <unistd.h>
#if HAVE_LZ4
#include "alloc-util.h"
#include "bitfield.h"
#include "compress.h"
-#include "fd-util.h"
+#include "dlfcn-util.h"
#include "fileio.h"
#include "io-util.h"
#include "log.h"
-#include "macro.h"
-#include "sparse-endian.h"
#include "string-table.h"
#include "string-util.h"
#include "unaligned.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <unistd.h>
-
-#include "dlfcn-util.h"
+#include "forward.h"
typedef enum Compression {
COMPRESSION_NONE,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "chase.h"
#include "conf-files.h"
-#include "constants.h"
#include "dirent-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "glyph-util.h"
#include "hashmap.h"
#include "log.h"
-#include "macro.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "set.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
static int files_add(
DIR *dir,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
-#include "macro.h"
+#include "forward.h"
enum {
CONF_FILES_EXECUTABLE = 1 << 0,
#if defined(__i386__) || defined(__x86_64__)
#include <cpuid.h>
#endif
-#include <errno.h>
#include <fcntl.h>
-#include <stdlib.h>
#include <threads.h>
#include <unistd.h>
-#include "alloc-util.h"
#include "confidential-virt.h"
#include "confidential-virt-fundamental.h"
#include "errno-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <stdbool.h>
-
-#include "errno-list.h"
-#include "macro.h"
+#include "forward.h"
typedef enum ConfidentialVirtualization {
CONFIDENTIAL_VIRTUALIZATION_NONE = 0,
#include "devnum-util.h"
#include "parse-util.h"
#include "path-util.h"
+#include "stdio-util.h"
#include "string-util.h"
int parse_devnum(const char *s, dev_t *ret) {
return 0;
}
+
+char* format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]) {
+ return ASSERT_PTR(snprintf_ok(buf, DEVNUM_STR_MAX, DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(d)));
+}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <stdbool.h>
-#include <sys/types.h>
#include <sys/sysmacros.h>
-#include "stdio-util.h"
+#include "forward.h"
int parse_devnum(const char *s, dev_t *ret);
#define DEVNUM_FORMAT_STR "%u:%u"
#define DEVNUM_FORMAT_VAL(d) major(d), minor(d)
-static inline char *format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]) {
- return ASSERT_PTR(snprintf_ok(buf, DEVNUM_STR_MAX, DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(d)));
-}
+char *format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]);
#define FORMAT_DEVNUM(d) format_devnum((d), (char[DEVNUM_STR_MAX]) {})
#include "dirent-util.h"
#include "path-util.h"
-#include "stat-util.h"
#include "string-util.h"
int dirent_ensure_type(int dir_fd, struct dirent *de) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <dirent.h>
-#include <errno.h>
-#include <stdbool.h>
+#include <dirent.h> /* IWYU pragma: export */
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
#include "path-util.h"
bool dirent_is_file(const struct dirent *de) _pure_;
#include "dlfcn-util.h"
#include "log.h"
+void* safe_dlclose(void *dl) {
+ if (!dl)
+ return NULL;
+
+ assert_se(dlclose(dl) == 0);
+ return NULL;
+}
+
static int dlsym_many_or_warnv(void *dl, int log_level, va_list ap) {
void (**fn)(void);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <dlfcn.h>
+#include <dlfcn.h> /* IWYU pragma: export */
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
-static inline void* safe_dlclose(void *dl) {
- if (!dl)
- return NULL;
-
- assert_se(dlclose(dl) == 0);
- return NULL;
-}
+void* safe_dlclose(void *dl);
static inline void dlclosep(void **dlp) {
safe_dlclose(*dlp);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "forward.h"
+
/* Length of a single label, with all escaping removed, excluding any trailing dot or NUL byte */
#define DNS_LABEL_MAX 63
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <time.h>
#include <unistd.h>
-#include "sd-id128.h"
-
#include "alloc-util.h"
#include "chattr-util.h"
#include "efivars.h"
#include "fd-util.h"
-#include "fileio.h"
#include "io-util.h"
#include "log.h"
-#include "macro.h"
#include "memory-util.h"
-#include "missing_fs.h"
-#include "stdio-util.h"
-#include "strv.h"
+#include "string-util.h"
#include "time-util.h"
#include "utf8.h"
#include "virt.h"
return (cache = decode_secure_boot_mode(secure, audit > 0, deployed > 0, setup > 0));
}
#endif
+
+char *efi_tilt_backslashes(char *s) {
+ return string_replace_char(s, '\\', '/');
+}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#if !ENABLE_EFI
-# include <errno.h>
-#endif
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
+#include "forward.h"
#include "sd-id128.h"
-#include "efivars-fundamental.h"
-#include "string-util.h"
-#include "time-util.h"
+#include "efivars-fundamental.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)
}
#endif
-static inline char *efi_tilt_backslashes(char *s) {
- return string_replace_char(s, '\\', '/');
-}
+char *efi_tilt_backslashes(char *s);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <unistd.h>
+
#include "alloc-util.h"
#include "env-file.h"
#include "env-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "macro.h"
+#include "forward.h"
int parse_env_filev(FILE *f, const char *fname, va_list ap);
int parse_env_file_fdv(int fd, const char *fname, va_list ap);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <limits.h>
-#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include "alloc-util.h"
#include "env-util.h"
#include "errno-util.h"
-#include "escape.h"
#include "extract-word.h"
+#include "format-util.h"
#include "log.h"
-#include "macro.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
-#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "syslog-util.h"
DIGITS LETTERS \
"_"
+size_t sc_arg_max(void) {
+ long l = sysconf(_SC_ARG_MAX);
+ assert(l > 0);
+ return (size_t) l;
+}
+
static bool env_name_is_valid_n(const char *e, size_t n) {
if (n == SIZE_MAX)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "assert-util.h"
-#include "macro.h"
-#include "string.h"
-
-static inline size_t sc_arg_max(void) {
- long l = sysconf(_SC_ARG_MAX);
- assert(l > 0);
- return (size_t) l;
-}
+#include "forward.h"
+
+size_t sc_arg_max(void);
bool env_name_is_valid(const char *e);
bool env_value_is_valid(const char *e);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <string.h>
-#include "assert-util.h"
#include "errno-list.h"
-#include "macro.h"
static const struct errno_name* lookup_errno(register const char *str,
register GPERF_LEN_TYPE len);
#include "errno-from-name.inc"
-#if !HAVE_STRERRORNAME_NP
+#if HAVE_STRERRORNAME_NP
+const char* errno_to_name(int id) {
+ if (id == 0) /* To stay in line with our own impl */
+ return NULL;
+
+ return strerrorname_np(ABS(id));
+}
+#else
#include "errno-to-name.inc"
const char* errno_to_name(int id) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <stdbool.h>
-#include <string.h>
+#include "forward.h"
-#include "macro.h"
-
-/*
- * MAX_ERRNO is defined as 4095 in linux/err.h
- * We use the same value here.
- */
-#define ERRNO_MAX 4095
-
-#if HAVE_STRERRORNAME_NP
-static inline const char* errno_to_name(int id) {
- if (id == 0) /* To stay in line with our own impl */
- return NULL;
-
- return strerrorname_np(ABS(id));
-}
-#else
const char* errno_to_name(int id);
-#endif
-int errno_from_name(const char *name);
+int errno_from_name(const char *name) _const_;
static inline bool errno_is_valid(int n) {
return n > 0 && n <= ERRNO_MAX;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <inttypes.h>
#include <string.h>
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
/* strerror(3) says that glibc uses a maximum length of 1024 bytes. */
-#define ERRNO_BUF_LEN 1024
+#define ERRNO_BUF_LEN 1024
/* Note: the lifetime of the compound literal is the immediately surrounding block,
* see C11 §6.5.2.5, and
* It will suppress bogus gcc warnings in case it assumes 'errno' might
* be 0 and thus the caller's error-handling might not be triggered. */
assert_return(errno > 0, -EINVAL);
+
return -errno;
}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "escape.h"
#include "hexdecoct.h"
-#include "macro.h"
+#include "string-util.h"
#include "strv.h"
#include "utf8.h"
/* Undoes C style string escaping, and optionally prefixes it. */
+ if (length == SIZE_MAX)
+ length = strlen(s);
+
pl = strlen_ptr(prefix);
ans = new(char, pl+length+1);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <uchar.h>
-
-#include "string-util.h"
+#include "forward.h"
/* What characters are special in the shell? */
/* must be escaped outside and inside double-quotes */
return cunescape_length_with_prefix(s, length, NULL, flags, ret);
}
static inline ssize_t cunescape(const char *s, UnescapeFlags flags, char **ret) {
- return cunescape_length(s, strlen(s), flags, ret);
+ return cunescape_length(s, SIZE_MAX, flags, ret);
}
typedef enum XEscapeFlags {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <inttypes.h>
#include <net/ethernet.h>
#include <stdio.h>
-#include <sys/types.h>
#include "ether-addr-util.h"
+#include "hash-funcs.h"
#include "hexdecoct.h"
-#include "log.h"
-#include "macro.h"
+#include "in-addr-util.h"
+#include "memory-util.h"
+#include "siphash24.h"
#include "string-util.h"
char* hw_addr_to_string_full(
siphash24_compress_safe(p->bytes, p->length, state);
}
+bool hw_addr_is_null(const struct hw_addr_data *addr) {
+ assert(addr);
+ return addr->length == 0 || memeqzero(addr->bytes, addr->length);
+}
+
DEFINE_HASH_OPS(hw_addr_hash_ops, struct hw_addr_data, hw_addr_hash_func, hw_addr_compare);
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(hw_addr_hash_ops_free, struct hw_addr_data, hw_addr_hash_func, hw_addr_compare, free);
siphash24_compress_typesafe(*p, state);
}
+bool ether_addr_is_broadcast(const struct ether_addr *addr) {
+ assert(addr);
+ return memeqbyte(0xff, addr->ether_addr_octet, ETH_ALEN);
+}
+
DEFINE_HASH_OPS(ether_addr_hash_ops, struct ether_addr, ether_addr_hash_func, ether_addr_compare);
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(ether_addr_hash_ops_free, struct ether_addr, ether_addr_hash_func, ether_addr_compare, free);
#pragma once
#include <linux/if_infiniband.h>
+#include <netinet/in.h>
#include <net/ethernet.h>
-#include <stdbool.h>
-#include "hash-funcs.h"
-#include "in-addr-util.h"
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
/* This is MAX_ADDR_LEN as defined in linux/netdevice.h, but net/if_arp.h
* defines a macro of the same name with a much lower size. */
static inline bool hw_addr_equal(const struct hw_addr_data *a, const struct hw_addr_data *b) {
return hw_addr_compare(a, b) == 0;
}
-static inline bool hw_addr_is_null(const struct hw_addr_data *addr) {
- assert(addr);
- return addr->length == 0 || memeqzero(addr->bytes, addr->length);
-}
+bool hw_addr_is_null(const struct hw_addr_data *addr) _pure_;
extern const struct hash_ops hw_addr_hash_ops;
extern const struct hash_ops hw_addr_hash_ops_free;
return ether_addr_equal(addr, ÐER_ADDR_NULL);
}
-static inline bool ether_addr_is_broadcast(const struct ether_addr *addr) {
- assert(addr);
- return memeqbyte(0xff, addr->ether_addr_octet, ETH_ALEN);
-}
+bool ether_addr_is_broadcast(const struct ether_addr *addr) _pure_;
static inline bool ether_addr_is_multicast(const struct ether_addr *addr) {
assert(addr);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <syslog.h>
-
#include "alloc-util.h"
#include "escape.h"
#include "extract-word.h"
#include "log.h"
-#include "macro.h"
#include "string-util.h"
-#include "strv.h"
#include "utf8.h"
int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "macro.h"
+#include "forward.h"
typedef enum ExtractFlags {
EXTRACT_RELAX = 1 << 0, /* Allow unbalanced quote and eat up trailing backslash. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
#include <linux/kcmp.h>
-#include <linux/magic.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include "alloc-util.h"
#include "dirent-util.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
+#include "format-util.h"
#include "fs-util.h"
-#include "io-util.h"
#include "log.h"
-#include "macro.h"
#include "missing_fcntl.h"
#include "missing_fs.h"
#include "missing_syscall.h"
#include "sort-util.h"
#include "stat-util.h"
#include "stdio-util.h"
+#include "string-util.h"
/* The maximum number of iterations in the loop to close descriptors in the fallback case
* when /proc/self/fd/ is inaccessible. */
return statx_mount_same(&sx1, &sx2);
}
+char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) {
+ assert(buf);
+ assert(fd >= 0);
+ assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd));
+ return buf;
+}
+
const char* accmode_to_string(int flags) {
switch (flags & O_ACCMODE_STRICT) {
case O_RDONLY:
#pragma once
#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdbool.h>
#include <stdio.h>
-#include <sys/socket.h>
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
#include "missing_fcntl.h"
-#include "stdio-util.h"
/* maximum length of fdname */
#define FDNAME_MAX 255
int fclose_nointr(FILE *f);
FILE* safe_fclose(FILE *f);
DIR* safe_closedir(DIR *f);
+static inline void* close_fd_ptr(void *p) {
+ safe_close(PTR_TO_FD(p));
+ return NULL;
+}
static inline void closep(int *fd) {
safe_close(*fd);
safe_fclose(*f);
}
-static inline void* close_fd_ptr(void *p) {
- safe_close(PTR_TO_FD(p));
- return NULL;
-}
-
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, pclose, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL);
#define PROC_FD_PATH_MAX \
(STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int))
-static inline char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) {
- assert(buf);
- assert(fd >= 0);
- assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd));
- return buf;
-}
+char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd);
#define FORMAT_PROC_FD_PATH(fd) \
format_proc_fd_path((char[PROC_FD_PATH_MAX]) {}, (fd))
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <ctype.h>
-#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdint.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
-#include "chase.h"
+#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
#include "hexdecoct.h"
#include "label.h"
#include "log.h"
-#include "macro.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "socket-util.h"
+#include "stat-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "sync-util.h"
#include "terminal-util.h"
+#include "time-util.h"
#include "tmpfile-util.h"
/* The maximum size of the file we'll read in one go in read_full_file() (64M). */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "macro.h"
-#include "time-util.h"
+#include "forward.h"
#define LONG_LINE_MAX (1U*1024U*1024U)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "filesystems-gperf.h"
+#include "nulstr-util.h"
#include "stat-util.h"
+#include "string-util.h"
const char* fs_type_to_string(statfs_f_type_t magic) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "nulstr-util.h"
+#include "forward.h"
#include "stat-util.h"
-#include "string-util.h"
#define FILESYSTEM_MAGIC_MAX 10
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "format-ifname.h"
-#include "log.h"
#include "stdio-util.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "format-util.h"
-#include "memory-util.h"
-#include "stdio-util.h"
-#include "strxcpyx.h"
char* format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) {
typedef struct {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <stdbool.h>
-
#include "cgroup-util.h"
-#include "macro.h"
+#include "forward.h"
+#include "stdio-util.h"
assert_cc(sizeof(pid_t) == sizeof(int32_t));
#define PID_PRI PRIi32
typedef enum CGroupMask CGroupMask;
typedef enum ChaseFlags ChaseFlags;
typedef enum ExtractFlags ExtractFlags;
+typedef enum Glyph Glyph;
typedef enum ImageClass ImageClass;
typedef enum JobMode JobMode;
typedef enum RuntimeScope RuntimeScope;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <linux/falloc.h>
-#include <linux/magic.h>
-#include <stddef.h>
#include <stdlib.h>
#include <sys/file.h>
#include <unistd.h>
#include "dirent-util.h"
#include "errno-util.h"
#include "fd-util.h"
-#include "fileio.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "label.h"
#include "lock-util.h"
#include "log.h"
-#include "macro.h"
#include "missing_fcntl.h"
-#include "missing_fs.h"
#include "missing_syscall.h"
#include "mkdir.h"
-#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "random-util.h"
#include "ratelimit.h"
#include "stat-util.h"
-#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "tmpfile-util.h"
#include "umask-util.h"
-#include "user-util.h"
int rmdir_parents(const char *path, const char *stop) {
char *p;
return mfree(p);
}
+char* unlink_and_free(char *p) {
+ PROTECT_ERRNO;
+
+ if (!p)
+ return NULL;
+
+ (void) unlink(p);
+ return mfree(p);
+}
+
int access_fd(int fd, int mode) {
assert(fd >= 0);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <dirent.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
+#include "forward.h"
#include "lock-util.h"
-#include "memory-util.h"
-#include "time-util.h"
-
-#define MODE_INVALID ((mode_t) -1)
/* The following macros add 1 when converting things, since 0 is a valid mode, while the pointer
* NULL is special */
char *rmdir_and_free(char *p);
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rmdir_and_free);
-static inline char* unlink_and_free(char *p) {
- if (!p)
- return NULL;
-
- (void) unlink(p);
- return mfree(p);
-}
+char* unlink_and_free(char *p);
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, unlink_and_free);
int access_fd(int fd, int mode);
#if HAVE_GCRYPT
+#include <sys/syslog.h>
+
#include "gcrypt-util.h"
-#include "hexdecoct.h"
-#include "log.h"
static void *gcrypt_dl = NULL;
#pragma once
-#include <errno.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "memory-util.h"
+#include "forward.h"
#if HAVE_GCRYPT
-#include <gcrypt.h>
+#include <gcrypt.h> /* IWYU pragma: export */
#include "dlfcn-util.h"
-#include "macro.h"
extern DLSYM_PROTOTYPE(gcry_md_close);
extern DLSYM_PROTOTYPE(gcry_md_copy);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
+#include <dirent.h>
#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
#include "dirent-util.h"
#include "errno-util.h"
#include "glob-util.h"
#include "log.h"
-#include "macro.h"
-#include "path-util.h"
+#include "string-util.h"
#include "strv.h"
static void closedir_wrapper(void* v) {
*ret = ans;
return 0;
}
+
+bool string_is_glob(const char *p) {
+ /* Check if a string contains any glob patterns. */
+ return !!strpbrk(p, GLOB_CHARS);
+}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <glob.h>
-#include <stdbool.h>
+#include <glob.h> /* IWYU pragma: export */
-#include "macro.h"
-#include "string-util.h"
+#include "forward.h"
/* Note: this function modifies pglob to set various functions. */
int safe_glob(const char *path, int flags, glob_t *pglob);
#define _cleanup_globfree_ _cleanup_(globfree)
-_pure_ static inline bool string_is_glob(const char *p) {
- /* Check if a string contains any glob patterns. */
- return !!strpbrk(p, GLOB_CHARS);
-}
+bool string_is_glob(const char *p) _pure_;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <stdbool.h>
-
-#include "macro.h"
+#include "forward.h"
typedef enum Glyph {
GLYPH_SPACE,
* Copyright © 2000, 2005 Red Hat, Inc.
*/
+#include <stdlib.h>
+
#include "gunicode.h"
-#include "macro.h"
#define unichar uint32_t
*/
#pragma once
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
+#include "forward.h"
char *utf8_prev_char (const char *p);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <stdlib.h>
#include <string.h>
#include <sys/sysmacros.h>
#include "hash-funcs.h"
#include "path-util.h"
+#include "siphash24.h"
#include "strv.h"
void string_hash_func(const char *p, struct siphash *state) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "alloc-util.h"
-#include "macro.h"
-#include "siphash24.h"
+#include "forward.h"
typedef void (*hash_func_t)(const void *p, struct siphash *state);
typedef int (*compare_func_t)(const void *a, const void *b);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fnmatch.h>
#include <pthread.h>
-#include <stdint.h>
-#include <stdlib.h>
#if HAVE_VALGRIND_VALGRIND_H
# include <valgrind/valgrind.h>
#endif
#include "alloc-util.h"
-#include "fileio.h"
+#include "extract-word.h"
#include "hashmap.h"
#include "log.h"
#include "logarithm.h"
-#include "macro.h"
#include "memory-util.h"
#include "mempool.h"
-#include "missing_syscall.h"
#include "process-util.h"
#include "random-util.h"
#include "set.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <limits.h>
-#include <stdbool.h>
-#include <stddef.h>
-
+#include "forward.h"
#include "hash-funcs.h"
#include "iterator.h"
-#include "macro.h"
/*
* A hash table implementation. As a minor optimization a NULL hashmap object
#define HASH_KEY_SIZE 16
-typedef void* (*hashmap_destroy_t)(void *p);
/* The base type for all hashmap and set types. Many functions in the implementation take (HashmapBase*)
* parameters and are run-time polymorphic, though the API is not meant to be polymorphic (do not call
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdint.h>
-#include <stdlib.h>
+#include <stdio.h>
#include "alloc-util.h"
#include "hexdecoct.h"
-#include "macro.h"
#include "memory-util.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
char octchar(int x) _const_;
int unoctchar(char c) _const_;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <assert.h>
#include <string.h>
#include "hmac.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdint.h>
-#include <stdlib.h>
-
+#include "forward.h"
#include "sha256.h"
/* Unoptimized implementation based on FIPS 198. 'res' has to be allocated by
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <sys/utsname.h>
-#include <unistd.h>
#include "alloc-util.h"
#include "env-file.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stdio.h>
-
-#include "macro.h"
+#include "forward.h"
#include "strv.h"
char* get_default_hostname_raw(void);
#include <arpa/inet.h>
#include <endian.h>
-#include <errno.h>
-#include <net/if.h>
-#include <stdint.h>
#include <stdio.h>
-#include <stdlib.h>
#include "alloc-util.h"
#include "errno-util.h"
+#include "hash-funcs.h"
#include "in-addr-util.h"
#include "logarithm.h"
-#include "macro.h"
#include "memory-util.h"
#include "parse-util.h"
#include "random-util.h"
+#include "siphash24.h"
#include "stdio-util.h"
#include "string-util.h"
-#include "strxcpyx.h"
bool in4_addr_is_null(const struct in_addr *a) {
assert(a);
return 0;
}
+const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len) {
+ return inet_ntop(family, a, buf, len);
+}
+
+const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len) {
+ return inet_ntop(AF_INET, a, buf, len);
+}
+
+const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len) {
+ return inet_ntop(AF_INET6, a, buf, len);
+}
+
int in_addr_prefix_to_string(
int family,
const union in_addr_union *u,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <arpa/inet.h>
#include <netinet/in.h>
-#include <stddef.h>
-#include <sys/socket.h>
-#include "hash-funcs.h"
-#include "macro.h"
+#include "forward.h"
union in_addr_union {
struct in_addr in;
return in_addr_to_string(AF_INET6, (const union in_addr_union*) u, ret);
}
-static inline const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len) {
- return inet_ntop(family, a, buf, len);
-}
-static inline const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len) {
- return inet_ntop(AF_INET, a, buf, len);
-}
-static inline const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len) {
- return inet_ntop(AF_INET6, a, buf, len);
-}
+const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len);
+const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len);
+const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len);
/* Note: the lifetime of the compound literal is the immediately surrounding block,
* see C11 §6.5.2.5, and
}
static inline size_t FAMILY_ADDRESS_SIZE(int family) {
- assert(IN_SET(family, AF_INET, AF_INET6));
- return family == AF_INET6 ? 16 : 4;
+ switch (family) {
+ case AF_INET:
+ return 4;
+ case AF_INET6:
+ return 16;
+ default:
+ assert_not_reached();
+ }
}
#define FAMILY_ADDRESS_SIZE_SAFE(f) \
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/if.h>
+#include <linux/if.h> /* IWYU pragma: export */
#define IF_NAMESIZE 16
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/if_arp.h>
+#include <linux/if_arp.h> /* IWYU pragma: export */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/ipv6.h>
+#include <linux/in.h> /* IWYU pragma: export */
+#include <linux/in6.h> /* IWYU pragma: export */
+#include <linux/ipv6.h> /* IWYU pragma: export */
#include <stddef.h>
#include <stdint.h>
#include <sys/socket.h>
#pragma once
#include <features.h>
+#include <linux/mount.h> /* IWYU pragma: export */
#include <stddef.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include "errno-util.h"
#include "initrd-util.h"
#include "log.h"
-#include "parse-util.h"
-#include "stat-util.h"
-#include "string-util.h"
static int saved_in_initrd = -1;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
+#include "forward.h"
bool in_initrd(void);
void in_initrd_force(bool value);
#include "fd-util.h"
#include "inotify-util.h"
-#include "stat-util.h"
+#include "log.h"
+#include "memory-util.h"
bool inotify_event_next(
union inotify_event_buffer *buffer,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <limits.h>
-#include <stddef.h>
-#include <sys/inotify.h>
+#include <sys/inotify.h> /* IWYU pragma: export */
+#include <syslog.h>
-#include "log.h"
+#include "forward.h"
#define INOTIFY_EVENT_MAX (offsetof(struct inotify_event, name) + NAME_MAX + 1)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <limits.h>
+#include <poll.h>
#include <stdio.h>
+#include <string.h>
+#include <time.h>
#include <unistd.h>
#include "errno-util.h"
#include "io-util.h"
-#include "iovec-util.h"
-#include "string-util.h"
#include "time-util.h"
int flush_fd(int fd) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <poll.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "macro.h"
-#include "time-util.h"
+#include "forward.h"
int flush_fd(int fd);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-
-#include "assert-util.h"
#include "ioprio-util.h"
#include "parse-util.h"
#include "string-table.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/ioprio.h>
+#include <linux/ioprio.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
static inline int ioprio_prio_class(int value) {
return IOPRIO_PRIO_CLASS(value);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <sys/types.h>
-#include <sys/uio.h>
+#include <sys/uio.h> /* IWYU pragma: export */
-#include "iovec-util-fundamental.h"
-#include "macro.h"
+#include "forward.h"
+#include "iovec-util-fundamental.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 */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <limits.h>
-
#include "alloc-util.h"
#include "iovec-util.h"
#include "iovec-wrapper.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
struct iovec_wrapper {
struct iovec *iovec;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "forward.h"
+
/* Ideally the Iterator would be an opaque struct, but it is instantiated
* by hashmap users, so the definition has to be here. Do not use its fields
* directly. */
#include "alloc-util.h"
#include "keyring-util.h"
#include "log.h"
-#include "memory-util.h"
#include "missing_syscall.h"
int keyring_read(key_serial_t serial, void **ret, size_t *ret_size) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/types.h>
-
+#include "forward.h"
#include "missing_keyctl.h"
/* Like TAKE_PTR() but for key_serial_t, resetting them to -1 */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stddef.h>
-
-#include "assert-util.h"
#include "label.h"
-#include "macro.h"
static const LabelOps *label_ops = NULL;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <sys/types.h>
+#include "forward.h"
typedef struct LabelOps {
int (*pre)(int dir_fd, const char *path, mode_t mode);
#include "parse-util.h"
#include "process-util.h"
#include "procfs-util.h"
-#include "string-util.h"
uint64_t physical_memory(void) {
_cleanup_free_ char *root = NULL, *value = NULL;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
+#include "forward.h"
uint64_t physical_memory(void);
uint64_t physical_memory_scale(uint64_t v, uint64_t max);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "macro.h"
+#include "forward.h"
/* The head of the linked list. Use this in the structure that shall
* contain the head of the linked list */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
#include <langinfo.h>
-#include <libintl.h>
-#include <stddef.h>
-#include <stdint.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include "constants.h"
#include "dirent-util.h"
#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
-#include "hashmap.h"
#include "locale-util.h"
#include "log.h"
#include "path-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <libintl.h>
-#include <locale.h>
-#include <stdbool.h>
+#include <locale.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
typedef enum LocaleVariable {
/* We don't list LC_ALL here on purpose. People should be
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fs-util.h"
#include "lock-util.h"
#include "log.h"
-#include "macro.h"
-#include "missing_fcntl.h"
#include "path-util.h"
#include "process-util.h"
+#include "string-util.h"
+#include "time-util.h"
int make_lock_file_at(int dir_fd, const char *p, int operation, LockFile *ret) {
_cleanup_close_ int fd = -EBADF, dfd = -EBADF;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
/* Include here so consumers have LOCK_{EX,SH,NB} available. */
-#include <sys/file.h>
+#include <sys/file.h> /* IWYU pragma: export */
-#include "time-util.h"
+#include "forward.h"
typedef struct LockFile {
int dir_fd;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-
+#include "forward.h"
#include "list.h"
-#include "macro.h"
-#include "memory-util.h"
/*
* The log context allows attaching extra metadata to log messages written to the journal via log.h. We keep
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stddef.h>
#include <sys/signalfd.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <sys/uio.h>
-#include <sys/un.h>
#include <threads.h>
#include <unistd.h>
#include "list.h"
#include "log.h"
#include "log-context.h"
-#include "macro.h"
-#include "missing_syscall.h"
#include "parse-util.h"
#include "proc-cmdline.h"
#include "process-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <syslog.h>
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
/* Some structures we reference but don't want to pull in headers for */
struct iovec;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <unistd.h>
+
#include "login-util.h"
#include "string-util.h"
return id[strspn(id, LETTERS DIGITS)] == '\0';
}
+
+bool logind_running(void) {
+ return access("/run/systemd/seats/", F_OK) >= 0;
+}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <unistd.h>
-
-#include "macro.h"
+#include "forward.h"
#define SD_LOGIND_ROOT_CHECK_INHIBITORS (UINT64_C(1) << 0)
#define SD_LOGIND_REBOOT_VIA_KEXEC (UINT64_C(1) << 1)
bool session_id_valid(const char *id) _pure_;
-static inline bool logind_running(void) {
- return access("/run/systemd/seats/", F_OK) >= 0;
-}
+bool logind_running(void);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "macro-fundamental.h"
+#include "macro-fundamental.h" /* IWYU pragma: export */
#if !defined(HAS_FEATURE_MEMORY_SANITIZER)
# if defined(__has_feature)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <math.h>
+#include <math.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
/* On some optimization level, iszero(x) is converted to (x == 0.0), and emits warning -Wfloat-equal.
* The argument must be a floating point, i.e. one of float, double, or long double. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <stdio.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
-#include "log.h"
-#include "macro.h"
#include "memfd-util.h"
-#include "missing_fcntl.h"
#include "missing_mman.h"
-#include "missing_syscall.h"
+#include "missing_sched.h"
#include "string-util.h"
#include "utf8.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
int memfd_create_wrapper(const char *name, unsigned mode);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <limits.h>
-#include <malloc.h>
-#include <stdbool.h>
#include <string.h>
-#include <sys/types.h>
-#include "cleanup-util.h"
-#include "macro.h"
-#include "memory-util-fundamental.h"
+#include "forward.h"
+#include "memory-util-fundamental.h" /* IWYU pragma: export */
size_t page_size(void) _pure_;
#define PAGE_ALIGN(l) ALIGN_TO(l, page_size())
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include "format-util.h"
#include "log.h"
-#include "macro.h"
#include "memory-util.h"
#include "mempool.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
+#include "forward.h"
struct pool;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdio.h>
-
-#include "macro.h"
+#include "forward.h"
typedef struct MemStream {
FILE *f;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/audit.h>
+#include <linux/audit.h> /* IWYU pragma: export */
#if HAVE_AUDIT
-# include <libaudit.h>
+# include <libaudit.h> /* IWYU pragma: export */
#endif
/* We use _Static_assert() directly here instead of assert_cc()
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/bpf.h>
+#include <linux/bpf.h> /* IWYU pragma: export */
/* defined in linux/filter.h */
/* Unconditional jumps, goto pc + off16 */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
+#include <fcntl.h> /* IWYU pragma: export */
/* This is defined since glibc-2.41. */
#ifndef F_DUPFD_QUERY
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/fs.h>
+#include <linux/fs.h> /* IWYU pragma: export */
/* Not exposed yet. Defined at fs/ext4/ext4.h */
#ifndef EXT4_IOC_RESIZE_FS
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <linux/keyctl.h>
+#include <linux/keyctl.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
/* From linux/key.h */
#ifndef KEY_POS_VIEW
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/magic.h>
+#include <linux/magic.h> /* IWYU pragma: export */
/* Not exposed yet (4.20). Defined at ipc/mqueue.c */
#ifndef MQUEUE_MAGIC
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/mman.h>
+#include <sys/mman.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
/* since glibc-2.38 */
#ifndef MFD_NOEXEC_SEAL
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <linux/nsfs.h>
+#include <linux/nsfs.h> /* IWYU pragma: export */
#include <linux/types.h>
/* Root namespace inode numbers, as per include/linux/proc_ns.h in the kernel source tree, since v3.8:
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <netinet/in.h>
+#include <netinet/in.h> /* IWYU pragma: export */
/* linux/in.h or netinet/in.h (since glibc-2.32) */
#ifndef IPPROTO_MPTCP
#include <linux/types.h>
#if HAVE_PIDFD_OPEN
-#include <sys/pidfd.h>
+#include <sys/pidfd.h> /* IWYU pragma: export */
#endif
#ifndef PIDFS_IOCTL_MAGIC
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/random.h>
+#include <sys/random.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
/* Defined since glibc-2.32. */
#ifndef GRND_INSECURE
#pragma once
#include <linux/types.h>
-#include <sched.h>
+#include <sched.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
/* 769071ac9f20b6a447410c7eaa55d1a5233ef40c (5.8),
* defined in sched.h since glibc-2.36. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/socket.h>
+#include <sys/socket.h> /* IWYU pragma: export */
/* Supported since kernel v6.5 (5e2ff6704a275be009be8979af17c52361b79b89) */
#ifndef SO_PASSPIDFD
/* Missing glibc definitions to access certain kernel APIs */
-#include <errno.h>
-#include <linux/time_types.h>
#include <signal.h>
#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/wait.h>
#include <unistd.h>
#ifdef ARCH_MIPS
#include <asm/sgidefs.h>
#endif
-#include "macro.h"
+#include "forward.h"
#include "missing_keyctl.h"
#include "missing_sched.h"
#include "missing_syscall_def.h"
*/
#pragma once
-#include "macro.h"
+#include "forward.h"
/* Note: if this code looks strange, this is because it is derived from the same
* template as the per-syscall blocks below. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/wait.h>
+#include <sys/wait.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
/* since glibc-2.36 */
#ifndef P_PIDFD
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdint.h>
+#include "forward.h"
/* This is currently not exported in the public kernel headers, but the libxfs library code part of xfsprogs
* defines it as public header */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stdbool.h>
-#include <string.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "btrfs.h"
#include "format-util.h"
#include "fs-util.h"
#include "log.h"
-#include "macro.h"
#include "mkdir.h"
#include "path-util.h"
#include "stat-util.h"
-#include "stdio-util.h"
+#include "string-util.h"
+#include "time-util.h"
#include "user-util.h"
int mkdirat_safe_internal(
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
-#include <sys/types.h>
-
-#include "time-util.h"
+#include "forward.h"
typedef enum MkdirFlags {
MKDIR_FOLLOW_SYMLINK = 1 << 0,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
#include <sys/mount.h>
#include "filesystems.h"
#include "fs-util.h"
#include "log.h"
-#include "missing_fcntl.h"
-#include "missing_fs.h"
-#include "missing_syscall.h"
-#include "mkdir.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "stat-util.h"
#include "stdio-util.h"
+#include "string-util.h"
#include "strv.h"
-#include "user-util.h"
/* This is the original MAX_HANDLE_SZ definition from the kernel, when the API was introduced. We use that in place of
* any more currently defined value to future-proof things: if the size is increased in the API headers, and our code
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <sys/types.h>
+#include "forward.h"
/* The limit used for /dev itself. 4MB should be enough since device nodes and symlinks don't
* consume any space and udev isn't supposed to create regular file either. There's no limit on the
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
-#include "missing_fs.h"
#include "missing_magic.h"
#include "missing_namespace.h"
#include "missing_sched.h"
-#include "missing_syscall.h"
#include "mountpoint-util.h"
#include "namespace-util.h"
#include "parse-util.h"
#include "pidfd-util.h"
+#include "pidref.h"
#include "process-util.h"
#include "stat-util.h"
#include "stdio-util.h"
return fd_inode_same(ns1, ns2);
}
+int in_same_namespace(pid_t pid1, pid_t pid2, NamespaceType type) {
+ assert(pid1 >= 0);
+ assert(pid2 >= 0);
+ return pidref_in_same_namespace(pid1 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid1),
+ pid2 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid2),
+ type);
+}
+
int namespace_get_leader(PidRef *pidref, NamespaceType type, PidRef *ret) {
int r;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/types.h>
-
-#include "pidref.h"
+#include "forward.h"
typedef enum NamespaceType {
NAMESPACE_CGROUP,
int namespace_is_init(NamespaceType type);
int pidref_in_same_namespace(PidRef *pid1, PidRef *pid2, NamespaceType type);
-static inline int in_same_namespace(pid_t pid1, pid_t pid2, NamespaceType type) {
- assert(pid1 >= 0);
- assert(pid2 >= 0);
- return pidref_in_same_namespace(pid1 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid1),
- pid2 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid2),
- type);
-}
+int in_same_namespace(pid_t pid1, pid_t pid2, NamespaceType type);
int namespace_get_leader(PidRef *pidref, NamespaceType type, PidRef *ret);
#include "alloc-util.h"
#include "nulstr-util.h"
+#include "set.h"
#include "string-util.h"
#include "strv.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <macro.h>
-#include <stdbool.h>
#include <string.h>
-#include "assert-util.h"
-#include "set.h"
+#include "forward.h"
#define NULSTR_FOREACH(i, l) \
for (typeof(*(l)) *(i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "fileio.h"
#include "ordered-set.h"
#include "strv.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdio.h>
-
+#include "forward.h"
#include "hashmap.h"
typedef struct OrderedSet OrderedSet;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <stdlib.h>
+
#include "alloc-util.h"
#include "chase.h"
#include "dirent-util.h"
#include "env-file.h"
-#include "env-util.h"
#include "errno-util.h"
#include "fd-util.h"
-#include "fileio.h"
#include "fs-util.h"
#include "glyph-util.h"
#include "log.h"
-#include "macro.h"
#include "os-util.h"
-#include "parse-util.h"
#include "path-util.h"
#include "stat-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
+#include "time-util.h"
#include "utf8.h"
#include "xattr-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stdio.h>
-
-#include "time-util.h"
+#include "forward.h"
typedef enum ImageClass {
IMAGE_MACHINE,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <inttypes.h>
#include <linux/ipv6.h>
#include <linux/netfilter/nf_tables.h>
-#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include "extract-word.h"
#include "locale-util.h"
#include "log.h"
-#include "macro.h"
#include "missing_network.h"
#include "parse-util.h"
#include "process-util.h"
-#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-#include <limits.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
typedef unsigned long loadavg_t;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fnmatch.h>
-#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "fs-util.h"
#include "glob-util.h"
#include "log.h"
-#include "macro.h"
#include "path-util.h"
#include "stat-util.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "macro.h"
-#include "time-util.h"
+#include "forward.h"
#define PATH_SPLIT_BIN(x) x "sbin:" x "bin"
#define PATH_SPLIT_BIN_NULSTR(x) x "sbin\0" x "bin\0"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdint.h>
+#include "forward.h"
/*
* For details about the file format see RFC:
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include "alloc-util.h"
#include "parse-util.h"
#include "percent-util.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <inttypes.h>
-#include <limits.h>
-
-#include "macro.h"
+#include "forward.h"
int parse_percent_unbounded(const char *p);
int parse_percent(const char *p);
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
-#include "log.h"
-#include "macro.h"
-#include "memory-util.h"
#include "missing_fs.h"
#include "missing_magic.h"
#include "mountpoint-util.h"
#include "parse-util.h"
-#include "path-util.h"
#include "pidfd-util.h"
#include "process-util.h"
#include "stat-util.h"
+#include "stdio-util.h"
#include "string-util.h"
static int have_pidfs = -1;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "missing_pidfd.h"
-#include "missing_syscall.h"
+#include "forward.h"
+#include "missing_pidfd.h" /* IWYU pragma: export */
+#include "missing_syscall.h" /* IWYU pragma: export */
int pidfd_get_namespace(int fd, unsigned long ns_type_cmd);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
+#include "format-util.h"
+#include "hash-funcs.h"
#include "log.h"
-#include "missing_syscall.h"
#include "missing_wait.h"
#include "parse-util.h"
#include "pidfd-util.h"
#include "pidref.h"
#include "process-util.h"
-#include "signal-util.h"
+#include "siphash24.h"
int pidref_acquire_pidfd_id(PidRef *pidref) {
int r;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
#include <signal.h>
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
/* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes
* continuously. This combines a PID, a modern Linux pidfd and the 64bit inode number of the pidfd into one
* The underlying algorithm used in this implementation is a Heap.
*/
-#include <errno.h>
-#include <stdlib.h>
-
#include "alloc-util.h"
-#include "hashmap.h"
#include "prioq.h"
struct prioq_item {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
-#include "hashmap.h"
-#include "macro.h"
+#include "forward.h"
typedef struct Prioq Prioq;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <stdbool.h>
-#include <stddef.h>
+#include <stdlib.h>
#include "alloc-util.h"
-#include "efivars.h"
#include "extract-word.h"
#include "fileio.h"
#include "getopt-defs.h"
#include "initrd-util.h"
-#include "macro.h"
+#include "log.h"
#include "parse-util.h"
#include "proc-cmdline.h"
#include "process-util.h"
return r;
}
+
+bool proc_cmdline_value_missing(const char *key, const char *value) {
+ assert(key);
+
+ if (!value) {
+ log_warning("Missing argument for %s= kernel command line switch, ignoring.", key);
+ return true;
+ }
+
+ return false;
+}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
-#include "log.h"
+#include "forward.h"
typedef enum ProcCmdlineFlags {
PROC_CMDLINE_STRIP_RD_PREFIX = 1 << 0, /* automatically strip "rd." prefix if it is set (and we are in the initrd, since otherwise we'd not consider it anyway) */
bool proc_cmdline_key_streq(const char *x, const char *y);
/* A little helper call, to be used in proc_cmdline_parse_t callbacks */
-static inline bool proc_cmdline_value_missing(const char *key, const char *value) {
- if (!value) {
- log_warning("Missing argument for %s= kernel command line switch, ignoring.", key);
- return true;
- }
-
- return false;
-}
+bool proc_cmdline_value_missing(const char *key, const char *value);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
#include <linux/oom.h>
#include <pthread.h>
#include <spawn.h>
-#include <stdbool.h>
#include <stdio.h>
-#include <stdlib.h>
#include <sys/mount.h>
#include <sys/personality.h>
#include <sys/prctl.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <syslog.h>
#include <threads.h>
#include "cgroup-util.h"
#include "dirent-util.h"
#include "env-file.h"
-#include "env-util.h"
#include "errno-util.h"
#include "escape.h"
#include "fd-util.h"
#include "iovec-util.h"
#include "locale-util.h"
#include "log.h"
-#include "macro.h"
#include "memory-util.h"
#include "missing_sched.h"
#include "missing_syscall.h"
#include "parse-util.h"
#include "path-util.h"
#include "pidfd-util.h"
+#include "pidref.h"
#include "process-util.h"
#include "raw-clone.h"
#include "rlimit-util.h"
#include "stdio-util.h"
#include "string-table.h"
#include "string-util.h"
-#include "terminal-util.h"
#include "time-util.h"
#include "user-util.h"
-#include "utf8.h"
/* The kernel limits userspace processes to TASK_COMM_LEN (16 bytes), but allows higher values for its own
* workers, e.g. "kworker/u9:3-kcryptd/253:0". Let's pick a fixed smallish limit that will work for the kernel.
return CMP(*a, *b);
}
+bool nice_is_valid(int n) {
+ return n >= PRIO_MIN && n < PRIO_MAX;
+}
+
+bool sched_policy_is_valid(int i) {
+ return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR);
+}
+
+bool sched_priority_is_valid(int i) {
+ return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
+}
+
/* The cached PID, possible values:
*
* == UNSET [0] → cache not initialized yet
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <sched.h>
#include <signal.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/resource.h>
-#include <sys/types.h>
-
-#include "alloc-util.h"
-#include "assert-util.h"
+
#include "fileio.h"
#include "format-util.h"
-#include "macro.h"
-#include "pidref.h"
-#include "time-util.h"
+#include "forward.h"
+#include "string-util.h"
#define procfs_file_alloca(pid, field) \
({ \
int pid_compare_func(const pid_t *a, const pid_t *b);
-static inline bool nice_is_valid(int n) {
- return n >= PRIO_MIN && n < PRIO_MAX;
-}
+bool nice_is_valid(int n);
-static inline bool sched_policy_is_valid(int i) {
- return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR);
-}
-
-static inline bool sched_priority_is_valid(int i) {
- return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
-}
+bool sched_policy_is_valid(int i) _const_;
+bool sched_priority_is_valid(int i) _const_;
#define PID_AUTOMATIC ((pid_t) INT_MIN) /* special value indicating "acquire pid from connection peer" */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <unistd.h>
#include "alloc-util.h"
-#include "constants.h"
+#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
-#include "log.h"
#include "parse-util.h"
#include "process-util.h"
#include "procfs-util.h"
#include "stdio-util.h"
#include "string-util.h"
+#include "time-util.h"
int procfs_get_pid_max(uint64_t *ret) {
_cleanup_free_ char *value = NULL;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
-
-#include "time-util.h"
+#include "forward.h"
int procfs_get_pid_max(uint64_t *ret);
int procfs_get_threads_max(uint64_t *ret);
#include <stdio.h>
#include <threads.h>
-#include <unistd.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fileio.h"
#include "parse-util.h"
#include "psi-util.h"
-#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
+#include "forward.h"
#include "parse-util.h"
-#include "time-util.h"
typedef enum PressureType {
PRESSURE_TYPE_SOME,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <pthread.h>
+#include <pthread.h> /* IWYU pragma: export */
-#include "assert-util.h"
+#include "forward.h"
static inline pthread_mutex_t* pthread_mutex_lock_assert(pthread_mutex_t *mutex) {
assert_se(pthread_mutex_lock(mutex) == 0);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <elf.h>
-#include <errno.h>
#include <fcntl.h>
#include <linux/random.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
#include <string.h>
#include <sys/auxv.h>
#include <sys/ioctl.h>
-#include <sys/time.h>
#include <threads.h>
#include "alloc-util.h"
-#include "env-util.h"
-#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "io-util.h"
#include "iovec-util.h"
#include "log.h"
#include "missing_random.h"
-#include "missing_syscall.h"
#include "parse-util.h"
#include "pidfd-util.h"
#include "process-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/uio.h>
-
-#include "macro.h"
+#include "forward.h"
void random_bytes(void *p, size_t n) _nonnull_if_nonzero_(1, 2); /* Returns random bytes suitable for most uses, but may be insecure sometimes. */
int crypto_random_bytes(void *p, size_t n) _nonnull_if_nonzero_(1, 2); /* Returns secure random bytes after waiting for the RNG to initialize. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <limits.h>
-#include <sys/time.h>
-
-#include "assert-util.h"
-#include "macro.h"
#include "ratelimit.h"
+#include "time-util.h"
/* Modelled after Linux' lib/ratelimit.c by Dave Young
* <hidave.darkstar@gmail.com>, which is licensed GPLv2. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
-#include "time-util.h"
+#include "forward.h"
typedef struct RateLimit {
usec_t interval; /* Keep those two fields first so they can be initialized easily: */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <sys/stat.h>
+
#include "alloc-util.h"
#include "dirent-util.h"
#include "fd-util.h"
-#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "mountpoint-util.h"
+#include "path-util.h"
#include "recurse-dir.h"
#include "sort-util.h"
#pragma once
#include <dirent.h>
-#include <limits.h>
-#include "errno-list.h"
-#include "macro.h"
-#include "stat-util.h"
+#include "forward.h"
typedef enum RecurseDirFlags {
/* Interpreted by readdir_all() */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stddef.h>
-#include <stdlib.h>
-
#include "alloc-util.h"
-#include "macro.h"
#include "replace-var.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "forward.h"
+
char* replace_var(const char *text, char *(*lookup)(const char *variable, void *userdata), void *userdata);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-
#include "alloc-util.h"
#include "errno-util.h"
#include "extract-word.h"
#include "fileio.h"
#include "format-util.h"
#include "log.h"
-#include "macro.h"
#include "parse-util.h"
#include "process-util.h"
#include "rlimit-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <sys/resource.h>
-#include <sys/types.h>
+#include <sys/resource.h> /* IWYU pragma: export */
-#include "macro.h"
+#include "forward.h"
#define _RLIMIT_MAX RLIMIT_NLIMITS
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-
-#include "macro.h"
+#include "forward.h"
typedef enum RuntimeScope {
RUNTIME_SCOPE_SYSTEM, /* for the system */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "extract-word.h"
+#include "forward.h"
#include "hashmap.h"
-#include "macro.h"
#define set_free_and_replace(a, b) \
free_and_replace_full(a, b, set_free)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <unistd.h>
#include "alloc-util.h"
#include "hexdecoct.h"
-#include "macro.h"
#include "sha256.h"
+#include "string-util.h"
int sha256_fd(int fd, uint64_t max_size, uint8_t ret[static SHA256_DIGEST_SIZE]) {
struct sha256_ctx ctx;
memcpy(ret, data, size);
return 0;
}
+
+bool sha256_is_valid(const char *s) {
+ return s && in_charset(s, HEXDIGITS) && (strlen(s) == SHA256_DIGEST_SIZE * 2);
+}
#pragma once
-#include <stdint.h>
-
-#include "sha256-fundamental.h"
-#include "string-util.h"
+#include "forward.h"
+#include "sha256-fundamental.h" /* IWYU pragma: export */
int sha256_fd(int fd, uint64_t max_size, uint8_t ret[static SHA256_DIGEST_SIZE]);
int parse_sha256(const char *s, uint8_t res[static SHA256_DIGEST_SIZE]);
-static inline bool sha256_is_valid(const char *s) {
- return s && in_charset(s, HEXDIGITS) && (strlen(s) == SHA256_DIGEST_SIZE * 2);
-}
+bool sha256_is_valid(const char *s);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <signal.h>
-#include <stddef.h>
#include <sys/mman.h>
-#include "log.h"
-#include "macro.h"
#include "memory-util.h"
-#include "missing_syscall.h"
-#include "process-util.h"
#include "sigbus.h"
#include "signal-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "forward.h"
+
void sigbus_install(void);
void sigbus_reset(void);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stdarg.h>
#include <threads.h>
#include "errno-util.h"
-#include "macro.h"
#include "missing_syscall.h"
#include "parse-util.h"
#include "signal-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <signal.h>
+#include <signal.h> /* IWYU pragma: export */
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
int reset_all_signal_handlers(void);
int reset_signal_mask(void);
#include <stdio.h>
-#include "macro.h"
#include "siphash24.h"
+#include "string-util.h"
#include "unaligned.h"
static uint64_t rotate_left(uint64_t x, uint8_t b) {
}
}
+void siphash24_compress_string(const char *in, struct siphash *state) {
+ siphash24_compress_safe(in, strlen_ptr(in), state);
+}
+
uint64_t siphash24_finalize(struct siphash *state) {
uint64_t b;
return siphash24_finalize(&state);
}
+
+uint64_t siphash24_string(const char *s, const uint8_t k[static 16]) {
+ return siphash24(s, strlen(s) + 1, k);
+}
#pragma once
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "string-util.h"
-#include "time-util.h"
+#include "forward.h"
struct siphash {
uint64_t v0;
siphash24_compress(in, inlen, state);
}
-static inline void siphash24_compress_string(const char *in, struct siphash *state) {
- siphash24_compress_safe(in, strlen_ptr(in), state);
-}
+void siphash24_compress_string(const char *in, struct siphash *state);
uint64_t siphash24_finalize(struct siphash *state);
uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]);
-static inline uint64_t siphash24_string(const char *s, const uint8_t k[static 16]) {
- return siphash24(s, strlen(s) + 1, k);
-}
+uint64_t siphash24_string(const char *s, const uint8_t k[static 16]);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <arpa/inet.h>
-#include <errno.h>
-#include <limits.h>
+#include <fcntl.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <mqueue.h>
#include <netdb.h>
#include <netinet/ip.h>
#include <poll.h>
-#include <stddef.h>
-#include <stdint.h>
#include <stdio.h>
-#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "errno-util.h"
#include "escape.h"
#include "fd-util.h"
-#include "fileio.h"
#include "format-ifname.h"
+#include "format-util.h"
+#include "in-addr-util.h"
#include "io-util.h"
#include "log.h"
#include "memory-util.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pidref.h"
#include "process-util.h"
#include "random-util.h"
#include "socket-util.h"
+#include "sparse-endian.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "sysctl-util.h"
-#include "user-util.h"
-#include "utf8.h"
#if ENABLE_IDN
# define IDN_FLAGS NI_IDN
}
int socket_get_mtu(int fd, int af, size_t *ret) {
- int mtu, r;
+ int mtu = 0, r; /* Avoid maybe-uninitialized false positive */
if (af == AF_UNSPEC) {
af = socket_get_family(fd);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <inttypes.h>
#include <linux/if_ether.h>
#include <linux/if_infiniband.h>
#include <linux/if_packet.h>
#include <linux/netlink.h>
#include <linux/vm_sockets.h>
#include <netinet/in.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <string.h>
#include <sys/socket.h>
-#include <sys/types.h>
#include <sys/un.h>
-#include "errno-util.h"
-#include "in-addr-util.h"
-#include "macro.h"
+#include "forward.h"
+#include "memory-util.h"
#include "missing_network.h"
#include "missing_socket.h"
-#include "pidref.h"
-#include "sparse-endian.h"
union sockaddr_union {
/* The minimal, abstract version */
socklen_t sl = sizeof(v);
if (getsockopt(fd, level, optname, &v, &sl) < 0)
- return negative_errno();
+ return -errno;
if (sl != sizeof(v))
return -EIO;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <stdlib.h>
+
#include "alloc-util.h"
#include "sort-util.h"
return NULL;
}
+void* bsearch_safe(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
+ /**
+ * Normal bsearch requires base to be nonnull. Here were require
+ * that only if nmemb > 0.
+ */
+
+ if (nmemb <= 0)
+ return NULL;
+
+ assert(base);
+ return bsearch(key, base, nmemb, size, compar);
+}
+
+void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
+ /**
+ * Normal qsort requires base to be nonnull. Here were require
+ * that only if nmemb > 0.
+ */
+
+ if (nmemb <= 1)
+ return;
+
+ assert(base);
+ qsort(base, nmemb, size, compar);
+}
+
+void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata) {
+ if (nmemb <= 1)
+ return;
+
+ assert(base);
+ qsort_r(base, nmemb, size, compar, userdata);
+}
+
int cmp_int(const int *a, const int *b) {
return CMP(*a, *b);
}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdlib.h>
-
-#include "assert-util.h"
-#include "macro.h"
-
-/* This is the same as glibc's internal __compar_d_fn_t type. glibc exports a public comparison_fn_t, for the
- * external type __compar_fn_t, but doesn't do anything similar for __compar_d_fn_t. Let's hence do that
- * ourselves, picking a name that is obvious, but likely enough to not clash with glibc's choice of naming if
- * they should ever add one. */
-typedef int (*comparison_userdata_fn_t)(const void *, const void *, void *);
+#include "forward.h"
void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
comparison_userdata_fn_t compar, void *arg);
(typeof((b)[0])*) xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_userdata_fn_t) _func_, userdata); \
})
-/**
- * Normal bsearch requires base to be nonnull. Here were require
- * that only if nmemb > 0.
- */
-static inline void* bsearch_safe(const void *key, const void *base,
- size_t nmemb, size_t size, comparison_fn_t compar) {
- if (nmemb <= 0)
- return NULL;
-
- assert(base);
- return bsearch(key, base, nmemb, size, compar);
-}
+void* bsearch_safe(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar);
#define typesafe_bsearch(k, b, n, func) \
({ \
(typeof((b)[0])*) bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_fn_t) _func_); \
})
-/**
- * Normal qsort requires base to be nonnull. Here were require
- * that only if nmemb > 0.
- */
-static inline void _qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
- if (nmemb <= 1)
- return;
-
- assert(base);
- qsort(base, nmemb, size, compar);
-}
+void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar);
/* A wrapper around the above, but that adds typesafety: the element size is automatically derived from the type and so
* is the prototype for the comparison function */
#define typesafe_qsort(p, n, func) \
({ \
int (*_func_)(const typeof((p)[0])*, const typeof((p)[0])*) = func; \
- _qsort_safe((p), (n), sizeof((p)[0]), (comparison_fn_t) _func_); \
+ qsort_safe((p), (n), sizeof((p)[0]), (comparison_fn_t) _func_); \
})
-static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata) {
- if (nmemb <= 1)
- return;
-
- assert(base);
- qsort_r(base, nmemb, size, compar, userdata);
-}
+void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata);
#define typesafe_qsort_r(p, n, func, userdata) \
({ \
#include <byteswap.h>
#include <endian.h>
-#include <stdint.h>
+
+#include "forward.h"
#ifdef __CHECKER__
#define __sd_bitwise __attribute__((__bitwise__))
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
-#include <sched.h>
#include <sys/statvfs.h>
-#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
#include "dirent-util.h"
#include "errno-util.h"
#include "fd-util.h"
-#include "fileio.h"
#include "filesystems.h"
#include "fs-util.h"
#include "hash-funcs.h"
#include "log.h"
-#include "macro.h"
-#include "missing_fs.h"
#include "missing_magic.h"
#include "mountpoint-util.h"
-#include "nulstr-util.h"
-#include "parse-util.h"
+#include "path-util.h"
+#include "siphash24.h"
#include "stat-util.h"
#include "string-util.h"
+#include "time-util.h"
static int verify_stat_at(
int fd,
return RET_NERRNO(fstatfs(dir_fd, ret));
}
+usec_t statx_timestamp_load(const struct statx_timestamp *ts) {
+ return timespec_load(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
+}
+nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts) {
+ return timespec_load_nsec(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
+}
+
void inode_hash_func(const struct stat *q, struct siphash *state) {
siphash24_compress_typesafe(q->st_dev, state);
siphash24_compress_typesafe(q->st_ino, state);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
-#include <sys/types.h>
-#include <sys/vfs.h>
-
-#include "fs-util.h"
-#include "macro.h"
-#include "siphash24.h"
-#include "time-util.h"
+#include <sys/stat.h> /* IWYU pragma: export */
+#include <sys/statfs.h> /* IWYU pragma: export */
+
+#include "forward.h"
int stat_verify_regular(const struct stat *st);
int verify_regular_at(int fd, const char *path, bool follow);
int xstatfsat(int dir_fd, const char *path, struct statfs *ret);
-static inline usec_t statx_timestamp_load(const struct statx_timestamp *ts) {
- return timespec_load(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
-}
-static inline nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts) {
- return timespec_load_nsec(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
-}
+usec_t statx_timestamp_load(const struct statx_timestamp *ts);
+nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts);
void inode_hash_func(const struct stat *q, struct siphash *state);
int inode_compare_func(const struct stat *a, const struct stat *b);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "memory-util.h"
#include "static-destruct.h"
void static_destruct_impl(const StaticDestructor *start, const StaticDestructor *end) {
#pragma once
-#include <errno.h>
-
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
typedef void (*free_func_t)(void *p);
#pragma once
#include <printf.h>
-#include <stdarg.h>
#include <stdio.h>
-#include <sys/types.h>
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
_printf_(3, 4)
static inline char* snprintf_ok(char *buf, size_t len, const char *format, ...) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "memory-util.h"
+#include "forward.h"
struct strbuf {
char *buf;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
+#include <stdio.h>
#include "parse-util.h"
#include "string-table.h"
#pragma once
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
const char* string_table_lookup_to_string(const char * const *table, size_t len, ssize_t i) _const_;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
#include <stdio.h>
-#include <stdlib.h>
#include "alloc-util.h"
#include "escape.h"
#include "extract-word.h"
-#include "fd-util.h"
-#include "fileio.h"
#include "glyph-util.h"
#include "gunicode.h"
#include "locale-util.h"
#include "log.h"
-#include "macro.h"
#include "memory-util.h"
#include "memstream-util.h"
#include "path-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
#include <string.h>
-#include <sys/types.h>
#include "alloc-util.h"
-#include "macro.h"
-#include "string-util-fundamental.h"
+#include "forward.h"
+#include "string-util-fundamental.h" /* IWYU pragma: export */
static inline char* strstr_ptr(const char *haystack, const char *needle) {
if (!haystack || !needle)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fnmatch.h>
-#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
#include "alloc-util.h"
#include "env-util.h"
#include "extract-word.h"
#include "fileio.h"
#include "gunicode.h"
+#include "hashmap.h"
#include "log.h"
#include "memory-util.h"
-#include "nulstr-util.h"
#include "sort-util.h"
#include "string-util.h"
#include "strv.h"
strv_free(hashmap_remove2(h, key, (void**) &key_free));
}
+void string_strv_ordered_hashmap_remove(OrderedHashmap *h, const char *key, const char *value) {
+ string_strv_hashmap_remove(PLAIN_HASHMAP(h), key, value);
+}
+
static int string_strv_hashmap_put_internal(Hashmap *h, const char *key, const char *value) {
char **l;
int r;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-
-#include "alloc-util.h"
-#include "hashmap.h"
-#include "memory-util.h"
-#include "strv-fundamental.h"
-
-typedef enum ExtractFlags ExtractFlags;
+#include "forward.h"
+#include "strv-fundamental.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_;
free_and_replace_full(a, b, strv_free)
void string_strv_hashmap_remove(Hashmap *h, const char *key, const char *value);
-static inline void string_strv_ordered_hashmap_remove(OrderedHashmap *h, const char *key, const char *value) {
- string_strv_hashmap_remove(PLAIN_HASHMAP(h), key, value);
-}
+void string_strv_ordered_hashmap_remove(OrderedHashmap *h, const char *key, const char *value);
int string_strv_hashmap_put(Hashmap **h, const char *key, const char *value);
int string_strv_ordered_hashmap_put(OrderedHashmap **h, const char *key, const char *value);
* occur outside of a loop where this is the preferred behavior.
*/
-#include <stdarg.h>
#include <stdio.h>
#include <string.h>
-#include "string-util.h"
#include "strxcpyx.h"
size_t strnpcpy_full(char **dest, size_t size, const char *src, size_t len, bool *ret_truncated) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "macro.h"
+#include "forward.h"
size_t strnpcpy_full(char **dest, size_t size, const char *src, size_t len, bool *ret_truncated);
static inline size_t strnpcpy(char **dest, size_t size, const char *src, size_t len) {
#include <fcntl.h>
#include <sys/stat.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "errno-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "forward.h"
+
int fsync_directory_of_file(int fd);
int fsync_full(int fd);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <fcntl.h>
#include <stdio.h>
-#include <unistd.h>
#include "af-list.h"
#include "alloc-util.h"
-#include "fd-util.h"
#include "fileio.h"
+#include "hashmap.h"
#include "log.h"
-#include "macro.h"
#include "parse-util.h"
#include "path-util.h"
#include "socket-util.h"
return sysctl_write_full(p, value, shadow);
}
+int sysctl_write_ip_property_boolean(int af, const char *ifname, const char *property, bool value, Hashmap **shadow) {
+ return sysctl_write_ip_property(af, ifname, property, one_zero(value), shadow);
+}
+
int sysctl_write_ip_neighbor_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow) {
const char *p;
return sysctl_write_full(p, value, shadow);
}
+int sysctl_write_ip_neighbor_property_uint32(int af, const char *ifname, const char *property, uint32_t value, Hashmap **shadow) {
+ char buf[DECIMAL_STR_MAX(uint32_t)];
+ xsprintf(buf, "%u", value);
+ return sysctl_write_ip_neighbor_property(af, ifname, property, buf, shadow);
+}
+
int sysctl_read(const char *property, char **ret) {
char *p;
int r;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stdint.h>
-#include "hashmap.h"
-#include "macro.h"
+#include "forward.h"
#include "stdio-util.h"
-#include "string-util.h"
char* sysctl_normalize(char *s);
int sysctl_read(const char *property, char **value);
int sysctl_read_ip_property_int(int af, const char *ifname, const char *property, int *ret);
int sysctl_read_ip_property_uint32(int af, const char *ifname, const char *property, uint32_t *ret);
int sysctl_write_ip_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow);
-static inline int sysctl_write_ip_property_boolean(int af, const char *ifname, const char *property, bool value, Hashmap **shadow) {
- return sysctl_write_ip_property(af, ifname, property, one_zero(value), shadow);
-}
+int sysctl_write_ip_property_boolean(int af, const char *ifname, const char *property, bool value, Hashmap **shadow);
int sysctl_write_ip_neighbor_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow);
-static inline int sysctl_write_ip_neighbor_property_uint32(int af, const char *ifname, const char *property, uint32_t value, Hashmap **shadow) {
- char buf[DECIMAL_STR_MAX(uint32_t)];
- xsprintf(buf, "%u", value);
- return sysctl_write_ip_neighbor_property(af, ifname, property, buf, shadow);
-}
+int sysctl_write_ip_neighbor_property_uint32(int af, const char *ifname, const char *property, uint32_t value, Hashmap **shadow);
#define DEFINE_SYSCTL_WRITE_IP_PROPERTY(name, type, format) \
static inline int sysctl_write_ip_property_##name(int af, const char *ifname, const char *property, type value, Hashmap **shadow) { \
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <limits.h>
#include <syslog.h>
#include "sd-id128.h"
#include "glob-util.h"
#include "hexdecoct.h"
-#include "macro.h"
#include "path-util.h"
#include "string-table.h"
+#include "string-util.h"
#include "syslog-util.h"
#include "unit-name.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
+#include "forward.h"
int log_facility_unshifted_to_string_alloc(int i, char **s);
int log_facility_unshifted_from_string(const char *s);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
#include <linux/kd.h>
#include <linux/tiocl.h>
#include <linux/vt.h>
#include <poll.h>
#include <signal.h>
-#include <stdarg.h>
-#include <stddef.h>
#include <stdlib.h>
#include <sys/inotify.h>
#include <sys/ioctl.h>
#include <sys/sysmacros.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
#include <termios.h>
+#include <time.h>
#include <unistd.h>
#include "alloc-util.h"
#include "ansi-color.h"
#include "chase.h"
-#include "constants.h"
#include "devnum-util.h"
-#include "env-util.h"
-#include "errno-list.h"
+#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
-#include "glyph-util.h"
#include "hexdecoct.h"
#include "inotify-util.h"
#include "io-util.h"
#include "log.h"
-#include "macro.h"
#include "missing_magic.h"
#include "namespace-util.h"
#include "parse-util.h"
#include "socket-util.h"
#include "stat-util.h"
#include "stdio-util.h"
-#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "time-util.h"
-#include "user-util.h"
#include "utf8.h"
#define ANSI_RESET_CURSOR \
return RET_NERRNO(ioctl(STDIN_FILENO, TIOCSCTTY, 0));
}
+void terminal_detach_session(void) {
+ (void) setsid();
+ (void) release_terminal();
+}
+
int terminal_vhangup_fd(int fd) {
assert(fd >= 0);
return RET_NERRNO(ioctl(fd, TIOCVHANGUP));
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <syslog.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "macro.h"
-#include "pidref.h"
-#include "time-util.h"
+#include "forward.h"
/* Erase characters until the end of the line */
#define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
int release_terminal(void);
int terminal_new_session(void);
-static inline void terminal_detach_session(void) {
- (void) setsid();
- (void) release_terminal();
-}
+void terminal_detach_session(void);
int terminal_vhangup_fd(int fd);
int terminal_vhangup(const char *tty);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
#include <stdlib.h>
#include <sys/mman.h>
-#include <sys/time.h>
#include <sys/timerfd.h>
-#include <sys/types.h>
#include <threads.h>
#include <unistd.h>
#include "fs-util.h"
#include "io-util.h"
#include "log.h"
-#include "macro.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "stat-util.h"
+#include "stdio-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
#include <time.h>
-typedef uint64_t usec_t;
-typedef uint64_t nsec_t;
+#include "forward.h"
#define PRI_NSEC PRIu64
#define PRI_USEC PRIu64
#define NSEC_FMT "%" PRI_NSEC
#define USEC_FMT "%" PRI_USEC
-#include "macro.h"
-
typedef struct dual_timestamp {
usec_t realtime;
usec_t monotonic;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <sys/mman.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
-#include "hexdecoct.h"
#include "log.h"
-#include "macro.h"
-#include "memfd-util.h"
-#include "missing_fcntl.h"
-#include "missing_syscall.h"
#include "path-util.h"
-#include "process-util.h"
#include "random-util.h"
-#include "stat-util.h"
-#include "stdio-util.h"
#include "string-util.h"
#include "sync-util.h"
#include "tmpfile-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stdio.h>
+#include "forward.h"
int fopen_temporary_at(int dir_fd, const char *path, FILE **ret_file, char **ret_path);
static inline int fopen_temporary(const char *path, FILE **ret_file, char **ret_path) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
/* The container base should have the last 16 bit set to zero */
assert_cc((CONTAINER_UID_BASE_MIN & 0xFFFFU) == 0);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "format-util.h"
-#include "log.h"
-#include "macro.h"
#include "namespace-util.h"
#include "path-util.h"
#include "process-util.h"
return 0;
}
+unsigned uid_range_size(const UIDRange *range) {
+ if (!range)
+ return 0;
+
+ unsigned n = 0;
+
+ FOREACH_ARRAY(e, range->entries, range->n_entries)
+ n += e->nr;
+
+ return n;
+}
+
+bool uid_range_is_empty(const UIDRange *range) {
+
+ if (!range)
+ return true;
+
+ FOREACH_ARRAY(e, range->entries, range->n_entries)
+ if (e->nr > 0)
+ return false;
+
+ return true;
+}
+
int uid_range_load_userns(const char *path, UIDRangeUsernsMode mode, UIDRange **ret) {
_cleanup_(uid_range_freep) UIDRange *range = NULL;
_cleanup_fclose_ FILE *f = NULL;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-#include "memory-util.h"
+#include "forward.h"
typedef struct UIDRangeEntry {
uid_t start, nr;
return range ? range->n_entries : 0;
}
-static inline unsigned uid_range_size(const UIDRange *range) {
- if (!range)
- return 0;
-
- unsigned n = 0;
-
- FOREACH_ARRAY(e, range->entries, range->n_entries)
- n += e->nr;
-
- return n;
-}
-
-static inline bool uid_range_is_empty(const UIDRange *range) {
-
- if (!range)
- return true;
-
- FOREACH_ARRAY(e, range->entries, range->n_entries)
- if (e->nr > 0)
- return false;
-
- return true;
-}
+unsigned uid_range_size(const UIDRange *range) _pure_;
+bool uid_range_is_empty(const UIDRange *range) _pure_;
bool uid_range_equal(const UIDRange *a, const UIDRange *b);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
#include <sys/stat.h>
-#include <sys/types.h>
-#include "macro.h"
+#include "forward.h"
static inline void umaskp(mode_t *u) {
umask(*u);
#pragma once
#include <endian.h>
-#include <stdint.h>
-#include "unaligned-fundamental.h"
+#include "forward.h"
+#include "unaligned-fundamental.h" /* IWYU pragma: export */
/* BE */
#include "alloc-util.h"
#include "bus-label.h"
+#include "glyph-util.h"
#include "string-table.h"
+#include "string-util.h"
#include "unit-def.h"
#include "unit-name.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
-#include "errno-list.h"
-#include "glyph-util.h"
-#include "macro.h"
+#include "forward.h"
/* The enum order is used to order unit jobs in the job queue
* when other criteria (cpu weight, nice level) are identical.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-
#include "sd-id128.h"
#include "alloc-util.h"
#include "glob-util.h"
-#include "hash-funcs.h"
#include "hexdecoct.h"
#include "log.h"
#include "memory-util.h"
#include "path-util.h"
-#include "random-util.h"
#include "sparse-endian.h"
#include "special.h"
-#include "stdio-util.h"
+#include "siphash24.h"
#include "string-util.h"
-#include "strv.h"
+#include "unit-def.h"
#include "unit-name.h"
/* Characters valid in a unit name. */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-
-#include "macro.h"
-#include "unit-def.h"
+#include "forward.h"
#define UNIT_NAME_MAX 256
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
-#include <stddef.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include "format-util.h"
#include "lock-util.h"
#include "log.h"
-#include "macro.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
-#include "random-util.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
"/usr/bin/true");
}
+bool shell_is_placeholder(const char *shell) {
+ return isempty(shell) || is_nologin_shell(shell);
+}
+
const char* default_root_shell_at(int rfd) {
/* We want to use the preferred shell, i.e. DEFAULT_USER_SHELL, which usually
* will be /bin/bash. Fall back to /bin/sh if DEFAULT_USER_SHELL is not found,
#endif
#include <pwd.h>
#include <shadow.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include "string-util.h"
+#include "forward.h"
/* Users managed by systemd-homed. See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
#define HOME_UID_MIN ((uid_t) 60001)
bool is_nologin_shell(const char *shell);
-static inline bool shell_is_placeholder(const char *shell) {
- return isempty(shell) || is_nologin_shell(shell);
-}
+bool shell_is_placeholder(const char *shell) _pure_;
typedef enum UserCredsFlags {
USER_CREDS_PREFER_NSS = 1 << 0, /* if set, only synthesize user records if database lacks them. Normally we bypass the userdb entirely for the records we can synthesize */
* Copyright (C) 2000 Red Hat, Inc.
*/
-#include <errno.h>
-#include <stdbool.h>
-#include <stdlib.h>
-
#include "alloc-util.h"
#include "gunicode.h"
#include "hexdecoct.h"
-#include "macro.h"
#include "string-util.h"
#include "utf8.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <uchar.h>
-
-#include "macro.h"
+#include "forward.h"
#define UTF8_REPLACEMENT_CHARACTER "\xef\xbf\xbd"
#define UTF8_BYTE_ORDER_MARK "\xef\xbb\xbf"
#if defined(__i386__) || defined(__x86_64__)
#include <cpuid.h>
#endif
-#include <errno.h>
-#include <stdint.h>
#include <stdlib.h>
#include <threads.h>
#include <unistd.h>
#include "alloc-util.h"
#include "dirent-util.h"
#include "env-util.h"
-#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
-#include "macro.h"
#include "namespace-util.h"
#include "parse-util.h"
+#include "pidref.h"
#include "process-util.h"
-#include "stat-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <errno.h>
-#include <stdbool.h>
-
-#include "errno-list.h"
-#include "macro.h"
+#include "forward.h"
typedef enum Virtualization {
VIRTUALIZATION_NONE = 0,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <errno.h>
#include <fcntl.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/time.h>
#include <sys/xattr.h>
#include <threads.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
-#include "macro.h"
+#include "fs-util.h"
#include "missing_syscall.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "sparse-endian.h"
#include "stat-util.h"
-#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <sys/types.h>
-
-#include "time-util.h"
+#include "forward.h"
int getxattr_at_malloc(int fd, const char *path, const char *name, int at_flags, char **ret, size_t *ret_size);
static inline int getxattr_malloc(const char *path, const char *name, char **ret, size_t *ret_size) {
#endif
#include "efi-fundamental.h"
-#include "string-util-fundamental.h"
#define CHID_TYPES_MAX 18
/* Any chids starting from EXTRA_CHID_BASE are non-standard and are subject to change and renumeration at any time */
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#if !SD_BOOT
+#include <endian.h>
+#endif
+
#include "edid-fundamental.h"
#include "efivars-fundamental.h"
# include "efi-string.h"
# include "util.h"
#else
-# include <endian.h>
# include <stddef.h>
# include <stdint.h>
# include <uchar.h>
#endif
-#include "string-util-fundamental.h"
+#include "macro-fundamental.h"
/* EDID structure, version 1.4 */
typedef struct EdidHeader {
#endif
#include "assert-fundamental.h"
-#include "macro-fundamental.h"
#include "memory-util-fundamental.h"
#include "sha256-fundamental.h"
#include "unaligned-fundamental.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#if !SD_BOOT
-# include <ctype.h>
-#endif
-
#include "macro-fundamental.h"
#include "string-util-fundamental.h"
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "macro-fundamental.h"
-
/* The various TPM PCRs we measure into from sd-stub and sd-boot. */
enum {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include "macro-fundamental.h"
+#include <stdbool.h>
/* List of PE sections that have special meaning for us in unified kernels. This is the canonical order in
* which we measure the sections into TPM PCR 11. PLEASE DO NOT REORDER! */