From 59faf80fcc7584ee9878dce986af4a4f8e3a375e Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Sat, 6 Apr 2024 02:27:34 +0100 Subject: [PATCH] threads: remove dead code (#2176) Signed-off-by: Nuno Cruces --- internal/platform/mmap_unix.go | 12 ------------ internal/platform/mmap_unsupported.go | 4 ---- internal/platform/mmap_windows.go | 9 --------- internal/platform/platform.go | 10 ---------- 4 files changed, 35 deletions(-) diff --git a/internal/platform/mmap_unix.go b/internal/platform/mmap_unix.go index f29bdc3f..a61996d5 100644 --- a/internal/platform/mmap_unix.go +++ b/internal/platform/mmap_unix.go @@ -14,18 +14,6 @@ const ( const MmapSupported = true -func mmapMemory(size int) ([]byte, error) { - return syscall.Mmap( - -1, - 0, - size, - syscall.PROT_READ|syscall.PROT_WRITE, - // Anonymous as this is not an actual file, but a memory, - // Private as this is in-process memory region. - syscall.MAP_ANON|syscall.MAP_PRIVATE, - ) -} - func munmapCodeSegment(code []byte) error { return syscall.Munmap(code) } diff --git a/internal/platform/mmap_unsupported.go b/internal/platform/mmap_unsupported.go index 4bcbbde8..27833db3 100644 --- a/internal/platform/mmap_unsupported.go +++ b/internal/platform/mmap_unsupported.go @@ -23,10 +23,6 @@ func mmapCodeSegmentARM64(size int) ([]byte, error) { panic(errUnsupported) } -func mmapMemory(size int) ([]byte, error) { - panic(errUnsupported) -} - func MprotectRX(b []byte) (err error) { panic(errUnsupported) } diff --git a/internal/platform/mmap_windows.go b/internal/platform/mmap_windows.go index 997f1a60..69fcb6d6 100644 --- a/internal/platform/mmap_windows.go +++ b/internal/platform/mmap_windows.go @@ -58,15 +58,6 @@ func virtualProtect(address, size, newprotect uintptr, oldprotect *uint32) error return nil } -func mmapMemory(size int) ([]byte, error) { - p, err := allocateMemory(uintptr(size), windows_PAGE_READWRITE) - if err != nil { - return nil, err - } - - return unsafe.Slice((*byte)(unsafe.Pointer(p)), size), nil -} - func mmapCodeSegmentAMD64(size int) ([]byte, error) { p, err := allocateMemory(uintptr(size), windows_PAGE_EXECUTE_READWRITE) if err != nil { diff --git a/internal/platform/platform.go b/internal/platform/platform.go index 0d918856..c6dc0f85 100644 --- a/internal/platform/platform.go +++ b/internal/platform/platform.go @@ -36,16 +36,6 @@ func MmapCodeSegment(size int) ([]byte, error) { } } -// MmapMemory allocates a buffer of the given size using mmap. A large size can be allocated at once -// without raising process memory usage, and physical pages will be allocated on access after calls to -// Grow. -func MmapMemory(size int) ([]byte, error) { - if size == 0 { - panic("BUG: MmapMemory with zero length") - } - return mmapMemory(size) -} - // RemapCodeSegment reallocates the memory mapping of an existing code segment // to increase its size. The previous code mapping is unmapped and must not be // reused after the function returns.