KallistiOS
git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
errno.h
Go to the documentation of this file.
1
/* KallistiOS ##version##
2
3
include/kos/errno.h
4
Copyright (C) 2025 Paul Cercueil
5
6
*/
7
8
/** \file kos/errno.h
9
\brief Errno helper functions.
10
\ingroup errno
11
12
This file contains functions and macros related to the 'errno' variable.
13
14
\author Paul Cercueil
15
*/
16
17
#ifndef __KOS_ERRNO_H
18
#define __KOS_ERRNO_H
19
20
#include <
errno.h
>
21
22
/** \cond */
23
static
inline
void
__errno_scoped_cleanup(
int
*e) {
24
if
(e)
25
errno = *e;
26
}
27
28
#define ___errno_save_scoped(l) \
29
int __scoped_errno_##l __attribute__((cleanup(__errno_scoped_cleanup))) = (errno)
30
31
#define __errno_save_scoped(l) ___errno_save_scoped(l)
32
/** \endcond */
33
34
/** \brief Save the current 'errno' value until the block exit
35
36
This macro will keep a copy of the current value of the errno variable, and
37
will restore it once the execution exits the functional block in which the
38
macro was called.
39
*/
40
#define errno_save_scoped() __errno_save_scoped(__LINE__)
41
42
/** \brief Return errno if the value is non-zero, otherwise return zero
43
44
This simple macro can be used to interface the functions that return 0 on
45
success and -1 on error, with the actual error code stored in the errno
46
variable.
47
48
\param x The integer value to process
49
\return 0 on success, a positive errno code on error
50
*/
51
#define errno_if_nonzero(x) ((x) ? errno : 0)
52
53
#endif
/* __KOS_ERRNO_H */
errno.h
Errno helper functions.
include
kos
errno.h
Generated by
1.12.0