Comments (7)
TCC passes on x86,x64 - so likely was resolved along the road somewhere.
from ccgo.
malloc_windows_ARCH.go is identical to the linux variants.
Seems some TCC/ARGV handling is broken though:
--- FAIL: TestTCC (27.87s)
all_test.go:363: ..\cc\testdata\tcc-0.9.26\tests\tests2\31_args.c: FAIL
==== ..\cc\testdata\tcc-0.9.26\tests\tests2\31_args.c
==== got
hello world 6
arg 0:
arg 1:
arg 2:
arg 3:
arg 4:
arg 5:
==== exp
hello world 6
arg 0: ./test
arg 1: -
arg 2: arg1
arg 3: arg2
arg 4: arg3
arg 5: arg4
# ccgo.New
// Code generated by ccgo DO NOT EDIT.
package main
import (
"fmt"
"math"
"os"
"path"
"runtime"
"unsafe"
"github.com/cznic/crt"
)
var (
argv []*int8
inf = math.Inf(1)
)
func ftrace(s string, args ...interface{}) {
_, fn, fl, _ := runtime.Caller(1)
fmt.Fprintf(os.Stderr, "# %s:%d: %v\n", path.Base(fn), fl, fmt.Sprintf(s, args...))
os.Stderr.Sync()
}
func main() {
os.Args[0] = "./test"
for _, v := range os.Args {
argv = append(argv, (*int8)(crt.CString(v)))
}
X_start(crt.NewTLS(), int32(len(os.Args)), &argv[0])
}
func X_start(tls *crt.TLS, _argc int32, _argv **int8) { // crt0.c:12:1
crt.X__register_stdfiles(tls, Xstdin, Xstdout, Xstderr)
crt.X__builtin_exit(tls, Xmain(tls, _argc, _argv))
return
}
var Xstdin unsafe.Pointer // crt0.c:10:6
func init() {
Xstdin = unsafe.Pointer(&X__stdfiles)
}
var X__stdfiles [3]unsafe.Pointer // crt0.c:9:15
var Xstdout unsafe.Pointer // crt0.c:10:31
func init() {
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
}
var Xstderr unsafe.Pointer // crt0.c:10:57
func init() {
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
}
func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) { // 31_args.c:3:1
var _Count int32 // 31_args.c:5:8
_ = _Count
r0 = i32(0)
crt.Xprintf(tls, str(0), _argc)
_Count = i32(0)
_0:
if _Count >= _argc {
goto _3
}
crt.Xprintf(tls, str(16), _Count, unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(_Count)))))
_Count += 1
goto _0
_3:
r0 = i32(0)
return
}
func bool2int(b bool) int32 {
if b {
return 1
}
return 0
}
func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed.
func i16(n int16) int16 { return n }
func i32(n int32) int32 { return n }
func i64(n int64) int64 { return n }
func i8(n int8) int8 { return n }
func init() { nzf32 *= -1; nzf64 *= -1 }
func u16(n uint16) uint16 { return n }
func u32(n uint32) uint32 { return n }
func u64(n uint64) uint64 { return n }
func u8(n byte) byte { return n }
var nzf32 float32 // -0.0
var nzf64 float64 // -0.0
func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) }
func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) }
var strTab = []byte("hello world %d\x0a\x00arg %d: %s\x0a\x00")
stdout:
hello world 6
arg 0:
arg 1:
arg 2:
arg 3:
arg 4:
arg 5:
all_test.go:372: 52/55 ok
all_test.go:374: failures: 3
from ccgo.
That's strange.
jnml@r550:~/src/github.com/cznic/ccgo$ git branch
* master
jnml@r550:~/src/github.com/cznic/ccgo$ git log -1
commit b2ac4af44cdaff88cf28de74c6b12c86fccb9911
Author: Jan Mercl <[email protected]>
Date: Mon Jun 12 17:51:13 2017 +0200
Use crt.{Calloc,Free,Malloc,Realloc}. Updates cznic/sqlite#12.
modified: all_test.go
modified: testdata/sqlite/test.c
jnml@r550:~/src/github.com/cznic/ccgo$ go test -v -run TCC -re 31_ |& tee log
=== RUN TestTCC
--- PASS: TestTCC (0.57s)
all_test.go:372: 1/1 ok
PASS
ok github.com/cznic/ccgo 0.575s
jnml@r550:~/src/github.com/cznic/ccgo$ go test -v -run TCC -re 31_ -log |& tee log
=== RUN TestTCC
--- PASS: TestTCC (0.57s)
all_test.go:368: ../cc/testdata/tcc-0.9.26/tests/tests2/31_args.c:
# ccgo.New
// Code generated by ccgo DO NOT EDIT.
package main
import (
"fmt"
"math"
"os"
"path"
"runtime"
"unsafe"
"github.com/cznic/crt"
)
var (
argv []*int8
inf = math.Inf(1)
)
func ftrace(s string, args ...interface{}) {
_, fn, fl, _ := runtime.Caller(1)
fmt.Fprintf(os.Stderr, "# %s:%d: %v\n", path.Base(fn), fl, fmt.Sprintf(s, args...))
os.Stderr.Sync()
}
func main() {
os.Args[0] = "./test"
for _, v := range os.Args {
argv = append(argv, (*int8)(crt.CString(v)))
}
X_start(crt.NewTLS(), int32(len(os.Args)), &argv[0])
}
func X_start(tls *crt.TLS, _argc int32, _argv **int8) { // crt0.c:12:1
crt.X__register_stdfiles(tls, Xstdin, Xstdout, Xstderr)
crt.X__builtin_exit(tls, Xmain(tls, _argc, _argv))
return
}
var Xstdin unsafe.Pointer // crt0.c:10:6
func init() {
Xstdin = unsafe.Pointer(&X__stdfiles)
}
var X__stdfiles [3]unsafe.Pointer // crt0.c:9:15
var Xstdout unsafe.Pointer // crt0.c:10:31
func init() {
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
}
var Xstderr unsafe.Pointer // crt0.c:10:57
func init() {
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
}
func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) { // 31_args.c:3:1
var _Count int32 // 31_args.c:5:8
_ = _Count
r0 = i32(0)
crt.Xprintf(tls, str(0), _argc)
_Count = i32(0)
_0:
if _Count >= _argc {
goto _3
}
crt.Xprintf(tls, str(16), _Count, unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(_Count)))))
_Count += 1
goto _0
_3:
r0 = i32(0)
return
}
func bool2int(b bool) int32 {
if b {
return 1
}
return 0
}
func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed.
func i16(n int16) int16 { return n }
func i32(n int32) int32 { return n }
func i64(n int64) int64 { return n }
func i8(n int8) int8 { return n }
func init() { nzf32 *= -1; nzf64 *= -1 }
func u16(n uint16) uint16 { return n }
func u32(n uint32) uint32 { return n }
func u64(n uint64) uint64 { return n }
func u8(n byte) byte { return n }
var nzf32 float32 // -0.0
var nzf64 float64 // -0.0
func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) }
func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) }
var strTab = []byte("hello world %d\x0a\x00arg %d: %s\x0a\x00")
stdout:
hello world 6
arg 0: ./test
arg 1: -
arg 2: arg1
arg 3: arg2
arg 4: arg3
arg 5: arg4
all_test.go:372: 1/1 ok
PASS
ok github.com/cznic/ccgo 0.580s
jnml@r550:~/src/github.com/cznic/ccgo$
from ccgo.
malloc_windows_ARCH.go is identical to the linux variants.
Are you sure? The return type is size_t
.
from ccgo.
size_t
is 32bits on x86 and 64 bits on x86_64 which matches the linux files.
from ccgo.
Ah, you're right. I was thinking mistakenly about long
, that's the problematic C type. We can just drop the _linux_
part of the filenames then.
from ccgo.
@steffengy I cannot recall if this issue was or was not already resolved on Windows. Do you?
from ccgo.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ccgo.