From 11bb1ac46d1b1dd0c0cf1748c4b52d93f1ac15e2 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Wed, 18 Nov 2020 19:38:12 +0100 Subject: [PATCH] compiler: Add specific errno.h file for EWARM compilation Error values use in the library are not POSIX. Unlike the GNU gcc,the EWARM toolchain doesn't support error such as EINVAL. To ensure coherency in error management we have to ensure that library and application use the same errno. Currently an "errno.h" is provided at application level which makes GCC work correctly, but this is not the case for the IAR. the added list is based on FreeBSD errno.h. Signed-off-by: Arnaud Pouliquen --- lib/CMakeLists.txt | 1 + lib/compiler/iar/CMakeLists.txt | 1 + lib/compiler/iar/errno.h | 60 +++++++++++++++++++++++++++++++++ lib/errno.h | 21 ++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 lib/compiler/iar/errno.h create mode 100644 lib/errno.h diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a139eb8..0a93487 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -13,6 +13,7 @@ collect (PROJECT_LIB_HEADERS condition.h) collect (PROJECT_LIB_HEADERS config.h) collect (PROJECT_LIB_HEADERS cpu.h) collect (PROJECT_LIB_HEADERS device.h) +collect (PROJECT_LIB_HEADERS errno.h) collect (PROJECT_LIB_HEADERS dma.h) collect (PROJECT_LIB_HEADERS io.h) collect (PROJECT_LIB_HEADERS irq.h) diff --git a/lib/compiler/iar/CMakeLists.txt b/lib/compiler/iar/CMakeLists.txt index 831ca70..3dbec5c 100644 --- a/lib/compiler/iar/CMakeLists.txt +++ b/lib/compiler/iar/CMakeLists.txt @@ -1,3 +1,4 @@ collect (PROJECT_LIB_HEADERS compiler.h) +collect (PROJECT_LIB_HEADERS errno.h) # vim: expandtab:ts=2:sw=2:smartindent diff --git a/lib/compiler/iar/errno.h b/lib/compiler/iar/errno.h new file mode 100644 index 0000000..69cd86c --- /dev/null +++ b/lib/compiler/iar/errno.h @@ -0,0 +1,60 @@ +/*- + * Copyright (c) 2020 STMicroelectronics. All rights reserved. + * + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __METAL_IAR_ERRNO__H__ +#define __METAL_IAR_ERRNO__H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define LIBMETAL_ERR_BASE 100 + +#define EPERM (LIBMETAL_ERR_BASE + 1) /* Operation not permitted */ +#define ENOENT (LIBMETAL_ERR_BASE + 2) /* No such file or directory */ +#define ESRCH (LIBMETAL_ERR_BASE + 3) /* No such process */ +#define EINTR (LIBMETAL_ERR_BASE + 4) /* Interrupted system call */ +#define EIO (LIBMETAL_ERR_BASE + 5) /* Input/output error */ +#define ENXIO (LIBMETAL_ERR_BASE + 6) /* Device not configured */ +#define E2BIG (LIBMETAL_ERR_BASE + 7) /* Argument list too long */ +#define ENOEXEC (LIBMETAL_ERR_BASE + 8) /* Exec format error */ +#define EBADF (LIBMETAL_ERR_BASE + 9) /* Bad file descriptor */ +#define ECHILD (LIBMETAL_ERR_BASE + 10) /* No child processes */ +#define EDEADLK (LIBMETAL_ERR_BASE + 11) /* Resource deadlock avoided */ +#define ENOMEM (LIBMETAL_ERR_BASE + 12) /* Cannot allocate memory */ +#define EACCES (LIBMETAL_ERR_BASE + 13) /* Permission denied */ +#define EFAULT (LIBMETAL_ERR_BASE + 14) /* Bad address */ +#define ENOTBLK (LIBMETAL_ERR_BASE + 15) /* Block device required */ +#define EBUSY (LIBMETAL_ERR_BASE + 16) /* Device busy */ +#define EEXIST (LIBMETAL_ERR_BASE + 17) /* File exists */ +#define EXDEV (LIBMETAL_ERR_BASE + 18) /* Cross-device link */ +#define ENODEV (LIBMETAL_ERR_BASE + 19) /* Operation not supported by device */ +#define ENOTDIR (LIBMETAL_ERR_BASE + 20) /* Not a directory */ +#define EISDIR (LIBMETAL_ERR_BASE + 21) /* Is a directory */ +#define EINVAL (LIBMETAL_ERR_BASE + 22) /* Invalid argument */ +#define ENFILE (LIBMETAL_ERR_BASE + 23) /* Too many open files in system */ +#define EMFILE (LIBMETAL_ERR_BASE + 24) /* Too many open files */ +#define ENOTTY (LIBMETAL_ERR_BASE + 25) /* Inappropriate ioctl for device */ +#define ETXTBSY (LIBMETAL_ERR_BASE + 26) /* Text file busy */ +#define EFBIG (LIBMETAL_ERR_BASE + 27) /* File too large */ +#define ENOSPC (LIBMETAL_ERR_BASE + 28) /* No space left on device */ +#define ESPIPE (LIBMETAL_ERR_BASE + 29) /* Illegal seek */ +#define EROFS (LIBMETAL_ERR_BASE + 30) /* Read-only filesystem */ +#define EMLINK (LIBMETAL_ERR_BASE + 31) /* Too many links */ +#define EPIPE (LIBMETAL_ERR_BASE + 32) /* Broken pipe */ +#define EAGAIN (LIBMETAL_ERR_BASE + 35) /* Resource temporarily unavailable */ + +#ifdef __cplusplus +} +#endif + +#endif /* __METAL_IAR_ERRNO__H__ */ diff --git a/lib/errno.h b/lib/errno.h new file mode 100644 index 0000000..fb4997e --- /dev/null +++ b/lib/errno.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 STMicroelectronnics. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file metal/errno.h + * @brief error specific primitives for libmetal. + */ + +#ifndef __METAL_ERRNO__H__ +#define __METAL_ERRNO__H__ + +#if defined(__ICCARM__) +# include +#else +# include +#endif + +#endif /* __METAL_ERRNO__H__ */