github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/pkg/runtime/cgo/libcgo.h (about)

     1  // Copyright 2009 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 <stdint.h>
     6  #include <stdlib.h>
     7  #include <stdio.h>
     8  
     9  #define nil ((void*)0)
    10  #define nelem(x) (sizeof(x)/sizeof((x)[0]))
    11  
    12  typedef uint32_t uint32;
    13  typedef uint64_t uint64;
    14  typedef uintptr_t uintptr;
    15  
    16  /*
    17   * The beginning of the per-goroutine structure,
    18   * as defined in ../pkg/runtime/runtime.h.
    19   * Just enough to edit these two fields.
    20   */
    21  typedef struct G G;
    22  struct G
    23  {
    24  	uintptr stackguard;
    25  	uintptr stackbase;
    26  };
    27  
    28  /*
    29   * Arguments to the _cgo_thread_start call.
    30   * Also known to ../pkg/runtime/runtime.h.
    31   */
    32  typedef struct ThreadStart ThreadStart;
    33  struct ThreadStart
    34  {
    35  	uintptr m;
    36  	G *g;
    37  	uintptr *tls;
    38  	void (*fn)(void);
    39  };
    40  
    41  /*
    42   * Called by 5c/6c/8c world.
    43   * Makes a local copy of the ThreadStart and
    44   * calls _cgo_sys_thread_start(ts).
    45   */
    46  extern void (*_cgo_thread_start)(ThreadStart *ts);
    47  
    48  /*
    49   * Creates the new operating system thread (OS, arch dependent).
    50   */
    51  void _cgo_sys_thread_start(ThreadStart *ts);
    52  
    53  /*
    54   * Call fn in the 6c world.
    55   */
    56  void crosscall_amd64(void (*fn)(void));
    57  
    58  /*
    59   * Call fn in the 8c world.
    60   */
    61  void crosscall_386(void (*fn)(void));