summary refs log tree commit diff stats
path: root/lib/wrappers
diff options
context:
space:
mode:
authorDaniil Yarancev <21169548+Yardanico@users.noreply.github.com>2018-06-05 21:25:45 +0300
committerGitHub <noreply@github.com>2018-06-05 21:25:45 +0300
commit642641359821b6a63c6cf7edaaa45873b7ea59c7 (patch)
tree627af3020528cb916b3174bd94304307ca875c77 /lib/wrappers
parentfb44c522e6173528efa8035ecc459c84887d0167 (diff)
parent3cbc07ac7877b03c605498760fe198e3200cc197 (diff)
downloadNim-642641359821b6a63c6cf7edaaa45873b7ea59c7.tar.gz
Merge pull request #2 from nim-lang/devel
Update
Diffstat (limited to 'lib/wrappers')
-rw-r--r--lib/wrappers/iup.nim2
-rw-r--r--lib/wrappers/joyent_http_parser.nim93
-rw-r--r--lib/wrappers/libsvm.nim117
-rw-r--r--lib/wrappers/mysql.nim8
-rw-r--r--lib/wrappers/odbcsql.nim2
-rw-r--r--lib/wrappers/openssl.nim129
-rw-r--r--lib/wrappers/pcre.nim2
-rw-r--r--lib/wrappers/postgres.nim2
-rw-r--r--lib/wrappers/sqlite3.nim2
9 files changed, 105 insertions, 252 deletions
diff --git a/lib/wrappers/iup.nim b/lib/wrappers/iup.nim
index d910173ca..dee2e14c7 100644
--- a/lib/wrappers/iup.nim
+++ b/lib/wrappers/iup.nim
@@ -34,7 +34,7 @@
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 # ****************************************************************************
 
-{.deadCodeElim: on.}
+{.deadCodeElim: on.}  # dce option deprecated
 
 when defined(windows):
   const dllname = "iup(|30|27|26|25|24).dll"
