...

Text file src/cmd/cgo/internal/test/callback_c.c

Documentation: cmd/cgo/internal/test

     1// Copyright 2011 The Go Authors. All rights reserved.
     2// Use of this source code is governed by a BSD-style
     3// license that can be found in the LICENSE file.
     4
     5#include <string.h>
     6
     7#include "_cgo_export.h"
     8
     9void
    10callback(void *f)
    11{
    12	// use some stack space
    13	volatile char data[64*1024];
    14
    15	data[0] = 0;
    16	goCallback(f);
    17        data[sizeof(data)-1] = 0;
    18}
    19
    20void
    21callGoFoo(void)
    22{
    23	extern void goFoo(void);
    24	goFoo();
    25}
    26
    27void
    28IntoC(void)
    29{
    30	BackIntoGo();
    31}
    32
    33void
    34Issue1560InC(void)
    35{
    36	Issue1560FromC();
    37}
    38
    39void
    40callGoStackCheck(void)
    41{
    42	extern void goStackCheck(void);
    43	goStackCheck();
    44}
    45
    46int
    47returnAfterGrow(void)
    48{
    49	extern int goReturnVal(void);
    50	goReturnVal();
    51	return 123456;
    52}
    53
    54int
    55returnAfterGrowFromGo(void)
    56{
    57	extern int goReturnVal(void);
    58	return goReturnVal();
    59}
    60
    61void
    62callGoWithString(void)
    63{
    64	extern void goWithString(GoString);
    65	const char *str = "string passed from C to Go";
    66	goWithString((GoString){str, strlen(str)});
    67}

View as plain text