mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-21 17:45:43 +02:00
* 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>
29 lines
485 B
Go
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
|
|
}
|