This source file includes following definitions.
- x_cgo_init
 
- _cgo_sys_thread_start
 
- threadentry
 
#define WIN64_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
#include <stdlib.h>
#include <stdio.h>
#include "libcgo.h"
static void threadentry(void*);
#define STACKSIZE (2*1024*1024)
void
x_cgo_init(G *g)
{
        int tmp;
        g->stackguard = (uintptr)&tmp - STACKSIZE + 8*1024;
}
void
_cgo_sys_thread_start(ThreadStart *ts)
{
        uintptr_t thandle;
        thandle = _beginthread(threadentry, 0, ts);
        if(thandle == -1) {
                fprintf(stderr, "runtime: failed to create new OS thread (%d)\n", errno);
                abort();
        }
}
static void
threadentry(void *v)
{
        ThreadStart ts;
        ts = *(ThreadStart*)v;
        free(v);
        ts.g->stackbase = (uintptr)&ts;
        ts.g->stackguard = (uintptr)&ts - STACKSIZE + 8*1024;
        
        asm volatile (
          "movq %0, %%gs:0x28\n"        
          "movq %%gs:0x28, %%rax\n" 
          "movq %1, 0(%%rax)\n" 
          "movq %2, 8(%%rax)\n" 
          :: "r"(ts.tls), "r"(ts.g), "r"(ts.m) : "%rax"
        );
        crosscall_amd64(ts.fn);
}