Commit 709096f1 authored by Ian Lance Taylor's avatar Ian Lance Taylor Committed by Russ Cox

misc/cgo/testcdefs: comment out test of packed structs

The [568]c compilers no longer support packed structs, so
using them with -cdefs no longer works.  Just commenting out
the test, rather than removing it, in case this needs to be
handled.  It may be that -cdefs can go away entirely in the
future, in which case so can this directory.

LGTM=mdempsky
R=rsc, mdempsky
CC=golang-codereviews
https://golang.org/cl/136030043
parent 0bb14d74
...@@ -56,4 +56,5 @@ typedef struct timespec { ...@@ -56,4 +56,5 @@ typedef struct timespec {
import "C" import "C"
type CdefsTest C.struct_cdefsTest type CdefsTest C.struct_cdefsTest
type PackedTest C.struct_packedTest
//type PackedTest C.struct_packedTest
...@@ -17,6 +17,8 @@ struct CdefsOrig { ...@@ -17,6 +17,8 @@ struct CdefsOrig {
int8 **array5[20][20]; int8 **array5[20][20];
}; };
// Packed structs are no longer supported for -cdefs.
/*
typedef struct PackedOrig PackedOrig; typedef struct PackedOrig PackedOrig;
#pragma pack on #pragma pack on
struct PackedOrig { struct PackedOrig {
...@@ -25,14 +27,15 @@ struct PackedOrig { ...@@ -25,14 +27,15 @@ struct PackedOrig {
int64 third; int64 third;
}; };
#pragma pack off #pragma pack off
*/
void void
main·test(int32 ret) main·test(int32 ret)
{ {
CdefsOrig o; CdefsOrig o;
CdefsTest t; CdefsTest t;
PackedOrig po; // PackedOrig po;
PackedTest pt; // PackedTest pt;
ret = 0; ret = 0;
if(sizeof(t.array1) != sizeof(o.array1) || offsetof(CdefsTest, array1[0]) != offsetof(CdefsOrig, array1[0])) { if(sizeof(t.array1) != sizeof(o.array1) || offsetof(CdefsTest, array1[0]) != offsetof(CdefsOrig, array1[0])) {
...@@ -55,6 +58,7 @@ main·test(int32 ret) ...@@ -55,6 +58,7 @@ main·test(int32 ret)
runtime·printf("array5: size, offset = %d, %d, want %d, %d\n", sizeof(t.array5), offsetof(CdefsTest, array5[0][0]), sizeof(o.array5), offsetof(CdefsOrig, array5[0][0])); runtime·printf("array5: size, offset = %d, %d, want %d, %d\n", sizeof(t.array5), offsetof(CdefsTest, array5[0][0]), sizeof(o.array5), offsetof(CdefsOrig, array5[0][0]));
ret = 1; ret = 1;
} }
/*
if(sizeof(pt.first) != sizeof(po.first) || offsetof(PackedTest, first) != offsetof(PackedOrig, first)) { if(sizeof(pt.first) != sizeof(po.first) || offsetof(PackedTest, first) != offsetof(PackedOrig, first)) {
runtime·printf("first: size, offset = %d, %d, want %d, %d\n", sizeof(pt.first), offsetof(PackedTest, first), sizeof(po.first), offsetof(PackedOrig, first)); runtime·printf("first: size, offset = %d, %d, want %d, %d\n", sizeof(pt.first), offsetof(PackedTest, first), sizeof(po.first), offsetof(PackedOrig, first));
ret = 1; ret = 1;
...@@ -67,5 +71,6 @@ main·test(int32 ret) ...@@ -67,5 +71,6 @@ main·test(int32 ret)
runtime·printf("third: size, offset = %d, %d, want %d, %d\n", sizeof(pt.third), offsetof(PackedTest, third), sizeof(po.third), offsetof(PackedOrig, third)); runtime·printf("third: size, offset = %d, %d, want %d, %d\n", sizeof(pt.third), offsetof(PackedTest, third), sizeof(po.third), offsetof(PackedOrig, third));
ret = 1; ret = 1;
} }
*/
FLUSH(&ret); // flush return value FLUSH(&ret); // flush return value
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment