Skip to content

Commit 3ccb09e

Browse files
committed
nsi_errno: Add new API to get the current host side errno
Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 32eab87 commit 3ccb09e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

common/src/include/nsi_errno.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@
103103
#define NSI_ERRNO_MID_EOVERFLOW 139 /**< Value overflow */
104104
#define NSI_ERRNO_MID_ECANCELED 140 /**< Operation canceled */
105105

106+
/* Convert a errno value to the intermediate represetation to pass it to the other side */
106107
int nsi_errno_to_mid(int err);
108+
/* Convert a errno value from the intermediate representation into the local libC value */
107109
int nsi_errno_from_mid(int err);
110+
/* Return the middleground representation of the current host libC errno */
111+
int nsi_get_errno_in_mid(void);
112+
/* Return the local representation of the current host libC errno */
113+
int nsi_host_get_errno(void);
108114

109115
#endif /* NSI_COMMON_SRC_NSI_ERRNO_H */

common/src/nsi_errno.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,15 @@ int nsi_errno_from_mid(int err)
128128

129129
return err;
130130
}
131+
132+
#if defined(NSI_RUNNER_BUILD)
133+
int nsi_get_errno_in_mid(void)
134+
{
135+
return nsi_errno_to_mid(errno);
136+
}
137+
#endif
138+
139+
int nsi_host_get_errno(void)
140+
{
141+
return nsi_errno_from_mid(nsi_get_errno_in_mid());
142+
}

0 commit comments

Comments
 (0)