2019-09-03 16:00:59 +00:00
|
|
|
package memory_map
|
|
|
|
|
2019-09-04 13:24:17 +00:00
|
|
|
import (
|
|
|
|
"os"
|
2019-10-22 07:49:42 +00:00
|
|
|
"strconv"
|
2019-09-04 13:24:17 +00:00
|
|
|
)
|
2019-09-03 16:00:59 +00:00
|
|
|
|
|
|
|
type MemoryBuffer struct {
|
|
|
|
aligned_length uint64
|
|
|
|
length uint64
|
|
|
|
aligned_ptr uintptr
|
|
|
|
ptr uintptr
|
|
|
|
Buffer []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
type MemoryMap struct {
|
|
|
|
File *os.File
|
|
|
|
file_memory_map_handle uintptr
|
|
|
|
write_map_views []MemoryBuffer
|
|
|
|
max_length uint64
|
2019-09-04 13:24:17 +00:00
|
|
|
End_of_file int64
|
2019-09-03 16:00:59 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 07:49:42 +00:00
|
|
|
func ReadMemoryMapMaxSizeMb(memoryMapMaxSizeMbString string) (uint32, error) {
|
|
|
|
if memoryMapMaxSizeMbString == "" {
|
|
|
|
return 0, nil
|
|
|
|
}
|
|
|
|
memoryMapMaxSize64, err := strconv.ParseUint(memoryMapMaxSizeMbString, 10, 32)
|
|
|
|
return uint32(memoryMapMaxSize64), err
|
2019-09-04 13:24:17 +00:00
|
|
|
}
|