mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 22:13:39 +00:00
Add goroutines and function pointers
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
// #include <stdio.h>
|
||||
// #include <stdlib.h>
|
||||
// #include <unistd.h>
|
||||
// #include <time.h>
|
||||
import "C"
|
||||
|
||||
const Microsecond = 1
|
||||
@@ -18,10 +19,20 @@ func putchar(c byte) {
|
||||
C.putchar(C.int(c))
|
||||
}
|
||||
|
||||
func Sleep(d Duration) {
|
||||
func sleep(d Duration) {
|
||||
C.usleep(C.useconds_t(d))
|
||||
}
|
||||
|
||||
// Return monotonic time in microseconds.
|
||||
//
|
||||
// TODO: use nanoseconds?
|
||||
// TODO: noescape
|
||||
func monotime() uint64 {
|
||||
var ts C.struct_timespec
|
||||
C.clock_gettime(C.CLOCK_MONOTONIC, &ts)
|
||||
return uint64(ts.tv_sec) * 1000 * 1000 + uint64(ts.tv_nsec) / 1000
|
||||
}
|
||||
|
||||
func abort() {
|
||||
C.abort()
|
||||
}
|
||||
@@ -35,5 +46,5 @@ func alloc(size uintptr) unsafe.Pointer {
|
||||
}
|
||||
|
||||
func free(ptr unsafe.Pointer) {
|
||||
C.free(ptr)
|
||||
//C.free(ptr) // TODO
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user