Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add actual Win32 errno values and error strings #18

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 141 additions & 4 deletions platform/xbox/functions/_PDCLIB/_PDCLIB_stdinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,147 @@ struct _PDCLIB_lc_messages_t _PDCLIB_lc_messages = {
0,
/* _PDCLIB_errno_texts */
{
/* no error */ (char *)"",
/* ERANGE */ (char *)"ERANGE (Range error)",
/* EDOM */ (char *)"EDOM (Domain error)",
/* EILSEQ */ (char *)"EILSEQ (Illegal sequence)"
/* */ (char *)"Success",
/* EPERM */ (char *)"EPERM (Operation not permitted)",
/* ENOENT */ (char *)"ENOENT (No such file or directory)",
/* ESRCH */ (char *)"ESRCH (No such process)",
/* EINTR */ (char *)"EINTR (Interrupted function)",
/* EIO */ (char *)"EIO (I/O error)",
/* ENXIO */ (char *)"ENXIO (No such device or address)",
/* E2BIG */ (char *)"E2BIG (Argument list too long)",
/* ENOEXEC */ (char *)"ENOEXEC (Executable file format error)",
/* EBADF */ (char *)"EBADF (Bad file descriptor)",
/* ECHILD */ (char *)"ECHILD (No child processes)",
/* EAGAIN */ (char *)"EAGAIN (Resource unavailable, try again)",
/* ENOMEM */ (char *)"ENOMEM (Not enough space)",
/* EACCES */ (char *)"EACCES (Permission denied)",
/* EFAULT */ (char *)"EFAULT (Bad address)",
/* unknown error */ (char *)"unknown error",
/* EBUSY */ (char *)"EBUSY (Device or resource busy)",
/* EEXIST */ (char *)"EEXIST (File exists)",
/* EXDEV */ (char *)"EXDEV (Cross-device link)",
/* ENODEV */ (char *)"ENODEV (No such device)",
/* ENOTDIR */ (char *)"ENOTDIR (Not a directory)",
/* EISDIR */ (char *)"EISDIR (Is a directory)",
/* EINVAL */ (char *)"EINVAL (Invalid argument)",
/* ENFILE */ (char *)"ENFILE (Too many files open in system)",
/* EMFILE */ (char *)"EMFILE (File descriptor value too large)",
/* ENOTTY */ (char *)"ENOTTY (Inappropriate I/O control operation)",
/* unknown error */ (char *)"unknown error",
/* EFBIG */ (char *)"EFBIG (File too large)",
/* ENOSPC */ (char *)"ENOSPC (No space left on device)",
/* ESPIPE */ (char *)"ESPIPE (Invalid seek)",
/* EROFS */ (char *)"EROFS (Read-only file system)",
/* EMLINK */ (char *)"EMLINK (Too many links)",
/* EPIPE */ (char *)"EPIPE (Broken pipe)",
/* EDOM */ (char *)"EDOM (Mathematics argument out of domain of function)",
/* ERANGE */ (char *)"ERANGE (Result too large)",
/* unknown error */ (char *)"unknown error",
/* EDEADLK */ (char *)"EDEADLK (Resource deadlock would occur)",
/* unknown error */ (char *)"unknown error",
/* ENAMETOOLONG */ (char *)"ENAMETOOLONG (Filename too long)",
/* ENOLCK */ (char *)"ENOLCK (No locks available)",
/* ENOSYS */ (char *)"ENOSYS (Function not supported)",
/* ENOTEMPTY */ (char *)"ENOTEMPTY (Directory not empty)",
/* EILSEQ */ (char *)"EILSEQ (Illegal byte sequence)",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
/* unknown error */ (char *)"unknown error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: My man page says:

The strerror(), strerror_l(), and the GNU-specific strerror_r() functions return the appropriate error description string, or an "Unknown error nnn" message if the error number is unknown.

I'm not sure if this is a Linux libc thing or C spec thing, but it's weird that the error number is not included here. Or are these values from the MS libc? (I did not look at the mentioned tool and also did not check what strerror does when the error number isn't part of the array).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C standard doesn't have that requirement, although I see the benefit. The "unknown error" message itself comes from the PDCLib tool itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the tool should dump out NULL and then https://github.com/DevSolar/pdclib/blob/8e10fcf7fd3bac2c5640a86fa165e7fa8c411803/functions/string/strerror.c#L14 should be improved to handle those.
Then it would be obvious which messages are from the OS which provided the strerror messages, and which ones are from pdclib. It would also save on binary size (also interesting for embedded platforms).

(Actually it's a bit weird, that the tool generates an array, instead of a switch/case, to avoid large gaps in error numbers)

Wether the handler for unknown messages remains as is (constant string), or provides more context (could sprintf() a number and add new messages to a list at runtime) could be decided later then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned this discussion upstream DevSolar#9

I'd like to wait at least for a response, considering this is a low-priority PR (or is it required for something?).

Copy link

@DevSolar DevSolar Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there... I tinkered a bit with a different approach that removes the "holes" in the array. But that means each entry needs to hold the errno value it refers to, as I can no longer use the array index for the lookup.

That means each of the entries gets sizeof( int ) wider, for saving one sizeof( char * ) per "hole" value... already a marginal saving. And then I need a bit more code for the lookup... long story short, the patched build was larger than the current one by roundabout 300 bytes for a release build. I don't think that is what you're looking for...?!?

A tarball with the patched sources is available at http://rootdirectory.ddns.net/static/pdclib_patch_strerror.tgz if you want to experiment with that version.

/* EADDRINUSE */ (char *)"EADDRINUSE (Address in use)",
/* EADDRNOTAVAIL */ (char *)"EADDRNOTAVAIL (Address not available)",
/* EAFNOSUPPORT */ (char *)"EAFNOSUPPORT (Address family not supported)",
/* EALREADY */ (char *)"EALREADY (Connection already in progress)",
/* EBADMSG */ (char *)"EBADMSG (Bad message)",
/* ECANCELED */ (char *)"ECANCELED (Operation canceled)",
/* ECONNABORTED */ (char *)"ECONNABORTED (Connection aborted)",
/* ECONNREFUSED */ (char *)"ECONNREFUSED (Connection refused)",
/* ECONNRESET */ (char *)"ECONNRESET (Connection reset)",
/* EDESTADDRREQ */ (char *)"EDESTADDRREQ (Destination address required)",
/* EHOSTUNREACH */ (char *)"EHOSTUNREACH (Host is unreachable)",
/* EIDRM */ (char *)"EIDRM (Identifier removed)",
/* EINPROGRESS */ (char *)"EINPROGRESS (Operation in progress)",
/* EISCONN */ (char *)"EISCONN (Socket is connected)",
/* ELOOP */ (char *)"ELOOP (Too many levels of symbolic links)",
/* EMSGSIZE */ (char *)"EMSGSIZE (Message too large)",
/* ENETDOWN */ (char *)"ENETDOWN (Network is down)",
/* ENETRESET */ (char *)"ENETRESET (Connection aborted by network)",
/* ENETUNREACH */ (char *)"ENETUNREACH (Network unreachable)",
/* ENOBUFS */ (char *)"ENOBUFS (No buffer space available)",
/* ENODATA */ (char *)"ENODATA (No message is available on the STREAM head read queue)",
/* ENOLINK */ (char *)"ENOLINK (Link has been severed)",
/* ENOMSG */ (char *)"ENOMSG (No message of the desired type)",
/* ENOPROTOOPT */ (char *)"ENOPROTOOPT (Protocol not available)",
/* ENOSR */ (char *)"ENOSR (No STREAM resources)",
/* ENOSTR */ (char *)"ENOSTR (Not a STREAM)",
/* ENOTCONN */ (char *)"ENOTCONN (The socket is not connected)",
/* ENOTRECOVERABLE */ (char *)"ENOTRECOVERABLE (State not recoverable)",
/* ENOTSOCK */ (char *)"ENOTSOCK (Not a socket)",
/* ENOTSUP */ (char *)"ENOTSUP (Not supported)",
/* EOPNOTSUPP */ (char *)"EOPNOTSUPP (Operation not supported on socket)",
/* unknown error */ (char *)"unknown error",
/* EOVERFLOW */ (char *)"EOVERFLOW (Value too large to be stored in data type)",
/* EOWNERDEAD */ (char *)"EOWNERDEAD (Previous owner died)",
/* EPROTO */ (char *)"EPROTO (Protocol error)",
/* EPROTONOSUPPORT */ (char *)"EPROTONOSUPPORT (Protocol not supported)",
/* EPROTOTYPE */ (char *)"EPROTOTYPE (Protocol wrong type for socket)",
/* ETIME */ (char *)"ETIME (Stream ioctl() timeout)",
/* ETIMEDOUT */ (char *)"ETIMEDOUT (Connection timed out)",
/* ETXTBSY */ (char *)"ETXTBSY (Text file busy)",
/* EWOULDBLOCK */ (char *)"EWOULDBLOCK (Operation would block)"
}
};

Expand Down
95 changes: 47 additions & 48 deletions platform/xbox/include/pdclib/_PDCLIB_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,35 +355,35 @@ typedef int _PDCLIB_fd_t;
/* Permission denied */
#define _PDCLIB_EACCES 13
/* Address in use */
#define _PDCLIB_EADDRINUSE 98
#define _PDCLIB_EADDRINUSE 100
/* Address not available */
#define _PDCLIB_EADDRNOTAVAIL 99
#define _PDCLIB_EADDRNOTAVAIL 101
/* Address family not supported */
#define _PDCLIB_EAFNOSUPPORT 97
#define _PDCLIB_EAFNOSUPPORT 102
/* Resource unavailable, try again */
#define _PDCLIB_EAGAIN 11
/* Connection already in progress */
#define _PDCLIB_EALREADY 114
#define _PDCLIB_EALREADY 103
/* Bad file descriptor */
#define _PDCLIB_EBADF 9
/* Bad message */
#define _PDCLIB_EBADMSG 74
#define _PDCLIB_EBADMSG 104
/* Device or resource busy */
#define _PDCLIB_EBUSY 16
/* Operation canceled */
#define _PDCLIB_ECANCELED 125
#define _PDCLIB_ECANCELED 105
/* No child processes */
#define _PDCLIB_ECHILD 10
/* Connection aborted */
#define _PDCLIB_ECONNABORTED 103
#define _PDCLIB_ECONNABORTED 106
/* Connection refused */
#define _PDCLIB_ECONNREFUSED 111
#define _PDCLIB_ECONNREFUSED 107
/* Connection reset */
#define _PDCLIB_ECONNRESET 104
#define _PDCLIB_ECONNRESET 108
/* Resource deadlock would occur */
#define _PDCLIB_EDEADLK 35
#define _PDCLIB_EDEADLK 36
/* Destination address required */
#define _PDCLIB_EDESTADDRREQ 89
#define _PDCLIB_EDESTADDRREQ 109
/* Mathematics argument out of domain of function */
#define _PDCLIB_EDOM 33
/* File exists */
Expand All @@ -393,101 +393,101 @@ typedef int _PDCLIB_fd_t;
/* File too large */
#define _PDCLIB_EFBIG 27
/* Host is unreachable */
#define _PDCLIB_EHOSTUNREACH 113
#define _PDCLIB_EHOSTUNREACH 110
/* Identifier removed */
#define _PDCLIB_EIDRM 43
#define _PDCLIB_EIDRM 111
/* Illegal byte sequence */
#define _PDCLIB_EILSEQ 84
#define _PDCLIB_EILSEQ 42
/* Operation in progress */
#define _PDCLIB_EINPROGRESS 115
#define _PDCLIB_EINPROGRESS 112
/* Interrupted function */
#define _PDCLIB_EINTR 4
/* Invalid argument */
#define _PDCLIB_EINVAL 22
/* I/O error */
#define _PDCLIB_EIO 5
/* Socket is connected */
#define _PDCLIB_EISCONN 106
#define _PDCLIB_EISCONN 113
/* Is a directory */
#define _PDCLIB_EISDIR 21
/* Too many levels of symbolic links */
#define _PDCLIB_ELOOP 40
#define _PDCLIB_ELOOP 114
/* File descriptor value too large */
#define _PDCLIB_EMFILE 24
/* Too many links */
#define _PDCLIB_EMLINK 31
/* Message too large */
#define _PDCLIB_EMSGSIZE 90
#define _PDCLIB_EMSGSIZE 115
/* Filename too long */
#define _PDCLIB_ENAMETOOLONG 36
#define _PDCLIB_ENAMETOOLONG 38
/* Network is down */
#define _PDCLIB_ENETDOWN 100
#define _PDCLIB_ENETDOWN 116
/* Connection aborted by network */
#define _PDCLIB_ENETRESET 102
#define _PDCLIB_ENETRESET 117
/* Network unreachable */
#define _PDCLIB_ENETUNREACH 101
#define _PDCLIB_ENETUNREACH 118
/* Too many files open in system */
#define _PDCLIB_ENFILE 23
/* No buffer space available */
#define _PDCLIB_ENOBUFS 105
#define _PDCLIB_ENOBUFS 119
/* No message is available on the STREAM head read queue */
#define _PDCLIB_ENODATA 61
#define _PDCLIB_ENODATA 120
/* No such device */
#define _PDCLIB_ENODEV 19
/* No such file or directory */
#define _PDCLIB_ENOENT 2
/* Executable file format error */
#define _PDCLIB_ENOEXEC 8
/* No locks available */
#define _PDCLIB_ENOLCK 37
#define _PDCLIB_ENOLCK 39
/* Link has been severed */
#define _PDCLIB_ENOLINK 67
#define _PDCLIB_ENOLINK 121
/* Not enough space */
#define _PDCLIB_ENOMEM 12
/* No message of the desired type */
#define _PDCLIB_ENOMSG 42
#define _PDCLIB_ENOMSG 122
/* Protocol not available */
#define _PDCLIB_ENOPROTOOPT 92
#define _PDCLIB_ENOPROTOOPT 123
/* No space left on device */
#define _PDCLIB_ENOSPC 28
/* No STREAM resources */
#define _PDCLIB_ENOSR 63
#define _PDCLIB_ENOSR 124
/* Not a STREAM */
#define _PDCLIB_ENOSTR 60
#define _PDCLIB_ENOSTR 125
/* Function not supported */
#define _PDCLIB_ENOSYS 38
#define _PDCLIB_ENOSYS 40
/* The socket is not connected */
#define _PDCLIB_ENOTCONN 107
#define _PDCLIB_ENOTCONN 126
/* Not a directory */
#define _PDCLIB_ENOTDIR 20
/* Directory not empty */
#define _PDCLIB_ENOTEMPTY 39
#define _PDCLIB_ENOTEMPTY 41
/* State not recoverable */
#define _PDCLIB_ENOTRECOVERABLE 131
#define _PDCLIB_ENOTRECOVERABLE 127
/* Not a socket */
#define _PDCLIB_ENOTSOCK 88
#define _PDCLIB_ENOTSOCK 128
/* Not supported */
#define _PDCLIB_ENOTSUP 95
#define _PDCLIB_ENOTSUP 129
/* Inappropriate I/O control operation */
#define _PDCLIB_ENOTTY 25
/* No such device or address */
#define _PDCLIB_ENXIO 6
/* Operation not supported on socket */
#define _PDCLIB_EOPNOTSUPP 95
#define _PDCLIB_EOPNOTSUPP 130
/* Value too large to be stored in data type */
#define _PDCLIB_EOVERFLOW 75
#define _PDCLIB_EOVERFLOW 132
/* Previous owner died */
#define _PDCLIB_EOWNERDEAD 130
#define _PDCLIB_EOWNERDEAD 133
/* Operation not permitted */
#define _PDCLIB_EPERM 1
/* Broken pipe */
#define _PDCLIB_EPIPE 32
/* Protocol error */
#define _PDCLIB_EPROTO 71
#define _PDCLIB_EPROTO 134
/* Protocol not supported */
#define _PDCLIB_EPROTONOSUPPORT 93
#define _PDCLIB_EPROTONOSUPPORT 135
/* Protocol wrong type for socket */
#define _PDCLIB_EPROTOTYPE 91
#define _PDCLIB_EPROTOTYPE 136
/* Result too large */
#define _PDCLIB_ERANGE 34
/* Read-only file system */
Expand All @@ -497,13 +497,13 @@ typedef int _PDCLIB_fd_t;
/* No such process */
#define _PDCLIB_ESRCH 3
/* Stream ioctl() timeout */
#define _PDCLIB_ETIME 62
#define _PDCLIB_ETIME 137
/* Connection timed out */
#define _PDCLIB_ETIMEDOUT 110
#define _PDCLIB_ETIMEDOUT 138
/* Text file busy */
#define _PDCLIB_ETXTBSY 26
#define _PDCLIB_ETXTBSY 139
/* Operation would block */
#define _PDCLIB_EWOULDBLOCK 11
#define _PDCLIB_EWOULDBLOCK 140
/* Cross-device link */
#define _PDCLIB_EXDEV 18

Expand All @@ -512,8 +512,7 @@ typedef int _PDCLIB_fd_t;
/* 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 132
#define _PDCLIB_ERRNO_MAX 141

/* The error message used for unknown error codes (generated by errno_readout */
/* for consistency between the 'holes' in the list of defined error messages */
Expand Down