Commit 9fc35dbf authored by Dan Winship's avatar Dan Winship

gioerror: map some more values to G_IO_ERROR_NOT_SUPPORTED

Map EPROTONOSUPPORT, ESOCKTNOSUPPORT, EPFNOSUPPORT and EAFNOSUPPORT to
G_IO_ERROR_NOT_SUPPORTED in g_io_error_from_errno(). (GSocket's
socket_io_error_from_errno() already did this with the corresponding
Winsock errors.)

Also map EOPNOTSUPP, which on Linux is the same as ENOTSUP, but may
not be on other platforms.

Also, rewrite the EAGAIN/EWOULDBLOCK section to use the simpler idiom
used by EEXIST/ENOTEMPTY and (now) ENOTSUP/EOPNOTSUPP.
parent 0afd6d22
......@@ -432,7 +432,7 @@ typedef enum {
* @G_IO_ERROR_NO_SPACE: No space left on drive.
* @G_IO_ERROR_INVALID_ARGUMENT: Invalid argument.
* @G_IO_ERROR_PERMISSION_DENIED: Permission denied.
* @G_IO_ERROR_NOT_SUPPORTED: Operation not supported for the current backend.
* @G_IO_ERROR_NOT_SUPPORTED: Operation (or one of its parameters) not supported
* @G_IO_ERROR_NOT_MOUNTED: File isn't mounted.
* @G_IO_ERROR_ALREADY_MOUNTED: File is already mounted.
* @G_IO_ERROR_CLOSED: File was closed.
......
......@@ -134,7 +134,8 @@ g_io_error_from_errno (gint err_no)
break;
#endif
#if defined(ENOTEMPTY) && (!defined (EEXIST) || (ENOTEMPTY != EEXIST))
/* ENOTEMPTY == EEXIST on AIX for backward compatibility reasons */
#if defined (ENOTEMPTY) && (!defined (EEXIST) || (ENOTEMPTY != EEXIST))
case ENOTEMPTY:
return G_IO_ERROR_NOT_EMPTY;
break;
......@@ -146,6 +147,37 @@ g_io_error_from_errno (gint err_no)
break;
#endif
/* EOPNOTSUPP == ENOTSUP on Linux, but POSIX considers them distinct */
#if defined (EOPNOTSUPP) && (!defined (ENOTSUP) || (EOPNOTSUPP != ENOTSUP))
case EOPNOTSUPP:
return G_IO_ERROR_NOT_SUPPORTED;
break;
#endif
#ifdef EPROTONOSUPPORT
case EPROTONOSUPPORT:
return G_IO_ERROR_NOT_SUPPORTED;
break;
#endif
#ifdef ESOCKTNOSUPPORT
case ESOCKTNOSUPPORT:
return G_IO_ERROR_NOT_SUPPORTED;
break;
#endif
#ifdef EPFNOSUPPORT
case EPFNOSUPPORT:
return G_IO_ERROR_NOT_SUPPORTED;
break;
#endif
#ifdef EAFNOSUPPORT
case EAFNOSUPPORT:
return G_IO_ERROR_NOT_SUPPORTED;
break;
#endif
#ifdef ETIMEDOUT
case ETIMEDOUT:
return G_IO_ERROR_TIMED_OUT;
......@@ -158,30 +190,17 @@ g_io_error_from_errno (gint err_no)
break;
#endif
/* some magic to deal with EWOULDBLOCK and EAGAIN.
* apparently on HP-UX these are actually defined to different values,
* but on Linux, for example, they are the same.
*/
#if defined(EWOULDBLOCK) && defined(EAGAIN) && EWOULDBLOCK == EAGAIN
/* we have both and they are the same: only emit one case. */
case EAGAIN:
return G_IO_ERROR_WOULD_BLOCK;
break;
#else
/* else: consider each of them separately. this handles both the
* case of having only one and the case where they are different values.
*/
# ifdef EAGAIN
case EAGAIN:
#ifdef EWOULDBLOCK
case EWOULDBLOCK:
return G_IO_ERROR_WOULD_BLOCK;
break;
# endif
#endif
# ifdef EWOULDBLOCK
case EWOULDBLOCK:
/* EWOULDBLOCK == EAGAIN on most systems, but POSIX considers them distinct */
#if defined (EAGAIN) && (!defined (EWOULDBLOCK) || (EWOULDBLOCK != EAGAIN))
case EAGAIN:
return G_IO_ERROR_WOULD_BLOCK;
break;
# endif
#endif
#ifdef EMFILE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment