mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/tiny_strerror: make use of flash_utils.h
This commit is contained in:
parent
6b501f74c6
commit
b05292f5e4
@ -21,102 +21,195 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "flash_utils.h"
|
||||||
#include "kernel_defines.h"
|
#include "kernel_defines.h"
|
||||||
#include "tiny_strerror.h"
|
#include "tiny_strerror.h"
|
||||||
|
|
||||||
static const char *lookup[] = {
|
static FLASH_ATTR const char _ok[] = "OK";
|
||||||
[0] = "OK",
|
static FLASH_ATTR const char _e2big[] = "-E2BIG";
|
||||||
[E2BIG] = "-E2BIG",
|
static FLASH_ATTR const char _eacces[] = "-EACCES";
|
||||||
[EACCES] = "-EACCES",
|
static FLASH_ATTR const char _eaddrinuse[] = "-EADDRINUSE";
|
||||||
[EADDRINUSE] = "-EADDRINUSE",
|
static FLASH_ATTR const char _eaddrnotavail[] = "-EADDRNOTAVAIL";
|
||||||
[EADDRNOTAVAIL] = "-EADDRNOTAVAIL",
|
static FLASH_ATTR const char _eafnosupport[] = "-EAFNOSUPPORT";
|
||||||
[EAFNOSUPPORT] = "-EAFNOSUPPORT",
|
static FLASH_ATTR const char _eagain[] = "-EAGAIN";
|
||||||
[EAGAIN] = "-EAGAIN",
|
static FLASH_ATTR const char _ealready[] = "-EALREADY";
|
||||||
[EALREADY] = "-EALREADY",
|
static FLASH_ATTR const char _ebadf[] = "-EBADF";
|
||||||
[EBADF] = "-EBADF",
|
static FLASH_ATTR const char _ebadmsg[] = "-EBADMSG";
|
||||||
[EBADMSG] = "-EBADMSG",
|
static FLASH_ATTR const char _ebusy[] = "-EBUSY";
|
||||||
[EBUSY] = "-EBUSY",
|
static FLASH_ATTR const char _ecanceled[] = "-ECANCELED";
|
||||||
[ECANCELED] = "-ECANCELED",
|
static FLASH_ATTR const char _echild[] = "-ECHILD";
|
||||||
[ECHILD] = "-ECHILD",
|
static FLASH_ATTR const char _econnaborted[] = "-ECONNABORTED";
|
||||||
[ECONNABORTED] = "-ECONNABORTED",
|
static FLASH_ATTR const char _econnrefused[] = "-ECONNREFUSED";
|
||||||
[ECONNREFUSED] = "-ECONNREFUSED",
|
static FLASH_ATTR const char _econnreset[] = "-ECONNRESET";
|
||||||
[ECONNRESET] = "-ECONNRESET",
|
static FLASH_ATTR const char _edeadlk[] = "-EDEADLK";
|
||||||
[EDEADLK] = "-EDEADLK",
|
static FLASH_ATTR const char _edestaddrreq[] = "-EDESTADDRREQ";
|
||||||
[EDESTADDRREQ] = "-EDESTADDRREQ",
|
static FLASH_ATTR const char _edom[] = "-EDOM";
|
||||||
[EDOM] = "-EDOM",
|
static FLASH_ATTR const char _edquot[] = "-EDQUOT";
|
||||||
[EDQUOT] = "-EDQUOT",
|
static FLASH_ATTR const char _eexist[] = "-EEXIST";
|
||||||
[EEXIST] = "-EEXIST",
|
static FLASH_ATTR const char _efault[] = "-EFAULT";
|
||||||
[EFAULT] = "-EFAULT",
|
static FLASH_ATTR const char _efbig[] = "-EFBIG";
|
||||||
[EFBIG] = "-EFBIG",
|
static FLASH_ATTR const char _ehostdown[] = "-EHOSTDOWN";
|
||||||
[EHOSTDOWN] = "-EHOSTDOWN",
|
static FLASH_ATTR const char _ehostunreach[] = "-EHOSTUNREACH";
|
||||||
[EHOSTUNREACH] = "-EHOSTUNREACH",
|
static FLASH_ATTR const char _eidrm[] = "-EIDRM";
|
||||||
[EIDRM] = "-EIDRM",
|
static FLASH_ATTR const char _eilseq[] = "-EILSEQ";
|
||||||
[EILSEQ] = "-EILSEQ",
|
static FLASH_ATTR const char _einprogress[] = "-EINPROGRESS";
|
||||||
[EINPROGRESS] = "-EINPROGRESS",
|
static FLASH_ATTR const char _eintr[] = "-EINTR";
|
||||||
[EINTR] = "-EINTR",
|
static FLASH_ATTR const char _einval[] = "-EINVAL";
|
||||||
[EINVAL] = "-EINVAL",
|
static FLASH_ATTR const char _eio[] = "-EIO";
|
||||||
[EIO] = "-EIO",
|
static FLASH_ATTR const char _eisconn[] = "-EISCONN";
|
||||||
[EISCONN] = "-EISCONN",
|
static FLASH_ATTR const char _eisdir[] = "-EISDIR";
|
||||||
[EISDIR] = "-EISDIR",
|
static FLASH_ATTR const char _eloop[] = "-ELOOP";
|
||||||
[ELOOP] = "-ELOOP",
|
static FLASH_ATTR const char _emfile[] = "-EMFILE";
|
||||||
[EMFILE] = "-EMFILE",
|
static FLASH_ATTR const char _emlink[] = "-EMLINK";
|
||||||
[EMLINK] = "-EMLINK",
|
static FLASH_ATTR const char _emsgsize[] = "-EMSGSIZE";
|
||||||
[EMSGSIZE] = "-EMSGSIZE",
|
static FLASH_ATTR const char _emultihop[] = "-EMULTIHOP";
|
||||||
[EMULTIHOP] = "-EMULTIHOP",
|
static FLASH_ATTR const char _enametoolong[] = "-ENAMETOOLONG";
|
||||||
[ENAMETOOLONG] = "-ENAMETOOLONG",
|
static FLASH_ATTR const char _enetdown[] = "-ENETDOWN";
|
||||||
[ENETDOWN] = "-ENETDOWN",
|
static FLASH_ATTR const char _enetreset[] = "-ENETRESET";
|
||||||
[ENETRESET] = "-ENETRESET",
|
static FLASH_ATTR const char _enetunreach[] = "-ENETUNREACH";
|
||||||
[ENETUNREACH] = "-ENETUNREACH",
|
static FLASH_ATTR const char _enfile[] = "-ENFILE";
|
||||||
[ENFILE] = "-ENFILE",
|
static FLASH_ATTR const char _enobufs[] = "-ENOBUFS";
|
||||||
[ENOBUFS] = "-ENOBUFS",
|
static FLASH_ATTR const char _enodata[] = "-ENODATA";
|
||||||
[ENODATA] = "-ENODATA",
|
static FLASH_ATTR const char _enodev[] = "-ENODEV";
|
||||||
[ENODEV] = "-ENODEV",
|
static FLASH_ATTR const char _enoent[] = "-ENOENT";
|
||||||
[ENOENT] = "-ENOENT",
|
static FLASH_ATTR const char _enoexec[] = "-ENOEXEC";
|
||||||
[ENOEXEC] = "-ENOEXEC",
|
static FLASH_ATTR const char _enolck[] = "-ENOLCK";
|
||||||
[ENOLCK] = "-ENOLCK",
|
static FLASH_ATTR const char _enolink[] = "-ENOLINK";
|
||||||
[ENOLINK] = "-ENOLILNK",
|
static FLASH_ATTR const char _enomem[] = "-ENOMEM";
|
||||||
[ENOMEM] = "-ENOMEM",
|
static FLASH_ATTR const char _enomsg[] = "-ENOMSG";
|
||||||
[ENOMSG] = "-ENOMSG",
|
static FLASH_ATTR const char _enoprotoopt[] = "-ENOPROTOOPT";
|
||||||
[ENOPROTOOPT] = "-ENOPROTOOPT",
|
static FLASH_ATTR const char _enospc[] = "-ENOSPC";
|
||||||
[ENOSPC] = "-ENOSPC",
|
static FLASH_ATTR const char _enosr[] = "-ENOSR";
|
||||||
[ENOSR] = "-ENOSR",
|
static FLASH_ATTR const char _enostr[] = "-ENOSTR";
|
||||||
[ENOSTR] = "-ENOSTR",
|
static FLASH_ATTR const char _enosys[] = "-ENOSYS";
|
||||||
[ENOSYS] = "-ENOSYS",
|
static FLASH_ATTR const char _enotconn[] = "-ENOTCONN";
|
||||||
[ENOTCONN] = "-ENOTCONN",
|
static FLASH_ATTR const char _enotdir[] = "-ENOTDIR";
|
||||||
[ENOTDIR] = "-ENOTDIR",
|
static FLASH_ATTR const char _enotempty[] = "-ENOTEMPTY";
|
||||||
[ENOTEMPTY] = "-ENOTEMPTY",
|
static FLASH_ATTR const char _enotrecoverable[] = "-ENOTRECOVERABLE";
|
||||||
[ENOTRECOVERABLE] = "-ENOTRECOVERABLE",
|
static FLASH_ATTR const char _enotsock[] = "-ENOTSOCK";
|
||||||
[ENOTSOCK] = "-ENOTSOCK",
|
static FLASH_ATTR const char _enotsup[] = "-ENOTSUP";
|
||||||
[ENOTSUP] = "-ENOTSUP",
|
static FLASH_ATTR const char _enotty[] = "-ENOTTY";
|
||||||
[ENOTTY] = "-ENOTTY",
|
static FLASH_ATTR const char _enxio[] = "-ENXIO";
|
||||||
[ENXIO] = "-ENXIO",
|
static FLASH_ATTR const char _eoverflow[] = "-EOVERFLOW";
|
||||||
[EOVERFLOW] = "-EOVERFLOW",
|
static FLASH_ATTR const char _eownerdead[] = "-EOWNERDEAD";
|
||||||
[EOWNERDEAD ] = "-EOWNERDEAD ",
|
static FLASH_ATTR const char _eperm[] = "-EPERM";
|
||||||
[EPERM] = "-EPERM",
|
static FLASH_ATTR const char _epfnosupport[] = "-EPFNOSUPPORT";
|
||||||
[EPFNOSUPPORT] = "-EPFNOSUPPORT",
|
static FLASH_ATTR const char _epipe[] = "-EPIPE";
|
||||||
[EPIPE] = "-EPIPE",
|
static FLASH_ATTR const char _eprotonosupport[] = "-EPROTONOSUPPORT";
|
||||||
[EPROTONOSUPPORT] = "-EPROTONOSUPPORT",
|
static FLASH_ATTR const char _eprototype[] = "-EPROTOTYPE";
|
||||||
[EPROTOTYPE] = "-EPROTOTYPE",
|
static FLASH_ATTR const char _eproto[] = "-EPROTO";
|
||||||
[EPROTO] = "-EPROTO",
|
static FLASH_ATTR const char _erange[] = "-ERANGE";
|
||||||
[ERANGE] = "-ERANGE",
|
static FLASH_ATTR const char _erofs[] = "-EROFS";
|
||||||
[EROFS] = "-EROFS",
|
static FLASH_ATTR const char _espipe[] = "-ESPIPE";
|
||||||
[ESPIPE] = "-ESPIPE",
|
static FLASH_ATTR const char _esrch[] = "-ESRCH";
|
||||||
[ESRCH] = "-ESRCH",
|
static FLASH_ATTR const char _estale[] = "-ESTALE";
|
||||||
[ESTALE] = "-ESTALE",
|
static FLASH_ATTR const char _etimedout[] = "-ETIMEDOUT";
|
||||||
[ETIMEDOUT] = "-ETIMEDOUT",
|
static FLASH_ATTR const char _etime[] = "-ETIME";
|
||||||
[ETIME] = "-ETIME",
|
static FLASH_ATTR const char _etoomanyrefs[] = "-ETOOMANYREFS";
|
||||||
[ETOOMANYREFS] = "-ETOOMANYREFS",
|
static FLASH_ATTR const char _etxtbsy[] = "-ETXTBSY";
|
||||||
[ETXTBSY] = "-ETXTBSY",
|
static FLASH_ATTR const char _exdev[] = "-EXDEV";
|
||||||
[EXDEV] = "-EXDEV",
|
/* EAGAIN and EWOULDBLOCK have the exact same meaning and consequently may
|
||||||
/* EAGAIN and EWOULDBLOCK have the exact same meaning and consequently may
|
* have the same numeric value */
|
||||||
* have the same numeric value */
|
|
||||||
#if EAGAIN != EWOULDBLOCK
|
#if EAGAIN != EWOULDBLOCK
|
||||||
[EWOULDBLOCK] = "-EWOULDBLOCK",
|
static FLASH_ATTR const char _ewouldblock[] = "-EWOULDBLOCK";
|
||||||
#endif
|
#endif
|
||||||
/* ENOTSUP and EOPNOTSUPP do not have the exact same meaning. Still, they
|
/* ENOTSUP and EOPNOTSUPP do not have the exact same meaning. Still, they
|
||||||
* have the same numeric value on Linux, breaking POSIX standard */
|
* have the same numeric value on Linux, breaking POSIX standard */
|
||||||
#if ENOTSUP != EOPNOTSUPP
|
#if ENOTSUP != EOPNOTSUPP
|
||||||
[EOPNOTSUPP] = "-EOPNOTSUPP",
|
static FLASH_ATTR const char _eopnotsupp[] = "-EOPNOTSUPP";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static FLASH_ATTR const char * FLASH_ATTR const lookup[] = {
|
||||||
|
[0] = _ok,
|
||||||
|
[E2BIG] = _e2big,
|
||||||
|
[EACCES] = _eacces,
|
||||||
|
[EADDRINUSE] = _eaddrinuse,
|
||||||
|
[EADDRNOTAVAIL] = _eaddrnotavail,
|
||||||
|
[EAFNOSUPPORT] = _eafnosupport,
|
||||||
|
[EAGAIN] = _eagain,
|
||||||
|
[EALREADY] = _ealready,
|
||||||
|
[EBADF] = _ebadf,
|
||||||
|
[EBADMSG] = _ebadmsg,
|
||||||
|
[EBUSY] = _ebusy,
|
||||||
|
[ECANCELED] = _ecanceled,
|
||||||
|
[ECHILD] = _echild,
|
||||||
|
[ECONNABORTED] = _econnaborted,
|
||||||
|
[ECONNREFUSED] = _econnrefused,
|
||||||
|
[ECONNRESET] = _econnreset,
|
||||||
|
[EDEADLK] = _edeadlk,
|
||||||
|
[EDESTADDRREQ] = _edestaddrreq,
|
||||||
|
[EDOM] = _edom,
|
||||||
|
[EDQUOT] = _edquot,
|
||||||
|
[EEXIST] = _eexist,
|
||||||
|
[EFAULT] = _efault,
|
||||||
|
[EFBIG] = _efbig,
|
||||||
|
[EHOSTDOWN] = _ehostdown,
|
||||||
|
[EHOSTUNREACH] = _ehostunreach,
|
||||||
|
[EIDRM] = _eidrm,
|
||||||
|
[EILSEQ] = _eilseq,
|
||||||
|
[EINPROGRESS] = _einprogress,
|
||||||
|
[EINTR] = _eintr,
|
||||||
|
[EINVAL] = _einval,
|
||||||
|
[EIO] = _eio,
|
||||||
|
[EISCONN] = _eisconn,
|
||||||
|
[EISDIR] = _eisdir,
|
||||||
|
[ELOOP] = _eloop,
|
||||||
|
[EMFILE] = _emfile,
|
||||||
|
[EMLINK] = _emlink,
|
||||||
|
[EMSGSIZE] = _emsgsize,
|
||||||
|
[EMULTIHOP] = _emultihop,
|
||||||
|
[ENAMETOOLONG] = _enametoolong,
|
||||||
|
[ENETDOWN] = _enetdown,
|
||||||
|
[ENETRESET] = _enetreset,
|
||||||
|
[ENETUNREACH] = _enetunreach,
|
||||||
|
[ENFILE] = _enfile,
|
||||||
|
[ENOBUFS] = _enobufs,
|
||||||
|
[ENODATA] = _enodata,
|
||||||
|
[ENODEV] = _enodev,
|
||||||
|
[ENOENT] = _enoent,
|
||||||
|
[ENOEXEC] = _enoexec,
|
||||||
|
[ENOLCK] = _enolck,
|
||||||
|
[ENOLINK] = _enolink,
|
||||||
|
[ENOMEM] = _enomem,
|
||||||
|
[ENOMSG] = _enomsg,
|
||||||
|
[ENOPROTOOPT] = _enoprotoopt,
|
||||||
|
[ENOSPC] = _enospc,
|
||||||
|
[ENOSR] = _enosr,
|
||||||
|
[ENOSTR] = _enostr,
|
||||||
|
[ENOSYS] = _enosys,
|
||||||
|
[ENOTCONN] = _enotconn,
|
||||||
|
[ENOTDIR] = _enotdir,
|
||||||
|
[ENOTEMPTY] = _enotempty,
|
||||||
|
[ENOTRECOVERABLE] = _enotrecoverable,
|
||||||
|
[ENOTSOCK] = _enotsock,
|
||||||
|
[ENOTSUP] = _enotsup,
|
||||||
|
[ENOTTY] = _enotty,
|
||||||
|
[ENXIO] = _enxio,
|
||||||
|
[EOVERFLOW] = _eoverflow,
|
||||||
|
[EOWNERDEAD ] = _eownerdead,
|
||||||
|
[EPERM] = _eperm,
|
||||||
|
[EPFNOSUPPORT] = _epfnosupport,
|
||||||
|
[EPIPE] = _epipe,
|
||||||
|
[EPROTONOSUPPORT] = _eprotonosupport,
|
||||||
|
[EPROTOTYPE] = _eprototype,
|
||||||
|
[EPROTO] = _eproto,
|
||||||
|
[ERANGE] = _erange,
|
||||||
|
[EROFS] = _erofs,
|
||||||
|
[ESPIPE] = _espipe,
|
||||||
|
[ESRCH] = _esrch,
|
||||||
|
[ESTALE] = _estale,
|
||||||
|
[ETIMEDOUT] = _etimedout,
|
||||||
|
[ETIME] = _etime,
|
||||||
|
[ETOOMANYREFS] = _etoomanyrefs,
|
||||||
|
[ETXTBSY] = _etxtbsy,
|
||||||
|
[EXDEV] = _exdev,
|
||||||
|
#if EAGAIN != EWOULDBLOCK
|
||||||
|
[EWOULDBLOCK] = _ewouldblock,
|
||||||
|
#endif
|
||||||
|
/* ENOTSUP and EOPNOTSUPP do not have the exact same meaning. Still, they
|
||||||
|
* have the same numeric value on Linux, breaking POSIX standard */
|
||||||
|
#if ENOTSUP != EOPNOTSUPP
|
||||||
|
[EOPNOTSUPP] = _eopnotsupp,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -146,6 +239,12 @@ const char *tiny_strerror(int errnum)
|
|||||||
retval = lookup[(unsigned)errnum];
|
retval = lookup[(unsigned)errnum];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_ACTIVE(HAS_FLASH_UTILS_ARCH)) {
|
||||||
|
static char buf[16];
|
||||||
|
flash_strncpy(buf, retval + offset, sizeof(buf));
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
return retval + offset;
|
return retval + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user