misc/cgo/test: test of issue 4339

This is not quite what that issue reports,
because this does not involve a DLL.
But I wanted to make sure this much was working.

Update #4339

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13653043
This commit is contained in:
Russ Cox 2013-09-11 09:56:38 -04:00
parent 3ee0744c06
commit 71ed6eb25a
4 changed files with 44 additions and 0 deletions

View File

@ -45,5 +45,6 @@ func Test5603(t *testing.T) { test5603(t) }
func Test3250(t *testing.T) { test3250(t) }
func TestCallbackStack(t *testing.T) { testCallbackStack(t) }
func TestFpVar(t *testing.T) { testFpVar(t) }
func Test4339(t *testing.T) { test4339(t) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }

18
misc/cgo/test/issue4339.c Normal file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include "issue4339.h"
static void
impl(void)
{
//printf("impl\n");
}
Issue4339 exported4339 = {"bar", impl};
void
handle4339(Issue4339 *x)
{
//printf("handle\n");
x->bar();
//printf("done\n");
}

View File

@ -0,0 +1,16 @@
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cgotest
/*
#include "issue4339.h"
*/
import "C"
import "testing"
func test4339(t *testing.T) {
C.handle4339(&C.exported4339)
}

View File

@ -0,0 +1,9 @@
typedef struct Issue4339 Issue4339;
struct Issue4339 {
char *name;
void (*bar)(void);
};
extern Issue4339 exported4339;
void handle4339(Issue4339*);