Skip to content

Commit

Permalink
Fix gcc-14 issues part 2. (#61)
Browse files Browse the repository at this point in the history
* Fix recently discovered nim-2.0 gcc-14 issues.

* One more place to fix.
  • Loading branch information
cheatfate authored Jun 26, 2024
1 parent 8790ee6 commit 554b464
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion bearssl/abi/bearssl_ec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,14 @@ const
EC_KBUF_PUB_MAX_SIZE* = 145


proc ecKeygen*(rngCtx: ptr ptr PrngClass; impl: ptr EcImpl; sk: ptr EcPrivateKey;
proc ecKeygen*(rngCtx: PrngClassPointerConst; impl: ptr EcImpl; sk: ptr EcPrivateKey;
kbuf: pointer; curve: cint): uint {.importcFunc, importc: "br_ec_keygen",
header: "bearssl_ec.h".}

proc ecKeygen*(rngCtx: ptr ptr PrngClass; impl: ptr EcImpl; sk: ptr EcPrivateKey;
kbuf: pointer; curve: cint): uint =
ecKeygen(PrngClassPointerConst(rngCtx), impl, sk, kbuf, curve)

proc ecComputePub*(impl: ptr EcImpl; pk: ptr EcPublicKey; kbuf: pointer;
sk: ptr EcPrivateKey): uint {.importcFunc,
importc: "br_ec_compute_pub", header: "bearssl_ec.h".}
3 changes: 2 additions & 1 deletion bearssl/abi/bearssl_rand.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type
update* {.importc: "update".}: proc (ctx: ptr ptr PrngClass; seed: pointer;
seedLen: uint) {.importcFunc.}

PrngClassPointerConst* {.importc: "const br_prng_class**", header: "bearssl_rand.h", bycopy.} = pointer


type
Expand Down Expand Up @@ -51,7 +52,7 @@ proc hmacDrbgGetHash*(ctx: var HmacDrbgContext): ptr HashClass {.inline.} =


type
PrngSeeder* {.importc: "br_prng_seeder".} = proc (ctx: ptr ptr PrngClass): cint {.importcFunc.}
PrngSeeder* {.importc: "br_prng_seeder".} = proc (ctx: PrngClassPointerConst): cint {.importcFunc.}
constCstringArray* {.importc: "const char**", nodecl.} = pointer

proc prngSeederSystem*(name: constCstringArray): PrngSeeder {.importcFunc,
Expand Down
5 changes: 4 additions & 1 deletion bearssl/abi/brssl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ type
vtable* {.importc: "vtable".}: ptr X509Class
inner* {.importc: "inner".}: ptr ptr X509Class

proc x509NoanchorInit*(xwc: var X509NoanchorContext; inner: ptr ptr X509Class) {.importcFunc,
proc x509NoanchorInit*(xwc: var X509NoanchorContext; inner: X509ClassPointerConst) {.importcFunc,
importc: "x509_noanchor_init", header: "brssl_cpp.h".}

proc x509NoanchorInit*(xwc: var X509NoanchorContext; inner: ptr ptr X509Class) =
x509NoanchorInit(xwc, X509ClassPointerConst(inner))

proc initNoAnchor*(xwc: var X509NoanchorContext, inner: ptr ptr X509Class) {.
importcFunc, importc: "x509_noanchor_init", header: "brssl_cpp.h", deprecated: "x509NoanchorInit".}
2 changes: 1 addition & 1 deletion bearssl/rand.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ proc new*(T: type HmacDrbgContext): ref HmacDrbgContext =
let rng = (ref HmacDrbgContext)()
hmacDrbgInit(rng[], addr sha256Vtable, nil, 0)

if seeder(addr rng.vtable) == 0:
if seeder(PrngClassPointerConst(addr rng.vtable)) == 0:
return nil

rng
Expand Down

0 comments on commit 554b464

Please sign in to comment.