1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,6 +19,7 @@ numpy.txt
|
|||||||
_go/
|
_go/
|
||||||
_runtime/
|
_runtime/
|
||||||
_tinygo/
|
_tinygo/
|
||||||
|
_output/
|
||||||
build.dir/
|
build.dir/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
|||||||
15
_demo/rand/rand.go
Normal file
15
_demo/rand/rand.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/goplus/llgo/c"
|
||||||
|
"github.com/goplus/llgo/c/math/rand"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var s c.Uint = 6
|
||||||
|
rand.Srand(s)
|
||||||
|
rr := rand.RandR(&s)
|
||||||
|
r := rand.Rand()
|
||||||
|
println("r:", r)
|
||||||
|
println("rr:", rr)
|
||||||
|
}
|
||||||
23
c/math/rand/rand.go
Normal file
23
c/math/rand/rand.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package rand
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "unsafe"
|
||||||
|
|
||||||
|
"github.com/goplus/llgo/c"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
LLGoPackage = "decl"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:linkname Rand C.rand
|
||||||
|
func Rand() c.Int
|
||||||
|
|
||||||
|
//go:linkname RandR C.rand_r
|
||||||
|
func RandR(*c.Uint) c.Int
|
||||||
|
|
||||||
|
//go:linkname Srand C.srand
|
||||||
|
func Srand(c.Uint)
|
||||||
|
|
||||||
|
//go:linkname Sranddev C.sranddev
|
||||||
|
func Sranddev()
|
||||||
Reference in New Issue
Block a user