From 9feedd59d824b75950b8d15be6a2a34534c2a6d9 Mon Sep 17 00:00:00 2001 From: Martin Baute Date: Thu, 10 Mar 2016 08:13:45 +0100 Subject: [PATCH] Reworked errno. Added values from Linux / Windows. Added error texts. Some errno values were missing (c&p error). --- functions/string/strerror.c | 4 +- internals/_PDCLIB_locale.h | 2 +- opt/tss_errno/errno.h | 163 ++++++++------- platform/example/functions/_PDCLIB/stdinit.c | 136 ++++++++++++- platform/example/internals/_PDCLIB_config.h | 192 +++++++++--------- .../gandr/functions/_PDCLIB/_PDCLIB_stdinit.c | 82 +++++++- platform/gandr/includes/_PDCLIB_config.h | 162 ++++++++------- .../posix/functions/_PDCLIB/_PDCLIB_stdinit.c | 136 ++++++++++++- platform/posix/internals/_PDCLIB_config.h | 125 +++++++++++- .../win32/functions/_PDCLIB/_PDCLIB_stdinit.c | 145 ++++++++++++- platform/win32/internals/_PDCLIB_config.h | 190 +++++++++-------- 11 files changed, 952 insertions(+), 385 deletions(-) diff --git a/functions/string/strerror.c b/functions/string/strerror.c index 0ed494d..47e064b 100644 --- a/functions/string/strerror.c +++ b/functions/string/strerror.c @@ -13,13 +13,13 @@ /* TODO: Doing this via a static array is not the way to do it. */ char * strerror( int errnum ) { - if ( errnum == 0 || errnum >= _PDCLIB_ERRNO_MAX ) + if ( errnum >= _PDCLIB_ERRNO_MAX ) { return (char *)"Unknown error"; } else { - return _PDCLIB_threadlocale()->_ErrnoStr[errnum]; + return (char *)_PDCLIB_threadlocale()->_ErrnoStr[errnum]; } } diff --git a/internals/_PDCLIB_locale.h b/internals/_PDCLIB_locale.h index 82e17b0..4595e9b 100644 --- a/internals/_PDCLIB_locale.h +++ b/internals/_PDCLIB_locale.h @@ -92,7 +92,7 @@ struct _PDCLIB_locale { const _PDCLIB_ctype_t *_CType; /* perror/strerror */ - char *_ErrnoStr[_PDCLIB_ERRNO_MAX]; + const char * const _ErrnoStr[_PDCLIB_ERRNO_MAX]; }; extern const _PDCLIB_wcinfo_t _PDCLIB_wcinfo[]; diff --git a/opt/tss_errno/errno.h b/opt/tss_errno/errno.h index cda22a0..3b3feab 100644 --- a/opt/tss_errno/errno.h +++ b/opt/tss_errno/errno.h @@ -6,97 +6,96 @@ #ifndef _PDCLIB_ERRNO_H #define _PDCLIB_ERRNO_H _PDCLIB_ERRNO_H + #include <_PDCLIB_int.h> + _PDCLIB_BEGIN_EXTERN_C extern int * _PDCLIB_errno_func( void ); #define errno (*_PDCLIB_errno_func()) -/* C99 */ -#define ERANGE _PDCLIB_ERANGE -#define EDOM _PDCLIB_EDOM -#define EILSEQ _PDCLIB_EILSEQ +/* C only requires the following three */ +#define ERANGE _PDCLIB_ERANGE +#define EDOM _PDCLIB_EDOM +#define EILSEQ _PDCLIB_EILSEQ -/* C++11. Yes, they did just copy the POSIX errno list into the standard - * - * ...take a DEEP breath... - */ -#define E2BIG _PDCLIB_E2BIG -#define ECONNRESET _PDCLIB_ECONNRESET -#define EISCONN _PDCLIB_EISCONN -#define ENOENT _PDCLIB_ENOENT +/* C++11 additionally requires the following (taken from POSIX) */ +#define E2BIG _PDCLIB_E2BIG +#define EACCES _PDCLIB_EACCES +#define EADDRINUSE _PDCLIB_EADDRINUSE +#define EADDRNOTAVAIL _PDCLIB_EADDRNOTAVAIL +#define EAFNOSUPPORT _PDCLIB_EAFNOSUPPORT +#define EAGAIN _PDCLIB_EAGAIN +#define EALREADY _PDCLIB_EALREADY +#define EBADF _PDCLIB_EBADF +#define EBADMSG _PDCLIB_EBADMSG +#define EBUSY _PDCLIB_EBUSY +#define ECANCELED _PDCLIB_ECANCELED +#define ECHILD _PDCLIB_ECHILD +#define ECONNABORTED _PDCLIB_ECONNABORTED +#define ECONNREFUSED _PDCLIB_ECONNREFUSED +#define ECONNRESET _PDCLIB_ECONNRESET +#define EDEADLK _PDCLIB_EDEADLK +#define EDESTADDRREQ _PDCLIB_EDESTADDRREQ +#define EEXIST _PDCLIB_EEXIST +#define EFAULT _PDCLIB_EFAULT +#define EFBIG _PDCLIB_EFBIG +#define EHOSTUNREACH _PDCLIB_EHOSTUNREACH +#define EIDRM _PDCLIB_EIDRM +#define EINPROGRESS _PDCLIB_EINPROGRESS +#define EINTR _PDCLIB_EINTR +#define EINVAL _PDCLIB_EINVAL +#define EIO _PDCLIB_EIO +#define EISCONN _PDCLIB_EISCONN +#define EISDIR _PDCLIB_EISDIR +#define ELOOP _PDCLIB_ELOOP +#define EMFILE _PDCLIB_EMFILE +#define EMLINK _PDCLIB_EMLINK +#define EMSGSIZE _PDCLIB_EMSGSIZE +#define ENAMETOOLONG _PDCLIB_ENAMETOOLONG +#define ENETDOWN _PDCLIB_ENETDOWN +#define ENETRESET _PDCLIB_ENETRESET +#define ENETUNREACH _PDCLIB_ENETUNREACH +#define ENFILE _PDCLIB_ENFILE +#define ENOBUFS _PDCLIB_ENOBUFS +#define ENODATA _PDCLIB_ENODATA +#define ENODEV _PDCLIB_ENODEV +#define ENOENT _PDCLIB_ENOENT +#define ENOEXEC _PDCLIB_ENOEXEC +#define ENOLCK _PDCLIB_ENOLCK +#define ENOLINK _PDCLIB_ENOLINK +#define ENOMEM _PDCLIB_ENOMEM +#define ENOMSG _PDCLIB_ENOMSG +#define ENOPROTOOPT _PDCLIB_ENOPROTOOPT +#define ENOSPC _PDCLIB_ENOSPC +#define ENOSR _PDCLIB_ENOSR +#define ENOSTR _PDCLIB_ENOSTR +#define ENOSYS _PDCLIB_ENOSYS +#define ENOTCONN _PDCLIB_ENOTCONN +#define ENOTDIR _PDCLIB_ENOTDIR +#define ENOTEMPTY _PDCLIB_ENOTEMPTY #define ENOTRECOVERABLE _PDCLIB_ENOTRECOVERABLE -#define EROFS _PDCLIB_EROFS -#define EACCES _PDCLIB_EACCES -#define EDEADLK _PDCLIB_EDEADLK -#define EISDIR _PDCLIB_EISDIR -#define ENOEXEC _PDCLIB_ENOEXEC -#define ENOTSOCK _PDCLIB_ENOTSOCK -#define ESPIPE _PDCLIB_ESPIPE -#define EADDRINUSE _PDCLIB_EADDRINUSE -#define EDESTADDRREQ _PDCLIB_EDESTADDRREQ -#define ELOOP _PDCLIB_ELOOP -#define ENOLCK _PDCLIB_ENOLCK -#define ENOTSUP _PDCLIB_ENOTSUPP -#define ESRCH _PDCLIB_ESRCH -#define EADDRNOTAVAIL _PDCLIB_EADDRNOTAVAIL -#define EMFILE _PDCLIB_EMFILE -#define ENOLINK _PDCLIB_ENOLINK -#define ENOTTY _PDCLIB_ENOTTY -#define ETIME _PDCLIB_ETIME -#define EAFNOSUPPORT _PDCLIB_EAFNOSUPPORT -#define EEXIST _PDCLIB_EEXIST -#define EMLINK _PDCLIB_EMLINK -#define ENOMEM _PDCLIB_ENOMEM -#define ENXIO _PDCLIB_ENXIO -#define ETIMEDOUT _PDCLIB_ETIMEDOUT -#define EAGAIN _PDCLIB_EAGAIN -#define EFAULT _PDCLIB_EFAULT -#define EMSGSIZE _PDCLIB_EMSGSIZE -#define ENOMSG _PDCLIB_ENOMSG -#define EOPNOTSUPP _PDCLIB_EOPNOTSUPP -#define ETXTBSY _PDCLIB_ETXTBSY -#define EALREADY _PDCLIB_EALREADY -#define EFBIG _PDCLIB_EFBIG -#define ENAMETOOLONG _PDCLIB_ENAMETOOLONG -#define ENOPROTOOPT _PDCLIB_ENOPROTOOPT -#define EOVERFLOW _PDCLIB_EOVERFLOW -#define EWOULDBLOCK _PDCLIB_EWOULDBLOCK -#define EBADF _PDCLIB_EBADF -#define EHOSTUNREACH _PDCLIB_EHOSTUNREACH -#define ENETDOWN _PDCLIB_ENETDOWN -#define ENOSPC _PDCLIB_ENOSPC -#define EOWNERDEAD _PDCLIB_EOWNERDEAD -#define EXDEV _PDCLIB_EXDEV -#define EBADMSG _PDCLIB_EBADMSG -#define EIDRM _PDCLIB_EIDRM -#define ENETRESET _PDCLIB_ENETRESET -#define ENOSR _PDCLIB_ENOSR -#define EPERM _PDCLIB_EPERM -#define EBUSY _PDCLIB_EBUSY -#define ENETUNREACH _PDCLIB_ENETUNREACH -#define ENOSTR _PDCLIB_ENOSTR -#define EPIPE _PDCLIB_EPIPE -#define ECANCELED _PDCLIB_ECANCELED -#define EINPROGRESS _PDCLIB_EINPROGRESS -#define ENFILE _PDCLIB_ENFILE -#define ENOSYS _PDCLIB_ENOSYS -#define EPROTO _PDCLIB_EPROTO -#define ECHILD _PDCLIB_ECHILD -#define EINTR _PDCLIB_EINTR -#define ENOBUFS _PDCLIB_ENOBUFS -#define ENOTCONN _PDCLIB_ENOTCONN +#define ENOTSOCK _PDCLIB_ENOTSOCK +#define ENOTSUP _PDCLIB_ENOTSUP +#define ENOTTY _PDCLIB_ENOTTY +#define ENXIO _PDCLIB_ENXIO +#define EOPNOTSUPP _PDCLIB_EOPNOTSUPP +#define EOVERFLOW _PDCLIB_EOVERFLOW +#define EOWNERDEAD _PDCLIB_EOWNERDEAD +#define EPERM _PDCLIB_EPERM +#define EPIPE _PDCLIB_EPIPE +#define EPROTO _PDCLIB_EPROTO #define EPROTONOSUPPORT _PDCLIB_EPROTONOSUPPORT -#define ECONNABORTED _PDCLIB_ECONNABORTED -#define EINVAL _PDCLIB_EINVAL -#define ENODATA _PDCLIB_ENODATA -#define ENOTDIR _PDCLIB_ENOTDIR -#define EPROTOTYPE _PDCLIB_EPROTOTYPE - -#ifdef _PDCLIB_EIO -#define EIO _PDCLIB_EIO -#endif +#define EPROTOTYPE _PDCLIB_EPROTOTYPE +#define EROFS _PDCLIB_EROFS +#define ESPIPE _PDCLIB_ESPIPE +#define ESRCH _PDCLIB_ESRCH +#define ETIME _PDCLIB_ETIME +#define ETIMEDOUT _PDCLIB_ETIMEDOUT +#define ETXTBSY _PDCLIB_ETXTBSY +#define EWOULDBLOCK _PDCLIB_EWOULDBLOCK +#define EXDEV _PDCLIB_EXDEV _PDCLIB_END_EXTERN_C -#endif +#endif diff --git a/platform/example/functions/_PDCLIB/stdinit.c b/platform/example/functions/_PDCLIB/stdinit.c index 986073e..1d0ba23 100644 --- a/platform/example/functions/_PDCLIB/stdinit.c +++ b/platform/example/functions/_PDCLIB/stdinit.c @@ -371,10 +371,138 @@ struct _PDCLIB_locale _PDCLIB_global_locale = { }, ._CType = &global_ctype[1], ._ErrnoStr = { - /* no error */ (char *)"", - /* ERANGE */ (char *)"ERANGE (Range error)", - /* EDOM */ (char *)"EDOM (Domain error)", - /* EILSEQ */ (char *)"EILSEQ (Illegal sequence)" + "Success", + "EPERM (operation not permitted)", + "ENOENT (no such file or directory)", + "ESRCH (no such process)", + "EINTR (interrupted)", + "EIO (io error)", + "ENXIO (no such device or address)", + "E2BIG (argument list too long)", + "ENOEXEC (executable format error)", + "EBADF (bad file descriptor)", + "ECHILD (no child process)", + "EAGAIN (resource unavailable try again)", + "ENOMEM (not enough memory)", + "EACCES (permission denied)", + "EFAULT (bad address)", + "Unknown error", + "EBUSY (device or resource busy)", + "EEXIST (file exists)", + "EXDEV (cross device link)", + "ENODEV (no such device)", + "ENOTDIR (not a directory)", + "EISDIR (is a directory)", + "EINVAL (invalid argument)", + "ENFILE (too many files open in system)", + "EMFILE (too many files open)", + "ENOTTY (inappropriate io control operation)", + "ETXTBSY (text file busy)", + "EFBIG (file too large)", + "ENOSPC (no space on device)", + "ESPIPE (invalid seek)", + "EROFS (read only file system)", + "EMLINK (too many links)", + "EPIPE (broken pipe)", + "EDOM (argument out of domain)", + "ERANGE (result out of range)", + "EDEADLK (resource deadlock would occur)", + "ENAMETOOLONG (filename too long)", + "ENOLCK (no lock available)", + "ENOSYS (function not supported)", + "ENOTEMPTY (directory not empty)", + "ELOOP (too many symbolic link levels)", + "Unknown error", + "ENOMSG (no message)", + "EIDRM (identifier removed)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "ENOSTR (not a stream)", + "ENODATA (no message available)", + "ETIME (stream timeout)", + "ENOSR (no stream resources)", + "Unknown error", + "Unknown error", + "Unknown error", + "ENOLINK (no link)", + "Unknown error", + "Unknown error", + "Unknown error", + "EPROTO (protocol error)", + "Unknown error", + "Unknown error", + "EBADMSG (bad message)", + "EOVERFLOW (value too large)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "EILSEQ (illegal byte sequence)", + "Unknown error", + "Unknown error", + "Unknown error", + "ENOTSOCK (not a socket)", + "EDESTADDRREQ (destination address required)", + "EMSGSIZE (message size)", + "EPROTOTYPE (wrong protocol type)", + "ENOPROTOOPT (no protocol option)", + "EPROTONOSUPPORT (protocol not supported)", + "Unknown error", + "ENOTSUP (not supported)", + "Unknown error", + "EAFNOSUPPORT (address family not supported)", + "EADDRINUSE (address in use)", + "EADDRNOTAVAIL (address not available)", + "ENETDOWN (network down)", + "ENETUNREACH (network unreachable)", + "ENETRESET (network reset)", + "ECONNABORTED (connection aborted)", + "ECONNRESET (connection reset)", + "ENOBUFS (no buffer space)", + "EISCONN (already connected)", + "ENOTCONN (not connected)", + "Unknown error", + "Unknown error", + "ETIMEDOUT (timed out)", + "ECONNREFUSED (connection refused)", + "Unknown error", + "EHOSTUNREACH (host unreachable)", + "EALREADY (connection already in progress)", + "EINPROGRESS (operation in progress)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "ECANCELED (operation canceled)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "EOWNERDEAD (owner dead)", + "ENOTRECOVERABLE (state not recoverable)", }, }; diff --git a/platform/example/internals/_PDCLIB_config.h b/platform/example/internals/_PDCLIB_config.h index 047fd94..3dc9a88 100644 --- a/platform/example/internals/_PDCLIB_config.h +++ b/platform/example/internals/_PDCLIB_config.h @@ -27,14 +27,6 @@ /* specific platforms, e.g. by swapping int instead of char. */ #define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size ); -/* The maximum value that errno can be set to. This is used to set the size */ -/* of the array in struct lconv () holding error messages for the */ -/* strerror() and perror() functions. (If you change this value because you */ -/* are using additional errno values, you *HAVE* to provide appropriate error */ -/* messages for *ALL* locales.) */ -/* Default is 4 (0, ERANGE, EDOM, EILSEQ). */ -#define _PDCLIB_ERRNO_MAX 4 - /* -------------------------------------------------------------------------- */ /* Integers */ /* -------------------------------------------------------------------------- */ @@ -370,105 +362,105 @@ typedef char * _PDCLIB_va_list; prefix removed by mechanics). If you do not want that kind of translation, you might want to "match" the - values used by PDCLib with those used by the host OS, as to avoid confusion. + values used by PDCLib with those used by the host OS, to avoid confusion. The C standard only defines three distinct errno values: ERANGE, EDOM, and EILSEQ. The standard leaves it up to "the implementation" whether there are - any more beyond those three. There is some controversy as to whether errno is - such a good idea at all, so you might want to come up with a different error - reporting facility for your platform. - - Things used to say "Since errno values beyond the three defined by the - standard are not portable anyway (unless you look at POSIX), having your own - error reporting facility would not hurt anybody either." at this point. - However, then somebody birthed C++11 into the world, which copied POSIX's - errno values into C++. Yes, even EINTR. Therefore, this library defines - them. That said, thats nothing stopping you from using your own error - reporting facility for things outside the C library. + any more beyond those three. + + However, C++11 introduced the whole list of POSIX errno values into the + standard, so PDCLib might as well define those as well. Sometimes the standard says to set errno to indicate an error, but does not prescribe a value. We will use a value from the following list. If POSIX defines a value, we use that; otherwise, we use as seems suitable. - - If porting to a system which uses an errno-like reporting system (e.g. a - UNIX), you'll probably want to define them to match what the OS uses */ -/* C errno values */ -#define _PDCLIB_ERANGE 1 -#define _PDCLIB_EDOM 2 -#define _PDCLIB_EILSEQ 3 - -/* C++11/POSIX errno values */ -#define _PDCLIB_E2BIG 4 -#define _PDCLIB_ECONNRESET 5 -#define _PDCLIB_EISCONN 6 -#define _PDCLIB_ENOENT 7 -#define _PDCLIB_ENOTRECOVERABLE 8 -#define _PDCLIB_EROFS 9 -#define _PDCLIB_EACCES 10 -#define _PDCLIB_EDEADLK 11 -#define _PDCLIB_EISDIR 12 -#define _PDCLIB_ENOEXEC 13 -#define _PDCLIB_ENOTSOCK 14 -#define _PDCLIB_ESPIPE 15 -#define _PDCLIB_EADDRINUSE 16 -#define _PDCLIB_EDESTADDRREQ 17 -#define _PDCLIB_ELOOP 18 -#define _PDCLIB_ENOLCK 19 -#define _PDCLIB_ENOTSUPP 20 -#define _PDCLIB_ESRCH 21 -#define _PDCLIB_EADDRNOTAVAIL 22 -#define _PDCLIB_EMFILE 23 -#define _PDCLIB_ENOLINK 24 -#define _PDCLIB_ENOTTY 25 -#define _PDCLIB_ETIME 26 -#define _PDCLIB_EAFNOSUPPORT 27 -#define _PDCLIB_EEXIST 28 -#define _PDCLIB_EMLINK 29 -#define _PDCLIB_ENOMEM 30 -#define _PDCLIB_ENXIO 31 -#define _PDCLIB_ETIMEDOUT 32 -#define _PDCLIB_EAGAIN 33 -#define _PDCLIB_EFAULT 34 -#define _PDCLIB_EMSGSIZE 35 -#define _PDCLIB_ENOMSG 36 -#define _PDCLIB_EOPNOTSUPP 37 -#define _PDCLIB_ETXTBSY 38 -#define _PDCLIB_EALREADY 39 -#define _PDCLIB_EFBIG 40 -#define _PDCLIB_ENAMETOOLONG 41 -#define _PDCLIB_ENOPROTOOPT 42 -#define _PDCLIB_EOVERFLOW 43 -#define _PDCLIB_EWOULDBLOCK _PDCLIB_EAGAIN -#define _PDCLIB_EBADF 44 -#define _PDCLIB_EHOSTUNREACH 45 -#define _PDCLIB_ENETDOWN 46 -#define _PDCLIB_ENOSPC 47 -#define _PDCLIB_EOWNERDEAD 48 -#define _PDCLIB_EXDEV 49 -#define _PDCLIB_EBADMSG 50 -#define _PDCLIB_EIDRM 51 -#define _PDCLIB_ENETRESET 52 -#define _PDCLIB_ENOSR 53 -#define _PDCLIB_EPERM 54 -#define _PDCLIB_EBUSY 55 -#define _PDCLIB_ENETUNREACH 56 -#define _PDCLIB_ENOSTR 57 -#define _PDCLIB_EPIPE 58 -#define _PDCLIB_ECANCELED 59 -#define _PDCLIB_EINPROGRESS 60 -#define _PDCLIB_ENFILE 61 -#define _PDCLIB_ENOSYS 62 -#define _PDCLIB_EPROTO 63 -#define _PDCLIB_ECHILD 64 -#define _PDCLIB_EINTR 65 -#define _PDCLIB_ENOBUFS 66 -#define _PDCLIB_ENOTCONN 67 -#define _PDCLIB_EPROTONOSUPPORT 68 -#define _PDCLIB_ECONNABORTED 69 -#define _PDCLIB_EINVAL 70 -#define _PDCLIB_ENODATA 71 -#define _PDCLIB_ENOTDIR 72 -#define _PDCLIB_EPROTOTYPE 73 + +/* These values were taken from Linux, gcc 4.8. */ +#define _PDCLIB_E2BIG 7 +#define _PDCLIB_EACCES 13 +#define _PDCLIB_EADDRINUSE 98 +#define _PDCLIB_EADDRNOTAVAIL 99 +#define _PDCLIB_EAFNOSUPPORT 97 +#define _PDCLIB_EAGAIN 11 +#define _PDCLIB_EALREADY 114 +#define _PDCLIB_EBADF 9 +#define _PDCLIB_EBADMSG 74 +#define _PDCLIB_EBUSY 16 +#define _PDCLIB_ECANCELED 125 +#define _PDCLIB_ECHILD 10 +#define _PDCLIB_ECONNABORTED 103 +#define _PDCLIB_ECONNREFUSED 111 +#define _PDCLIB_ECONNRESET 104 +#define _PDCLIB_EDEADLK 35 +#define _PDCLIB_EDESTADDRREQ 89 +#define _PDCLIB_EDOM 33 +#define _PDCLIB_EEXIST 17 +#define _PDCLIB_EFAULT 14 +#define _PDCLIB_EFBIG 27 +#define _PDCLIB_EHOSTUNREACH 113 +#define _PDCLIB_EIDRM 43 +#define _PDCLIB_EILSEQ 84 +#define _PDCLIB_EINPROGRESS 115 +#define _PDCLIB_EINTR 4 +#define _PDCLIB_EINVAL 22 +#define _PDCLIB_EIO 5 +#define _PDCLIB_EISCONN 106 +#define _PDCLIB_EISDIR 21 +#define _PDCLIB_ELOOP 40 +#define _PDCLIB_EMFILE 24 +#define _PDCLIB_EMLINK 31 +#define _PDCLIB_EMSGSIZE 90 +#define _PDCLIB_ENAMETOOLONG 36 +#define _PDCLIB_ENETDOWN 100 +#define _PDCLIB_ENETRESET 102 +#define _PDCLIB_ENETUNREACH 101 +#define _PDCLIB_ENFILE 23 +#define _PDCLIB_ENOBUFS 105 +#define _PDCLIB_ENODATA 61 +#define _PDCLIB_ENODEV 19 +#define _PDCLIB_ENOENT 2 +#define _PDCLIB_ENOEXEC 8 +#define _PDCLIB_ENOLCK 37 +#define _PDCLIB_ENOLINK 67 +#define _PDCLIB_ENOMEM 12 +#define _PDCLIB_ENOMSG 42 +#define _PDCLIB_ENOPROTOOPT 92 +#define _PDCLIB_ENOSPC 28 +#define _PDCLIB_ENOSR 63 +#define _PDCLIB_ENOSTR 60 +#define _PDCLIB_ENOSYS 38 +#define _PDCLIB_ENOTCONN 107 +#define _PDCLIB_ENOTDIR 20 +#define _PDCLIB_ENOTEMPTY 39 +#define _PDCLIB_ENOTRECOVERABLE 131 +#define _PDCLIB_ENOTSOCK 88 +#define _PDCLIB_ENOTSUP 95 +#define _PDCLIB_ENOTTY 25 +#define _PDCLIB_ENXIO 6 +#define _PDCLIB_EOPNOTSUPP 95 +#define _PDCLIB_EOVERFLOW 75 +#define _PDCLIB_EOWNERDEAD 130 +#define _PDCLIB_EPERM 1 +#define _PDCLIB_EPIPE 32 +#define _PDCLIB_EPROTO 71 +#define _PDCLIB_EPROTONOSUPPORT 93 +#define _PDCLIB_EPROTOTYPE 91 +#define _PDCLIB_ERANGE 34 +#define _PDCLIB_EROFS 30 +#define _PDCLIB_ESPIPE 29 +#define _PDCLIB_ESRCH 3 +#define _PDCLIB_ETIME 62 +#define _PDCLIB_ETIMEDOUT 110 +#define _PDCLIB_ETXTBSY 26 +#define _PDCLIB_EWOULDBLOCK 11 +#define _PDCLIB_EXDEV 18 + +/* This is used to set the size of the array in struct lconv () */ +/* holding the error messages for the strerror() and perror() fuctions. If */ +/* you change this value because you are using additional errno values, you */ +/* *HAVE* to provide appropriate error messages for *ALL* locales. */ +/* Needs to be one higher than the highest errno value above. */ +#define _PDCLIB_ERRNO_MAX 132 #endif diff --git a/platform/gandr/functions/_PDCLIB/_PDCLIB_stdinit.c b/platform/gandr/functions/_PDCLIB/_PDCLIB_stdinit.c index c622ff0..54ef0e3 100644 --- a/platform/gandr/functions/_PDCLIB/_PDCLIB_stdinit.c +++ b/platform/gandr/functions/_PDCLIB/_PDCLIB_stdinit.c @@ -310,10 +310,84 @@ struct _PDCLIB_locale _PDCLIB_global_locale = { }, ._CType = &global_ctype[1], ._ErrnoStr = { - /* no error */ (char *)"", - /* ERANGE */ (char *)"ERANGE (Range error)", - /* EDOM */ (char *)"EDOM (Domain error)", - /* EILSEQ */ (char *)"EILSEQ (Illegal sequence)" + "Success", + "ERANGE (result out of range)", + "EDOM (argument out of domain)", + "EILSEQ (illegal byte sequence)", + "E2BIG (argument list too long)", + "ECONNRESET (connection reset)", + "EISCONN (already connected)", + "ENOENT (no such file or directory)", + "ENOTRECOVERABLE (state not recoverable)", + "EROFS (read only file system)", + "EACCES (permission denied)", + "EDEADLK (resource deadlock would occur)", + "EISDIR (is a directory)", + "ENOEXEC (executable format error)", + "ENOTSOCK (not a socket)", + "ESPIPE (invalid seek)", + "EADDRINUSE (address in use)", + "EDESTADDRREQ (destination address required)", + "ELOOP (too many symbolic link levels)", + "ENOLCK (no lock available)", + "ENOTSUP (not supported)", + "ESRCH (no such process)", + "EADDRNOTAVAIL (address not available)", + "EMFILE (too many files open)", + "ENOLINK (no link)", + "ENOTTY (inappropriate io control operation)", + "ETIME (stream timeout)", + "EAFNOSUPPORT (address family not supported)", + "EEXIST (file exists)", + "EMLINK (too many links)", + "ENOMEM (not enough memory)", + "ENXIO (no such device or address)", + "ETIMEDOUT (timed out)", + "EAGAIN (resource unavailable try again)", + "EFAULT (bad address)", + "EMSGSIZE (message size)", + "ENOMSG (no message)", + "EOPNOTSUPP (operation not supported)", + "ETXTBSY (text file busy)", + "EALREADY (connection already in progress)", + "EFBIG (file too large)", + "ENAMETOOLONG (filename too long)", + "ENOPROTOOPT (no protocol option)", + "EOVERFLOW (value too large)", + "EBADF (bad file descriptor)", + "EHOSTUNREACH (host unreachable)", + "ENETDOWN (network down)", + "ENOSPC (no space on device)", + "EOWNERDEAD (owner dead)", + "EXDEV (cross device link)", + "EBADMSG (bad message)", + "EIDRM (identifier removed)", + "ENETRESET (network reset)", + "ENOSR (no stream resources)", + "EPERM (operation not permitted)", + "EBUSY (device or resource busy)", + "ENETUNREACH (network unreachable)", + "ENOSTR (not a stream)", + "EPIPE (broken pipe)", + "ECANCELED (operation canceled)", + "EINPROGRESS (operation in progress)", + "ENFILE (too many files open in system)", + "ENOSYS (function not supported)", + "EPROTO (protocol error)", + "ECHILD (no child process)", + "EINTR (interrupted)", + "ENOBUFS (no buffer space)", + "ENOTCONN (not connected)", + "EPROTONOSUPPORT (protocol not supported)", + "ECONNABORTED (connection aborted)", + "EINVAL (invalid argument)", + "ENODATA (no message available)", + "ENOTDIR (not a directory)", + "EPROTOTYPE (wrong protocol type)", + "EIO (io error)", + "ECONNREFUSED (connection refused)", + "ENODEV (no such device)", + "ENOTEMPTY (directory not empty)", }, }; diff --git a/platform/gandr/includes/_PDCLIB_config.h b/platform/gandr/includes/_PDCLIB_config.h index b21186c..bfd1788 100644 --- a/platform/gandr/includes/_PDCLIB_config.h +++ b/platform/gandr/includes/_PDCLIB_config.h @@ -212,82 +212,90 @@ typedef __builtin_va_list _PDCLIB_va_list; /* errno -------------------------------------------------------------------- */ /* errno values as per C++11 */ -#define _PDCLIB_ERANGE 1 -#define _PDCLIB_EDOM 2 -#define _PDCLIB_EILSEQ 3 -#define _PDCLIB_E2BIG 4 -#define _PDCLIB_ECONNRESET 5 -#define _PDCLIB_EISCONN 6 -#define _PDCLIB_ENOENT 7 -#define _PDCLIB_ENOTRECOVERABLE 8 -#define _PDCLIB_EROFS 9 -#define _PDCLIB_EACCES 10 -#define _PDCLIB_EDEADLK 11 -#define _PDCLIB_EISDIR 12 -#define _PDCLIB_ENOEXEC 13 -#define _PDCLIB_ENOTSOCK 14 -#define _PDCLIB_ESPIPE 15 -#define _PDCLIB_EADDRINUSE 16 -#define _PDCLIB_EDESTADDRREQ 17 -#define _PDCLIB_ELOOP 18 -#define _PDCLIB_ENOLCK 19 -#define _PDCLIB_ENOTSUPP 20 -#define _PDCLIB_ESRCH 21 -#define _PDCLIB_EADDRNOTAVAIL 22 -#define _PDCLIB_EMFILE 23 -#define _PDCLIB_ENOLINK 24 -#define _PDCLIB_ENOTTY 25 -#define _PDCLIB_ETIME 26 -#define _PDCLIB_EAFNOSUPPORT 27 -#define _PDCLIB_EEXIST 28 -#define _PDCLIB_EMLINK 29 -#define _PDCLIB_ENOMEM 30 -#define _PDCLIB_ENXIO 31 -#define _PDCLIB_ETIMEDOUT 32 -#define _PDCLIB_EAGAIN 33 -#define _PDCLIB_EFAULT 34 -#define _PDCLIB_EMSGSIZE 35 -#define _PDCLIB_ENOMSG 36 -#define _PDCLIB_EOPNOTSUPP 37 -#define _PDCLIB_ETXTBSY 38 -#define _PDCLIB_EALREADY 39 -#define _PDCLIB_EFBIG 40 -#define _PDCLIB_ENAMETOOLONG 41 -#define _PDCLIB_ENOPROTOOPT 42 -#define _PDCLIB_EOVERFLOW 43 -#define _PDCLIB_EWOULDBLOCK _PDCLIB_EAGAIN -#define _PDCLIB_EBADF 44 -#define _PDCLIB_EHOSTUNREACH 45 -#define _PDCLIB_ENETDOWN 46 -#define _PDCLIB_ENOSPC 47 -#define _PDCLIB_EOWNERDEAD 48 -#define _PDCLIB_EXDEV 49 -#define _PDCLIB_EBADMSG 50 -#define _PDCLIB_EIDRM 51 -#define _PDCLIB_ENETRESET 52 -#define _PDCLIB_ENOSR 53 -#define _PDCLIB_EPERM 54 -#define _PDCLIB_EBUSY 55 -#define _PDCLIB_ENETUNREACH 56 -#define _PDCLIB_ENOSTR 57 -#define _PDCLIB_EPIPE 58 -#define _PDCLIB_ECANCELED 59 -#define _PDCLIB_EINPROGRESS 60 -#define _PDCLIB_ENFILE 61 -#define _PDCLIB_ENOSYS 62 -#define _PDCLIB_EPROTO 63 -#define _PDCLIB_ECHILD 64 -#define _PDCLIB_EINTR 65 -#define _PDCLIB_ENOBUFS 66 -#define _PDCLIB_ENOTCONN 67 -#define _PDCLIB_EPROTONOSUPPORT 68 -#define _PDCLIB_ECONNABORTED 69 -#define _PDCLIB_EINVAL 70 -#define _PDCLIB_ENODATA 71 -#define _PDCLIB_ENOTDIR 72 -#define _PDCLIB_EPROTOTYPE 73 -#define _PDCLIB_EIO 74 - -#define _PDCLIB_ERRNO_MAX 74 +#define _PDCLIB_ERANGE 1 +#define _PDCLIB_EDOM 2 +#define _PDCLIB_EILSEQ 3 +#define _PDCLIB_E2BIG 4 +#define _PDCLIB_ECONNRESET 5 +#define _PDCLIB_EISCONN 6 +#define _PDCLIB_ENOENT 7 +#define _PDCLIB_ENOTRECOVERABLE 8 +#define _PDCLIB_EROFS 9 +#define _PDCLIB_EACCES 10 +#define _PDCLIB_EDEADLK 11 +#define _PDCLIB_EISDIR 12 +#define _PDCLIB_ENOEXEC 13 +#define _PDCLIB_ENOTSOCK 14 +#define _PDCLIB_ESPIPE 15 +#define _PDCLIB_EADDRINUSE 16 +#define _PDCLIB_EDESTADDRREQ 17 +#define _PDCLIB_ELOOP 18 +#define _PDCLIB_ENOLCK 19 +#define _PDCLIB_ENOTSUP 20 +#define _PDCLIB_ESRCH 21 +#define _PDCLIB_EADDRNOTAVAIL 22 +#define _PDCLIB_EMFILE 23 +#define _PDCLIB_ENOLINK 24 +#define _PDCLIB_ENOTTY 25 +#define _PDCLIB_ETIME 26 +#define _PDCLIB_EAFNOSUPPORT 27 +#define _PDCLIB_EEXIST 28 +#define _PDCLIB_EMLINK 29 +#define _PDCLIB_ENOMEM 30 +#define _PDCLIB_ENXIO 31 +#define _PDCLIB_ETIMEDOUT 32 +#define _PDCLIB_EAGAIN 33 +#define _PDCLIB_EFAULT 34 +#define _PDCLIB_EMSGSIZE 35 +#define _PDCLIB_ENOMSG 36 +#define _PDCLIB_EOPNOTSUPP 37 +#define _PDCLIB_ETXTBSY 38 +#define _PDCLIB_EALREADY 39 +#define _PDCLIB_EFBIG 40 +#define _PDCLIB_ENAMETOOLONG 41 +#define _PDCLIB_ENOPROTOOPT 42 +#define _PDCLIB_EOVERFLOW 43 +#define _PDCLIB_EWOULDBLOCK _PDCLIB_EAGAIN +#define _PDCLIB_EBADF 44 +#define _PDCLIB_EHOSTUNREACH 45 +#define _PDCLIB_ENETDOWN 46 +#define _PDCLIB_ENOSPC 47 +#define _PDCLIB_EOWNERDEAD 48 +#define _PDCLIB_EXDEV 49 +#define _PDCLIB_EBADMSG 50 +#define _PDCLIB_EIDRM 51 +#define _PDCLIB_ENETRESET 52 +#define _PDCLIB_ENOSR 53 +#define _PDCLIB_EPERM 54 +#define _PDCLIB_EBUSY 55 +#define _PDCLIB_ENETUNREACH 56 +#define _PDCLIB_ENOSTR 57 +#define _PDCLIB_EPIPE 58 +#define _PDCLIB_ECANCELED 59 +#define _PDCLIB_EINPROGRESS 60 +#define _PDCLIB_ENFILE 61 +#define _PDCLIB_ENOSYS 62 +#define _PDCLIB_EPROTO 63 +#define _PDCLIB_ECHILD 64 +#define _PDCLIB_EINTR 65 +#define _PDCLIB_ENOBUFS 66 +#define _PDCLIB_ENOTCONN 67 +#define _PDCLIB_EPROTONOSUPPORT 68 +#define _PDCLIB_ECONNABORTED 69 +#define _PDCLIB_EINVAL 70 +#define _PDCLIB_ENODATA 71 +#define _PDCLIB_ENOTDIR 72 +#define _PDCLIB_EPROTOTYPE 73 +#define _PDCLIB_EIO 74 +#define _PDCLIB_ECONNREFUSED 75 +#define _PDCLIB_ENODEV 76 +#define _PDCLIB_ENOTEMPTY 77 + +/* This is used to set the size of the array in struct lconv () */ +/* holding the error messages for the strerror() and perror() fuctions. If */ +/* you change this value because you are using additional errno values, you */ +/* *HAVE* to provide appropriate error messages for *ALL* locales. */ +/* Needs to be one higher than the highest errno value above. */ +#define _PDCLIB_ERRNO_MAX 78 #endif diff --git a/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c b/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c index defb303..a92fe67 100644 --- a/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c +++ b/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c @@ -377,10 +377,138 @@ struct _PDCLIB_locale _PDCLIB_global_locale = { }, ._CType = &global_ctype[1], ._ErrnoStr = { - /* no error */ (char *)"", - /* ERANGE */ (char *)"ERANGE (Range error)", - /* EDOM */ (char *)"EDOM (Domain error)", - /* EILSEQ */ (char *)"EILSEQ (Illegal sequence)" + "Success", + "EPERM (operation not permitted)", + "ENOENT (no such file or directory)", + "ESRCH (no such process)", + "EINTR (interrupted)", + "EIO (io error)", + "ENXIO (no such device or address)", + "E2BIG (argument list too long)", + "ENOEXEC (executable format error)", + "EBADF (bad file descriptor)", + "ECHILD (no child process)", + "EAGAIN (resource unavailable try again)", + "ENOMEM (not enough memory)", + "EACCES (permission denied)", + "EFAULT (bad address)", + "Unknown error", + "EBUSY (device or resource busy)", + "EEXIST (file exists)", + "EXDEV (cross device link)", + "ENODEV (no such device)", + "ENOTDIR (not a directory)", + "EISDIR (is a directory)", + "EINVAL (invalid argument)", + "ENFILE (too many files open in system)", + "EMFILE (too many files open)", + "ENOTTY (inappropriate io control operation)", + "ETXTBSY (text file busy)", + "EFBIG (file too large)", + "ENOSPC (no space on device)", + "ESPIPE (invalid seek)", + "EROFS (read only file system)", + "EMLINK (too many links)", + "EPIPE (broken pipe)", + "EDOM (argument out of domain)", + "ERANGE (result out of range)", + "EDEADLK (resource deadlock would occur)", + "ENAMETOOLONG (filename too long)", + "ENOLCK (no lock available)", + "ENOSYS (function not supported)", + "ENOTEMPTY (directory not empty)", + "ELOOP (too many symbolic link levels)", + "Unknown error", + "ENOMSG (no message)", + "EIDRM (identifier removed)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "ENOSTR (not a stream)", + "ENODATA (no message available)", + "ETIME (stream timeout)", + "ENOSR (no stream resources)", + "Unknown error", + "Unknown error", + "Unknown error", + "ENOLINK (no link)", + "Unknown error", + "Unknown error", + "Unknown error", + "EPROTO (protocol error)", + "Unknown error", + "Unknown error", + "EBADMSG (bad message)", + "EOVERFLOW (value too large)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "EILSEQ (illegal byte sequence)", + "Unknown error", + "Unknown error", + "Unknown error", + "ENOTSOCK (not a socket)", + "EDESTADDRREQ (destination address required)", + "EMSGSIZE (message size)", + "EPROTOTYPE (wrong protocol type)", + "ENOPROTOOPT (no protocol option)", + "EPROTONOSUPPORT (protocol not supported)", + "Unknown error", + "ENOTSUP (not supported)", + "Unknown error", + "EAFNOSUPPORT (address family not supported)", + "EADDRINUSE (address in use)", + "EADDRNOTAVAIL (address not available)", + "ENETDOWN (network down)", + "ENETUNREACH (network unreachable)", + "ENETRESET (network reset)", + "ECONNABORTED (connection aborted)", + "ECONNRESET (connection reset)", + "ENOBUFS (no buffer space)", + "EISCONN (already connected)", + "ENOTCONN (not connected)", + "Unknown error", + "Unknown error", + "ETIMEDOUT (timed out)", + "ECONNREFUSED (connection refused)", + "Unknown error", + "EHOSTUNREACH (host unreachable)", + "EALREADY (connection already in progress)", + "EINPROGRESS (operation in progress)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "ECANCELED (operation canceled)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "EOWNERDEAD (owner dead)", + "ENOTRECOVERABLE (state not recoverable)", }, }; diff --git a/platform/posix/internals/_PDCLIB_config.h b/platform/posix/internals/_PDCLIB_config.h index ae30e0a..5b71195 100644 --- a/platform/posix/internals/_PDCLIB_config.h +++ b/platform/posix/internals/_PDCLIB_config.h @@ -27,14 +27,6 @@ /* specific platforms, e.g. by swapping int instead of char. */ #define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size ); -/* The maximum value that errno can be set to. This is used to set the size */ -/* of the array in struct lconv () holding error messages for the */ -/* strerror() and perror() functions. (If you change this value because you */ -/* are using additional errno values, you *HAVE* to provide appropriate error */ -/* messages for *ALL* locales.) */ -/* Default is 4 (0, ERANGE, EDOM, EILSEQ). */ -#define _PDCLIB_ERRNO_MAX 4 - /* -------------------------------------------------------------------------- */ /* Integers */ /* -------------------------------------------------------------------------- */ @@ -371,4 +363,121 @@ struct _PDCLIB_imaxdiv_t */ #define _PDCLIB_UNGETCBUFSIZE 1 +/* errno -------------------------------------------------------------------- */ + +/* These are the values that _PDCLIB_errno can be set to by the library. + + By keeping PDCLib's errno in the _PDCLIB_* namespace, the library is capable + to "translate" between errno values used by the hosting operating system and + those used and passed out by the library. + + Example: In the example platform, the remove() function uses the unlink() + system call as backend. Linux sets its errno to EISDIR if you try to unlink() + a directory, but POSIX demands EPERM. Within the remove() function, you can + catch the 'errno == EISDIR', and set '_PDCLIB_errno = _PDCLIB_EPERM'. Anyone + using PDCLib's will "see" EPERM instead of EISDIR (the _PDCLIB_* + prefix removed by mechanics). + + If you do not want that kind of translation, you might want to "match" the + values used by PDCLib with those used by the host OS, to avoid confusion. + + The C standard only defines three distinct errno values: ERANGE, EDOM, and + EILSEQ. The standard leaves it up to "the implementation" whether there are + any more beyond those three. + + However, C++11 introduced the whole list of POSIX errno values into the + standard, so PDCLib might as well define those as well. + + Sometimes the standard says to set errno to indicate an error, but does not + prescribe a value. We will use a value from the following list. If POSIX + defines a value, we use that; otherwise, we use as seems suitable. +*/ + +/* These values were taken from Linux, gcc 4.8. */ +#define _PDCLIB_E2BIG 7 +#define _PDCLIB_EACCES 13 +#define _PDCLIB_EADDRINUSE 98 +#define _PDCLIB_EADDRNOTAVAIL 99 +#define _PDCLIB_EAFNOSUPPORT 97 +#define _PDCLIB_EAGAIN 11 +#define _PDCLIB_EALREADY 114 +#define _PDCLIB_EBADF 9 +#define _PDCLIB_EBADMSG 74 +#define _PDCLIB_EBUSY 16 +#define _PDCLIB_ECANCELED 125 +#define _PDCLIB_ECHILD 10 +#define _PDCLIB_ECONNABORTED 103 +#define _PDCLIB_ECONNREFUSED 111 +#define _PDCLIB_ECONNRESET 104 +#define _PDCLIB_EDEADLK 35 +#define _PDCLIB_EDESTADDRREQ 89 +#define _PDCLIB_EDOM 33 +#define _PDCLIB_EEXIST 17 +#define _PDCLIB_EFAULT 14 +#define _PDCLIB_EFBIG 27 +#define _PDCLIB_EHOSTUNREACH 113 +#define _PDCLIB_EIDRM 43 +#define _PDCLIB_EILSEQ 84 +#define _PDCLIB_EINPROGRESS 115 +#define _PDCLIB_EINTR 4 +#define _PDCLIB_EINVAL 22 +#define _PDCLIB_EIO 5 +#define _PDCLIB_EISCONN 106 +#define _PDCLIB_EISDIR 21 +#define _PDCLIB_ELOOP 40 +#define _PDCLIB_EMFILE 24 +#define _PDCLIB_EMLINK 31 +#define _PDCLIB_EMSGSIZE 90 +#define _PDCLIB_ENAMETOOLONG 36 +#define _PDCLIB_ENETDOWN 100 +#define _PDCLIB_ENETRESET 102 +#define _PDCLIB_ENETUNREACH 101 +#define _PDCLIB_ENFILE 23 +#define _PDCLIB_ENOBUFS 105 +#define _PDCLIB_ENODATA 61 +#define _PDCLIB_ENODEV 19 +#define _PDCLIB_ENOENT 2 +#define _PDCLIB_ENOEXEC 8 +#define _PDCLIB_ENOLCK 37 +#define _PDCLIB_ENOLINK 67 +#define _PDCLIB_ENOMEM 12 +#define _PDCLIB_ENOMSG 42 +#define _PDCLIB_ENOPROTOOPT 92 +#define _PDCLIB_ENOSPC 28 +#define _PDCLIB_ENOSR 63 +#define _PDCLIB_ENOSTR 60 +#define _PDCLIB_ENOSYS 38 +#define _PDCLIB_ENOTCONN 107 +#define _PDCLIB_ENOTDIR 20 +#define _PDCLIB_ENOTEMPTY 39 +#define _PDCLIB_ENOTRECOVERABLE 131 +#define _PDCLIB_ENOTSOCK 88 +#define _PDCLIB_ENOTSUP 95 +#define _PDCLIB_ENOTTY 25 +#define _PDCLIB_ENXIO 6 +#define _PDCLIB_EOPNOTSUPP 95 +#define _PDCLIB_EOVERFLOW 75 +#define _PDCLIB_EOWNERDEAD 130 +#define _PDCLIB_EPERM 1 +#define _PDCLIB_EPIPE 32 +#define _PDCLIB_EPROTO 71 +#define _PDCLIB_EPROTONOSUPPORT 93 +#define _PDCLIB_EPROTOTYPE 91 +#define _PDCLIB_ERANGE 34 +#define _PDCLIB_EROFS 30 +#define _PDCLIB_ESPIPE 29 +#define _PDCLIB_ESRCH 3 +#define _PDCLIB_ETIME 62 +#define _PDCLIB_ETIMEDOUT 110 +#define _PDCLIB_ETXTBSY 26 +#define _PDCLIB_EWOULDBLOCK 11 +#define _PDCLIB_EXDEV 18 + +/* This is used to set the size of the array in struct lconv () */ +/* holding the error messages for the strerror() and perror() fuctions. If */ +/* you change this value because you are using additional errno values, you */ +/* *HAVE* to provide appropriate error messages for *ALL* locales. */ +/* Needs to be one higher than the highest errno value above. */ +#define _PDCLIB_ERRNO_MAX 132 + #endif diff --git a/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c b/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c index 15ce30b..8d1dc9c 100644 --- a/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c +++ b/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c @@ -374,10 +374,147 @@ struct _PDCLIB_locale _PDCLIB_global_locale = { }, ._CType = &global_ctype[1], ._ErrnoStr = { - /* no error */ (char *)"", - /* ERANGE */ (char *)"ERANGE (Range error)", - /* EDOM */ (char *)"EDOM (Domain error)", - /* EILSEQ */ (char *)"EILSEQ (Illegal sequence)" + "Success" + "EPERM (operation not permitted)", + "ENOENT (no such file or directory)", + "ESRCH (no such process)", + "EINTR (interrupted)", + "EIO (io error)", + "ENXIO (no such device or address)", + "E2BIG (argument list too long)", + "ENOEXEC (executable format error)", + "EBADF (bad file descriptor)", + "ECHILD (no child process)", + "EAGAIN (resource unavailable try again)", + "ENOMEM (not enough memory)", + "EACCES (permission denied)", + "EFAULT (bad address)", + "Unknown error", + "EBUSY (device or resource busy)", + "EEXIST (file exists)", + "EXDEV (cross device link)", + "ENODEV (no such device)", + "ENOTDIR (not a directory)", + "EISDIR (is a directory)", + "EINVAL (invalid argument)", + "ENFILE (too many files open in system)", + "EMFILE (too many files open)", + "ENOTTY (inappropriate io control operation)", + "Unknown error", + "EFBIG (file too large)", + "ENOSPC (no space on device)", + "ESPIPE (invalid seek)", + "EROFS (read only file system)", + "EMLINK (too many links)", + "EPIPE (broken pipe)", + "EDOM (argument out of domain)", + "ERANGE (result out of range)", + "Unknown error", + "EDEADLK (resource deadlock would occur)", + "Unknown error", + "ENAMETOOLONG (filename too long)", + "ENOLCK (no lock available)", + "ENOSYS (function not supported)", + "ENOTEMPTY (directory not empty)", + "EILSEQ (illegal byte sequence)", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "Unknown error", + "EADDRINUSE (address in use)", + "EADDRNOTAVAIL (address not available)", + "EAFNOSUPPORT (address family not supported)", + "EALREADY (connection already in progress)", + "EBADMSG (bad message)", + "ECANCELED (operation canceled)", + "ECONNABORTED (connection aborted)", + "ECONNREFUSED (connection refused)", + "ECONNRESET (connection reset)", + "EDESTADDRREQ (destination address required)", + "EHOSTUNREACH (host unreachable)", + "EIDRM (identifier removed)", + "EINPROGRESS (operation in progress)", + "EISCONN (already connected)", + "ELOOP (too many symbolic link levels)", + "EMSGSIZE (message size)", + "ENETDOWN (network down)", + "ENETRESET (network reset)", + "ENETUNREACH (network unreachable)", + "ENOBUFS (no buffer space)", + "ENODATA (no message available)", + "ENOLINK (no link)", + "ENOMSG (no message)", + "ENOPROTOOPT (no protocol option)", + "ENOSR (no stream resources)", + "ENOSTR (not a stream)", + "ENOTCONN (not connected)", + "ENOTRECOVERABLE (state not recoverable)", + "ENOTSOCK (not a socket)", + "ENOTSUP (not supported)", + "EOPNOTSUPP (operation not supported)", + "Unknown error", + "EOVERFLOW (value too large)", + "EOWNERDEAD (owner dead)", + "EPROTO (protocol error)", + "EPROTONOSUPPORT (protocol not supported)", + "EPROTOTYPE (wrong protocol type)", + "ETIME (stream timeout)", + "ETIMEDOUT (timed out)", + "ETXTBSY (text file busy)", + "EWOULDBLOCK (operation would block)", }, }; #endif diff --git a/platform/win32/internals/_PDCLIB_config.h b/platform/win32/internals/_PDCLIB_config.h index ea5ef47..da83cba 100644 --- a/platform/win32/internals/_PDCLIB_config.h +++ b/platform/win32/internals/_PDCLIB_config.h @@ -27,14 +27,6 @@ /* specific platforms, e.g. by swapping int instead of char. */ #define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size ); -/* The maximum value that errno can be set to. This is used to set the size */ -/* of the array in struct lconv () holding error messages for the */ -/* strerror() and perror() functions. (If you change this value because you */ -/* are using additional errno values, you *HAVE* to provide appropriate error */ -/* messages for *ALL* locales.) */ -/* Default is 4 (0, ERANGE, EDOM, EILSEQ). */ -#define _PDCLIB_ERRNO_MAX 4 - /* -------------------------------------------------------------------------- */ /* Integers */ /* -------------------------------------------------------------------------- */ @@ -400,101 +392,101 @@ struct _PDCLIB_imaxdiv_t The C standard only defines three distinct errno values: ERANGE, EDOM, and EILSEQ. The standard leaves it up to "the implementation" whether there are - any more beyond those three. There is some controversy as to whether errno is - such a good idea at all, so you might want to come up with a different error - reporting facility for your platform. - - Things used to say "Since errno values beyond the three defined by the - standard are not portable anyway (unless you look at POSIX), having your own - error reporting facility would not hurt anybody either." at this point. - However, then somebody birthed C++11 into the world, which copied POSIX's - errno values into C++. Yes, even EINTR. Therefore, this library defines - them. That said, thats nothing stopping you from using your own error - reporting facility for things outside the C library. + any more beyond those three. + + However, C++11 introduced the whole list of POSIX errno values into the + standard, so PDCLib might as well define those as well. Sometimes the standard says to set errno to indicate an error, but does not prescribe a value. We will use a value from the following list. If POSIX defines a value, we use that; otherwise, we use as seems suitable. - - If porting to a system which uses an errno-like reporting system (e.g. a - UNIX), you'll probably want to define them to match what the OS uses */ -/* C errno values */ -#define _PDCLIB_ERANGE 1 -#define _PDCLIB_EDOM 2 -#define _PDCLIB_EILSEQ 3 - -/* C++11/POSIX errno values */ -#define _PDCLIB_E2BIG 4 -#define _PDCLIB_ECONNRESET 5 -#define _PDCLIB_EISCONN 6 -#define _PDCLIB_ENOENT 7 -#define _PDCLIB_ENOTRECOVERABLE 8 -#define _PDCLIB_EROFS 9 -#define _PDCLIB_EACCES 10 -#define _PDCLIB_EDEADLK 11 -#define _PDCLIB_EISDIR 12 -#define _PDCLIB_ENOEXEC 13 -#define _PDCLIB_ENOTSOCK 14 -#define _PDCLIB_ESPIPE 15 -#define _PDCLIB_EADDRINUSE 16 -#define _PDCLIB_EDESTADDRREQ 17 -#define _PDCLIB_ELOOP 18 -#define _PDCLIB_ENOLCK 19 -#define _PDCLIB_ENOTSUPP 20 -#define _PDCLIB_ESRCH 21 -#define _PDCLIB_EADDRNOTAVAIL 22 -#define _PDCLIB_EMFILE 23 -#define _PDCLIB_ENOLINK 24 -#define _PDCLIB_ENOTTY 25 -#define _PDCLIB_ETIME 26 -#define _PDCLIB_EAFNOSUPPORT 27 -#define _PDCLIB_EEXIST 28 -#define _PDCLIB_EMLINK 29 -#define _PDCLIB_ENOMEM 30 -#define _PDCLIB_ENXIO 31 -#define _PDCLIB_ETIMEDOUT 32 -#define _PDCLIB_EAGAIN 33 -#define _PDCLIB_EFAULT 34 -#define _PDCLIB_EMSGSIZE 35 -#define _PDCLIB_ENOMSG 36 -#define _PDCLIB_EOPNOTSUPP 37 -#define _PDCLIB_ETXTBSY 38 -#define _PDCLIB_EALREADY 39 -#define _PDCLIB_EFBIG 40 -#define _PDCLIB_ENAMETOOLONG 41 -#define _PDCLIB_ENOPROTOOPT 42 -#define _PDCLIB_EOVERFLOW 43 -#define _PDCLIB_EWOULDBLOCK _PDCLIB_EAGAIN -#define _PDCLIB_EBADF 44 -#define _PDCLIB_EHOSTUNREACH 45 -#define _PDCLIB_ENETDOWN 46 -#define _PDCLIB_ENOSPC 47 -#define _PDCLIB_EOWNERDEAD 48 -#define _PDCLIB_EXDEV 49 -#define _PDCLIB_EBADMSG 50 -#define _PDCLIB_EIDRM 51 -#define _PDCLIB_ENETRESET 52 -#define _PDCLIB_ENOSR 53 -#define _PDCLIB_EPERM 54 -#define _PDCLIB_EBUSY 55 -#define _PDCLIB_ENETUNREACH 56 -#define _PDCLIB_ENOSTR 57 -#define _PDCLIB_EPIPE 58 -#define _PDCLIB_ECANCELED 59 -#define _PDCLIB_EINPROGRESS 60 -#define _PDCLIB_ENFILE 61 -#define _PDCLIB_ENOSYS 62 -#define _PDCLIB_EPROTO 63 -#define _PDCLIB_ECHILD 64 -#define _PDCLIB_EINTR 65 -#define _PDCLIB_ENOBUFS 66 -#define _PDCLIB_ENOTCONN 67 -#define _PDCLIB_EPROTONOSUPPORT 68 -#define _PDCLIB_ECONNABORTED 69 -#define _PDCLIB_EINVAL 70 -#define _PDCLIB_ENODATA 71 -#define _PDCLIB_ENOTDIR 72 -#define _PDCLIB_EPROTOTYPE 73 + +/* These values were taken from Windows 7, MSVC 2010. */ +#define _PDCLIB_E2BIG 7 +#define _PDCLIB_EACCES 13 +#define _PDCLIB_EADDRINUSE 100 +#define _PDCLIB_EADDRNOTAVAIL 101 +#define _PDCLIB_EAFNOSUPPORT 102 +#define _PDCLIB_EAGAIN 11 +#define _PDCLIB_EALREADY 103 +#define _PDCLIB_EBADF 9 +#define _PDCLIB_EBADMSG 104 +#define _PDCLIB_EBUSY 16 +#define _PDCLIB_ECANCELED 105 +#define _PDCLIB_ECHILD 10 +#define _PDCLIB_ECONNABORTED 106 +#define _PDCLIB_ECONNREFUSED 107 +#define _PDCLIB_ECONNRESET 108 +#define _PDCLIB_EDEADLK 36 +#define _PDCLIB_EDESTADDRREQ 109 +#define _PDCLIB_EDOM 33 +#define _PDCLIB_EEXIST 17 +#define _PDCLIB_EFAULT 14 +#define _PDCLIB_EFBIG 27 +#define _PDCLIB_EHOSTUNREACH 110 +#define _PDCLIB_EIDRM 111 +#define _PDCLIB_EILSEQ 42 +#define _PDCLIB_EINPROGRESS 112 +#define _PDCLIB_EINTR 4 +#define _PDCLIB_EINVAL 22 +#define _PDCLIB_EIO 5 +#define _PDCLIB_EISCONN 113 +#define _PDCLIB_EISDIR 21 +#define _PDCLIB_ELOOP 114 +#define _PDCLIB_EMFILE 24 +#define _PDCLIB_EMLINK 31 +#define _PDCLIB_EMSGSIZE 115 +#define _PDCLIB_ENAMETOOLONG 38 +#define _PDCLIB_ENETDOWN 116 +#define _PDCLIB_ENETRESET 117 +#define _PDCLIB_ENETUNREACH 118 +#define _PDCLIB_ENFILE 23 +#define _PDCLIB_ENOBUFS 119 +#define _PDCLIB_ENODATA 120 +#define _PDCLIB_ENODEV 19 +#define _PDCLIB_ENOENT 2 +#define _PDCLIB_ENOEXEC 8 +#define _PDCLIB_ENOLCK 39 +#define _PDCLIB_ENOLINK 121 +#define _PDCLIB_ENOMEM 12 +#define _PDCLIB_ENOMSG 122 +#define _PDCLIB_ENOPROTOOPT 123 +#define _PDCLIB_ENOSPC 28 +#define _PDCLIB_ENOSR 124 +#define _PDCLIB_ENOSTR 125 +#define _PDCLIB_ENOSYS 40 +#define _PDCLIB_ENOTCONN 126 +#define _PDCLIB_ENOTDIR 20 +#define _PDCLIB_ENOTEMPTY 41 +#define _PDCLIB_ENOTRECOVERABLE 127 +#define _PDCLIB_ENOTSOCK 128 +#define _PDCLIB_ENOTSUP 129 +#define _PDCLIB_ENOTTY 25 +#define _PDCLIB_ENXIO 6 +#define _PDCLIB_EOPNOTSUPP 130 +#define _PDCLIB_EOVERFLOW 132 +#define _PDCLIB_EOWNERDEAD 133 +#define _PDCLIB_EPERM 1 +#define _PDCLIB_EPIPE 32 +#define _PDCLIB_EPROTO 134 +#define _PDCLIB_EPROTONOSUPPORT 135 +#define _PDCLIB_EPROTOTYPE 136 +#define _PDCLIB_ERANGE 34 +#define _PDCLIB_EROFS 30 +#define _PDCLIB_ESPIPE 29 +#define _PDCLIB_ESRCH 3 +#define _PDCLIB_ETIME 137 +#define _PDCLIB_ETIMEDOUT 138 +#define _PDCLIB_ETXTBSY 139 +#define _PDCLIB_EWOULDBLOCK 140 +#define _PDCLIB_EXDEV 18 + +/* This is used to set the size of the array in struct lconv () */ +/* holding the error messages for the strerror() and perror() fuctions. If */ +/* you change this value because you are using additional errno values, you */ +/* *HAVE* to provide appropriate error messages for *ALL* locales. */ +/* Needs to be one higher than the highest errno value above. */ +#define _PDCLIB_ERRNO_MAX 141 #endif -- 2.40.0