Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ http://www.tcl-lang.org

$ sudo yum install tk-devel

### Experimental CGo-free backend

* At present, it only works in Linux.
* Use [modernc.org/tk](https://pkg.go.dev/modernc.org/tk) to get rid of cgo.
* Need not to install Tcl/Tk.
* Usage

Build without cgo enabled
```
CGO_ENABLED=0 go build
```

If cgo is necessary, you can also build with `tclgo` tag
```
go build -tags tclgo
```

### Demo

https://github.com/visualfc/atk_demo
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
module github.com/visualfc/atk

go 1.14

require (
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
modernc.org/libc v1.16.0
modernc.org/tcl v1.13.0
modernc.org/tk v1.0.23
)
2 changes: 1 addition & 1 deletion tk/interp/cbytes_unix.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018 visualfc. All rights reserved.

// +build go1.7,!windows
// +build go1.7,!windows,!tclgo

package interp

Expand Down
22 changes: 22 additions & 0 deletions tk/interp/cbytes_unix_tclgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2018 visualfc. All rights reserved.

// +build !windows,tclgo !windows,!cgo

package interp

import (
"unsafe"

"modernc.org/libc"
"modernc.org/libc/sys/types"
)

func toCBytes(tls *libc.TLS, b []byte) uintptr {
if len(b) == 0 {
return 0
}

p := libc.Xcalloc(tls, types.Size_t(len(b)), 1)
copy((*libc.RawMem)(unsafe.Pointer(p))[:len(b):len(b)], b)
return p
}
2 changes: 1 addition & 1 deletion tk/interp/interp_unix.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018 visualfc. All rights reserved.

// +build !windows
// +build !windows,!tclgo

package interp

Expand Down
Loading