Files
compute-blade-agent/pkg/hal/helper.go
Cedric Kienzler ff6898f514 chore(go version)!: Bump go version to 1.24 (#58)
* refactor(workflows): Improve GitHub Action workflows

* bump go version to 1.24

* set coverage report baseline to correct workflow

* nit: keep same

* require older go version

* let semantic-prs write to PR

* let semantic-prs write to PR

* bump go version to 1.24

* bump dependencies

---------

Co-authored-by: Cedric Kienzler <cedric@specht-labs.de>
2025-06-06 14:19:42 +02:00

29 lines
485 B
Go

//go:build linux
package hal
import (
"os"
"syscall"
"unsafe"
)
func mmap(file *os.File, base int64, length int) ([]uint32, []uint8, error) {
mem8, err := syscall.Mmap(
int(file.Fd()),
base,
length,
syscall.PROT_READ|syscall.PROT_WRITE,
syscall.MAP_SHARED,
)
if err != nil {
return nil, nil, err
}
// Convert []uint8 to []uint32 using unsafe.Slice
ptr := unsafe.Pointer(&mem8[0])
mem32 := unsafe.Slice((*uint32)(ptr), len(mem8)/4)
return mem32, mem8, nil
}