Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
ad4f95d3
Commit
ad4f95d3
authored
14 years ago
by
Wei Guangjing
Committed by
Alex Brainman
14 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syscall: add windows version of Pipe()
R=brainman, rsc CC=golang-dev
https://golang.org/cl/1715046
parent
f656a876
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
2 deletions
+60
-2
src/pkg/syscall/syscall_windows.go
src/pkg/syscall/syscall_windows.go
+20
-2
src/pkg/syscall/zsyscall_windows_386.go
src/pkg/syscall/zsyscall_windows_386.go
+32
-0
src/pkg/syscall/ztypes_windows_386.go
src/pkg/syscall/ztypes_windows_386.go
+8
-0
No files found.
src/pkg/syscall/syscall_windows.go
View file @
ad4f95d3
...
...
@@ -138,6 +138,8 @@ func getSysProcAddr(m uint32, pname string) uintptr {
//sys DuplicateHandle(hSourceProcessHandle int32, hSourceHandle int32, hTargetProcessHandle int32, lpTargetHandle *int32, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (ok bool, errno int)
//sys WaitForSingleObject(handle int32, waitMilliseconds uint32) (event uint32, errno int) [failretval=0xffffffff]
//sys GetTempPath(buflen uint32, buf *uint16) (n uint32, errno int) = GetTempPathW
//sys CreatePipe(readhandle *uint32, writehandle *uint32, lpsa *byte, size uint32) (ok bool, errno int)
//sys GetFileType(filehandle uint32) (n uint32, errno int)
//sys CryptAcquireContext(provhandle *uint32, container *uint16, provider *uint16, provtype uint32, flags uint32) (ok bool, errno int) = advapi32.CryptAcquireContextW
//sys CryptReleaseContext(provhandle uint32, flags uint32) (ok bool, errno int) = advapi32.CryptReleaseContext
//sys CryptGenRandom(provhandle uint32, buflen uint32, buf *byte) (ok bool, errno int) = advapi32.CryptGenRandom
...
...
@@ -261,6 +263,11 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, errno int) {
}
hi
:=
int32
(
offset
>>
32
)
lo
:=
int32
(
offset
)
// use GetFileType to check pipe, pipe can't do seek
ft
,
_
:=
GetFileType
(
uint32
(
fd
))
if
ft
==
FILE_TYPE_PIPE
{
return
0
,
EPIPE
}
rlo
,
e
:=
SetFilePointer
(
int32
(
fd
),
lo
,
&
hi
,
w
)
if
e
!=
0
{
return
0
,
e
...
...
@@ -388,6 +395,19 @@ func Sleep(nsec int64) (errno int) {
return
0
}
func
Pipe
(
p
[]
int
)
(
errno
int
)
{
if
len
(
p
)
!=
2
{
return
EINVAL
}
var
r
,
w
uint32
if
ok
,
errno
:=
CreatePipe
(
&
r
,
&
w
,
nil
,
0
);
!
ok
{
return
errno
}
p
[
0
]
=
int
(
r
)
p
[
1
]
=
int
(
w
)
return
0
}
// TODO(brainman): implement Utimes, or rewrite os.file.Chtimes() instead
func
Utimes
(
path
string
,
tv
[]
Timeval
)
(
errno
int
)
{
return
EWINDOWS
...
...
@@ -605,8 +625,6 @@ func Getgroups() (gids []int, errno int) { return nil, EWINDOWS }
// TODO(brainman): fix all this meaningless code, it is here to compile exec.go
func
Pipe
(
p
[]
int
)
(
errno
int
)
{
return
EWINDOWS
}
func
read
(
fd
int
,
buf
*
byte
,
nbuf
int
)
(
n
int
,
errno
int
)
{
return
0
,
EWINDOWS
}
...
...
This diff is collapsed.
Click to expand it.
src/pkg/syscall/zsyscall_windows_386.go
View file @
ad4f95d3
...
...
@@ -47,6 +47,8 @@ var (
procDuplicateHandle
=
getSysProcAddr
(
modkernel32
,
"DuplicateHandle"
)
procWaitForSingleObject
=
getSysProcAddr
(
modkernel32
,
"WaitForSingleObject"
)
procGetTempPathW
=
getSysProcAddr
(
modkernel32
,
"GetTempPathW"
)
procCreatePipe
=
getSysProcAddr
(
modkernel32
,
"CreatePipe"
)
procGetFileType
=
getSysProcAddr
(
modkernel32
,
"GetFileType"
)
procCryptAcquireContextW
=
getSysProcAddr
(
modadvapi32
,
"CryptAcquireContextW"
)
procCryptReleaseContext
=
getSysProcAddr
(
modadvapi32
,
"CryptReleaseContext"
)
procCryptGenRandom
=
getSysProcAddr
(
modadvapi32
,
"CryptGenRandom"
)
...
...
@@ -591,6 +593,36 @@ func GetTempPath(buflen uint32, buf *uint16) (n uint32, errno int) {
return
}
func
CreatePipe
(
readhandle
*
uint32
,
writehandle
*
uint32
,
lpsa
*
byte
,
size
uint32
)
(
ok
bool
,
errno
int
)
{
r0
,
_
,
e1
:=
Syscall6
(
procCreatePipe
,
uintptr
(
unsafe
.
Pointer
(
readhandle
)),
uintptr
(
unsafe
.
Pointer
(
writehandle
)),
uintptr
(
unsafe
.
Pointer
(
lpsa
)),
uintptr
(
size
),
0
,
0
)
ok
=
bool
(
r0
!=
0
)
if
!
ok
{
if
e1
!=
0
{
errno
=
int
(
e1
)
}
else
{
errno
=
EINVAL
}
}
else
{
errno
=
0
}
return
}
func
GetFileType
(
filehandle
uint32
)
(
n
uint32
,
errno
int
)
{
r0
,
_
,
e1
:=
Syscall
(
procGetFileType
,
uintptr
(
filehandle
),
0
,
0
)
n
=
uint32
(
r0
)
if
n
==
0
{
if
e1
!=
0
{
errno
=
int
(
e1
)
}
else
{
errno
=
EINVAL
}
}
else
{
errno
=
0
}
return
}
func
CryptAcquireContext
(
provhandle
*
uint32
,
container
*
uint16
,
provider
*
uint16
,
provtype
uint32
,
flags
uint32
)
(
ok
bool
,
errno
int
)
{
r0
,
_
,
e1
:=
Syscall6
(
procCryptAcquireContextW
,
uintptr
(
unsafe
.
Pointer
(
provhandle
)),
uintptr
(
unsafe
.
Pointer
(
container
)),
uintptr
(
unsafe
.
Pointer
(
provider
)),
uintptr
(
provtype
),
uintptr
(
flags
),
0
)
ok
=
bool
(
r0
!=
0
)
...
...
This diff is collapsed.
Click to expand it.
src/pkg/syscall/ztypes_windows_386.go
View file @
ad4f95d3
...
...
@@ -328,3 +328,11 @@ const (
S_IWUSR
=
0x80
S_IXUSR
=
0x40
)
const
(
FILE_TYPE_CHAR
=
0x0002
FILE_TYPE_DISK
=
0x0001
FILE_TYPE_PIPE
=
0x0003
FILE_TYPE_REMOTE
=
0x8000
FILE_TYPE_UNKNOWN
=
0x0000
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment