Import upstream version 0.0~git20220503.988cb79
Debian Janitor
2 years ago
105 | 105 | |
106 | 106 | // ARM contains the supported CPU features of the current ARM (32-bit) platform. |
107 | 107 | // All feature flags are false if: |
108 | // 1. the current platform is not arm, or | |
109 | // 2. the current operating system is not Linux. | |
108 | // 1. the current platform is not arm, or | |
109 | // 2. the current operating system is not Linux. | |
110 | 110 | var ARM struct { |
111 | 111 | _ CacheLinePad |
112 | 112 | HasSWP bool // SWP instruction support |
52 | 52 | // LookPath instead returns an error. |
53 | 53 | func LookPath(file string) (string, error) { |
54 | 54 | path, err := exec.LookPath(file) |
55 | if err != nil { | |
55 | if err != nil && !isGo119ErrDot(err) { | |
56 | 56 | return "", err |
57 | 57 | } |
58 | 58 | if filepath.Base(file) == file && !filepath.IsAbs(path) { |
0 | // Copyright 2022 The Go Authors. All rights reserved. | |
1 | // Use of this source code is governed by a BSD-style | |
2 | // license that can be found in the LICENSE file. | |
3 | ||
4 | //go:build !go1.19 | |
5 | // +build !go1.19 | |
6 | ||
7 | package execabs | |
8 | ||
9 | func isGo119ErrDot(err error) bool { | |
10 | return false | |
11 | } |
0 | // Copyright 2022 The Go Authors. All rights reserved. | |
1 | // Use of this source code is governed by a BSD-style | |
2 | // license that can be found in the LICENSE file. | |
3 | ||
4 | //go:build go1.19 | |
5 | // +build go1.19 | |
6 | ||
7 | package execabs | |
8 | ||
9 | import "strings" | |
10 | ||
11 | func isGo119ErrDot(err error) bool { | |
12 | // TODO: return errors.Is(err, exec.ErrDot) | |
13 | return strings.Contains(err.Error(), "current directory") | |
14 | } |
9 | 9 | (like syscall_plan9.go) and generates system call bodies. |
10 | 10 | The prototypes are marked by lines beginning with "//sys" |
11 | 11 | and read like func declarations if //sys is replaced by func, but: |
12 | * The parameter lists must give a name for each argument. | |
13 | This includes return parameters. | |
14 | * The parameter lists must give a type for each argument: | |
15 | the (x, y, z int) shorthand is not allowed. | |
16 | * If the return parameter is an error number, it must be named errno. | |
12 | - The parameter lists must give a name for each argument. | |
13 | This includes return parameters. | |
14 | - The parameter lists must give a type for each argument: | |
15 | the (x, y, z int) shorthand is not allowed. | |
16 | - If the return parameter is an error number, it must be named errno. | |
17 | 17 | |
18 | 18 | A line beginning with //sysnb is like //sys, except that the |
19 | 19 | goroutine will not be suspended during the execution of the system |
112 | 112 | |
113 | 113 | // use is a no-op, but the compiler cannot see that it is. |
114 | 114 | // Calling use(p) ensures that p is kept live until that point. |
115 | // | |
115 | 116 | //go:noescape |
116 | 117 | func use(p unsafe.Pointer) |
114 | 114 | var ioSync int64 |
115 | 115 | |
116 | 116 | //sys fd2path(fd int, buf []byte) (err error) |
117 | ||
117 | 118 | func Fd2path(fd int) (path string, err error) { |
118 | 119 | var buf [512]byte |
119 | 120 | |
125 | 126 | } |
126 | 127 | |
127 | 128 | //sys pipe(p *[2]int32) (err error) |
129 | ||
128 | 130 | func Pipe(p []int) (err error) { |
129 | 131 | if len(p) != 2 { |
130 | 132 | return syscall.ErrorString("bad arg in system call") |
179 | 181 | } |
180 | 182 | |
181 | 183 | //sys await(s []byte) (n int, err error) |
184 | ||
182 | 185 | func Await(w *Waitmsg) (err error) { |
183 | 186 | var buf [512]byte |
184 | 187 | var f [5][]byte |
300 | 303 | } |
301 | 304 | |
302 | 305 | //sys open(path string, mode int) (fd int, err error) |
306 | ||
303 | 307 | func Open(path string, mode int) (fd int, err error) { |
304 | 308 | fixwd() |
305 | 309 | return open(path, mode) |
306 | 310 | } |
307 | 311 | |
308 | 312 | //sys create(path string, mode int, perm uint32) (fd int, err error) |
313 | ||
309 | 314 | func Create(path string, mode int, perm uint32) (fd int, err error) { |
310 | 315 | fixwd() |
311 | 316 | return create(path, mode, perm) |
312 | 317 | } |
313 | 318 | |
314 | 319 | //sys remove(path string) (err error) |
320 | ||
315 | 321 | func Remove(path string) error { |
316 | 322 | fixwd() |
317 | 323 | return remove(path) |
318 | 324 | } |
319 | 325 | |
320 | 326 | //sys stat(path string, edir []byte) (n int, err error) |
327 | ||
321 | 328 | func Stat(path string, edir []byte) (n int, err error) { |
322 | 329 | fixwd() |
323 | 330 | return stat(path, edir) |
324 | 331 | } |
325 | 332 | |
326 | 333 | //sys bind(name string, old string, flag int) (err error) |
334 | ||
327 | 335 | func Bind(name string, old string, flag int) (err error) { |
328 | 336 | fixwd() |
329 | 337 | return bind(name, old, flag) |
330 | 338 | } |
331 | 339 | |
332 | 340 | //sys mount(fd int, afd int, old string, flag int, aname string) (err error) |
341 | ||
333 | 342 | func Mount(fd int, afd int, old string, flag int, aname string) (err error) { |
334 | 343 | fixwd() |
335 | 344 | return mount(fd, afd, old, flag, aname) |
336 | 345 | } |
337 | 346 | |
338 | 347 | //sys wstat(path string, edir []byte) (err error) |
348 | ||
339 | 349 | func Wstat(path string, edir []byte) (err error) { |
340 | 350 | fixwd() |
341 | 351 | return wstat(path, edir) |
5 | 5 | // consts, funcs, and types into a common source file, per GOOS. |
6 | 6 | // |
7 | 7 | // Usage: |
8 | // $ mkmerge -out MERGED FILE [FILE ...] | |
8 | // | |
9 | // $ mkmerge -out MERGED FILE [FILE ...] | |
9 | 10 | // |
10 | 11 | // Example: |
11 | // # Remove all common consts, funcs, and types from zerrors_linux_*.go | |
12 | // # and write the common code into zerrors_linux.go | |
13 | // $ mkmerge -out zerrors_linux.go zerrors_linux_*.go | |
12 | // | |
13 | // # Remove all common consts, funcs, and types from zerrors_linux_*.go | |
14 | // # and write the common code into zerrors_linux.go | |
15 | // $ mkmerge -out zerrors_linux.go zerrors_linux_*.go | |
14 | 16 | // |
15 | 17 | // mkmerge performs the merge in the following steps: |
16 | // 1. Construct the set of common code that is identical in all | |
17 | // architecture-specific files. | |
18 | // 2. Write this common code to the merged file. | |
19 | // 3. Remove the common code from all architecture-specific files. | |
18 | // 1. Construct the set of common code that is identical in all | |
19 | // architecture-specific files. | |
20 | // 2. Write this common code to the merged file. | |
21 | // 3. Remove the common code from all architecture-specific files. | |
20 | 22 | package main |
21 | 23 | |
22 | 24 | import ( |
5 | 5 | // +build ignore |
6 | 6 | |
7 | 7 | // mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go. |
8 | //This program must be run after mksyscall.go. | |
8 | // This program must be run after mksyscall.go. | |
9 | 9 | package main |
10 | 10 | |
11 | 11 | import ( |
9 | 9 | (like syscall_darwin.go) and generates system call bodies. |
10 | 10 | The prototypes are marked by lines beginning with "//sys" |
11 | 11 | and read like func declarations if //sys is replaced by func, but: |
12 | * The parameter lists must give a name for each argument. | |
13 | This includes return parameters. | |
14 | * The parameter lists must give a type for each argument: | |
15 | the (x, y, z int) shorthand is not allowed. | |
16 | * If the return parameter is an error number, it must be named errno. | |
12 | - The parameter lists must give a name for each argument. | |
13 | This includes return parameters. | |
14 | - The parameter lists must give a type for each argument: | |
15 | the (x, y, z int) shorthand is not allowed. | |
16 | - If the return parameter is an error number, it must be named errno. | |
17 | 17 | |
18 | 18 | A line beginning with //sysnb is like //sys, except that the |
19 | 19 | goroutine will not be suspended during the execution of the system |
9 | 9 | (like syscall_aix.go) and generates system call bodies. |
10 | 10 | The prototypes are marked by lines beginning with "//sys" |
11 | 11 | and read like func declarations if //sys is replaced by func, but: |
12 | * The parameter lists must give a name for each argument. | |
13 | This includes return parameters. | |
14 | * The parameter lists must give a type for each argument: | |
15 | the (x, y, z int) shorthand is not allowed. | |
16 | * If the return parameter is an error number, it must be named err. | |
17 | * If go func name needs to be different than its libc name, | |
18 | * or the function is not in libc, name could be specified | |
19 | * at the end, after "=" sign, like | |
20 | //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt | |
12 | - The parameter lists must give a name for each argument. | |
13 | This includes return parameters. | |
14 | - The parameter lists must give a type for each argument: | |
15 | the (x, y, z int) shorthand is not allowed. | |
16 | - If the return parameter is an error number, it must be named err. | |
17 | - If go func name needs to be different than its libc name, | |
18 | - or the function is not in libc, name could be specified | |
19 | - at the end, after "=" sign, like | |
20 | //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt | |
21 | 21 | */ |
22 | 22 | package main |
23 | 23 |
36 | 36 | } |
37 | 37 | |
38 | 38 | //sys utimes(path string, times *[2]Timeval) (err error) |
39 | ||
39 | 40 | func Utimes(path string, tv []Timeval) error { |
40 | 41 | if len(tv) != 2 { |
41 | 42 | return EINVAL |
44 | 45 | } |
45 | 46 | |
46 | 47 | //sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error) |
48 | ||
47 | 49 | func UtimesNano(path string, ts []Timespec) error { |
48 | 50 | if len(ts) != 2 { |
49 | 51 | return EINVAL |
299 | 301 | } |
300 | 302 | |
301 | 303 | //sys getdirent(fd int, buf []byte) (n int, err error) |
304 | ||
302 | 305 | func Getdents(fd int, buf []byte) (n int, err error) { |
303 | 306 | return getdirent(fd, buf) |
304 | 307 | } |
305 | 308 | |
306 | 309 | //sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error) |
310 | ||
307 | 311 | func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { |
308 | 312 | var status _C_int |
309 | 313 | var r Pid_t |
371 | 375 | //sys fcntl(fd int, cmd int, arg int) (val int, err error) |
372 | 376 | |
373 | 377 | //sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range |
378 | ||
374 | 379 | func Fsync(fd int) error { |
375 | 380 | return fsyncRange(fd, O_SYNC, 0, 0) |
376 | 381 | } |
535 | 540 | //sys Getsystemcfg(label int) (n uint64) |
536 | 541 | |
537 | 542 | //sys umount(target string) (err error) |
543 | ||
538 | 544 | func Unmount(target string, flags int) (err error) { |
539 | 545 | if flags != 0 { |
540 | 546 | // AIX doesn't have any flags for umount. |
124 | 124 | } |
125 | 125 | |
126 | 126 | //sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error) |
127 | ||
127 | 128 | func pread(fd int, p []byte, offset int64) (n int, err error) { |
128 | 129 | return extpread(fd, p, 0, offset) |
129 | 130 | } |
130 | 131 | |
131 | 132 | //sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) |
133 | ||
132 | 134 | func pwrite(fd int, p []byte, offset int64) (n int, err error) { |
133 | 135 | return extpwrite(fd, p, 0, offset) |
134 | 136 | } |
511 | 511 | // |
512 | 512 | // Server example: |
513 | 513 | // |
514 | // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) | |
515 | // _ = unix.Bind(fd, &unix.SockaddrRFCOMM{ | |
516 | // Channel: 1, | |
517 | // Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00 | |
518 | // }) | |
519 | // _ = Listen(fd, 1) | |
520 | // nfd, sa, _ := Accept(fd) | |
521 | // fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd) | |
522 | // Read(nfd, buf) | |
514 | // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) | |
515 | // _ = unix.Bind(fd, &unix.SockaddrRFCOMM{ | |
516 | // Channel: 1, | |
517 | // Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00 | |
518 | // }) | |
519 | // _ = Listen(fd, 1) | |
520 | // nfd, sa, _ := Accept(fd) | |
521 | // fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd) | |
522 | // Read(nfd, buf) | |
523 | 523 | // |
524 | 524 | // Client example: |
525 | 525 | // |
526 | // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) | |
527 | // _ = Connect(fd, &SockaddrRFCOMM{ | |
528 | // Channel: 1, | |
529 | // Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11 | |
530 | // }) | |
531 | // Write(fd, []byte(`hello`)) | |
526 | // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM) | |
527 | // _ = Connect(fd, &SockaddrRFCOMM{ | |
528 | // Channel: 1, | |
529 | // Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11 | |
530 | // }) | |
531 | // Write(fd, []byte(`hello`)) | |
532 | 532 | type SockaddrRFCOMM struct { |
533 | 533 | // Addr represents a bluetooth address, byte ordering is little-endian. |
534 | 534 | Addr [6]uint8 |
555 | 555 | // The SockaddrCAN struct must be bound to the socket file descriptor |
556 | 556 | // using Bind before the CAN socket can be used. |
557 | 557 | // |
558 | // // Read one raw CAN frame | |
559 | // fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW) | |
560 | // addr := &SockaddrCAN{Ifindex: index} | |
561 | // Bind(fd, addr) | |
562 | // frame := make([]byte, 16) | |
563 | // Read(fd, frame) | |
558 | // // Read one raw CAN frame | |
559 | // fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW) | |
560 | // addr := &SockaddrCAN{Ifindex: index} | |
561 | // Bind(fd, addr) | |
562 | // frame := make([]byte, 16) | |
563 | // Read(fd, frame) | |
564 | 564 | // |
565 | 565 | // The full SocketCAN documentation can be found in the linux kernel |
566 | 566 | // archives at: https://www.kernel.org/doc/Documentation/networking/can.txt |
631 | 631 | // Here is an example of using an AF_ALG socket with SHA1 hashing. |
632 | 632 | // The initial socket setup process is as follows: |
633 | 633 | // |
634 | // // Open a socket to perform SHA1 hashing. | |
635 | // fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0) | |
636 | // addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"} | |
637 | // unix.Bind(fd, addr) | |
638 | // // Note: unix.Accept does not work at this time; must invoke accept() | |
639 | // // manually using unix.Syscall. | |
640 | // hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0) | |
634 | // // Open a socket to perform SHA1 hashing. | |
635 | // fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0) | |
636 | // addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"} | |
637 | // unix.Bind(fd, addr) | |
638 | // // Note: unix.Accept does not work at this time; must invoke accept() | |
639 | // // manually using unix.Syscall. | |
640 | // hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0) | |
641 | 641 | // |
642 | 642 | // Once a file descriptor has been returned from Accept, it may be used to |
643 | 643 | // perform SHA1 hashing. The descriptor is not safe for concurrent use, but |
646 | 646 | // When hashing a small byte slice or string, a single Write and Read may |
647 | 647 | // be used: |
648 | 648 | // |
649 | // // Assume hashfd is already configured using the setup process. | |
650 | // hash := os.NewFile(hashfd, "sha1") | |
651 | // // Hash an input string and read the results. Each Write discards | |
652 | // // previous hash state. Read always reads the current state. | |
653 | // b := make([]byte, 20) | |
654 | // for i := 0; i < 2; i++ { | |
655 | // io.WriteString(hash, "Hello, world.") | |
656 | // hash.Read(b) | |
657 | // fmt.Println(hex.EncodeToString(b)) | |
658 | // } | |
659 | // // Output: | |
660 | // // 2ae01472317d1935a84797ec1983ae243fc6aa28 | |
661 | // // 2ae01472317d1935a84797ec1983ae243fc6aa28 | |
649 | // // Assume hashfd is already configured using the setup process. | |
650 | // hash := os.NewFile(hashfd, "sha1") | |
651 | // // Hash an input string and read the results. Each Write discards | |
652 | // // previous hash state. Read always reads the current state. | |
653 | // b := make([]byte, 20) | |
654 | // for i := 0; i < 2; i++ { | |
655 | // io.WriteString(hash, "Hello, world.") | |
656 | // hash.Read(b) | |
657 | // fmt.Println(hex.EncodeToString(b)) | |
658 | // } | |
659 | // // Output: | |
660 | // // 2ae01472317d1935a84797ec1983ae243fc6aa28 | |
661 | // // 2ae01472317d1935a84797ec1983ae243fc6aa28 | |
662 | 662 | // |
663 | 663 | // For hashing larger byte slices, or byte streams such as those read from |
664 | 664 | // a file or socket, use Sendto with MSG_MORE to instruct the kernel to update |
665 | 665 | // the hash digest instead of creating a new one for a given chunk and finalizing it. |
666 | 666 | // |
667 | // // Assume hashfd and addr are already configured using the setup process. | |
668 | // hash := os.NewFile(hashfd, "sha1") | |
669 | // // Hash the contents of a file. | |
670 | // f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz") | |
671 | // b := make([]byte, 4096) | |
672 | // for { | |
673 | // n, err := f.Read(b) | |
674 | // if err == io.EOF { | |
675 | // break | |
676 | // } | |
677 | // unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr) | |
678 | // } | |
679 | // hash.Read(b) | |
680 | // fmt.Println(hex.EncodeToString(b)) | |
681 | // // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5 | |
667 | // // Assume hashfd and addr are already configured using the setup process. | |
668 | // hash := os.NewFile(hashfd, "sha1") | |
669 | // // Hash the contents of a file. | |
670 | // f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz") | |
671 | // b := make([]byte, 4096) | |
672 | // for { | |
673 | // n, err := f.Read(b) | |
674 | // if err == io.EOF { | |
675 | // break | |
676 | // } | |
677 | // unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr) | |
678 | // } | |
679 | // hash.Read(b) | |
680 | // fmt.Println(hex.EncodeToString(b)) | |
681 | // // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5 | |
682 | 682 | // |
683 | 683 | // For more information, see: http://www.chronox.de/crypto-API/crypto/userspace-if.html. |
684 | 684 | type SockaddrALG struct { |
80 | 80 | } |
81 | 81 | |
82 | 82 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) |
83 | ||
83 | 84 | func Pipe2(p []int, flags int) error { |
84 | 85 | if len(p) != 2 { |
85 | 86 | return EINVAL |
94 | 95 | } |
95 | 96 | |
96 | 97 | //sys Getdents(fd int, buf []byte) (n int, err error) |
98 | ||
97 | 99 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { |
98 | 100 | n, err = Getdents(fd, buf) |
99 | 101 | if err != nil || basep == nil { |
14 | 14 | // in http://msdn.microsoft.com/en-us/library/ms880421. |
15 | 15 | // This function returns "" (2 double quotes) if s is empty. |
16 | 16 | // Alternatively, these transformations are done: |
17 | // - every back slash (\) is doubled, but only if immediately | |
18 | // followed by double quote ("); | |
19 | // - every double quote (") is escaped by back slash (\); | |
20 | // - finally, s is wrapped with double quotes (arg -> "arg"), | |
21 | // but only if there is space or tab inside s. | |
17 | // - every back slash (\) is doubled, but only if immediately | |
18 | // followed by double quote ("); | |
19 | // - every double quote (") is escaped by back slash (\); | |
20 | // - finally, s is wrapped with double quotes (arg -> "arg"), | |
21 | // but only if there is space or tab inside s. | |
22 | 22 | func EscapeArg(s string) string { |
23 | 23 | if len(s) == 0 { |
24 | 24 | return "\"\"" |
11 | 11 | The prototypes are marked by lines beginning with "//sys" and read |
12 | 12 | like func declarations if //sys is replaced by func, but: |
13 | 13 | |
14 | * The parameter lists must give a name for each argument. This | |
15 | includes return parameters. | |
16 | ||
17 | * The parameter lists must give a type for each argument: | |
18 | the (x, y, z int) shorthand is not allowed. | |
19 | ||
20 | * If the return parameter is an error number, it must be named err. | |
21 | ||
22 | * If go func name needs to be different from its winapi dll name, | |
23 | the winapi name could be specified at the end, after "=" sign, like | |
24 | //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA | |
25 | ||
26 | * Each function that returns err needs to supply a condition, that | |
27 | return value of winapi will be tested against to detect failure. | |
28 | This would set err to windows "last-error", otherwise it will be nil. | |
29 | The value can be provided at end of //sys declaration, like | |
30 | //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA | |
31 | and is [failretval==0] by default. | |
32 | ||
33 | * If the function name ends in a "?", then the function not existing is non- | |
34 | fatal, and an error will be returned instead of panicking. | |
14 | - The parameter lists must give a name for each argument. This | |
15 | includes return parameters. | |
16 | ||
17 | - The parameter lists must give a type for each argument: | |
18 | the (x, y, z int) shorthand is not allowed. | |
19 | ||
20 | - If the return parameter is an error number, it must be named err. | |
21 | ||
22 | - If go func name needs to be different from its winapi dll name, | |
23 | the winapi name could be specified at the end, after "=" sign, like | |
24 | //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA | |
25 | ||
26 | - Each function that returns err needs to supply a condition, that | |
27 | return value of winapi will be tested against to detect failure. | |
28 | This would set err to windows "last-error", otherwise it will be nil. | |
29 | The value can be provided at end of //sys declaration, like | |
30 | //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA | |
31 | and is [failretval==0] by default. | |
32 | ||
33 | - If the function name ends in a "?", then the function not existing is non- | |
34 | fatal, and an error will be returned instead of panicking. | |
35 | 35 | |
36 | 36 | Usage: |
37 | ||
37 | 38 | mkwinsyscall [flags] [path ...] |
38 | 39 | |
39 | 40 | The flags are: |
41 | ||
40 | 42 | -output |
41 | 43 | Specify output file name (outputs to console if blank). |
42 | 44 | -trace |
19 | 19 | // log.Fatal(err) |
20 | 20 | // } |
21 | 21 | // fmt.Printf("Windows system root is %q\n", s) |
22 | // | |
23 | 22 | package registry |
24 | 23 | |
25 | 24 | import ( |
5 | 5 | // +build windows |
6 | 6 | |
7 | 7 | // Package debug provides facilities to execute svc.Handler on console. |
8 | // | |
9 | 8 | package debug |
10 | 9 | |
11 | 10 | import ( |
5 | 5 | // +build windows |
6 | 6 | |
7 | 7 | // Package eventlog implements access to Windows event log. |
8 | // | |
9 | 8 | package eventlog |
10 | 9 | |
11 | 10 | import ( |
11 | 11 | // stop / start / pause / continue any service, and how to |
12 | 12 | // write to event log. It also shows how to use debug |
13 | 13 | // facilities available in debug package. |
14 | // | |
15 | 14 | package main |
16 | 15 | |
17 | 16 | import ( |
8 | 8 | // It can be used to install and remove them. It can also start, |
9 | 9 | // stop and pause them. The package can query / change current |
10 | 10 | // service state and config parameters. |
11 | // | |
12 | 11 | package mgr |
13 | 12 | |
14 | 13 | import ( |