]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: detect misuse of generated _cgo_export.h
authorShenghou Ma <minux@golang.org>
Thu, 5 Feb 2015 19:16:13 +0000 (14:16 -0500)
committerMinux Ma <minux@golang.org>
Fri, 6 Feb 2015 05:37:02 +0000 (05:37 +0000)
Fixes #9742.

Change-Id: Ifedf7ff9465bc49534b708d414c8e435ee9ce6cd
Reviewed-on: https://go-review.googlesource.com/3970
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/cgo/out.go

index a4bd5579d353c9c1c2f0f0bf8e6c9ed7cbe68b33..346ae94546d1aaeb680d80eb353c5976c6b76001 100644 (file)
@@ -636,7 +636,7 @@ func (p *Package) writeExports(fgo2, fm io.Writer) {
        fgcc := creat(*objDir + "_cgo_export.c")
        fgcch := creat(*objDir + "_cgo_export.h")
 
-       fmt.Fprintf(fgcch, "/* Created by cgo - DO NOT EDIT. */\n")
+       fmt.Fprintf(fgcch, "/* Created by cgo - DO NOT EDIT. */\n/*  This file is arch-specific.  */\n")
        fmt.Fprintf(fgcch, "%s\n", p.Preamble)
        fmt.Fprintf(fgcch, "%s\n", p.gccExportHeaderProlog())
 
@@ -1310,6 +1310,10 @@ typedef double GoFloat64;
 typedef __complex float GoComplex64;
 typedef __complex double GoComplex128;
 
+// static assertion to make sure the file is being used on architecture
+// at least with matching size of GoInt.
+typedef char _check_for_GOINTBITS_bit_pointer_matching_GoInt[sizeof(void*)==GOINTBITS/8 ? 1:-1];
+
 typedef struct { char *p; GoInt n; } GoString;
 typedef void *GoMap;
 typedef void *GoChan;