...

Source file src/cmd/vendor/golang.org/x/telemetry/internal/mmap/mmap.go

Documentation: cmd/vendor/golang.org/x/telemetry/internal/mmap

     1  // Copyright 2011 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This package is a lightly modified version of the mmap code
     6  // in github.com/google/codesearch/index.
     7  
     8  // The mmap package provides an abstraction for memory mapping files
     9  // on different platforms.
    10  package mmap
    11  
    12  import (
    13  	"os"
    14  )
    15  
    16  // The backing file is never closed, so Data
    17  // remains valid for the lifetime of the process.
    18  type Data struct {
    19  	// TODO(pjw): might be better to define versions of Data
    20  	// for the 3 specializations
    21  	f    *os.File
    22  	Data []byte
    23  	// Some windows magic
    24  	Windows interface{}
    25  }
    26  
    27  // Mmap maps the given file into memory.
    28  // When remapping a file, pass the most recently returned Data.
    29  func Mmap(f *os.File) (*Data, error) {
    30  	return mmapFile(f)
    31  }
    32  
    33  // Munmap unmaps the given file from memory.
    34  func Munmap(d *Data) error {
    35  	return munmapFile(d)
    36  }
    37  

View as plain text