macro: Reduce transitive includes

This commit is contained in:
Daan De Meyer
2025-05-09 11:33:31 +02:00
parent 3b58245624
commit 3b7d332047
76 changed files with 128 additions and 48 deletions
+7 -2
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include <inttypes.h>
#include <string.h>
@@ -42,6 +43,12 @@ static inline void _reset_errno_(int *saved_errno) {
PROTECT_ERRNO; \
errno = ABS(value)
#define return_with_errno(r, err) \
do { \
errno = ABS(err); \
return r; \
} while (false)
static inline int negative_errno(void) {
/* This helper should be used to shut up gcc if you know 'errno' is
* negative. Instead of "return -errno;", use "return negative_errno();"
@@ -103,8 +110,6 @@ static inline int errno_or_else(int fallback) {
return ERRNO_IS_NEG_##name(-ABS(r)); \
}
assert_cc(INT_MAX <= INTMAX_MAX);
/* For send()/recv() or read()/write(). */
static inline bool ERRNO_IS_NEG_TRANSIENT(intmax_t r) {
return IN_SET(r,