diff --git a/scripts/native_simulator/Makefile b/scripts/native_simulator/Makefile index f9d078a99d8..905fe88be98 100644 --- a/scripts/native_simulator/Makefile +++ b/scripts/native_simulator/Makefile @@ -68,8 +68,8 @@ NSI_CPPFLAGS?=-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTE NO_PIE_CO:=-fno-pie -fno-pic DEPENDFLAGS:=-MMD -MP -COMMON_BUILD_FLAGS:=${NSI_DEBUG} ${NSI_WARNINGS} ${NSI_OPT} ${NO_PIE_CO} -DNSI_N_CPUS=${NSI_N_CPUS}\ - -ffunction-sections -fdata-sections ${DEPENDFLAGS} ${NSI_BUILD_OPTIONS} +COMMON_BUILD_FLAGS:=-DNSI_RUNNER_BUILD ${NSI_DEBUG} ${NSI_WARNINGS} ${NSI_OPT} ${NO_PIE_CO} \ + -DNSI_N_CPUS=${NSI_N_CPUS} -ffunction-sections -fdata-sections ${DEPENDFLAGS} ${NSI_BUILD_OPTIONS} CFLAGS:=-std=c11 ${COMMON_BUILD_FLAGS} ${NSI_BUILD_C_OPTIONS} CXXFLAGS:=${COMMON_BUILD_FLAGS} ${NSI_BUILD_CXX_OPTIONS} FINALLINK_FLAGS:=${NO_PIE_CO} -no-pie ${NSI_WARNINGS} \ diff --git a/scripts/native_simulator/common/src/include/nsi_errno.h b/scripts/native_simulator/common/src/include/nsi_errno.h index 1b16c61ba4f..317d113cdde 100644 --- a/scripts/native_simulator/common/src/include/nsi_errno.h +++ b/scripts/native_simulator/common/src/include/nsi_errno.h @@ -103,7 +103,13 @@ #define NSI_ERRNO_MID_EOVERFLOW 139 /**< Value overflow */ #define NSI_ERRNO_MID_ECANCELED 140 /**< Operation canceled */ +/* Convert a errno value to the intermediate represetation to pass it to the other side */ int nsi_errno_to_mid(int err); +/* Convert a errno value from the intermediate representation into the local libC value */ int nsi_errno_from_mid(int err); +/* Return the middleground representation of the current host libC errno */ +int nsi_get_errno_in_mid(void); +/* Return the local representation of the current host libC errno */ +int nsi_host_get_errno(void); #endif /* NSI_COMMON_SRC_NSI_ERRNO_H */ diff --git a/scripts/native_simulator/common/src/nsi_errno.c b/scripts/native_simulator/common/src/nsi_errno.c index 89af97ae514..25b58e85fa8 100644 --- a/scripts/native_simulator/common/src/nsi_errno.c +++ b/scripts/native_simulator/common/src/nsi_errno.c @@ -128,3 +128,15 @@ int nsi_errno_from_mid(int err) return err; } + +#if defined(NSI_RUNNER_BUILD) +int nsi_get_errno_in_mid(void) +{ + return nsi_errno_to_mid(errno); +} +#endif + +int nsi_host_get_errno(void) +{ + return nsi_errno_from_mid(nsi_get_errno_in_mid()); +}