diff --git a/lib/wrappers/joyent_http_parser.nim b/lib/wrappers/joyent_http_parser.nim
deleted file mode 100644
index f7412d2b8..000000000
--- a/lib/wrappers/joyent_http_parser.nim
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-#
-#            Nim's Runtime Library
-#        (c) Copyright 2015 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-type
-  csize = int
-
-  HttpDataProc* = proc (a2: ptr HttpParser, at: cstring, length: csize): cint {.cdecl.}
-  HttpProc* = proc (a2: ptr HttpParser): cint {.cdecl.}
-
-  HttpMethod* = enum
-    HTTP_DELETE = 0, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_CONNECT,
-    HTTP_OPTIONS, HTTP_TRACE, HTTP_COPY, HTTP_LOCK, HTTP_MKCOL, HTTP_MOVE,
-    HTTP_PROPFIND, HTTP_PROPPATCH, HTTP_UNLOCK, HTTP_REPORT, HTTP_MKACTIVITY,
-    HTTP_CHECKOUT, HTTP_MERGE, HTTP_MSEARCH, HTTP_NOTIFY, HTTP_SUBSCRIBE,
-    HTTP_UNSUBSCRIBE, HTTP_PATCH
-
-  HttpParserType* = enum
-    HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH
-
-  ParserFlag* = enum
-    F_CHUNKED = 1 shl 0,
-    F_CONNECTION_KEEP_ALIVE = 1 shl 1,
-    F_CONNECTION_CLOSE = 1 shl 2,
-    F_TRAILING = 1 shl 3,
-    F_UPGRADE = 1 shl 4,
-    F_SKIPBODY = 1 shl 5
-
-  HttpErrNo* = enum
-    HPE_OK, HPE_CB_message_begin, HPE_CB_path, HPE_CB_query_string, HPE_CB_url,
-    HPE_CB_fragment, HPE_CB_header_field, HPE_CB_header_value,
-    HPE_CB_headers_complete, HPE_CB_body, HPE_CB_message_complete,
-    HPE_INVALID_EOF_STATE, HPE_HEADER_OVERFLOW, HPE_CLOSED_CONNECTION,
-    HPE_INVALID_VERSION, HPE_INVALID_STATUS, HPE_INVALID_METHOD,
-    HPE_INVALID_URL, HPE_INVALID_HOST, HPE_INVALID_PORT, HPE_INVALID_PATH,
-    HPE_INVALID_QUERY_STRING, HPE_INVALID_FRAGMENT, HPE_LF_EXPECTED,
-    HPE_INVALID_HEADER_TOKEN, HPE_INVALID_CONTENT_LENGTH,
-    HPE_INVALID_CHUNK_SIZE, HPE_INVALID_CONSTANT, HPE_INVALID_INTERNAL_STATE,
-    HPE_STRICT, HPE_UNKNOWN
-
-  HttpParser*{.pure, final, importc: "http_parser", header: "http_parser.h".} = object
-    typ {.importc: "type".}: char
-    flags {.importc: "flags".}: char
-    state*{.importc: "state".}: char
-    header_state*{.importc: "header_state".}: char
-    index*{.importc: "index".}: char
-    nread*{.importc: "nread".}: cint
-    content_length*{.importc: "content_length".}: int64
-    http_major*{.importc: "http_major".}: cshort
-    http_minor*{.importc: "http_minor".}: cshort
-    status_code*{.importc: "status_code".}: cshort
-    http_method*{.importc: "method".}: cshort
-    http_errno_bits {.importc: "http_errno".}: char
-    upgrade {.importc: "upgrade".}: bool
-    data*{.importc: "data".}: pointer
-
-  HttpParserSettings*{.pure, final, importc: "http_parser_settings", header: "http_parser.h".} = object
-    on_message_begin*{.importc: "on_message_begin".}: HttpProc
-    on_url*{.importc: "on_url".}: HttpDataProc
-    on_header_field*{.importc: "on_header_field".}: HttpDataProc
-    on_header_value*{.importc: "on_header_value".}: HttpDataProc
-    on_headers_complete*{.importc: "on_headers_complete".}: HttpProc
-    on_body*{.importc: "on_body".}: HttpDataProc
-    on_message_complete*{.importc: "on_message_complete".}: HttpProc
-{.deprecated: [THttpMethod: HttpMethod, THttpParserType: HttpParserType,
-              TParserFlag: ParserFlag, THttpErrNo: HttpErrNo,
-              THttpParser: HttpParser, THttpParserSettings: HttpParserSettings].}
-
-proc http_parser_init*(parser: var HttpParser, typ: HttpParserType){.
-    importc: "http_parser_init", header: "http_parser.h".}
-
-proc http_parser_execute*(parser: var HttpParser,
-                          settings: var HttpParserSettings, data: cstring,
-                          len: csize): csize {.
-    importc: "http_parser_execute", header: "http_parser.h".}
-
-proc http_should_keep_alive*(parser: var HttpParser): cint{.
-    importc: "http_should_keep_alive", header: "http_parser.h".}
-
-proc http_method_str*(m: HttpMethod): cstring{.
-    importc: "http_method_str", header: "http_parser.h".}
-
-proc http_errno_name*(err: HttpErrNo): cstring{.
-    importc: "http_errno_name", header: "http_parser.h".}
-
-proc http_errno_description*(err: HttpErrNo): cstring{.
-    importc: "http_errno_description", header: "http_parser.h".}
-
diff --git a/lib/wrappers/libsvm.nim b/lib/wrappers/libsvm.nim
deleted file mode 100644
index ac5889410..000000000
--- a/lib/wrappers/libsvm.nim
+++ /dev/null
@@ -1,117 +0,0 @@
-#
-#
-#            Nim's Runtime Library
-#        (c) Copyright 2012 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module is a low level wrapper for `libsvm`:idx:.
-
-{.deadCodeElim: on.}
-const
-  LIBSVM_VERSION* = 312
-
-when defined(windows):
-  const svmdll* = "libsvm.dll"
-elif defined(macosx):
-  const svmdll* = "libsvm.dylib"
-else:
-  const svmdll* = "libsvm.so"
-
-type
-  Node*{.pure, final.} = object
-    index*: cint
-    value*: cdouble
-
-  Problem*{.pure, final.} = object
-    L*: cint
-    y*: ptr cdouble
-    x*: ptr ptr Node
-
-  Type*{.size: sizeof(cint).} = enum
-    C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR
-
-  KernelType*{.size: sizeof(cint).} = enum
-    LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED
-
-  Parameter*{.pure, final.} = object
-    typ*: Type
-    kernelType*: KernelType
-    degree*: cint             # for poly
-    gamma*: cdouble           # for poly/rbf/sigmoid
-    coef0*: cdouble           # for poly/sigmoid
-                              # these are for training only
-    cache_size*: cdouble      # in MB
-    eps*: cdouble             # stopping criteria
-    C*: cdouble               # for C_SVC, EPSILON_SVR and NU_SVR
-    nr_weight*: cint          # for C_SVC
-    weight_label*: ptr cint   # for C_SVC
-    weight*: ptr cdouble      # for C_SVC
-    nu*: cdouble              # for NU_SVC, ONE_CLASS, and NU_SVR
-    p*: cdouble               # for EPSILON_SVR
-    shrinking*: cint          # use the shrinking heuristics
-    probability*: cint        # do probability estimates
-{.deprecated: [Tnode: Node, Tproblem: Problem, Ttype: Type,
-              TKernelType: KernelType, Tparameter: Parameter].}
-
-#
-# svm_model
-#
-
-type
-  Model*{.pure, final.} = object
-    param*: Parameter         # parameter
-    nr_class*: cint           # number of classes, = 2 in regression/one class svm
-    L*: cint                  # total #SV
-    SV*: ptr ptr Node         # SVs (SV[l])
-    sv_coef*: ptr ptr cdouble # coefficients for SVs in decision functions (sv_coef[k-1][l])
-    rho*: ptr cdouble         # constants in decision functions (rho[k*(k-1)/2])
-    probA*: ptr cdouble       # pariwise probability information
-    probB*: ptr cdouble       # for classification only
-    label*: ptr cint          # label of each class (label[k])
-    nSV*: ptr cint            # number of SVs for each class (nSV[k])
-                              # nSV[0] + nSV[1] + ... + nSV[k-1] = l
-                              # XXX
-    free_sv*: cint            # 1 if svm_model is created by svm_load_model
-                              # 0 if svm_model is created by svm_train
-{.deprecated: [TModel: Model].}
-
-proc train*(prob: ptr Problem, param: ptr Parameter): ptr Model{.cdecl,
-    importc: "svm_train", dynlib: svmdll.}
-proc cross_validation*(prob: ptr Problem, param: ptr Parameter, nr_fold: cint,
-                       target: ptr cdouble){.cdecl,
-    importc: "svm_cross_validation", dynlib: svmdll.}
-proc save_model*(model_file_name: cstring, model: ptr Model): cint{.cdecl,
-    importc: "svm_save_model", dynlib: svmdll.}
-proc load_model*(model_file_name: cstring): ptr Model{.cdecl,
-    importc: "svm_load_model", dynlib: svmdll.}
-proc get_svm_type*(model: ptr Model): cint{.cdecl, importc: "svm_get_svm_type",
-    dynlib: svmdll.}
-proc get_nr_class*(model: ptr Model): cint{.cdecl, importc: "svm_get_nr_class",
-    dynlib: svmdll.}
-proc get_labels*(model: ptr Model, label: ptr cint){.cdecl,
-    importc: "svm_get_labels", dynlib: svmdll.}
-proc get_svr_probability*(model: ptr Model): cdouble{.cdecl,
-    importc: "svm_get_svr_probability", dynlib: svmdll.}
-proc predict_values*(model: ptr Model, x: ptr Node, dec_values: ptr cdouble): cdouble{.
-    cdecl, importc: "svm_predict_values", dynlib: svmdll.}
-proc predict*(model: ptr Model, x: ptr Node): cdouble{.cdecl,
-    importc: "svm_predict", dynlib: svmdll.}
-proc predict_probability*(model: ptr Model, x: ptr Node,
-                          prob_estimates: ptr cdouble): cdouble{.cdecl,
-    importc: "svm_predict_probability", dynlib: svmdll.}
-proc free_model_content*(model_ptr: ptr Model){.cdecl,
-    importc: "svm_free_model_content", dynlib: svmdll.}
-proc free_and_destroy_model*(model_ptr_ptr: ptr ptr Model){.cdecl,
-    importc: "svm_free_and_destroy_model", dynlib: svmdll.}
-proc destroy_param*(param: ptr Parameter){.cdecl, importc: "svm_destroy_param",
-    dynlib: svmdll.}
-proc check_parameter*(prob: ptr Problem, param: ptr Parameter): cstring{.
-    cdecl, importc: "svm_check_parameter", dynlib: svmdll.}
-proc check_probability_model*(model: ptr Model): cint{.cdecl,
-    importc: "svm_check_probability_model", dynlib: svmdll.}
-
-proc set_print_string_function*(print_func: proc (arg: cstring) {.cdecl.}){.
-    cdecl, importc: "svm_set_print_string_function", dynlib: svmdll.}
diff --git a/lib/wrappers/mysql.nim b/lib/wrappers/mysql.nim
index 6dbed23b3..06c663822 100644
--- a/lib/wrappers/mysql.nim
+++ b/lib/wrappers/mysql.nim
@@ -7,19 +7,19 @@
 #    distribution, for details about the copyright.
 #
 
