After some adjustments, apply the changes OpenSSL 1.0.0d on OpenVMS
[openssl.git] / crypto / bio / b_sock.c
index 5ea621c0cf865c8202b5313ede04459fe9c8c44c..54112e6ebe4eaca20b5e7438bc114e0ece684ab7 100644 (file)
@@ -551,7 +551,30 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
 #ifdef __DJGPP__
        i=ioctlsocket(fd,type,(char *)arg);
 #else
-       i=ioctlsocket(fd,type,arg);
+# if defined(OPENSSL_SYS_VMS)
+       /* 2011-02-18 SMS.
+        * VMS ioctl() can't tolerate a 64-bit "void *arg", but we
+        * observe that all the consumers pass in an "unsigned long *",
+        * so we arrange a local copy with a short pointer, and use
+        * that, instead.
+        */
+#  if __INITIAL_POINTER_SIZE == 64
+#   define ARG arg_32p
+#   pragma pointer_size save
+#   pragma pointer_size 32
+       unsigned long arg_32;
+       unsigned long *arg_32p;
+#   pragma pointer_size restore
+       arg_32p = &arg_32;
+       arg_32 = *((unsigned long *) arg);
+#  else /* __INITIAL_POINTER_SIZE == 64 */
+#   define ARG arg
+#  endif /* __INITIAL_POINTER_SIZE == 64 [else] */
+# else /* defined(OPENSSL_SYS_VMS) */
+#  define ARG arg
+# endif /* defined(OPENSSL_SYS_VMS) [else] */
+
+       i=ioctlsocket(fd,type,ARG);
 #endif /* __DJGPP__ */
        if (i < 0)
                SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error());
@@ -731,7 +754,14 @@ again:
 #ifdef SO_REUSEADDR
                err_num=get_last_socket_error();
                if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) &&
+#ifdef OPENSSL_SYS_WINDOWS
+                       /* Some versions of Windows define EADDRINUSE to
+                        * a dummy value.
+                        */
+                       (err_num == WSAEADDRINUSE))
+#else
                        (err_num == EADDRINUSE))
+#endif
                        {
                        client = server;
                        if (h == NULL || strcmp(h,"*") == 0)