Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "debug/elf" | 9 "debug/elf" |
10 "debug/macho" | 10 "debug/macho" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 fmt.Fprintf(fgcc, "_cgo%s%s(void *v)\n", cPrefix, n.Mangle) | 478 fmt.Fprintf(fgcc, "_cgo%s%s(void *v)\n", cPrefix, n.Mangle) |
479 fmt.Fprintf(fgcc, "{\n") | 479 fmt.Fprintf(fgcc, "{\n") |
480 if n.AddError { | 480 if n.AddError { |
481 fmt.Fprintf(fgcc, "\tint e;\n") // assuming 32 bit (see comment above structType) | 481 fmt.Fprintf(fgcc, "\tint e;\n") // assuming 32 bit (see comment above structType) |
482 fmt.Fprintf(fgcc, "\terrno = 0;\n") | 482 fmt.Fprintf(fgcc, "\terrno = 0;\n") |
483 } | 483 } |
484 // We're trying to write a gcc struct that matches 6c/8c/5c's layout. | 484 // We're trying to write a gcc struct that matches 6c/8c/5c's layout. |
485 // Use packed attribute to force no padding in this struct in case | 485 // Use packed attribute to force no padding in this struct in case |
486 // gcc has different packing requirements. For example, | 486 // gcc has different packing requirements. For example, |
487 // on 386 Windows, gcc wants to 8-align int64s, but 8c does not. | 487 // on 386 Windows, gcc wants to 8-align int64s, but 8c does not. |
488 » // Use __gcc_struct__ to work around http://gcc.gnu.org/bugzilla/show_bu g.cgi?id=52991 | 488 » // Use __gcc_struct__ to work around http://gcc.gnu.org/PR52991 on x86, |
iant
2013/06/03 18:16:03
To reference the GCC bug report, use http://gcc.gn
| |
489 // and http://golang.org/issue/5603. | 489 // and http://golang.org/issue/5603. |
490 » fmt.Fprintf(fgcc, "\t%s __attribute__((__packed__, __gcc_struct__)) *a = v;\n", ctype) | 490 » extraAttr := "" |
iant
2013/06/03 18:16:03
This won't work on ARM. __gcc_struct__ is only fo
| |
491 » if goarch == "amd64" || goarch == "386" { | |
492 » » extraAttr = ", __gcc_struct__" | |
493 » } | |
494 » fmt.Fprintf(fgcc, "\t%s __attribute__((__packed__%v)) *a = v;\n", ctype, extraAttr) | |
491 fmt.Fprintf(fgcc, "\t") | 495 fmt.Fprintf(fgcc, "\t") |
492 if t := n.FuncType.Result; t != nil { | 496 if t := n.FuncType.Result; t != nil { |
493 fmt.Fprintf(fgcc, "a->r = ") | 497 fmt.Fprintf(fgcc, "a->r = ") |
494 if c := t.C.String(); c[len(c)-1] == '*' { | 498 if c := t.C.String(); c[len(c)-1] == '*' { |
495 fmt.Fprint(fgcc, "(__typeof__(a->r)) ") | 499 fmt.Fprint(fgcc, "(__typeof__(a->r)) ") |
496 } | 500 } |
497 } | 501 } |
498 fmt.Fprintf(fgcc, "%s(", n.C) | 502 fmt.Fprintf(fgcc, "%s(", n.C) |
499 for i, t := range n.FuncType.Params { | 503 for i, t := range n.FuncType.Params { |
500 if i > 0 { | 504 if i > 0 { |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1144 typedef double GoFloat64; | 1148 typedef double GoFloat64; |
1145 typedef __complex float GoComplex64; | 1149 typedef __complex float GoComplex64; |
1146 typedef __complex double GoComplex128; | 1150 typedef __complex double GoComplex128; |
1147 | 1151 |
1148 typedef struct { char *p; GoInt n; } GoString; | 1152 typedef struct { char *p; GoInt n; } GoString; |
1149 typedef void *GoMap; | 1153 typedef void *GoMap; |
1150 typedef void *GoChan; | 1154 typedef void *GoChan; |
1151 typedef struct { void *t; void *v; } GoInterface; | 1155 typedef struct { void *t; void *v; } GoInterface; |
1152 typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; | 1156 typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; |
1153 ` | 1157 ` |
LEFT | RIGHT |