-{.deadCodeElim: on.}
+{.deadCodeElim: on.}  # dce option deprecated
 {.push, callconv: cdecl.}
 
 when defined(Unix):
   when defined(macosx):
     const
-      lib = "libmysqlclient.(15|16|17|18|19|20).dylib"
+      lib = "(libmysqlclient|libmariadbclient)(|.20|.19|.18|.17|.16|.15).dylib"
   else:
     const
-      lib = "libmysqlclient.so.(15|16|17|18|19|20)"
+      lib = "(libmysqlclient|libmariadbclient).so(|.20|.19|.18|.17|.16|.15)"
 when defined(Windows):
   const
-    lib = "libmysql.dll"
+    lib = "(libmysql.dll|libmariadb.dll)"
 type
   my_bool* = bool
   Pmy_bool* = ptr my_bool
diff --git a/lib/wrappers/odbcsql.nim b/lib/wrappers/odbcsql.nim
index 1b2544ec0..43d1c504d 100644
--- a/lib/wrappers/odbcsql.nim
+++ b/lib/wrappers/odbcsql.nim
@@ -7,7 +7,7 @@
 #    distribution, for details about the copyright.
 #
 
-{.deadCodeElim: on.}
+{.deadCodeElim: on.}  # dce option deprecated
 
 when not defined(ODBCVER):
   const
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
index 55b0bc3f8..a24575d11 100644
--- a/lib/wrappers/openssl.nim
+++ b/lib/wrappers/openssl.nim
@@ -8,33 +8,46 @@
 #
 
 ## OpenSSL support
