summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/windows')
-rw-r--r--src/pkg/runtime/windows/386/defs.h81
-rw-r--r--src/pkg/runtime/windows/386/rt0.s14
-rw-r--r--src/pkg/runtime/windows/386/signal.c98
-rw-r--r--src/pkg/runtime/windows/386/sys.s252
-rw-r--r--src/pkg/runtime/windows/amd64/defs.h40
-rw-r--r--src/pkg/runtime/windows/amd64/rt0.s10
-rw-r--r--src/pkg/runtime/windows/amd64/signal.c20
-rw-r--r--src/pkg/runtime/windows/amd64/sys.s129
-rw-r--r--src/pkg/runtime/windows/defs.c37
-rw-r--r--src/pkg/runtime/windows/mem.c70
-rw-r--r--src/pkg/runtime/windows/os.h30
-rw-r--r--src/pkg/runtime/windows/signals.h3
-rw-r--r--src/pkg/runtime/windows/syscall.goc67
-rw-r--r--src/pkg/runtime/windows/thread.c420
14 files changed, 0 insertions, 1271 deletions
diff --git a/src/pkg/runtime/windows/386/defs.h b/src/pkg/runtime/windows/386/defs.h
deleted file mode 100644
index 49fc19504..000000000
--- a/src/pkg/runtime/windows/386/defs.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// c:\Users\Hector\Code\go\bin\godefs.exe defs.c
-
-// MACHINE GENERATED - DO NOT EDIT.
-
-// Constants
-enum {
- PROT_NONE = 0,
- PROT_READ = 0x1,
- PROT_WRITE = 0x2,
- PROT_EXEC = 0x4,
- MAP_ANON = 0x1,
- MAP_PRIVATE = 0x2,
- SIGINT = 0x2,
- CTRL_C_EVENT = 0,
- CTRL_BREAK_EVENT = 0x1,
- EXCEPTION_ACCESS_VIOLATION = 0xc0000005,
- EXCEPTION_BREAKPOINT = 0x80000003,
- EXCEPTION_FLT_DENORMAL_OPERAND = 0xc000008d,
- EXCEPTION_FLT_DIVIDE_BY_ZERO = 0xc000008e,
- EXCEPTION_FLT_INEXACT_RESULT = 0xc000008f,
- EXCEPTION_FLT_OVERFLOW = 0xc0000091,
- EXCEPTION_FLT_UNDERFLOW = 0xc0000093,
- EXCEPTION_INT_DIVIDE_BY_ZERO = 0xc0000094,
- EXCEPTION_INT_OVERFLOW = 0xc0000095,
-};
-
-// Types
-#pragma pack on
-
-typedef struct ExceptionRecord ExceptionRecord;
-struct ExceptionRecord {
- uint32 ExceptionCode;
- uint32 ExceptionFlags;
- ExceptionRecord *ExceptionRecord;
- void *ExceptionAddress;
- uint32 NumberParameters;
- uint32 ExceptionInformation[15];
-};
-
-typedef struct FloatingSaveArea FloatingSaveArea;
-struct FloatingSaveArea {
- uint32 ControlWord;
- uint32 StatusWord;
- uint32 TagWord;
- uint32 ErrorOffset;
- uint32 ErrorSelector;
- uint32 DataOffset;
- uint32 DataSelector;
- uint8 RegisterArea[80];
- uint32 Cr0NpxState;
-};
-
-typedef struct Context Context;
-struct Context {
- uint32 ContextFlags;
- uint32 Dr0;
- uint32 Dr1;
- uint32 Dr2;
- uint32 Dr3;
- uint32 Dr6;
- uint32 Dr7;
- FloatingSaveArea FloatSave;
- uint32 SegGs;
- uint32 SegFs;
- uint32 SegEs;
- uint32 SegDs;
- uint32 Edi;
- uint32 Esi;
- uint32 Ebx;
- uint32 Edx;
- uint32 Ecx;
- uint32 Eax;
- uint32 Ebp;
- uint32 Eip;
- uint32 SegCs;
- uint32 EFlags;
- uint32 Esp;
- uint32 SegSs;
- uint8 ExtendedRegisters[512];
-};
-#pragma pack off
diff --git a/src/pkg/runtime/windows/386/rt0.s b/src/pkg/runtime/windows/386/rt0.s
deleted file mode 100644
index 3b023de2f..000000000
--- a/src/pkg/runtime/windows/386/rt0.s
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-TEXT _rt0_386_windows(SB),7,$0
- // Set up SEH frame for bootstrap m
- PUSHL $runtime·sigtramp(SB)
- PUSHL 0(FS)
- MOVL SP, 0(FS)
-
- JMP _rt0_386(SB)
-
-DATA runtime·iswindows(SB)/4, $1
-GLOBL runtime·iswindows(SB), $4
diff --git a/src/pkg/runtime/windows/386/signal.c b/src/pkg/runtime/windows/386/signal.c
deleted file mode 100644
index cc6a2302f..000000000
--- a/src/pkg/runtime/windows/386/signal.c
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "runtime.h"
-#include "defs.h"
-#include "os.h"
-
-void
-runtime·dumpregs(Context *r)
-{
- runtime·printf("eax %x\n", r->Eax);
- runtime·printf("ebx %x\n", r->Ebx);
- runtime·printf("ecx %x\n", r->Ecx);
- runtime·printf("edx %x\n", r->Edx);
- runtime·printf("edi %x\n", r->Edi);
- runtime·printf("esi %x\n", r->Esi);
- runtime·printf("ebp %x\n", r->Ebp);
- runtime·printf("esp %x\n", r->Esp);
- runtime·printf("eip %x\n", r->Eip);
- runtime·printf("eflags %x\n", r->EFlags);
- runtime·printf("cs %x\n", r->SegCs);
- runtime·printf("fs %x\n", r->SegFs);
- runtime·printf("gs %x\n", r->SegGs);
-}
-
-void
-runtime·initsig(int32)
-{
- runtime·siginit();
-}
-
-uint32
-runtime·sighandler(ExceptionRecord *info, void *frame, Context *r)
-{
- uintptr *sp;
- G *gp;
-
- USED(frame);
-
- switch(info->ExceptionCode) {
- case EXCEPTION_BREAKPOINT:
- r->Eip--; // because 8l generates 2 bytes for INT3
- return 1;
- }
-
- if((gp = m->curg) != nil && runtime·issigpanic(info->ExceptionCode)) {
- // Make it look like a call to the signal func.
- // Have to pass arguments out of band since
- // augmenting the stack frame would break
- // the unwinding code.
- gp->sig = info->ExceptionCode;
- gp->sigcode0 = info->ExceptionInformation[0];
- gp->sigcode1 = info->ExceptionInformation[1];
- gp->sigpc = r->Eip;
-
- // Only push runtime·sigpanic if r->eip != 0.
- // If r->eip == 0, probably panicked because of a
- // call to a nil func. Not pushing that onto sp will
- // make the trace look like a call to runtime·sigpanic instead.
- // (Otherwise the trace will end at runtime·sigpanic and we
- // won't get to see who faulted.)
- if(r->Eip != 0) {
- sp = (uintptr*)r->Esp;
- *--sp = r->Eip;
- r->Esp = (uintptr)sp;
- }
- r->Eip = (uintptr)runtime·sigpanic;
- return 0;
- }
-
- if(runtime·panicking) // traceback already printed
- runtime·exit(2);
- runtime·panicking = 1;
-
- runtime·printf("Exception %x %p %p\n", info->ExceptionCode,
- info->ExceptionInformation[0], info->ExceptionInformation[1]);
-
- runtime·printf("PC=%x\n", r->Eip);
- runtime·printf("\n");
-
- if(runtime·gotraceback()){
- runtime·traceback((void*)r->Eip, (void*)r->Esp, 0, m->curg);
- runtime·tracebackothers(m->curg);
- runtime·dumpregs(r);
- }
-
- runtime·exit(2);
- return 0;
-}
-
-void
-runtime·resetcpuprofiler(int32 hz)
-{
- // TODO: Enable profiling interrupts.
-
- m->profilehz = hz;
-}
diff --git a/src/pkg/runtime/windows/386/sys.s b/src/pkg/runtime/windows/386/sys.s
deleted file mode 100644
index d38405075..000000000
--- a/src/pkg/runtime/windows/386/sys.s
+++ /dev/null
@@ -1,252 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "386/asm.h"
-
-// void *stdcall_raw(void *fn, int32 count, uintptr *args)
-TEXT runtime·stdcall_raw(SB),7,$0
- // Copy arguments from stack.
- MOVL fn+0(FP), AX
- MOVL count+4(FP), CX // words
- MOVL args+8(FP), BP
-
- // Switch to m->g0 if needed.
- get_tls(DI)
- MOVL m(DI), DX
- MOVL 0(FS), SI
- MOVL SI, m_sehframe(DX)
- MOVL m_g0(DX), SI
- CMPL g(DI), SI
- MOVL SP, BX
- JEQ 2(PC)
- MOVL (g_sched+gobuf_sp)(SI), SP
- PUSHL BX
- PUSHL g(DI)
- MOVL SI, g(DI)
-
- // Copy args to new stack.
- MOVL CX, BX
- SALL $2, BX
- SUBL BX, SP // room for args
- MOVL SP, DI
- MOVL BP, SI
- CLD
- REP; MOVSL
-
- // Call stdcall function.
- CALL AX
-
- // Restore original SP, g.
- get_tls(DI)
- POPL g(DI)
- POPL SP
-
- // Someday the convention will be D is always cleared.
- CLD
-
- RET
-
-// faster get/set last error
-TEXT runtime·getlasterror(SB),7,$0
- MOVL 0x34(FS), AX
- RET
-
-TEXT runtime·setlasterror(SB),7,$0
- MOVL err+0(FP), AX
- MOVL AX, 0x34(FS)
- RET
-
-TEXT runtime·sigtramp(SB),7,$0
- PUSHL BP // cdecl
- PUSHL BX
- PUSHL SI
- PUSHL DI
- PUSHL 0(FS)
- CALL runtime·sigtramp1(SB)
- POPL 0(FS)
- POPL DI
- POPL SI
- POPL BX
- POPL BP
- RET
-
-TEXT runtime·sigtramp1(SB),0,$16-40
- // unwinding?
- MOVL info+24(FP), BX
- MOVL 4(BX), CX // exception flags
- ANDL $6, CX
- MOVL $1, AX
- JNZ sigdone
-
- // place ourselves at the top of the SEH chain to
- // ensure SEH frames lie within thread stack bounds
- MOVL frame+28(FP), CX // our SEH frame
- MOVL CX, 0(FS)
-
- // copy arguments for call to sighandler
- MOVL BX, 0(SP)
- MOVL CX, 4(SP)
- MOVL context+32(FP), BX
- MOVL BX, 8(SP)
- MOVL dispatcher+36(FP), BX
- MOVL BX, 12(SP)
-
- CALL runtime·sighandler(SB)
- TESTL AX, AX
- JZ sigdone
-
- // call windows default handler early
- MOVL 4(SP), BX // our SEH frame
- MOVL 0(BX), BX // SEH frame of default handler
- MOVL BX, 4(SP) // set establisher frame
- CALL 4(BX)
-
-sigdone:
- RET
-
-// Windows runs the ctrl handler in a new thread.
-TEXT runtime·ctrlhandler(SB),7,$0
- PUSHL BP
- MOVL SP, BP
- PUSHL BX
- PUSHL SI
- PUSHL DI
- PUSHL 0x2c(FS)
- MOVL SP, BX
-
- // setup dummy m, g
- SUBL $(m_sehframe+4), SP // at least space for m_sehframe
- LEAL m_tls(SP), CX
- MOVL CX, 0x2c(FS)
- MOVL SP, m(CX)
- MOVL SP, DX
- SUBL $8, SP // space for g_stack{guard,base}
- MOVL SP, g(CX)
- MOVL SP, m_g0(DX)
- LEAL -4096(SP), CX
- MOVL CX, g_stackguard(SP)
- MOVL BX, g_stackbase(SP)
-
- PUSHL 8(BP)
- CALL runtime·ctrlhandler1(SB)
- POPL CX
-
- get_tls(CX)
- MOVL g(CX), CX
- MOVL g_stackbase(CX), SP
- POPL 0x2c(FS)
- POPL DI
- POPL SI
- POPL BX
- POPL BP
- MOVL 0(SP), CX
- ADDL $8, SP
- JMP CX
-
-// Called from dynamic function created by ../thread.c compilecallback,
-// running on Windows stack (not Go stack).
-// BX, BP, SI, DI registers and DF flag are preserved
-// as required by windows callback convention.
-// AX = address of go func we need to call
-// DX = total size of arguments
-//
-TEXT runtime·callbackasm+0(SB),7,$0
- // preserve whatever's at the memory location that
- // the callback will use to store the return value
- LEAL 8(SP), CX
- PUSHL 0(CX)(DX*1)
- ADDL $4, DX // extend argsize by size of return value
-
- // save registers as required for windows callback
- PUSHL 0(FS)
- PUSHL DI
- PUSHL SI
- PUSHL BP
- PUSHL BX
- PUSHL DX
- PUSHL CX
- PUSHL AX
-
- // reinstall our SEH handler
- get_tls(CX)
- MOVL m(CX), CX
- MOVL m_sehframe(CX), CX
- MOVL CX, 0(FS)
- CLD
-
- CALL runtime·cgocallback(SB)
-
- // restore registers as required for windows callback
- POPL AX
- POPL CX
- POPL DX
- POPL BX
- POPL BP
- POPL SI
- POPL DI
- POPL 0(FS)
- CLD
-
- MOVL -4(CX)(DX*1), AX
- POPL -4(CX)(DX*1)
- RET
-
-// void tstart(M *newm);
-TEXT runtime·tstart(SB),7,$0
- MOVL newm+4(SP), CX // m
- MOVL m_g0(CX), DX // g
-
- // Set up SEH frame
- PUSHL $runtime·sigtramp(SB)
- PUSHL 0(FS)
- MOVL SP, 0(FS)
-
- // Layout new m scheduler stack on os stack.
- MOVL SP, AX
- MOVL AX, g_stackbase(DX)
- SUBL $(64*1024), AX // stack size
- MOVL AX, g_stackguard(DX)
-
- // Set up tls.
- LEAL m_tls(CX), SI
- MOVL SI, 0x2c(FS)
- MOVL CX, m(SI)
- MOVL DX, g(SI)
-
- // Someday the convention will be D is always cleared.
- CLD
-
- CALL runtime·stackcheck(SB) // clobbers AX,CX
-
- CALL runtime·mstart(SB)
-
- // Pop SEH frame
- MOVL 0(FS), SP
- POPL 0(FS)
- POPL CX
-
- RET
-
-// uint32 tstart_stdcall(M *newm);
-TEXT runtime·tstart_stdcall(SB),7,$0
- MOVL newm+4(SP), BX
-
- PUSHL BX
- CALL runtime·tstart(SB)
- POPL BX
-
- // Adjust stack for stdcall to return properly.
- MOVL (SP), AX // save return address
- ADDL $4, SP // remove single parameter
- MOVL AX, (SP) // restore return address
-
- XORL AX, AX // return 0 == success
-
- RET
-
-// setldt(int entry, int address, int limit)
-TEXT runtime·setldt(SB),7,$0
- MOVL address+4(FP), CX
- MOVL CX, 0x2c(FS)
- RET
diff --git a/src/pkg/runtime/windows/amd64/defs.h b/src/pkg/runtime/windows/amd64/defs.h
deleted file mode 100644
index 830c6a855..000000000
--- a/src/pkg/runtime/windows/amd64/defs.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// g:\opensource\go\bin\godefs.exe -f -m64 defs.c
-
-// MACHINE GENERATED - DO NOT EDIT.
-
-// Constants
-enum {
- PROT_NONE = 0,
- PROT_READ = 0x1,
- PROT_WRITE = 0x2,
- PROT_EXEC = 0x4,
- MAP_ANON = 0x1,
- MAP_PRIVATE = 0x2,
- SIGINT = 0x2,
- CTRL_C_EVENT = 0,
- CTRL_BREAK_EVENT = 0x1,
- EXCEPTION_ACCESS_VIOLATION = 0xc0000005,
- EXCEPTION_BREAKPOINT = 0x80000003,
- EXCEPTION_FLT_DENORMAL_OPERAND = 0xc000008d,
- EXCEPTION_FLT_DIVIDE_BY_ZERO = 0xc000008e,
- EXCEPTION_FLT_INEXACT_RESULT = 0xc000008f,
- EXCEPTION_FLT_OVERFLOW = 0xc0000091,
- EXCEPTION_FLT_UNDERFLOW = 0xc0000093,
- EXCEPTION_INT_DIVIDE_BY_ZERO = 0xc0000094,
- EXCEPTION_INT_OVERFLOW = 0xc0000095,
-};
-
-// Types
-#pragma pack on
-
-typedef struct ExceptionRecord ExceptionRecord;
-struct ExceptionRecord {
- uint32 ExceptionCode;
- uint32 ExceptionFlags;
- ExceptionRecord *ExceptionRecord;
- void *ExceptionAddress;
- uint32 NumberParameters;
- byte pad_godefs_0[4];
- uint64 ExceptionInformation[15];
-};
-#pragma pack off
diff --git a/src/pkg/runtime/windows/amd64/rt0.s b/src/pkg/runtime/windows/amd64/rt0.s
deleted file mode 100644
index e54e7edeb..000000000
--- a/src/pkg/runtime/windows/amd64/rt0.s
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "amd64/asm.h"
-
-TEXT _rt0_amd64_windows(SB),7,$-8
- MOVQ $_rt0_amd64(SB), AX
- MOVQ SP, DI
- JMP AX
diff --git a/src/pkg/runtime/windows/amd64/signal.c b/src/pkg/runtime/windows/amd64/signal.c
deleted file mode 100644
index 1fc3eb060..000000000
--- a/src/pkg/runtime/windows/amd64/signal.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "runtime.h"
-#include "defs.h"
-#include "os.h"
-
-void
-runtime·initsig(int32 queue)
-{
-}
-
-void
-runtime·resetcpuprofiler(int32 hz)
-{
- // TODO: Enable profiling interrupts.
-
- m->profilehz = hz;
-}
diff --git a/src/pkg/runtime/windows/amd64/sys.s b/src/pkg/runtime/windows/amd64/sys.s
deleted file mode 100644
index b1eacfc82..000000000
--- a/src/pkg/runtime/windows/amd64/sys.s
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "amd64/asm.h"
-
-// void *stdcall_raw(void *fn, uintptr nargs, void *args)
-TEXT runtime·stdcall_raw(SB),7,$8
- MOVQ fn+0(FP), AX
- MOVQ nargs+8(FP), CX
- MOVQ args+16(FP), R11
-
- // Switch to m->g0 if needed.
- get_tls(DI)
- MOVQ m(DI), DX
- MOVQ g(DI), SI
- MOVQ SI, 0(SP) // save g
- MOVQ SP, m_gostack(DX) // save SP
- MOVQ m_g0(DX), SI
- CMPQ g(DI), SI
- JEQ 3(PC)
- MOVQ (g_sched+gobuf_sp)(SI), SP
- MOVQ SI, g(DI)
-
- SUBQ $0x60, SP
-
- // Copy args to new stack.
- MOVQ SP, DI
- MOVQ R11, SI
- CLD
- REP; MOVSQ
- MOVQ 0(R11), CX
- MOVQ 8(R11), DX
- MOVQ 16(R11), R8
- MOVQ 24(R11), R9
-
- // Call stdcall function.
- CALL AX
-
- // Restore original SP, g.
- get_tls(DI)
- MOVQ m(DI), DX
- MOVQ m_gostack(DX), SP // restore SP
- MOVQ 0(SP), SI // restore g
- MOVQ SI, g(DI)
-
- RET
-
-// faster get/set last error
-TEXT runtime·getlasterror(SB),7,$0
- MOVQ 0x30(GS), AX
- MOVL 0x68(AX), AX
- RET
-
-TEXT runtime·setlasterror(SB),7,$0
- MOVL err+0(FP), AX
- MOVQ 0x30(GS), CX
- MOVL AX, 0x68(CX)
- RET
-
-// Windows runs the ctrl handler in a new thread.
-TEXT runtime·ctrlhandler(SB),7,$0
- // TODO
- RET
-
-TEXT runtime·callbackasm(SB),7,$0
- // TODO
- RET
-
-// void tstart(M *newm);
-TEXT runtime·tstart(SB),7,$0
- MOVQ newm+8(SP), CX // m
- MOVQ m_g0(CX), DX // g
-
- MOVQ SP, DI // remember stack
-
- // Layout new m scheduler stack on os stack.
- MOVQ SP, AX
- MOVQ AX, g_stackbase(DX)
- SUBQ $(64*1024), AX // stack size
- MOVQ AX, g_stackguard(DX)
-
- // Set up tls.
- LEAQ m_tls(CX), SI
- MOVQ SI, 0x58(GS)
- MOVQ CX, m(SI)
- MOVQ DX, g(SI)
-
- // Someday the convention will be D is always cleared.
- CLD
-
- PUSHQ DI // original stack
-
- CALL runtime·stackcheck(SB) // clobbers AX,CX
-
- CALL runtime·mstart(SB)
-
- POPQ DI // original stack
- MOVQ DI, SP
-
- RET
-
-// uint32 tstart_stdcall(M *newm);
-TEXT runtime·tstart_stdcall(SB),7,$0
- MOVQ CX, BX // stdcall first arg in RCX
-
- PUSHQ BX
- CALL runtime·tstart+0(SB)
- POPQ BX
-
- // Adjust stack for stdcall to return properly.
- MOVQ (SP), AX // save return address
- ADDQ $8, SP // remove single parameter
- MOVQ AX, (SP) // restore return address
-
- XORL AX, AX // return 0 == success
-
- RET
-
-TEXT runtime·notok(SB),7,$0
- MOVQ $0xf1, BP
- MOVQ BP, (BP)
- RET
-
-// set tls base to DI
-TEXT runtime·settls(SB),7,$0
- MOVQ DI, 0x58(GS)
- RET
-
diff --git a/src/pkg/runtime/windows/defs.c b/src/pkg/runtime/windows/defs.c
deleted file mode 100644
index 3b2824940..000000000
--- a/src/pkg/runtime/windows/defs.c
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include <signal.h>
-#include <stdarg.h>
-#include <windef.h>
-#include <winbase.h>
-#include <wincon.h>
-
-enum {
- $PROT_NONE = 0,
- $PROT_READ = 1,
- $PROT_WRITE = 2,
- $PROT_EXEC = 4,
-
- $MAP_ANON = 1,
- $MAP_PRIVATE = 2,
-
- $SIGINT = SIGINT,
- $CTRL_C_EVENT = CTRL_C_EVENT,
- $CTRL_BREAK_EVENT = CTRL_BREAK_EVENT,
-
- $EXCEPTION_ACCESS_VIOLATION = STATUS_ACCESS_VIOLATION,
- $EXCEPTION_BREAKPOINT = STATUS_BREAKPOINT,
- $EXCEPTION_FLT_DENORMAL_OPERAND = STATUS_FLOAT_DENORMAL_OPERAND,
- $EXCEPTION_FLT_DIVIDE_BY_ZERO = STATUS_FLOAT_DIVIDE_BY_ZERO,
- $EXCEPTION_FLT_INEXACT_RESULT = STATUS_FLOAT_INEXACT_RESULT,
- $EXCEPTION_FLT_OVERFLOW = STATUS_FLOAT_OVERFLOW,
- $EXCEPTION_FLT_UNDERFLOW = STATUS_FLOAT_UNDERFLOW,
- $EXCEPTION_INT_DIVIDE_BY_ZERO = STATUS_INTEGER_DIVIDE_BY_ZERO,
- $EXCEPTION_INT_OVERFLOW = STATUS_INTEGER_OVERFLOW,
-};
-
-typedef EXCEPTION_RECORD $ExceptionRecord;
-typedef FLOATING_SAVE_AREA $FloatingSaveArea;
-typedef CONTEXT $Context;
diff --git a/src/pkg/runtime/windows/mem.c b/src/pkg/runtime/windows/mem.c
deleted file mode 100644
index 5d2291fa3..000000000
--- a/src/pkg/runtime/windows/mem.c
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "runtime.h"
-#include "os.h"
-#include "defs.h"
-#include "malloc.h"
-
-enum {
- MEM_COMMIT = 0x1000,
- MEM_RESERVE = 0x2000,
- MEM_RELEASE = 0x8000,
-
- PAGE_EXECUTE_READWRITE = 0x40,
-};
-
-#pragma dynimport runtime·VirtualAlloc VirtualAlloc "kernel32.dll"
-#pragma dynimport runtime·VirtualFree VirtualFree "kernel32.dll"
-extern void *runtime·VirtualAlloc;
-extern void *runtime·VirtualFree;
-
-void*
-runtime·SysAlloc(uintptr n)
-{
- mstats.sys += n;
- return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)(MEM_COMMIT|MEM_RESERVE), (uintptr)PAGE_EXECUTE_READWRITE);
-}
-
-void
-runtime·SysUnused(void *v, uintptr n)
-{
- USED(v);
- USED(n);
-}
-
-void
-runtime·SysFree(void *v, uintptr n)
-{
- uintptr r;
-
- mstats.sys -= n;
- r = (uintptr)runtime·stdcall(runtime·VirtualFree, 3, v, (uintptr)0, (uintptr)MEM_RELEASE);
- if(r == 0)
- runtime·throw("runtime: failed to release pages");
-}
-
-void*
-runtime·SysReserve(void *v, uintptr n)
-{
- // v is just a hint.
- // First try at v.
- v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_EXECUTE_READWRITE);
- if(v != nil)
- return v;
-
- // Next let the kernel choose the address.
- return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_EXECUTE_READWRITE);
-}
-
-void
-runtime·SysMap(void *v, uintptr n)
-{
- void *p;
-
- mstats.sys += n;
- p = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, (uintptr)MEM_COMMIT, (uintptr)PAGE_EXECUTE_READWRITE);
- if(p != v)
- runtime·throw("runtime: cannot map pages in arena address space");
-}
diff --git a/src/pkg/runtime/windows/os.h b/src/pkg/runtime/windows/os.h
deleted file mode 100644
index bc9678733..000000000
--- a/src/pkg/runtime/windows/os.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-extern void *runtime·LoadLibraryEx;
-extern void *runtime·GetProcAddress;
-
-// Call a Windows function with stdcall conventions,
-// and switch to os stack during the call.
-#pragma varargck countpos runtime·stdcall 2
-#pragma varargck type runtime·stdcall void*
-#pragma varargck type runtime·stdcall uintptr
-void *runtime·stdcall_raw(void *fn, uintptr nargs, void *args);
-void *runtime·stdcall(void *fn, int32 count, ...);
-uintptr runtime·syscall(void *fn, uintptr nargs, void *args, uintptr *err);
-
-uintptr runtime·getlasterror(void);
-void runtime·setlasterror(uintptr err);
-
-// Function to be called by windows CreateThread
-// to start new os thread.
-uint32 runtime·tstart_stdcall(M *newm);
-
-uint32 runtime·issigpanic(uint32);
-void runtime·sigpanic(void);
-uint32 runtime·ctrlhandler(uint32 type);
-
-// Windows dll function to go callback entry.
-byte *runtime·compilecallback(Eface fn, bool cleanstack);
-void *runtime·callbackasm(void);
diff --git a/src/pkg/runtime/windows/signals.h b/src/pkg/runtime/windows/signals.h
deleted file mode 100644
index 6943714b0..000000000
--- a/src/pkg/runtime/windows/signals.h
+++ /dev/null
@@ -1,3 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
diff --git a/src/pkg/runtime/windows/syscall.goc b/src/pkg/runtime/windows/syscall.goc
deleted file mode 100644
index 85071e051..000000000
--- a/src/pkg/runtime/windows/syscall.goc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package syscall
-#include "runtime.h"
-#include "os.h"
-
-func loadlibraryex(filename uintptr) (handle uintptr) {
- uintptr args[3] = { filename };
- handle = runtime·syscall(runtime·LoadLibraryEx, 3, args, nil);
-}
-
-func getprocaddress(handle uintptr, procname uintptr) (proc uintptr) {
- USED(procname);
- proc = runtime·syscall(runtime·GetProcAddress, 2, &handle, nil);
-}
-
-func NewCallback(fn Eface) (code uintptr) {
- code = (uintptr)runtime·compilecallback(fn, true);
-}
-
-func Syscall(fn uintptr, nargs uintptr, a1 uintptr, a2 uintptr, a3 uintptr) (r1 uintptr, r2 uintptr, err uintptr) {
- USED(a2);
- USED(a3);
- r1 = runtime·syscall((void*)fn, nargs, &a1, &err);
- r2 = 0;
-}
-
-func Syscall6(fn uintptr, nargs uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr, a6 uintptr) (r1 uintptr, r2 uintptr, err uintptr) {
- USED(a2);
- USED(a3);
- USED(a4);
- USED(a5);
- USED(a6);
- r1 = runtime·syscall((void*)fn, nargs, &a1, &err);
- r2 = 0;
-}
-
-func Syscall9(fn uintptr, nargs uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr, a6 uintptr, a7 uintptr, a8 uintptr, a9 uintptr) (r1 uintptr, r2 uintptr, err uintptr) {
- USED(a2);
- USED(a3);
- USED(a4);
- USED(a5);
- USED(a6);
- USED(a7);
- USED(a8);
- USED(a9);
- r1 = runtime·syscall((void*)fn, nargs, &a1, &err);
- r2 = 0;
-}
-
-func Syscall12(fn uintptr, nargs uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr, a6 uintptr, a7 uintptr, a8 uintptr, a9 uintptr, a10 uintptr, a11 uintptr, a12 uintptr) (r1 uintptr, r2 uintptr, err uintptr) {
- USED(a2);
- USED(a3);
- USED(a4);
- USED(a5);
- USED(a6);
- USED(a7);
- USED(a8);
- USED(a9);
- USED(a10);
- USED(a11);
- USED(a12);
- r1 = runtime·syscall((void*)fn, nargs, &a1, &err);
- r2 = 0;
-}
diff --git a/src/pkg/runtime/windows/thread.c b/src/pkg/runtime/windows/thread.c
deleted file mode 100644
index 5644fd5dd..000000000
--- a/src/pkg/runtime/windows/thread.c
+++ /dev/null
@@ -1,420 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "runtime.h"
-#include "type.h"
-#include "defs.h"
-#include "os.h"
-
-#pragma dynimport runtime·CloseHandle CloseHandle "kernel32.dll"
-#pragma dynimport runtime·CreateEvent CreateEventA "kernel32.dll"
-#pragma dynimport runtime·CreateThread CreateThread "kernel32.dll"
-#pragma dynimport runtime·ExitProcess ExitProcess "kernel32.dll"
-#pragma dynimport runtime·FreeEnvironmentStringsW FreeEnvironmentStringsW "kernel32.dll"
-#pragma dynimport runtime·GetEnvironmentStringsW GetEnvironmentStringsW "kernel32.dll"
-#pragma dynimport runtime·GetProcAddress GetProcAddress "kernel32.dll"
-#pragma dynimport runtime·GetStdHandle GetStdHandle "kernel32.dll"
-#pragma dynimport runtime·LoadLibraryEx LoadLibraryExA "kernel32.dll"
-#pragma dynimport runtime·QueryPerformanceCounter QueryPerformanceCounter "kernel32.dll"
-#pragma dynimport runtime·QueryPerformanceFrequency QueryPerformanceFrequency "kernel32.dll"
-#pragma dynimport runtime·SetConsoleCtrlHandler SetConsoleCtrlHandler "kernel32.dll"
-#pragma dynimport runtime·SetEvent SetEvent "kernel32.dll"
-#pragma dynimport runtime·WaitForSingleObject WaitForSingleObject "kernel32.dll"
-#pragma dynimport runtime·WriteFile WriteFile "kernel32.dll"
-
-extern void *runtime·CloseHandle;
-extern void *runtime·CreateEvent;
-extern void *runtime·CreateThread;
-extern void *runtime·ExitProcess;
-extern void *runtime·FreeEnvironmentStringsW;
-extern void *runtime·GetEnvironmentStringsW;
-extern void *runtime·GetProcAddress;
-extern void *runtime·GetStdHandle;
-extern void *runtime·LoadLibraryEx;
-extern void *runtime·QueryPerformanceCounter;
-extern void *runtime·QueryPerformanceFrequency;
-extern void *runtime·SetConsoleCtrlHandler;
-extern void *runtime·SetEvent;
-extern void *runtime·WaitForSingleObject;
-extern void *runtime·WriteFile;
-
-static int64 timerfreq;
-
-void
-runtime·osinit(void)
-{
- runtime·stdcall(runtime·QueryPerformanceFrequency, 1, &timerfreq);
- runtime·stdcall(runtime·SetConsoleCtrlHandler, 2, runtime·ctrlhandler, (uintptr)1);
-}
-
-void
-runtime·goenvs(void)
-{
- extern Slice os·Envs;
-
- uint16 *env;
- String *s;
- int32 i, n;
- uint16 *p;
-
- env = runtime·stdcall(runtime·GetEnvironmentStringsW, 0);
-
- n = 0;
- for(p=env; *p; n++)
- p += runtime·findnullw(p)+1;
-
- s = runtime·malloc(n*sizeof s[0]);
-
- p = env;
- for(i=0; i<n; i++) {
- s[i] = runtime·gostringw(p);
- p += runtime·findnullw(p)+1;
- }
- os·Envs.array = (byte*)s;
- os·Envs.len = n;
- os·Envs.cap = n;
-
- runtime·stdcall(runtime·FreeEnvironmentStringsW, 1, env);
-}
-
-void
-runtime·exit(int32 code)
-{
- runtime·stdcall(runtime·ExitProcess, 1, (uintptr)code);
-}
-
-int32
-runtime·write(int32 fd, void *buf, int32 n)
-{
- void *handle;
- uint32 written;
-
- written = 0;
- switch(fd) {
- case 1:
- handle = runtime·stdcall(runtime·GetStdHandle, 1, (uintptr)-11);
- break;
- case 2:
- handle = runtime·stdcall(runtime·GetStdHandle, 1, (uintptr)-12);
- break;
- default:
- return -1;
- }
- runtime·stdcall(runtime·WriteFile, 5, handle, buf, (uintptr)n, &written, (uintptr)0);
- return written;
-}
-
-// Thread-safe allocation of an event.
-static void
-initevent(void **pevent)
-{
- void *event;
-
- event = runtime·stdcall(runtime·CreateEvent, 4, (uintptr)0, (uintptr)0, (uintptr)0, (uintptr)0);
- if(!runtime·casp(pevent, 0, event)) {
- // Someone else filled it in. Use theirs.
- runtime·stdcall(runtime·CloseHandle, 1, event);
- }
-}
-
-static void
-eventlock(Lock *l)
-{
- // Allocate event if needed.
- if(l->event == 0)
- initevent(&l->event);
-
- if(runtime·xadd(&l->key, 1) > 1) // someone else has it; wait
- runtime·stdcall(runtime·WaitForSingleObject, 2, l->event, (uintptr)-1);
-}
-
-static void
-eventunlock(Lock *l)
-{
- if(runtime·xadd(&l->key, -1) > 0) // someone else is waiting
- runtime·stdcall(runtime·SetEvent, 1, l->event);
-}
-
-void
-runtime·lock(Lock *l)
-{
- if(m->locks < 0)
- runtime·throw("lock count");
- m->locks++;
- eventlock(l);
-}
-
-void
-runtime·unlock(Lock *l)
-{
- m->locks--;
- if(m->locks < 0)
- runtime·throw("lock count");
- eventunlock(l);
-}
-
-void
-runtime·destroylock(Lock *l)
-{
- if(l->event != 0)
- runtime·stdcall(runtime·CloseHandle, 1, l->event);
-}
-
-void
-runtime·noteclear(Note *n)
-{
- n->lock.key = 0; // memset(n, 0, sizeof *n)
- eventlock(&n->lock);
-}
-
-void
-runtime·notewakeup(Note *n)
-{
- eventunlock(&n->lock);
-}
-
-void
-runtime·notesleep(Note *n)
-{
- eventlock(&n->lock);
- eventunlock(&n->lock); // Let other sleepers find out too.
-}
-
-void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
-{
- void *thandle;
-
- USED(stk);
- USED(g); // assuming g = m->g0
- USED(fn); // assuming fn = mstart
-
- thandle = runtime·stdcall(runtime·CreateThread, 6, (uintptr)0, (uintptr)0, runtime·tstart_stdcall, m, (uintptr)0, (uintptr)0);
- if(thandle == 0) {
- runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount(), runtime·getlasterror());
- runtime·throw("runtime.newosproc");
- }
-}
-
-// Called to initialize a new m (including the bootstrap m).
-void
-runtime·minit(void)
-{
-}
-
-void
-runtime·gettime(int64 *sec, int32 *usec)
-{
- int64 count;
-
- runtime·stdcall(runtime·QueryPerformanceCounter, 1, &count);
- *sec = count / timerfreq;
- count %= timerfreq;
- *usec = count*1000000 / timerfreq;
-}
-
-// Calling stdcall on os stack.
-#pragma textflag 7
-void *
-runtime·stdcall(void *fn, int32 count, ...)
-{
- return runtime·stdcall_raw(fn, count, (uintptr*)&count + 1);
-}
-
-uintptr
-runtime·syscall(void *fn, uintptr nargs, void *args, uintptr *err)
-{
- G *oldlock;
- uintptr ret;
-
- /*
- * Lock g to m to ensure we stay on the same stack if we do a callback.
- */
- oldlock = m->lockedg;
- m->lockedg = g;
- g->lockedm = m;
-
- runtime·entersyscall();
- runtime·setlasterror(0);
- ret = (uintptr)runtime·stdcall_raw(fn, nargs, args);
- if(err)
- *err = runtime·getlasterror();
- runtime·exitsyscall();
-
- m->lockedg = oldlock;
- if(oldlock == nil)
- g->lockedm = nil;
-
- return ret;
-}
-
-uint32
-runtime·issigpanic(uint32 code)
-{
- switch(code) {
- case EXCEPTION_ACCESS_VIOLATION:
- case EXCEPTION_INT_DIVIDE_BY_ZERO:
- case EXCEPTION_INT_OVERFLOW:
- case EXCEPTION_FLT_DENORMAL_OPERAND:
- case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- case EXCEPTION_FLT_INEXACT_RESULT:
- case EXCEPTION_FLT_OVERFLOW:
- case EXCEPTION_FLT_UNDERFLOW:
- return 1;
- }
- return 0;
-}
-
-void
-runtime·sigpanic(void)
-{
- switch(g->sig) {
- case EXCEPTION_ACCESS_VIOLATION:
- if(g->sigcode1 < 0x1000)
- runtime·panicstring("invalid memory address or nil pointer dereference");
- runtime·printf("unexpected fault address %p\n", g->sigcode1);
- runtime·throw("fault");
- case EXCEPTION_INT_DIVIDE_BY_ZERO:
- runtime·panicstring("integer divide by zero");
- case EXCEPTION_INT_OVERFLOW:
- runtime·panicstring("integer overflow");
- case EXCEPTION_FLT_DENORMAL_OPERAND:
- case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- case EXCEPTION_FLT_INEXACT_RESULT:
- case EXCEPTION_FLT_OVERFLOW:
- case EXCEPTION_FLT_UNDERFLOW:
- runtime·panicstring("floating point error");
- }
- runtime·throw("fault");
-}
-
-String
-runtime·signame(int32 sig)
-{
- int8 *s;
-
- switch(sig) {
- case SIGINT:
- s = "SIGINT: interrupt";
- break;
- default:
- return runtime·emptystring;
- }
- return runtime·gostringnocopy((byte*)s);
-}
-
-uint32
-runtime·ctrlhandler1(uint32 type)
-{
- int32 s;
-
- switch(type) {
- case CTRL_C_EVENT:
- case CTRL_BREAK_EVENT:
- s = SIGINT;
- break;
- default:
- return 0;
- }
-
- if(runtime·sigsend(s))
- return 1;
- runtime·exit(2); // SIGINT, SIGTERM, etc
- return 0;
-}
-
-// Will keep all callbacks in a linked list, so they don't get garbage collected.
-typedef struct Callback Callback;
-struct Callback {
- Callback* link;
- void* gobody;
- byte asmbody;
-};
-
-typedef struct Callbacks Callbacks;
-struct Callbacks {
- Lock;
- Callback* link;
- int32 n;
-};
-
-static Callbacks cbs;
-
-// Call back from windows dll into go.
-byte *
-runtime·compilecallback(Eface fn, bool cleanstack)
-{
- Func *f;
- int32 argsize, n;
- byte *p;
- Callback *c;
-
- if(fn.type->kind != KindFunc)
- runtime·panicstring("not a function");
- if((f = runtime·findfunc((uintptr)fn.data)) == nil)
- runtime·throw("cannot find function");
- argsize = (f->args-2) * 4;
-
- // compute size of new fn.
- // must match code laid out below.
- n = 1+4; // MOVL fn, AX
- n += 1+4; // MOVL argsize, DX
- n += 1+4; // MOVL callbackasm, CX
- n += 2; // CALL CX
- n += 1; // RET
- if(cleanstack)
- n += 2; // ... argsize
-
- runtime·lock(&cbs);
- for(c = cbs.link; c != nil; c = c->link) {
- if(c->gobody == fn.data) {
- runtime·unlock(&cbs);
- return &c->asmbody;
- }
- }
- if(cbs.n >= 2000)
- runtime·throw("too many callback functions");
- c = runtime·mal(sizeof *c + n);
- c->gobody = fn.data;
- c->link = cbs.link;
- cbs.link = c;
- cbs.n++;
- runtime·unlock(&cbs);
-
- p = &c->asmbody;
-
- // MOVL fn, AX
- *p++ = 0xb8;
- *(uint32*)p = (uint32)fn.data;
- p += 4;
-
- // MOVL argsize, DX
- *p++ = 0xba;
- *(uint32*)p = argsize;
- p += 4;
-
- // MOVL callbackasm, CX
- *p++ = 0xb9;
- *(uint32*)p = (uint32)runtime·callbackasm;
- p += 4;
-
- // CALL CX
- *p++ = 0xff;
- *p++ = 0xd1;
-
- // RET argsize?
- if(cleanstack) {
- *p++ = 0xc2;
- *(uint16*)p = argsize;
- } else
- *p = 0xc3;
-
- return &c->asmbody;
-}
-
-void
-os·sigpipe(void)
-{
- runtime·throw("too many writes on closed pipe");
-}