Skip to content

Commit 47593c8

Browse files
committed
all: fix CI failures from VGC PR - add missing stubs, fix README
1 parent dd253e5 commit 47593c8

4 files changed

Lines changed: 54 additions & 26 deletions

File tree

vlib/builtin/builtin_d_vgc.c.v

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// builtin_d_vgc.c.v - V Garbage Collector additional support
2-
// Conditionally compiled when -gc vgc is used.
3-
// The public gc_* API is provided by builtin_notd_gcboehm.c.v (which delegates
4-
// to VGC via $if vgc ? blocks) to avoid duplicate function definitions.
2+
// Conditionally compiled when -d vgc is used.
53
// The gc_heap_usage/gc_memory_use functions are in allocation.c.v with $if vgc ? branches.
64

75
module builtin

vlib/builtin/builtin_notd_gcboehm.c.v

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,32 @@ fn C.GC_get_memory_use() usize
2424
fn C.GC_gcollect()
2525

2626
// gc_check_leaks is useful for detecting leaks, but it needs the GC to run.
27-
// When GC is not used, it is a NOP. When VGC is active, delegates to vgc.
27+
// When GC is not used, it is a NOP.
2828
pub fn gc_check_leaks() {}
2929

3030
// gc_is_enabled() returns true, if the GC is enabled at runtime.
31-
// With `-gc none` returns false. With `-gc vgc` delegates to the VGC.
31+
// It will always return false, with `-gc none`.
32+
// See also gc_disable() and gc_enable().
3233
pub fn gc_is_enabled() bool {
33-
$if vgc ? {
34-
return C.vgc_atomic_load_u32(unsafe { &vgc_heap.gc_enabled }) != 0
35-
}
3634
return false
3735
}
3836

3937
// gc_enable explicitly enables the GC.
40-
pub fn gc_enable() {
41-
$if vgc ? {
42-
C.vgc_atomic_store_u32(unsafe { &vgc_heap.gc_enabled }, 1)
43-
}
44-
}
38+
// Note, that garbage collections are done automatically, when needed in most cases,
39+
// and also that by default the GC is on, so you do not need to enable it.
40+
// See also gc_disable() and gc_collect().
41+
// Note that gc_enable() is a NOP with `-gc none`.
42+
pub fn gc_enable() {}
4543

4644
// gc_disable explicitly disables the GC.
47-
pub fn gc_disable() {
48-
$if vgc ? {
49-
C.vgc_atomic_store_u32(unsafe { &vgc_heap.gc_enabled }, 0)
50-
}
51-
}
45+
// Do not forget to enable it again by calling gc_enable(), when your program is otherwise idle, and can afford it.
46+
// See also gc_enable() and gc_collect().
47+
// Note that gc_disable() is a NOP with `-gc none`.
48+
pub fn gc_disable() {}
5249

5350
// gc_collect explicitly performs a garbage collection.
54-
pub fn gc_collect() {
55-
$if vgc ? {
56-
vgc_gc_start()
57-
}
58-
}
51+
// When the GC is not on, (with `-gc none`), it is a NOP.
52+
pub fn gc_collect() {}
5953

6054
pub type FnGC_WarnCB = fn (msg &char, arg usize)
6155

vlib/builtin/vgc_notd_vgc.c.v

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module builtin
2+
3+
// Stub declarations for VGC functions, so that V does not error
4+
// because of the missing definitions in $if vgc ? { } blocks.
5+
// Note: they will NOT be called, since calls to them are wrapped with `$if vgc ? { }`.
6+
7+
fn vgc_malloc(n usize) voidptr {
8+
return unsafe { nil }
9+
}
10+
11+
fn vgc_malloc_noscan(n usize) voidptr {
12+
return unsafe { nil }
13+
}
14+
15+
fn vgc_realloc(old_ptr voidptr, new_size usize) voidptr {
16+
return unsafe { nil }
17+
}
18+
19+
fn vgc_calloc(n usize) voidptr {
20+
return unsafe { nil }
21+
}
22+
23+
fn vgc_free(ptr voidptr) {
24+
}
25+
26+
fn vgc_heap_usage() (usize, usize, usize, usize, usize) {
27+
return 0, 0, 0, 0, 0
28+
}
29+
30+
fn vgc_memory_use() usize {
31+
return 0
32+
}

vlib/goroutines/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# goroutines
22

3-
Go-style goroutine runtime for V, implementing the GMP (Goroutine-Machine-Processor) scheduling model translated from the Go runtime (`src/runtime/proc.go`, `runtime2.go`, `chan.go`).
3+
Go-style goroutine runtime for V, implementing the GMP
4+
(Goroutine-Machine-Processor) scheduling model translated
5+
from the Go runtime (`src/runtime/proc.go`, `runtime2.go`,
6+
`chan.go`).
47

58
## Overview
69

7-
This module provides lightweight goroutines for V's `go` keyword, as opposed to `spawn` which creates OS threads.
10+
This module provides lightweight goroutines for V's `go`
11+
keyword, as opposed to `spawn` which creates OS threads.
812

913
### GMP Model
1014

@@ -22,7 +26,7 @@ This module provides lightweight goroutines for V's `go` keyword, as opposed to
2226

2327
## Usage
2428

25-
```v
29+
```v ignore
2630
// `go` launches a goroutine (lightweight, scheduled by GMP)
2731
go expensive_computation()
2832

0 commit comments

Comments
 (0)