Windows: conditionalize mappings of error values
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 1 Aug 2011 15:05:51 +0000 (11:05 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Mon, 1 Aug 2011 17:42:55 +0000 (10:42 -0700)
Visual Studio 10 adds a large number of additional POSIX C99
error values to errno.h.  Wrap each mapping with #ifndef to ensure
that we do not redefine the C runtime errno.h definition.

Change-Id: Ia6929d9ff84358059efcc4a53dcc91ee2612fc5a
Reviewed-on: http://gerrit.openafs.org/5129
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/util/errmap_nt.h

index 9f8b692..6e9dd66 100644 (file)
 /* Declare NT to Unix-ish error translation function */
 extern int nterr_nt2unix(long ntErr, int defaultErr);
 
-/* Include native error code definitions */
+/* Include C Runtime Library error code definitions */
 #include <errno.h>
 
-/* Define additional local codes beyond NT errno range. */
+/*
+ * Define additional POSIX codes not specified by
+ * Visual Studio.  Different versions include different
+ * error code definitions.  If an error is not declared
+ * by the C Runtime Library, define it using the equivalent
+ * Winsock error.  If there is no Winsock equivalent,
+ * define an AFS private value in the Winsock space.
+ */
 
 /* Overloaded codes. */
 #ifndef EWOULDBLOCK
 #define EWOULDBLOCK        WSAEWOULDBLOCK
 #endif
 
+#ifndef EINPROGRESS
 #define EINPROGRESS             WSAEINPROGRESS
+#endif
+#ifndef EALREADY
 #define EALREADY                WSAEALREADY
+#endif
+#ifndef ENOTSOCK
 #define ENOTSOCK                WSAENOTSOCK
-#define EDESTADDRREQ            WSAEDESTADDRREQ
+#endif
+#ifndef EDESTADDRREQ
+#define EDESTADDRREQ           WSAEDESTADDRREQ
+#endif
+#ifndef EMSGSIZE
 #define EMSGSIZE                WSAEMSGSIZE
+#endif
+#ifndef EPROTOTYPE
 #define EPROTOTYPE              WSAEPROTOTYPE
+#endif
+#ifndef ENOPROTOOPT
 #define ENOPROTOOPT             WSAENOPROTOOPT
+#endif
+#ifndef EPROTONOSUPPORT
 #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
+#endif
+#ifndef ESOCKTNOSUPPORT
 #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
+#endif
+#ifndef EOPNOTSUPP
 #define EOPNOTSUPP              WSAEOPNOTSUPP
+#endif
+#ifndef EPFNOSUPPORT
 #define EPFNOSUPPORT            WSAEPFNOSUPPORT
+#endif
+#ifndef EAFNOSUPPORT
 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
+#endif
+#ifndef EADDRINUSE
 #define EADDRINUSE              WSAEADDRINUSE
+#endif
+#ifndef EADDRNOTAVAIL
 #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
+#endif
+#ifndef ENETDOWN
 #define ENETDOWN                WSAENETDOWN
+#endif
+#ifndef ENETUNREACH
 #define ENETUNREACH             WSAENETUNREACH
+#endif
+#ifndef ENETRESET
 #define ENETRESET               WSAENETRESET
+#endif
+#ifndef ECONNABORTED
 #define ECONNABORTED            WSAECONNABORTED
+#endif
+#ifndef ECONNRESET
 #define ECONNRESET              WSAECONNRESET
+#endif
+#ifndef ENOBUFS
 #define ENOBUFS                 WSAENOBUFS
+#endif
+#ifndef EISCONN
 #define EISCONN                 WSAEISCONN
+#endif
+#ifndef ENOTCONN
 #define ENOTCONN                WSAENOTCONN
+#endif
+#ifndef ESHUTDOWN
 #define ESHUTDOWN               WSAESHUTDOWN
+#endif
+#ifndef ETOOMANYREFS
 #define ETOOMANYREFS            WSAETOOMANYREFS
+#endif
+#ifndef ETIMEDOUT
 #define ETIMEDOUT               WSAETIMEDOUT
+#endif
+#ifndef ECONNREFUSED
 #define ECONNREFUSED            WSAECONNREFUSED
-#ifdef ELOOP
-#undef ELOOP
 #endif
+#ifndef ELOOP
 #define ELOOP                   WSAELOOP
-#ifdef ENAMETOOLONG
-#undef ENAMETOOLONG
 #endif
+#ifndef ENAMETOOLONG
 #define ENAMETOOLONG            WSAENAMETOOLONG
+#endif
+#ifndef EHOSTDOWN
 #define EHOSTDOWN               WSAEHOSTDOWN
+#endif
+#ifndef EHOSTUNREACH
 #define EHOSTUNREACH            WSAEHOSTUNREACH
-#ifdef ENOTEMPTY
-#undef ENOTEMPTY
 #endif
+#ifndef ENOTEMPTY
 #define ENOTEMPTY               WSAENOTEMPTY
+#endif
+#ifndef EPROCLIM
 #define EPROCLIM                WSAEPROCLIM
+#endif
+#ifndef EUSERS
 #define EUSERS                  WSAEUSERS
+#endif
+#ifndef EDQUOT
 #define EDQUOT                  WSAEDQUOT
+#endif
+#ifndef ESTALE
 #define ESTALE                  WSAESTALE
+#endif
+#ifndef EREMOTE
 #define EREMOTE                 WSAEREMOTE
+#endif
 
 /*
  * New codes
@@ -75,10 +145,18 @@ extern int nterr_nt2unix(long ntErr, int defaultErr);
  */
 #define AFS_NT_ERRNO_BASE  WSABASEERR + 1100
 
+#ifndef EOVERFLOW
 #define EOVERFLOW          (AFS_NT_ERRNO_BASE + 0)
+#endif
+#ifndef ENOMSG
 #define ENOMSG             (AFS_NT_ERRNO_BASE + 1)
+#endif
+#ifndef ETIME
 #define ETIME              (AFS_NT_ERRNO_BASE + 2)
+#endif
+#ifndef ENOTBLK
 #define ENOTBLK                   (AFS_NT_ERRNO_BASE + 3)
+#endif
 
 #endif /* OPENAFS_ERRMAP_NT_H  */