Update from 1.0.0-stable
[openssl.git] / e_os.h
diff --git a/e_os.h b/e_os.h
index 01d7963ecc93019a7462436bd2519e752ac0c63d..0f4b7994f55efb5f964e225c24c7d349ddeb6ab2 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -112,7 +112,7 @@ extern "C" {
 /********************************************************************
  The Microsoft section
  ********************************************************************/
-/* The following is used becaue of the small stack in some
+/* The following is used because of the small stack in some
  * Microsoft operating systems */
 #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)
 #  define MS_STATIC    static
@@ -275,16 +275,17 @@ extern "C" {
 #    if !defined(OPENSSL_NO_SOCK) && defined(_WIN32_WINNT)
        /*
         * Just like defining _WIN32_WINNT including winsock2.h implies
-        * certain "discipline" for maintaing [broad] binary compatibility.
+        * certain "discipline" for maintaining [broad] binary compatibility.
         * As long as structures are invariant among Winsock versions,
         * it's sufficient to check for specific Winsock2 API availability
         * at run-time [DSO_global_lookup is recommended]...
         */
 #      include <winsock2.h>
 #      include <ws2tcpip.h>
-       /* yes, they have to be #included prior <windows.h> */
+       /* yes, they have to be #included prior to <windows.h> */
 #    endif
 #    include <windows.h>
+#    include <stdio.h>
 #    include <stddef.h>
 #    include <errno.h>
 #    include <string.h>
@@ -300,13 +301,38 @@ static unsigned int _strlen31(const char *str)
 #    endif
 #    include <malloc.h>
 #    if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
-       /* compensate for bug is VC6 ctype.h */
+       /* compensate for bug in VC6 ctype.h */
 #      undef isspace
 #      undef isdigit
 #      undef isalnum
 #      undef isupper
 #      undef isxdigit
 #    endif
+#    if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
+#      if _MSC_VER>=1300
+#        undef stdin
+#        undef stdout
+#        undef stderr
+         FILE *__iob_func();
+#        define stdin  (&__iob_func()[0])
+#        define stdout (&__iob_func()[1])
+#        define stderr (&__iob_func()[2])
+#      elif defined(I_CAN_LIVE_WITH_LNK4049)
+#        undef stdin
+#        undef stdout
+#        undef stderr
+         /* pre-1300 has __p__iob(), but it's available only in msvcrt.lib,
+          * or in other words with /MD. Declaring implicit import, i.e.
+          * with _imp_ prefix, works correctly with all compiler options,
+         * but without /MD results in LINK warning LNK4049:
+         * 'locally defined symbol "__iob" imported'.
+          */
+         extern FILE *_imp___iob;
+#        define stdin  (&_imp___iob[0])
+#        define stdout (&_imp___iob[1])
+#        define stderr (&_imp___iob[2])
+#      endif
+#    endif
 #  endif
 #  include <io.h>
 #  include <fcntl.h>
@@ -346,7 +372,7 @@ static unsigned int _strlen31(const char *str)
 #    define DEFAULT_HOME  "C:"
 #  endif
 
-#else /* The non-microsoft world world */
+#else /* The non-microsoft world */
 
 #  ifdef OPENSSL_SYS_VMS
 #    define VMS 1
@@ -598,6 +624,18 @@ static unsigned int _strlen31(const char *str)
 #    define INVALID_SOCKET     (-1)
 #    endif /* INVALID_SOCKET */
 #  endif
+
+/* Some IPv6 implementations are broken, disable them in known bad
+ * versions.
+ */
+#  if !defined(OPENSSL_USE_IPV6)
+#    if defined(AF_INET6) && !defined(OPENSSL_SYS_BEOS_BONE) && !defined(NETWARE_CLIB)
+#      define OPENSSL_USE_IPV6 1
+#    else
+#      define OPENSSL_USE_IPV6 0
+#    endif
+#  endif
+
 #endif
 
 #if defined(__ultrix)