Forgot "cvs add", so only the surrounding changes made it... sigh.
[openssl.git] / e_os2.h
diff --git a/e_os2.h b/e_os2.h
index 4785720a5c4c26d413840d7d5aceaa8cca49018d..ed90f222e2180c2c5b20cc5660cd8acfb69ad58a 100644 (file)
--- a/e_os2.h
+++ b/e_os2.h
  *
  */
 
+#include <openssl/opensslconf.h>
+
 #ifndef HEADER_E_OS2_H
 #define HEADER_E_OS2_H
 
-#include <openssl/opensslconf.h> /* OPENSSL_UNISTD */
-
 #ifdef  __cplusplus
 extern "C" {
 #endif
@@ -108,6 +108,24 @@ extern "C" {
 #if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT)
 # undef OPENSSL_SYS_UNIX
 # define OPENSSL_SYS_WINDOWS
+# ifndef OPENSSL_SYS_MSDOS
+#  define OPENSSL_SYS_MSDOS
+# endif
+#endif
+
+/* DLL settings.  This part is a bit tough, because it's up to the application
+   implementor how he or she will link the application, so it requires some
+   macro to be used. */
+#ifdef OPENSSL_SYS_WINDOWS
+# ifndef OPENSSL_OPT_WINDLL
+#  if defined(_WINDLL) /* This is used when building OpenSSL to indicate that
+                          DLL linkage should be used */
+#   define OPENSSL_OPT_WINDLL
+#  elif defined(_DLL) /* This one is used quite much in the VC++ header
+                         files */
+#   define OPENSSL_OPT_WINDLL
+#  endif
+# endif
 #endif
 
 /* -------------------------------- OpenVMS -------------------------------- */
@@ -186,7 +204,7 @@ extern "C" {
 # define OPENSSL_EXPORT globalref
 # define OPENSSL_IMPORT globalref
 # define OPENSSL_GLOBAL globaldef
-#elif defined(OPENSSL_SYS_WINDOWS)
+#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
 # define OPENSSL_EXPORT extern _declspec(dllexport)
 # define OPENSSL_IMPORT extern _declspec(dllimport)
 # define OPENSSL_GLOBAL
@@ -197,6 +215,28 @@ extern "C" {
 #endif
 #define OPENSSL_EXTERN OPENSSL_IMPORT
 
+/* Macros to allow global variables to be reached through function calls when
+   required (if a shared library version requvres it, for example.
+   The way it's done allows definitions like this:
+
+       // in foobar.c
+       OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0;
+       // in foobar.h
+       OPENSSL_DECLARE_GLOBAL(int,foobar);
+       #define foobar OPENSSL_GLOBAL_REF(foobar)
+*/
+#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
+# define OPENSSL_IMPLEMENT_GLOBAL(type,name) extern static type _hide_##name; \
+        type *_shadow_##name(void) { static type local_var; return &local_var; } \
+        static type _hide_##name
+# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)
+# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))
+#else
+# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name
+# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
+# define OPENSSL_GLOBAL_REF(name) _shadow_##name
+#endif
+
 #ifdef  __cplusplus
 }
 #endif