Mercurial > yakumo_izuru > aya
comparison vendor/golang.org/x/sys/windows/syscall.go @ 68:4b79810863f6 draft
Ready to release 0.6.0
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author | yakumo.izuru |
---|---|
date | Wed, 13 Sep 2023 10:49:50 +0000 |
parents | 787b5ee0289d |
children |
comparison
equal
deleted
inserted
replaced
67:4edfa07d5fe0 | 68:4b79810863f6 |
---|---|
28 import ( | 28 import ( |
29 "bytes" | 29 "bytes" |
30 "strings" | 30 "strings" |
31 "syscall" | 31 "syscall" |
32 "unsafe" | 32 "unsafe" |
33 | |
34 "golang.org/x/sys/internal/unsafeheader" | |
35 ) | 33 ) |
36 | 34 |
37 // ByteSliceFromString returns a NUL-terminated slice of bytes | 35 // ByteSliceFromString returns a NUL-terminated slice of bytes |
38 // containing the text of s. If s contains a NUL byte at any | 36 // containing the text of s. If s contains a NUL byte at any |
39 // location, it returns (nil, syscall.EINVAL). | 37 // location, it returns (nil, syscall.EINVAL). |
81 n := 0 | 79 n := 0 |
82 for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ { | 80 for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ { |
83 ptr = unsafe.Pointer(uintptr(ptr) + 1) | 81 ptr = unsafe.Pointer(uintptr(ptr) + 1) |
84 } | 82 } |
85 | 83 |
86 var s []byte | 84 return string(unsafe.Slice(p, n)) |
87 h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) | |
88 h.Data = unsafe.Pointer(p) | |
89 h.Len = n | |
90 h.Cap = n | |
91 | |
92 return string(s) | |
93 } | 85 } |
94 | 86 |
95 // Single-word zero for use when we need a valid pointer to 0 bytes. | 87 // Single-word zero for use when we need a valid pointer to 0 bytes. |
96 // See mksyscall.pl. | 88 // See mksyscall.pl. |
97 var _zero uintptr | 89 var _zero uintptr |