diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-07-12 16:19:23 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-07-12 16:19:23 +0000 |
commit | 715afd5da8c2d5aacd7ab64535b92dac1abc3f37 (patch) | |
tree | 432c7c1ada560a23f26de6e9b8beefdda97ccdcc /pkg/sentry/fs/ashmem/uint64_range.go | |
parent | e3abe5ebdf5e0c98429faee7d57d126d452f7293 (diff) | |
parent | 69e0affaecda24b4d193e4592202b55b53afecc3 (diff) |
Merge 69e0affa (automated)
Diffstat (limited to 'pkg/sentry/fs/ashmem/uint64_range.go')
-rwxr-xr-x | pkg/sentry/fs/ashmem/uint64_range.go | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/pkg/sentry/fs/ashmem/uint64_range.go b/pkg/sentry/fs/ashmem/uint64_range.go deleted file mode 100755 index d71a10b16..000000000 --- a/pkg/sentry/fs/ashmem/uint64_range.go +++ /dev/null @@ -1,62 +0,0 @@ -package ashmem - -// A Range represents a contiguous range of T. -// -// +stateify savable -type Range struct { - // Start is the inclusive start of the range. - Start uint64 - - // End is the exclusive end of the range. - End uint64 -} - -// WellFormed returns true if r.Start <= r.End. All other methods on a Range -// require that the Range is well-formed. -func (r Range) WellFormed() bool { - return r.Start <= r.End -} - -// Length returns the length of the range. -func (r Range) Length() uint64 { - return r.End - r.Start -} - -// Contains returns true if r contains x. -func (r Range) Contains(x uint64) bool { - return r.Start <= x && x < r.End -} - -// Overlaps returns true if r and r2 overlap. -func (r Range) Overlaps(r2 Range) bool { - return r.Start < r2.End && r2.Start < r.End -} - -// IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is -// contained within r. -func (r Range) IsSupersetOf(r2 Range) bool { - return r.Start <= r2.Start && r.End >= r2.End -} - -// Intersect returns a range consisting of the intersection between r and r2. -// If r and r2 do not overlap, Intersect returns a range with unspecified -// bounds, but for which Length() == 0. -func (r Range) Intersect(r2 Range) Range { - if r.Start < r2.Start { - r.Start = r2.Start - } - if r.End > r2.End { - r.End = r2.End - } - if r.End < r.Start { - r.End = r.Start - } - return r -} - -// CanSplitAt returns true if it is legal to split a segment spanning the range -// r at x; that is, splitting at x would produce two ranges, both of which have -// non-zero length. -func (r Range) CanSplitAt(x uint64) bool { - return r.Contains(x) && r.Start < x -} |