unix: update z/OS implementation of fcntl and mmap

- Add a wrapper function around fcntl to handle different operation
  types and new fcntl implementation that accepts uintptr as an arg.
- Add support for calling mmap/munmap with address pointers.
- Add accompanying tests for new functions.

Change-Id: If5e77aa4cf2cccfd431de4f3bd0c5014a761e167
GitHub-Last-Rev: 07e32a4ab797c7baffdb50f8407cf679cabf1dae
GitHub-Pull-Request: golang/sys#216
Reviewed-on: https://go-review.googlesource.com/c/sys/+/610296
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Joon Lee
2024-10-25 15:27:13 +00:00
committed by Gopher Robot
parent df4a4da00c
commit 123459f096
5 changed files with 213 additions and 26 deletions
+14
View File
@@ -72,3 +72,17 @@ func TestMmap(t *testing.T) {
t.Fatalf("Munmap: %v", err)
}
}
func TestMmapPtr(t *testing.T) {
p, err := unix.MmapPtr(-1, 0, nil, uintptr(2*unix.Getpagesize()),
unix.PROT_READ|unix.PROT_WRITE, unix.MAP_ANON|unix.MAP_PRIVATE)
if err != nil {
t.Fatalf("MmapPtr: %v", err)
}
*(*byte)(p) = 42
if err := unix.MunmapPtr(p, uintptr(2*unix.Getpagesize())); err != nil {
t.Fatalf("MunmapPtr: %v", err)
}
}