Text file src/runtime/cgo/gcc_windows_arm64.c

     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  #define WIN32_LEAN_AND_MEAN
     6  #include <windows.h>
     7  #include <process.h>
     8  #include <stdlib.h>
     9  #include <stdio.h>
    10  #include <errno.h>
    11  #include "libcgo.h"
    12  #include "libcgo_windows.h"
    13  
    14  static void threadentry(void*);
    15  static void (*setg_gcc)(void*);
    16  
    17  void
    18  x_cgo_init(G *g, void (*setg)(void*))
    19  {
    20  	setg_gcc = setg;
    21  }
    22  
    23  void
    24  _cgo_sys_thread_start(ThreadStart *ts)
    25  {
    26  	uintptr_t thandle;
    27  
    28  	thandle = _beginthread(threadentry, 0, ts);
    29  	if(thandle == -1) {
    30  		fprintf(stderr, "runtime: failed to create new OS thread (%d)\n", errno);
    31  		abort();
    32  	}
    33  }
    34  
    35  extern void crosscall1(void (*fn)(void), void (*setg_gcc)(void*), void *g);
    36  
    37  static void
    38  threadentry(void *v)
    39  {
    40  	ThreadStart ts;
    41  
    42  	ts = *(ThreadStart*)v;
    43  	free(v);
    44  
    45  	crosscall1(ts.fn, setg_gcc, (void *)ts.g);
    46  }
    47  

View as plain text