mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix for rlock
/lock
handling (#8536)
This commit is contained in:
parent
de37b52d4b
commit
2424e2cb02
@ -3420,13 +3420,24 @@ fn (mut g Gen) lock_expr(node ast.LockExpr) {
|
|||||||
mtxs = g.new_tmp_var()
|
mtxs = g.new_tmp_var()
|
||||||
g.writeln('uintptr_t _arr_$mtxs[$node.lockeds.len];')
|
g.writeln('uintptr_t _arr_$mtxs[$node.lockeds.len];')
|
||||||
g.writeln('bool _isrlck_$mtxs[$node.lockeds.len];')
|
g.writeln('bool _isrlck_$mtxs[$node.lockeds.len];')
|
||||||
|
mut j := 0
|
||||||
for i, id in node.lockeds {
|
for i, id in node.lockeds {
|
||||||
name := id.name
|
if !node.is_rlock[i] {
|
||||||
deref := if id.is_mut { '->' } else { '.' }
|
name := id.name
|
||||||
g.writeln('_arr_$mtxs[$i] = &$name${deref}mtx;')
|
deref := if id.is_mut { '->' } else { '.' }
|
||||||
// TODO: fix `vfmt` to allow this in string interpolation
|
g.writeln('_arr_$mtxs[$j] = &$name${deref}mtx;')
|
||||||
is_rlock_str := node.is_rlock[i].str()
|
g.writeln('_isrlck_$mtxs[$j] = false;')
|
||||||
g.writeln('_isrlck_$mtxs[$i] = $is_rlock_str;')
|
j++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i, id in node.lockeds {
|
||||||
|
if node.is_rlock[i] {
|
||||||
|
name := id.name
|
||||||
|
deref := if id.is_mut { '->' } else { '.' }
|
||||||
|
g.writeln('_arr_$mtxs[$j] = &$name${deref}mtx;')
|
||||||
|
g.writeln('_isrlck_$mtxs[$j] = true;')
|
||||||
|
j++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.writeln('__sort_ptr(_arr_$mtxs, _isrlck_$mtxs, $node.lockeds.len);')
|
g.writeln('__sort_ptr(_arr_$mtxs, _isrlck_$mtxs, $node.lockeds.len);')
|
||||||
g.writeln('for (int $mtxs=0; $mtxs<$node.lockeds.len; $mtxs++) {')
|
g.writeln('for (int $mtxs=0; $mtxs<$node.lockeds.len; $mtxs++) {')
|
||||||
|
@ -37,7 +37,7 @@ static inline void __sort_ptr(uintptr_t a[], bool b[], int l)
|
|||||||
uintptr_t ins = a[i];
|
uintptr_t ins = a[i];
|
||||||
bool insb = b[i];
|
bool insb = b[i];
|
||||||
int j = i;
|
int j = i;
|
||||||
while(j>0 && (a[j-1] > ins || b[j-1] && !insb)) {
|
while(j>0 && a[j-1] > ins) {
|
||||||
a[j] = a[j-1];
|
a[j] = a[j-1];
|
||||||
b[j] = b[j-1];
|
b[j] = b[j-1];
|
||||||
j--;
|
j--;
|
||||||
|
Loading…
Reference in New Issue
Block a user