...
Run Format

Text file misc/cgo/testso/cgoso_c.c

     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	// +build ignore
     6	
     7	#ifdef WIN32
     8	// A Windows DLL is unable to call an arbitrary function in
     9	// the main executable. Work around that by making the main
    10	// executable pass the callback function pointer to us.
    11	void (*goCallback)(void);
    12	__declspec(dllexport) void setCallback(void *f)
    13	{
    14		goCallback = (void (*)())f;
    15	}
    16	__declspec(dllexport) void sofunc(void);
    17	#else
    18	extern void goCallback(void);
    19	void setCallback(void *f) { (void)f; }
    20	#endif
    21	
    22	// OpenBSD and older Darwin lack TLS support
    23	#if !defined(__OpenBSD__) && !defined(__APPLE__)
    24	__thread int tlsvar = 12345;
    25	#endif
    26	
    27	void sofunc(void)
    28	{
    29		goCallback();
    30	}

View as plain text