-
-{.deadCodeElim: on.}
+##
+## When OpenSSL is dynamically linked, the wrapper provides partial forward and backward
+## compatibility for OpenSSL versions above and below 1.1.0
+##
+## OpenSSL can also be statically linked using ``--dynlibOverride:ssl`` for OpenSSL >= 1.1.0.
+## If you want to statically link against OpenSSL 1.0.x, you now have to
+## define the ``openssl10`` symbol via ``-d:openssl10``.
+##
+## Build and test examples:
+##
+## .. code-block::
+##   ./bin/nim c -d:ssl -p:. -r tests/untestable/tssl.nim
+##   ./bin/nim c -d:ssl -p:. --dynlibOverride:ssl --passL:-lcrypto --passL:-lssl -r tests/untestable/tssl.nim
+
+{.deadCodeElim: on.}  # dce option deprecated
 
 const useWinVersion = defined(Windows) or defined(nimdoc)
 
 when useWinVersion:
   when not defined(nimOldDlls) and defined(cpu64):
     const
-      DLLSSLName = "(ssleay64|libssl64).dll"
-      DLLUtilName = "libeay64.dll"
+      DLLSSLName* = "(libssl-1_1-x64|ssleay64|libssl64).dll"
+      DLLUtilName* = "(libcrypto-1_1-x64|libeay64).dll"
   else:
     const
-      DLLSSLName = "(ssleay32|libssl32).dll"
-      DLLUtilName = "libeay32.dll"
+      DLLSSLName* = "(libssl-1_1|ssleay32|libssl32).dll"
+      DLLUtilName* =  "(libcrypto-1_1|libeay32).dll"
 
   from winlean import SocketHandle
 else:
-  const
-    versions = "(|.38|.39|.41|.43|.10|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8)"
+  const versions = "(.1.1|.38|.39|.41|.43|.44|.45|.10|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|)"
+
   when defined(macosx):
     const
-      DLLSSLName = "libssl" & versions & ".dylib"
-      DLLUtilName = "libcrypto" & versions & ".dylib"
+      DLLSSLName* = "libssl" & versions & ".dylib"
+      DLLUtilName* = "libcrypto" & versions & ".dylib"
   else:
     const
