From 28caf32e980f3ab547d48221e44961cf4981d664 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Fri, 24 Jan 2025 12:05:00 +0100 Subject: [PATCH] sys/tiny_strerror: fix compilation with picolibc on Ubuntu The picolibc shipped in Ubuntu does not provided non-POSIX errnos by default. If the errno codes are not provided, we can also not provide corresponding strings. This guards the effected strings corresponding to non-POSIX errnos behind `#ifdef`, so that they are only provided when the corresponding errno is. --- sys/tiny_strerror/tiny_strerror.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/tiny_strerror/tiny_strerror.c b/sys/tiny_strerror/tiny_strerror.c index 77732f4d78..386d1686d2 100644 --- a/sys/tiny_strerror/tiny_strerror.c +++ b/sys/tiny_strerror/tiny_strerror.c @@ -48,7 +48,9 @@ static FLASH_ATTR const char _edquot[] = "-EDQUOT"; static FLASH_ATTR const char _eexist[] = "-EEXIST"; static FLASH_ATTR const char _efault[] = "-EFAULT"; static FLASH_ATTR const char _efbig[] = "-EFBIG"; +#ifdef EHOSTDOWN /* not part of POSIX and not universally available */ static FLASH_ATTR const char _ehostdown[] = "-EHOSTDOWN"; +#endif static FLASH_ATTR const char _ehostunreach[] = "-EHOSTUNREACH"; static FLASH_ATTR const char _eidrm[] = "-EIDRM"; static FLASH_ATTR const char _eilseq[] = "-EILSEQ"; @@ -93,7 +95,9 @@ static FLASH_ATTR const char _enxio[] = "-ENXIO"; static FLASH_ATTR const char _eoverflow[] = "-EOVERFLOW"; static FLASH_ATTR const char _eownerdead[] = "-EOWNERDEAD"; static FLASH_ATTR const char _eperm[] = "-EPERM"; +#ifdef EPFNOSUPPORT /* not part of POSIX and not universally available */ static FLASH_ATTR const char _epfnosupport[] = "-EPFNOSUPPORT"; +#endif static FLASH_ATTR const char _epipe[] = "-EPIPE"; static FLASH_ATTR const char _eprotonosupport[] = "-EPROTONOSUPPORT"; static FLASH_ATTR const char _eprototype[] = "-EPROTOTYPE"; @@ -105,7 +109,9 @@ static FLASH_ATTR const char _esrch[] = "-ESRCH"; static FLASH_ATTR const char _estale[] = "-ESTALE"; static FLASH_ATTR const char _etimedout[] = "-ETIMEDOUT"; static FLASH_ATTR const char _etime[] = "-ETIME"; +#ifdef ETOOMANYREFS /* not part of POSIX and not universally available */ static FLASH_ATTR const char _etoomanyrefs[] = "-ETOOMANYREFS"; +#endif static FLASH_ATTR const char _etxtbsy[] = "-ETXTBSY"; static FLASH_ATTR const char _exdev[] = "-EXDEV"; /* EAGAIN and EWOULDBLOCK have the exact same meaning and consequently may @@ -143,7 +149,9 @@ static FLASH_ATTR const char * FLASH_ATTR const lookup[] = { [EEXIST] = _eexist, [EFAULT] = _efault, [EFBIG] = _efbig, +#ifdef EHOSTDOWN /* not part of POSIX and not universally available */ [EHOSTDOWN] = _ehostdown, +#endif [EHOSTUNREACH] = _ehostunreach, [EIDRM] = _eidrm, [EILSEQ] = _eilseq, @@ -188,7 +196,9 @@ static FLASH_ATTR const char * FLASH_ATTR const lookup[] = { [EOVERFLOW] = _eoverflow, [EOWNERDEAD ] = _eownerdead, [EPERM] = _eperm, +#ifdef EPFNOSUPPORT /* not part of POSIX and not universally available */ [EPFNOSUPPORT] = _epfnosupport, +#endif [EPIPE] = _epipe, [EPROTONOSUPPORT] = _eprotonosupport, [EPROTOTYPE] = _eprototype, @@ -200,7 +210,9 @@ static FLASH_ATTR const char * FLASH_ATTR const lookup[] = { [ESTALE] = _estale, [ETIMEDOUT] = _etimedout, [ETIME] = _etime, +#ifdef ETOOMANYREFS /* not part of POSIX and not universally available */ [ETOOMANYREFS] = _etoomanyrefs, +#endif [ETXTBSY] = _etxtbsy, [EXDEV] = _exdev, #if EAGAIN != EWOULDBLOCK