2018-05-14 10:59:18 +00:00
|
|
|
package main
|
|
|
|
|
2018-12-15 04:39:50 +00:00
|
|
|
import (
|
2020-02-28 23:11:07 +00:00
|
|
|
//"reflect"
|
|
|
|
//"runtime"
|
|
|
|
//"unsafe"
|
|
|
|
"github.com/Azareal/Gosora/uutils"
|
2018-12-15 04:39:50 +00:00
|
|
|
)
|
|
|
|
|
2020-02-28 23:11:07 +00:00
|
|
|
// TODO: Add a safe build mode for things like Google Appengine
|
|
|
|
|
2018-05-16 11:44:32 +00:00
|
|
|
var GetFrag = func(name string) [][]byte {
|
|
|
|
return nil
|
|
|
|
}
|
2018-12-15 04:39:50 +00:00
|
|
|
|
|
|
|
type WriteString interface {
|
|
|
|
WriteString(s string) (n int, err error)
|
|
|
|
}
|
|
|
|
|
2020-02-28 23:11:07 +00:00
|
|
|
var StringToBytes = uutils.StringToBytes
|
|
|
|
var BytesToString = uutils.BytesToString
|
|
|
|
var Nanotime = uutils.Nanotime
|
|
|
|
|
|
|
|
/*
|
2018-12-15 04:39:50 +00:00
|
|
|
func StringToBytes(s string) (bytes []byte) {
|
|
|
|
str := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
|
|
slice := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
|
|
|
|
slice.Data = str.Data
|
|
|
|
slice.Len = str.Len
|
|
|
|
slice.Cap = str.Len
|
|
|
|
runtime.KeepAlive(&s)
|
|
|
|
return bytes
|
|
|
|
}
|
2018-12-31 09:03:49 +00:00
|
|
|
func BytesToString(bytes []byte) (s string) {
|
|
|
|
slice := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
|
|
|
|
str := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
|
|
str.Data = slice.Data
|
|
|
|
str.Len = slice.Len
|
|
|
|
runtime.KeepAlive(&bytes)
|
|
|
|
return s
|
|
|
|
}
|
2020-02-28 23:11:07 +00:00
|
|
|
//go:noescape
|
|
|
|
//go:linkname nanotime runtime.nanotime
|
|
|
|
func nanotime() int64
|
|
|
|
func Nanotime() int64 {
|
|
|
|
return nanotime()
|
2020-03-22 23:14:08 +00:00
|
|
|
}*/
|