-      DLLSSLName = "libssl.so" & versions
-      DLLUtilName = "libcrypto.so" & versions
+      DLLSSLName* = "libssl.so" & versions
+      DLLUtilName* = "libcrypto.so" & versions
   from posix import SocketHandle
 
 import dynlib
@@ -140,6 +153,7 @@ const
   SSL_OP_NO_SSLv2* = 0x01000000
   SSL_OP_NO_SSLv3* = 0x02000000
   SSL_OP_NO_TLSv1* = 0x04000000
+  SSL_OP_NO_TLSv1_1* = 0x08000000
   SSL_OP_ALL* = 0x000FFFFF
   SSL_VERIFY_NONE* = 0x00000000
   SSL_VERIFY_PEER* = 0x00000001
@@ -191,16 +205,45 @@ const
 
 proc TLSv1_method*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
 
+# TLS_method(), TLS_server_method(), TLS_client_method() are introduced in 1.1.0
+# and support SSLv3, TLSv1, TLSv1.1 and TLSv1.2
+# SSLv23_method(), SSLv23_server_method(), SSLv23_client_method() are removed in 1.1.0
+
 when compileOption("dynlibOverride", "ssl"):
-  proc SSL_library_init*(): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
-  proc SSL_load_error_strings*() {.cdecl, dynlib: DLLSSLName, importc.}
-  proc SSLv23_client_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+  # Static linking
+
+  when defined(openssl10):
+    proc SSL_library_init*(): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
+    proc SSL_load_error_strings*() {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSLv23_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+  else:
+    proc OPENSSL_init_ssl*(opts: uint64, settings: uint8): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
+    proc SSL_library_init*(): cint {.discardable.} =
+      ## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0
+      return OPENSSL_init_ssl(0.uint64, 0.uint8)
+
+    proc TLS_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSLv23_method*(): PSSL_METHOD =
+      TLS_method()
+
+    proc OpenSSL_version_num(): culong {.cdecl, dynlib: DLLSSLName, importc.}
+
+    proc getOpenSSLVersion*(): culong =
+      ## Return OpenSSL version as unsigned long
+      OpenSSL_version_num()
 
-  proc SSLv23_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSL_load_error_strings*() =
+      ## Removed from OpenSSL 1.1.0
+      # This proc prevents breaking existing code calling SslLoadErrorStrings
+      # Static linking against OpenSSL < 1.1.0 is not supported
+      discard
+
+  template OpenSSL_add_all_algorithms*() = discard
+
+  proc SSLv23_client_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
   proc SSLv2_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
   proc SSLv3_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
 
-  template OpenSSL_add_all_algorithms*() = discard
 else:
   # Here we're trying to stay compatible with openssl 1.0.* and 1.1.*. Some
   # symbols are loaded dynamically and we don't use them if not found.
@@ -223,38 +266,58 @@ else:
       if not dl.isNil:
         result = symAddr(dl, name)
 
+  proc loadPSSLMethod(method1, method2: string): PSSL_METHOD =
+    ## Load <method1> from OpenSSL if available, otherwise <method2>
+    let m1 = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym(method1))
+    if not m1.isNil:
+      return m1()
+    cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym(method2))()
+
   proc SSL_library_init*(): cint {.discardable.} =
-    let theProc = cast[proc(): cint {.cdecl.}](sslSym("SSL_library_init"))
-    if not theProc.isNil: result = theProc()
+    ## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0 otherwise
+    ## SSL_library_init
+    let theProc = cast[proc(opts: uint64, settings: uint8): cint {.cdecl.}](sslSym("OPENSSL_init_ssl"))
+    if not theProc.isNil:
+      return theProc(0, 0)
+    let olderProc = cast[proc(): cint {.cdecl.}](sslSym("SSL_library_init"))
+    if not olderProc.isNil: result = olderProc()
 
   proc SSL_load_error_strings*() =
     let theProc = cast[proc() {.cdecl.}](sslSym("SSL_load_error_strings"))
     if not theProc.isNil: theProc()
 
   proc SSLv23_client_method*(): PSSL_METHOD =
-    let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv23_client_method"))
-    if not theProc.isNil: result = theProc()
-    else: result = TLSv1_method()
+    loadPSSLMethod("SSLv23_client_method", "TLS_client_method")
 
   proc SSLv23_method*(): PSSL_METHOD =
