macro: Reduce transitive includes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user