From 4f70d9700a125bc055cdaf694a65f26f7e869ee3 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 10 Apr 2026 14:49:19 +0300 Subject: [PATCH] markused: fix typedefs --- vlib/crypto/md5/md5.v | 7 ++----- vlib/crypto/sha1/sha1.v | 7 ++----- vlib/crypto/sha256/sha256.v | 16 +++++----------- vlib/crypto/sha512/sha512.v | 4 +--- vlib/db/sqlite/sqlite.c.v | 3 +++ vlib/v/gen/c/fn.v | 4 ---- vlib/v/markused/walker.v | 8 ++++++++ 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/vlib/crypto/md5/md5.v b/vlib/crypto/md5/md5.v index 4091e5fff..f8e6880d3 100644 --- a/vlib/crypto/md5/md5.v +++ b/vlib/crypto/md5/md5.v @@ -64,11 +64,8 @@ fn (d &Digest) clone() &Digest { // new returns a new Digest (implementing hash.Hash) computing the MD5 checksum. pub fn new() &Digest { - mut d := &Digest{ - s: []u32{len: 4} - x: []u8{len: block_size} - } - d.reset() + mut d := &Digest{} + d.init() return d } diff --git a/vlib/crypto/sha1/sha1.v b/vlib/crypto/sha1/sha1.v index 2684334c1..b7e99cebe 100644 --- a/vlib/crypto/sha1/sha1.v +++ b/vlib/crypto/sha1/sha1.v @@ -70,11 +70,8 @@ fn (d &Digest) clone() &Digest { // new returns a new Digest (implementing hash.Hash) computing the SHA1 checksum. pub fn new() &Digest { - mut d := &Digest{ - x: []u8{len: chunk} - h: []u32{len: 5} - } - d.reset() + mut d := &Digest{} + d.init() return d } diff --git a/vlib/crypto/sha256/sha256.v b/vlib/crypto/sha256/sha256.v index 460eee4da..642063a27 100644 --- a/vlib/crypto/sha256/sha256.v +++ b/vlib/crypto/sha256/sha256.v @@ -97,22 +97,16 @@ fn (d &Digest) clone() &Digest { // new returns a new Digest (implementing hash.Hash) computing the SHA256 checksum. pub fn new() &Digest { - mut d := &Digest{ - h: []u32{len: 8} - x: []u8{len: chunk} - } - d.reset() + mut d := &Digest{} + d.init() return d } // new224 returns a new Digest (implementing hash.Hash) computing the SHA224 checksum. pub fn new224() &Digest { - mut d := &Digest{ - h: []u32{len: 8} - x: []u8{len: chunk} - is224: true - } - d.reset() + mut d := &Digest{} + d.is224 = true + d.init() return d } diff --git a/vlib/crypto/sha512/sha512.v b/vlib/crypto/sha512/sha512.v index 96fa158b9..e6b7cd4f6 100644 --- a/vlib/crypto/sha512/sha512.v +++ b/vlib/crypto/sha512/sha512.v @@ -143,11 +143,9 @@ fn (d &Digest) clone() &Digest { // internal fn new_digest(hash crypto.Hash) &Digest { mut d := &Digest{ - h: []u64{len: 8} - x: []u8{len: chunk} function: hash } - d.reset() + d.init() return d } diff --git a/vlib/db/sqlite/sqlite.c.v b/vlib/db/sqlite/sqlite.c.v index c19247ae8..29d57fef3 100644 --- a/vlib/db/sqlite/sqlite.c.v +++ b/vlib/db/sqlite/sqlite.c.v @@ -5,6 +5,9 @@ $if freebsd || openbsd { #flag -L/usr/local/lib } #flag -I@VEXEROOT/thirdparty/sqlite +$if tinyc { + #flag -DSQLITE_DISABLE_INTRINSIC +} $if $pkgconfig('sqlite3') { #pkgconfig sqlite3 } $else $if windows { diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index 406c45b40..b190dc447 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -5691,10 +5691,6 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type_ ast.Type, lang a exp_styp := g.styp(expected_type) arg_styp := g.styp(arg_typ) if exp_styp != arg_styp { - if g.pref.skip_unused { - mut muttable := unsafe { &ast.Table(g.table) } - muttable.used_features.used_syms[expected_type.idx()] = true - } g.write('(${exp_styp})') g.expr(arg.expr) return diff --git a/vlib/v/markused/walker.v b/vlib/v/markused/walker.v index 7a68cfcea..66b32c80f 100644 --- a/vlib/v/markused/walker.v +++ b/vlib/v/markused/walker.v @@ -1126,6 +1126,14 @@ pub fn (mut w Walker) call_expr(mut node ast.CallExpr) { break } } + // Mark function pointer types used in expected arg types, so their typedefs are emitted. + // When cgen casts an argument to the expected function pointer type, the typedef must exist. + for exp_type in node.expected_arg_types { + exp_sym := w.table.sym(exp_type) + if exp_sym.kind == .function && !exp_sym.name.starts_with('fn ') { + w.mark_by_type(exp_type) + } + } for concrete_type in node.concrete_types { w.mark_by_type(concrete_type) } -- 2.39.5