-    let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv23_method"))
-    if not theProc.isNil: result = theProc()
-    else: result = TLSv1_method()
+    loadPSSLMethod("SSLv23_method", "TLS_method")
 
   proc SSLv2_method*(): PSSL_METHOD =
-    let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv2_method"))
-    if not theProc.isNil: result = theProc()
-    else: result = TLSv1_method()
+    loadPSSLMethod("SSLv2_method", "TLS_method")
 
   proc SSLv3_method*(): PSSL_METHOD =
-    let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv3_method"))
-    if not theProc.isNil: result = theProc()
-    else: result = TLSv1_method()
+    loadPSSLMethod("SSLv3_method", "TLS_method")
+
+  proc TLS_method*(): PSSL_METHOD =
+    loadPSSLMethod("TLS_method", "SSLv23_method")
+
+  proc TLS_client_method*(): PSSL_METHOD =
+    loadPSSLMethod("TLS_client_method", "SSLv23_client_method")
+
+  proc TLS_server_method*(): PSSL_METHOD =
+    loadPSSLMethod("TLS_server_method", "SSLv23_server_method")
 
   proc OpenSSL_add_all_algorithms*() =
     let theProc = cast[proc() {.cdecl.}](sslSym("OPENSSL_add_all_algorithms_conf"))
     if not theProc.isNil: theProc()
 
+  proc getOpenSSLVersion*(): culong =
+    ## Return OpenSSL version as unsigned long or 0 if not available
+    let theProc = cast[proc(): culong {.cdecl.}](sslSym("OpenSSL_version_num"))
+    result =
+      if theProc.isNil: 0.culong
+      else: theProc()
+
 proc ERR_load_BIO_strings*(){.cdecl, dynlib: DLLUtilName, importc.}
 
 proc SSL_new*(context: SslCtx): SslPtr{.cdecl, dynlib: DLLSSLName, importc.}
@@ -327,7 +390,7 @@ proc ERR_peek_last_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
 
 proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
 
-when not useWinVersion and not defined(macosx) and not defined(android):
+when not useWinVersion and not defined(macosx) and not defined(android) and not defined(nimNoAllocForSSL):
   proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
     dynlib: DLLUtilName, importc.}
 
@@ -341,7 +404,7 @@ when not useWinVersion and not defined(macosx) and not defined(android):
     if p != nil: dealloc(p)
 
 proc CRYPTO_malloc_init*() =
-  when not useWinVersion and not defined(macosx) and not defined(android):
+  when not useWinVersion and not defined(macosx) and not defined(android) and not defined(nimNoAllocForSSL):
     CRYPTO_set_mem_functions(allocWrapper, reallocWrapper, deallocWrapper)
 
 proc SSL_CTX_ctrl*(ctx: SslCtx, cmd: cInt, larg: int, parg: pointer): int{.
diff --git a/lib/wrappers/pcre.nim b/lib/wrappers/pcre.nim
index 6c7088bbf..e9e11960c 100644
--- a/lib/wrappers/pcre.nim
+++ b/lib/wrappers/pcre.nim
@@ -7,7 +7,7 @@
 #    distribution, for details about the copyright.
 #
 
-{.deadCodeElim: on.}
+{.deadCodeElim: on.}  # dce option deprecated
 
 # The current PCRE version information.
 
diff --git a/lib/wrappers/postgres.nim b/lib/wrappers/postgres.nim
index f9a10dccb..7cb816f68 100644
--- a/lib/wrappers/postgres.nim
+++ b/lib/wrappers/postgres.nim
@@ -15,7 +15,7 @@
 # connection-protocol.
 #
 
-{.deadCodeElim: on.}
+{.deadCodeElim: on.}  # dce option deprecated
 
 when defined(windows):
   const
diff --git a/lib/wrappers/sqlite3.nim b/lib/wrappers/sqlite3.nim
index a12945832..0276a0a65 100644
--- a/lib/wrappers/sqlite3.nim
+++ b/lib/wrappers/sqlite3.nim
@@ -7,7 +7,7 @@
 #    distribution, for details about the copyright.
 #
 
-{.deadCodeElim: on.}
+{.deadCodeElim: on.}  # dce option deprecated
 when defined(windows):
   when defined(nimOldDlls):
     const Lib = "sqlite3.dll"