1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

avr_libc_extra: implement strerror()

Add a minimal implementation of `strerror()`.
All other targets use either newlib or picolibc and provide this
function, add it to AVR so we can rely on it in common code.
This commit is contained in:
Benjamin Valentin 2021-08-09 16:24:04 +02:00
parent 02d80eefc9
commit 64846c0af4

View File

@ -177,4 +177,80 @@ ssize_t write(int fd, const void *src, size_t count)
#endif
}
const char *strerror(int errnum)
{
if (errnum < 0) {
errnum = -errnum;
}
switch (errnum) {
case 0: return "OK";
case EDOM: return "EDOM";
case ERANGE: return "ERANGE";
case ENOSYS: return "ENOSYS";
case EINTR: return "EINTR";
case E2BIG: return "E2BIG";
case EACCES: return "EACCES";
case EADDRINUSE: return "EADDRINUSE";
case EADDRNOTAVAIL: return "EADDRNOTAVAIL";
case EAFNOSUPPORT: return "EAFNOSUPPORT";
case EAGAIN: return "EAGAIN";
case EALREADY: return "EALREADY";
case EBADF: return "EBADF";
case EBUSY: return "EBUSY";
case ECHILD: return "ECHILD";
case ECONNABORTED: return "ECONNABORTED";
case ECONNREFUSED: return "ECONNREFUSED";
case ECONNRESET: return "ECONNRESET";
case EDEADLK: return "EDEADLK";
case EDESTADDRREQ: return "EDESTADDRREQ";
case EEXIST: return "EEXIST";
case EFAULT: return "EFAULT";
case EFBIG: return "EFBIG";
case EHOSTUNREACH: return "EHOSTUNREACH";
case EILSEQ: return "EILSEQ";
case EINPROGRESS: return "EINPROGRESS";
case EINVAL: return "EINVAL";
case EIO: return "EIO";
case EISCONN: return "EISCONN";
case EISDIR: return "EISDIR";
case ELOOP: return "ELOOP";
case EMFILE: return "EMFILE";
case EMLINK: return "EMLINK";
case EMSGSIZE: return "EMSGSIZE";
case ENAMETOOLONG: return "ENAMETOOLONG";
case ENETDOWN: return "ENETDOWN";
case ENETRESET: return "ENETRESET";
case ENETUNREACH: return "ENETUNREACH";
case ENFILE: return "ENFILE";
case ENOBUFS: return "ENOBUFS";
case ENODEV: return "ENODEV";
case ENOENT: return "ENOENT";
case ENOEXEC: return "ENOEXEC";
case ENOLCK: return "ENOLCK";
case ENOMEM: return "ENOMEM";
case ENOMSG: return "ENOMSG";
case ENOPROTOOPT: return "ENOPROTOOPT";
case ENOSPC: return "ENOSPC";
case ENOTCONN: return "ENOTCONN";
case ENOTDIR: return "ENOTDIR";
case ENOTEMPTY: return "ENOTEMPTY";
case ENOTSOCK: return "ENOTSOCK";
case ENOTTY: return "ENOTTY";
case ENXIO: return "ENXIO";
case EOPNOTSUPP: return "EOPNOTSUPP";
case EPERM: return "EPERM";
case EPIPE: return "EPIPE";
case EPROTONOSUPPORT: return "EPROTONOSUPPORT";
case EPROTOTYPE: return "EPROTOTYPE";
case EROFS: return "EROFS";
case ESPIPE: return "ESPIPE";
case ESRCH: return "ESRCH";
case ETIMEDOUT: return "ETIMEDOUT";
case EWOULDBLOCK: return "EWOULDBLOCK";
case EXDEV: return "EXDEV";
default: return "unknown";
}
}
/** @} */