tests: fix compilation of the semaphore_wait.v program with latest V

This commit is contained in:
Delyan Angelov 2024-10-26 17:22:06 +03:00
parent 31c01fe956
commit d25f281b25
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 12 additions and 7 deletions

View File

@ -294,6 +294,11 @@ fn get_all_commands() []Command {
rmfile: 'vtmp_unused'
}
$if linux {
res << Command{
line: '${vexe} -o swait vlib/v/tests/reliability/semaphore_wait.v'
okmsg: 'V can compile semaphore_wait.v on Linux with GC on.'
rmfile: 'swait'
}
res << Command{
line: '${vexe} -cc gcc -keepc -freestanding -o bel vlib/os/bare/bare_example_linux.v'
okmsg: 'V can compile with -freestanding on Linux with GCC.'

View File

@ -46,23 +46,23 @@ const log2n = 9
const n = 1 << log2n
const n4 = f64(u64(1) << (4 * log2n))
fn waste_mem() {
fn waste_mem() ! {
mut objs := PtrPtrObj{
nxt: []&PtrObj{len: n}
nxt: unsafe { []&PtrObj{len: n} }
}
for {
sz := rand.int_in_range(10, 1000)
sz := rand.int_in_range(10, 1000)!
mut new_obj := &PtrObj{
nxt: []&DataObj{len: sz}
nxt: unsafe { []&DataObj{len: sz} }
}
sz2 := rand.int_in_range(10, 500000)
sz2 := rand.int_in_range(10, 500000)!
new_obj2 := &DataObj{
data: []f64{len: sz2}
}
idx2 := rand.int_in_range(0, sz)
idx2 := rand.int_in_range(0, sz)!
new_obj.nxt[idx2] = new_obj2
// non-equally distributed random index
idx := int(math.sqrt(math.sqrt(rand.f64n(n4))))
idx := int(math.sqrt(math.sqrt(rand.f64n(n4)!)))
objs.nxt[idx] = new_obj
}
}