wrappers/openssl: mark casts as gcsafe
Nim will pretend that these proc are not gcsafe if they are not marked.
This commit is contained in:
parent
b323bccd81
commit
3cd74c6408
1 changed files with 12 additions and 16 deletions
|
|
@ -403,29 +403,25 @@ else:
|
||||||
|
|
||||||
proc getOpenSSLVersion*(): culong =
|
proc getOpenSSLVersion*(): culong =
|
||||||
## Return OpenSSL version as unsigned long or 0 if not available
|
## Return OpenSSL version as unsigned long or 0 if not available
|
||||||
let theProc = cast[proc(): culong {.cdecl.}](utilSymNullable("OpenSSL_version_num", "SSLeay"))
|
let theProc = cast[proc(): culong {.cdecl, gcsafe.}](utilSymNullable("OpenSSL_version_num", "SSLeay"))
|
||||||
{.gcsafe.}:
|
result =
|
||||||
result =
|
if theProc.isNil: 0.culong
|
||||||
if theProc.isNil: 0.culong
|
else: theProc()
|
||||||
else: theProc()
|
|
||||||
|
|
||||||
proc SSL_in_init*(ssl: SslPtr): cint =
|
proc SSL_in_init*(ssl: SslPtr): cint =
|
||||||
# A compatibility wrapper for `SSL_in_init()` for OpenSSL 1.0, 1.1 and LibreSSL
|
# A compatibility wrapper for `SSL_in_init()` for OpenSSL 1.0, 1.1 and LibreSSL
|
||||||
const MainProc = "SSL_in_init"
|
const MainProc = "SSL_in_init"
|
||||||
let
|
let
|
||||||
theProc {.global.} = cast[proc(ssl: SslPtr): cint {.cdecl.}](sslSymNullable(MainProc))
|
theProc {.global.} = cast[proc(ssl: SslPtr): cint {.cdecl, gcsafe.}](sslSymNullable(MainProc))
|
||||||
# Fallback
|
# Fallback
|
||||||
sslState {.global.} = cast[proc(ssl: SslPtr): cint {.cdecl.}](sslSymNullable("SSL_state"))
|
sslState {.global.} = cast[proc(ssl: SslPtr): cint {.cdecl, gcsafe.}](sslSymNullable("SSL_state"))
|
||||||
|
|
||||||
# FIXME: This shouldn't be needed, but the compiler is complaining about
|
if not theProc.isNil:
|
||||||
# `sslState` being GC-ed memory???
|
theProc(ssl)
|
||||||
{.gcsafe.}:
|
elif not sslState.isNil:
|
||||||
if not theProc.isNil:
|
sslState(ssl) and SSL_ST_INIT
|
||||||
theProc(ssl)
|
else:
|
||||||
elif not sslState.isNil:
|
raiseInvalidLibrary MainProc
|
||||||
sslState(ssl) and SSL_ST_INIT
|
|
||||||
else:
|
|
||||||
raiseInvalidLibrary MainProc
|
|
||||||
|
|
||||||
proc ERR_load_BIO_strings*(){.cdecl, dynlib: DLLUtilName, importc.}
|
proc ERR_load_BIO_strings*(){.cdecl, dynlib: DLLUtilName, importc.}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue