]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: another attempt to allow stdcall to be used from both 386 and amd64 arch
authorAlex Brainman <alex.brainman@gmail.com>
Tue, 28 Jun 2011 02:46:16 +0000 (12:46 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Tue, 28 Jun 2011 02:46:16 +0000 (12:46 +1000)
R=rsc
CC=golang-dev, vcc.163
https://golang.org/cl/4627071

src/pkg/runtime/windows/mem.c
src/pkg/runtime/windows/os.h
src/pkg/runtime/windows/thread.c

index 54d77da37e2f0d0da5b1b631e6efb6995f6850f9..5d2291fa322fcb85cfe64c561c5d3faacf3e8e68 100644 (file)
@@ -24,7 +24,7 @@ void*
 runtime·SysAlloc(uintptr n)
 {
        mstats.sys += n;
-       return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+       return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)(MEM_COMMIT|MEM_RESERVE), (uintptr)PAGE_EXECUTE_READWRITE);
 }
 
 void
@@ -40,7 +40,7 @@ runtime·SysFree(void *v, uintptr n)
        uintptr r;
 
        mstats.sys -= n;
-       r = (uintptr)runtime·stdcall(runtime·VirtualFree, 3, v, 0, MEM_RELEASE);
+       r = (uintptr)runtime·stdcall(runtime·VirtualFree, 3, v, (uintptr)0, (uintptr)MEM_RELEASE);
        if(r == 0)
                runtime·throw("runtime: failed to release pages");
 }
@@ -50,12 +50,12 @@ runtime·SysReserve(void *v, uintptr n)
 {
        // v is just a hint.
        // First try at v.
-       v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+       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, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+       return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, (uintptr)MEM_RESERVE, (uintptr)PAGE_EXECUTE_READWRITE);
 }
 
 void
@@ -64,7 +64,7 @@ runtime·SysMap(void *v, uintptr n)
        void *p;
        
        mstats.sys += n;
-       p = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+       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");
 }
index 77881e86ecb22de77bd3d71f5585a190f3016f9b..bc96787334f9e5e005f8290c63e754f223d81584 100644 (file)
@@ -7,6 +7,9 @@ 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);
index 81ad68033319d76ab15763bfb1dcb83aa5e0c41c..0c362d42c64abda229d1a6e821ab6722a9b73691 100644 (file)
@@ -45,7 +45,7 @@ void
 runtime·osinit(void)
 {
        runtime·stdcall(runtime·QueryPerformanceFrequency, 1, &timerfreq);
-       runtime·stdcall(runtime·SetConsoleCtrlHandler, 2, runtime·ctrlhandler, 1);
+       runtime·stdcall(runtime·SetConsoleCtrlHandler, 2, runtime·ctrlhandler, (uintptr)1);
 }
 
 void
@@ -81,7 +81,7 @@ runtime·goenvs(void)
 void
 runtime·exit(int32 code)
 {
-       runtime·stdcall(runtime·ExitProcess, 1, code);
+       runtime·stdcall(runtime·ExitProcess, 1, (uintptr)code);
 }
 
 int32
@@ -93,15 +93,15 @@ runtime·write(int32 fd, void *buf, int32 n)
        written = 0;
        switch(fd) {
        case 1:
-               handle = runtime·stdcall(runtime·GetStdHandle, 1, -11);
+               handle = runtime·stdcall(runtime·GetStdHandle, 1, (uintptr)-11);
                break;
        case 2:
-               handle = runtime·stdcall(runtime·GetStdHandle, 1, -12);
+               handle = runtime·stdcall(runtime·GetStdHandle, 1, (uintptr)-12);
                break;
        default:
                return -1;
        }
-       runtime·stdcall(runtime·WriteFile, 5, handle, buf, n, &written, 0);
+       runtime·stdcall(runtime·WriteFile, 5, handle, buf, (uintptr)n, &written, (uintptr)0);
        return written;
 }
 
@@ -111,7 +111,7 @@ initevent(void **pevent)
 {
        void *event;
 
-       event = runtime·stdcall(runtime·CreateEvent, 4, 0, 0, 0, 0);
+       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);
@@ -126,7 +126,7 @@ eventlock(Lock *l)
                initevent(&l->event);
 
        if(runtime·xadd(&l->key, 1) > 1)       // someone else has it; wait
-               runtime·stdcall(runtime·WaitForSingleObject, 2, l->event, -1);
+               runtime·stdcall(runtime·WaitForSingleObject, 2, l->event, (uintptr)-1);
 }
 
 static void
@@ -190,7 +190,7 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
        USED(g);        // assuming g = m->g0
        USED(fn);       // assuming fn = mstart
 
-       thandle = runtime·stdcall(runtime·CreateThread, 6, 0, 0, runtime·tstart_stdcall, m, 0, 0);
+       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");