-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix mimirtool build on windows. Signed-off-by: Peter Štibraný <pstibrany@gmail.com> * CHANGELOG.md Signed-off-by: Peter Štibraný <pstibrany@gmail.com> * Move changelog entry to 2.2.0-rc.1 / Mimirtool section. Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Provenance-includes-location: https://github.com/prometheus/prometheus/blob/main/tsdb/fileutil/mmap_386.go | ||
// Provenance-includes-license: Apache-2.0 | ||
// Provenance-includes-copyright: The Prometheus Authors. | ||
|
||
//go:build windows | ||
// +build windows | ||
|
||
package fileutil | ||
|
||
const maxMapSize = 0x7FFFFFFF // 2GB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Provenance-includes-location: https://github.com/prometheus/prometheus/blob/main/tsdb/fileutil/mmap_amd64.go | ||
// Provenance-includes-license: Apache-2.0 | ||
// Provenance-includes-copyright: The Prometheus Authors. | ||
|
||
//go:build windows | ||
// +build windows | ||
|
||
package fileutil | ||
|
||
const maxMapSize = 0xFFFFFFFFFFFF // 256TB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Provenance-includes-location: https://github.com/prometheus/prometheus/blob/main/tsdb/fileutil/mmap_arm64.go | ||
// Provenance-includes-license: Apache-2.0 | ||
// Provenance-includes-copyright: The Prometheus Authors. | ||
|
||
//go:build windows | ||
// +build windows | ||
|
||
package fileutil | ||
|
||
const maxMapSize = 0xFFFFFFFFFFFF // 256TB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Provenance-includes-location: https://github.com/prometheus/prometheus/blob/main/tsdb/fileutil/mmap_windows.go | ||
// Provenance-includes-license: Apache-2.0 | ||
// Provenance-includes-copyright: The Prometheus Authors. | ||
|
||
package fileutil | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
func mmap(f *os.File, size int, populate bool) ([]byte, error) { | ||
low, high := uint32(size), uint32(size>>32) | ||
h, errno := syscall.CreateFileMapping(syscall.Handle(f.Fd()), nil, syscall.PAGE_READONLY, high, low, nil) | ||
if h == 0 { | ||
return nil, os.NewSyscallError("CreateFileMapping", errno) | ||
} | ||
|
||
addr, errno := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, uintptr(size)) | ||
if addr == 0 { | ||
return nil, os.NewSyscallError("MapViewOfFile", errno) | ||
} | ||
|
||
if err := syscall.CloseHandle(syscall.Handle(h)); err != nil { | ||
return nil, os.NewSyscallError("CloseHandle", err) | ||
} | ||
|
||
return (*[maxMapSize]byte)(unsafe.Pointer(addr))[:size], nil | ||
} | ||
|
||
func munmap(b []byte) error { | ||
if err := syscall.UnmapViewOfFile((uintptr)(unsafe.Pointer(&b[0]))); err != nil { | ||
return os.NewSyscallError("UnmapViewOfFile", err) | ||
} | ||
return nil | ||
} |