]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: extract an ExampleLoadLibrary from comment
authorShenghou Ma <minux.ma@gmail.com>
Wed, 29 Aug 2012 13:44:46 +0000 (21:44 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Wed, 29 Aug 2012 13:44:46 +0000 (21:44 +0800)
   while we are at it, fix some out-of-date comments.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6498054

src/pkg/syscall/asm_windows_386.s
src/pkg/syscall/asm_windows_amd64.s
src/pkg/syscall/syscall_windows.go
src/pkg/syscall/syscall_windows_test.go

index a7b95643ddee265131f50f03b5b09493d125481b..8b52fa9851373a9e4f46a18aa661b871b446a63c 100644 (file)
@@ -3,5 +3,5 @@
 // license that can be found in the LICENSE file.
 
 //
-// System calls for 386, Windows are implemented in ../runtime/windows/syscall.goc
+// System calls for 386, Windows are implemented in ../runtime/syscall_windows.goc
 //
index 8b38710c7968bbddda47e3fbec5cfeec30f6bd3e..5813404d17721980f5b9719981492622772a6cae 100644 (file)
@@ -3,5 +3,5 @@
 // license that can be found in the LICENSE file.
 
 //
-// System calls for amd64, Windows are implemented in ../runtime/windows/syscall.goc
+// System calls for amd64, Windows are implemented in ../runtime/syscall_windows.goc
 //
index a3adadb0e1fcb06b8e06cb56e371b261ee8bff76..6408879c161228593fef03f4199badfb792039f3 100644 (file)
@@ -15,43 +15,6 @@ type Handle uintptr
 
 const InvalidHandle = ^Handle(0)
 
-/*
-
-small demo to detect version of windows you are running:
-
-package main
-
-import (
-       "syscall"
-)
-
-func abort(funcname string, err error) {
-       panic(funcname + " failed: " + err.Error())
-}
-
-func print_version(v uint32) {
-       major := byte(v)
-       minor := uint8(v >> 8)
-       build := uint16(v >> 16)
-       print("windows version ", major, ".", minor, " (Build ", build, ")\n")
-}
-
-func main() {
-       h, err := syscall.LoadLibrary("kernel32.dll")
-       if err != nil {
-               abort("LoadLibrary", err)
-       }
-       defer syscall.FreeLibrary(h)
-       proc, err := syscall.GetProcAddress(h, "GetVersion")
-       if err != nil {
-               abort("GetProcAddress", err)
-       }
-       r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0)
-       print_version(uint32(r))
-}
-
-*/
-
 // StringToUTF16 is deprecated. Use UTF16FromString instead.
 // If s contains a NUL byte this function panics instead of
 // returning an error.
@@ -142,7 +105,7 @@ func (e Errno) Timeout() bool {
 // Converts a Go function to a function pointer conforming
 // to the stdcall calling convention.  This is useful when
 // interoperating with Windows code requiring callbacks.
-// Implemented in ../runtime/windows/syscall.goc
+// Implemented in ../runtime/syscall_windows.goc
 func NewCallback(fn interface{}) uintptr
 
 // windows api calls
index 005a3cc728fea75bc10e923b7fe3df1a86160b58..86842f2ad24c91e0b6e76908096fe0d8a1c11670 100644 (file)
@@ -49,3 +49,24 @@ func TestWin32finddata(t *testing.T) {
                t.Fatalf("memory corruption: want=%d got=%d", want, x.got)
        }
 }
+
+func abort(funcname string, err error) {
+       panic(funcname + " failed: " + err.Error())
+}
+
+func ExampleLoadLibrary() {
+       h, err := syscall.LoadLibrary("kernel32.dll")
+       if err != nil {
+               abort("LoadLibrary", err)
+       }
+       defer syscall.FreeLibrary(h)
+       proc, err := syscall.GetProcAddress(h, "GetVersion")
+       if err != nil {
+               abort("GetProcAddress", err)
+       }
+       r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0)
+       major := byte(r)
+       minor := uint8(r >> 8)
+       build := uint16(r >> 16)
+       print("windows version ", major, ".", minor, " (Build ", build, ")\n")
+}