summaryrefslogtreecommitdiff
path: root/src/cmd/cgo/out.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2014-08-05 18:12:32 -0700
committerMatthew Dempsky <mdempsky@google.com>2014-08-05 18:12:32 -0700
commit4066aff8b63ca59b8866c482872c14a2087ae8b4 (patch)
tree48160ddfe5f55e1f6d735e946deda34a29004c8b /src/cmd/cgo/out.go
parent7846f72f54f04574afa96507a895c24d39257ff5 (diff)
downloadgo-4066aff8b63ca59b8866c482872c14a2087ae8b4.tar.gz
cmd/cgo: fix handling of defs_linux.go
Instead of including <sys/types.h> to get size_t, instead include the ISO C standard <stddef.h> header, which defines fewer additional types at risk of colliding with the user code. In particular, this prevents collisions between <sys/types.h>'s userspace definitions with the kernel definitions needed by defs_linux.go. Also, -cdefs mode uses #pragma pack, so we can keep misaligned fields. Fixes issue 8477. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/120610043 Committer: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/cgo/out.go')
-rw-r--r--src/cmd/cgo/out.go10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index c6c27c4db..1ef78b757 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -1148,16 +1148,10 @@ __cgo_size_assert(double, 8)
`
const builtinProlog = `
-#include <sys/types.h> /* for size_t below */
+#include <stddef.h> /* for ptrdiff_t and size_t below */
/* Define intgo when compiling with GCC. */
-#ifdef __PTRDIFF_TYPE__
-typedef __PTRDIFF_TYPE__ intgo;
-#elif defined(_LP64)
-typedef long long intgo;
-#else
-typedef int intgo;
-#endif
+typedef ptrdiff_t intgo;
typedef struct { char *p; intgo n; } _GoString_;
typedef struct { char *p; intgo n; intgo c; } _GoBytes_;