| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
/* IWYU pragma: always_keep */ |
| 5 |
|
| 6 |
#include <errno.h> /* IWYU pragma: export */ |
| 7 |
#include <inttypes.h> /* IWYU pragma: export */ |
| 8 |
#include <limits.h> /* IWYU pragma: export */ |
| 9 |
#include <paths.h> /* IWYU pragma: export */ |
| 10 |
#include <stdarg.h> /* IWYU pragma: export */ |
| 11 |
#include <stdbool.h> /* IWYU pragma: export */ |
| 12 |
#include <stddef.h> /* IWYU pragma: export */ |
| 13 |
#include <stdint.h> /* IWYU pragma: export */ |
| 14 |
#include <sys/types.h> /* IWYU pragma: export */ |
| 15 |
#include <uchar.h> /* IWYU pragma: export */ |
| 16 |
|
| 17 |
#include "assert-util.h" /* IWYU pragma: export */ |
| 18 |
#include "cleanup-util.h" /* IWYU pragma: export */ |
| 19 |
#include "macro.h" /* IWYU pragma: export */ |
| 20 |
|
| 21 |
#include "../fundamental/string-table.h" /* IWYU pragma: export */ |
| 22 |
|
| 23 |
/* Generic types */ |
| 24 |
|
| 25 |
typedef uint64_t usec_t; |
| 26 |
typedef uint64_t nsec_t; |
| 27 |
|
| 28 |
/* Libc/Linux forward declarations */ |
| 29 |
|
| 30 |
struct dirent; |
| 31 |
struct ether_addr; |
| 32 |
struct fiemap; |
| 33 |
struct file_handle; |
| 34 |
struct glob_t; |
| 35 |
struct group; |
| 36 |
struct icmp6_hdr; |
| 37 |
struct in_addr; |
| 38 |
struct in6_addr; |
| 39 |
struct inotify_event; |
| 40 |
struct iovec; |
| 41 |
struct mount_attr; |
| 42 |
struct msghdr; |
| 43 |
struct passwd; |
| 44 |
struct pollfd; |
| 45 |
struct rlimit; |
| 46 |
struct sgrp; |
| 47 |
struct shadow; |
| 48 |
struct signalfd_siginfo; |
| 49 |
struct siphash; |
| 50 |
struct sockaddr; |
| 51 |
struct spwd; |
| 52 |
struct stat; |
| 53 |
struct statfs; |
| 54 |
struct statx_timestamp; |
| 55 |
struct statx; |
| 56 |
struct termios; |
| 57 |
struct tm; |
| 58 |
struct ucred; |
| 59 |
|
| 60 |
/* To forward declare FILE and DIR, we have to declare the internal struct names for them. Since these are |
| 61 |
* used for C++ symbol name mangling, they're effectively part of the ABI and won't actually change. */ |
| 62 |
typedef struct _IO_FILE FILE; |
| 63 |
typedef struct __dirstream DIR; |
| 64 |
|
| 65 |
/* 3rd-party library forward declarations */ |
| 66 |
|
| 67 |
enum bpf_map_type; |
| 68 |
|
| 69 |
struct fdisk_context; |
| 70 |
struct fdisk_table; |
| 71 |
struct crypt_device; |
| 72 |
|
| 73 |
typedef struct buf_mem_st BUF_MEM; |
| 74 |
typedef struct evp_pkey_st EVP_PKEY; |
| 75 |
typedef struct evp_md_st EVP_MD; |
| 76 |
typedef struct evp_md_ctx_st EVP_MD_CTX; |
| 77 |
typedef struct ssl_st SSL; |
| 78 |
typedef struct ssl_ctx_st SSL_CTX; |
| 79 |
typedef struct ssl_session_st SSL_SESSION; |
| 80 |
typedef struct x509_st X509; |
| 81 |
|
| 82 |
/* basic/ forward declarations */ |
| 83 |
|
| 84 |
typedef void (*hash_func_t)(const void *p, struct siphash *state); |
| 85 |
typedef int (*compare_func_t)(const void *a, const void *b); |
| 86 |
typedef compare_func_t comparison_fn_t; |
| 87 |
typedef int (*comparison_userdata_fn_t)(const void *, const void *, void *); |
| 88 |
|
| 89 |
struct hash_ops; |
| 90 |
struct hw_addr_data; |
| 91 |
struct in_addr_data; |
| 92 |
struct iovec_wrapper; |
| 93 |
union in_addr_union; |
| 94 |
union sockaddr_union; |
| 95 |
|
| 96 |
typedef enum Architecture Architecture; |
| 97 |
typedef enum CGroupFlags CGroupFlags; |
| 98 |
typedef enum CGroupMask CGroupMask; |
| 99 |
typedef enum ChaseFlags ChaseFlags; |
| 100 |
typedef enum ConfFilesFlags ConfFilesFlags; |
| 101 |
typedef enum ExtractFlags ExtractFlags; |
| 102 |
typedef enum ForkFlags ForkFlags; |
| 103 |
typedef enum Glyph Glyph; |
| 104 |
typedef enum ImageClass ImageClass; |
| 105 |
typedef enum JobMode JobMode; |
| 106 |
typedef enum RuntimeScope RuntimeScope; |
| 107 |
typedef enum StringSafeFlags StringSafeFlags; |
| 108 |
typedef enum TimestampStyle TimestampStyle; |
| 109 |
typedef enum UnitActiveState UnitActiveState; |
| 110 |
typedef enum UnitDependency UnitDependency; |
| 111 |
typedef enum UnitNameMangle UnitNameMangle; |
| 112 |
typedef enum UnitType UnitType; |
| 113 |
typedef enum WaitFlags WaitFlags; |
| 114 |
|
| 115 |
typedef struct Fiber Fiber; |
| 116 |
typedef struct FiberOps FiberOps; |
| 117 |
typedef struct Hashmap Hashmap; |
| 118 |
typedef struct HashmapBase HashmapBase; |
| 119 |
typedef struct IteratedCache IteratedCache; |
| 120 |
typedef struct Iterator Iterator; |
| 121 |
typedef struct LogContext LogContext; |
| 122 |
typedef struct OrderedHashmap OrderedHashmap; |
| 123 |
typedef struct OrderedSet OrderedSet; |
| 124 |
typedef struct Set Set; |
| 125 |
|
| 126 |
typedef struct dual_timestamp dual_timestamp; |
| 127 |
typedef struct triple_timestamp triple_timestamp; |
| 128 |
typedef struct Compressor Compressor; |
| 129 |
typedef struct ConfFile ConfFile; |
| 130 |
typedef struct LockFile LockFile; |
| 131 |
typedef struct PidRef PidRef; |
| 132 |
typedef struct Prioq Prioq; |
| 133 |
typedef struct RateLimit RateLimit; |
| 134 |
typedef struct SocketAddress SocketAddress; |
| 135 |
|
| 136 |
/* Constants */ |
| 137 |
|
| 138 |
/* We duplicate various commonly used constants here so we can keep most static inline functions without |
| 139 |
* having to include the full header that provides these constants. */ |
| 140 |
|
| 141 |
/* glibc defines AT_FDCWD as -100, but musl defines it as (-100). */ |
| 142 |
#ifdef __GLIBC__ |
| 143 |
#define AT_FDCWD -100 |
| 144 |
#else |
| 145 |
#define AT_FDCWD (-100) |
| 146 |
#endif |
| 147 |
#define AT_EMPTY_PATH 0x1000 |
| 148 |
#define AT_SYMLINK_FOLLOW 0x400 |
| 149 |
#define AT_SYMLINK_NOFOLLOW 0x100 |
| 150 |
|
| 151 |
#define MODE_INVALID ((mode_t) -1) |
| 152 |
|
| 153 |
#define UID_INVALID ((uid_t) -1) |
| 154 |
#define GID_INVALID ((gid_t) -1) |
| 155 |
|
| 156 |
#define USEC_INFINITY ((usec_t) UINT64_MAX) |
| 157 |
#define NSEC_INFINITY ((nsec_t) UINT64_MAX) |
| 158 |
|
| 159 |
/* MAX_ERRNO is defined as 4095 in linux/err.h. We use the same value here. */ |
| 160 |
#define ERRNO_MAX 4095 |
| 161 |
|
| 162 |
/* This is MAX_ADDR_LEN as defined in linux/netdevice.h, but net/if_arp.h |
| 163 |
* defines a macro of the same name with a much lower size. */ |
| 164 |
#define HW_ADDR_MAX_SIZE 32 |