Consolidate various TAKE_* into TAKE_GENERIC(), add TAKE_STRUCT()

This commit is contained in:
Dan Streetman
2023-01-24 18:33:43 +00:00
committed by Luca Boccassi
parent 98a1353014
commit 40c5cc2b21
4 changed files with 17 additions and 30 deletions
+2 -8
View File
@@ -90,14 +90,8 @@ static inline int make_null_stdio(void) {
return rearrange_stdio(-EBADF, -EBADF, -EBADF);
}
/* Like TAKE_PTR() but for file descriptors, resetting them to -1 */
#define TAKE_FD(fd) \
({ \
int *_fd_ = &(fd); \
int _ret_ = *_fd_; \
*_fd_ = -EBADF; \
_ret_; \
})
/* Like TAKE_PTR() but for file descriptors, resetting them to -EBADF */
#define TAKE_FD(fd) TAKE_GENERIC(fd, int, -EBADF)
/* Like free_and_replace(), but for file descriptors */
#define close_and_replace(a, b) \