cgen: create enclosing block on C side for V `lock` blocks (#8538)
parent
2424e2cb02
commit
cee00a3551
|
@ -3448,7 +3448,9 @@ fn (mut g Gen) lock_expr(node ast.LockExpr) {
|
||||||
g.writeln('\t\tsync__RwMutex_lock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
g.writeln('\t\tsync__RwMutex_lock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
||||||
g.writeln('}')
|
g.writeln('}')
|
||||||
}
|
}
|
||||||
|
g.writeln('/*lock*/ {')
|
||||||
g.stmts(node.stmts)
|
g.stmts(node.stmts)
|
||||||
|
g.writeln('}')
|
||||||
if node.lockeds.len == 0 {
|
if node.lockeds.len == 0 {
|
||||||
// this should not happen
|
// this should not happen
|
||||||
} else if node.lockeds.len == 1 {
|
} else if node.lockeds.len == 1 {
|
||||||
|
@ -3465,7 +3467,7 @@ fn (mut g Gen) lock_expr(node ast.LockExpr) {
|
||||||
g.writeln('\t\tsync__RwMutex_runlock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
g.writeln('\t\tsync__RwMutex_runlock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
||||||
g.writeln('\telse')
|
g.writeln('\telse')
|
||||||
g.writeln('\t\tsync__RwMutex_unlock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
g.writeln('\t\tsync__RwMutex_unlock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
||||||
g.writeln('}')
|
g.write('}')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,12 @@ fn test_shared_as_value() {
|
||||||
assert v == 35
|
assert v == 35
|
||||||
}
|
}
|
||||||
rlock m {
|
rlock m {
|
||||||
w := m_val(m)
|
u := m_val(m)
|
||||||
assert w == -3.125
|
assert u == -3.125
|
||||||
}
|
}
|
||||||
lock a {
|
lock a {
|
||||||
x := a_val(a)
|
u := a_val(a)
|
||||||
assert x == 4
|
assert u == 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue