Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building on ARM64 Linux #9

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 2 additions & 29 deletions gommap_test.go
Original file line number Diff line number Diff line change
@@ -4,11 +4,12 @@ package gommap

import (
"io/ioutil"
. "launchpad.net/gocheck"
"os"
"path"
"syscall"
"testing"

. "launchpad.net/gocheck"
)

func TestAll(t *testing.T) {
@@ -150,31 +151,3 @@ func (s *S) TestIsResidentUnderOnePage(c *C) {
c.Assert(err, IsNil)
c.Assert(mapped, DeepEquals, []bool{true})
}

func (s *S) TestIsResidentTwoPages(c *C) {
testPath := path.Join(c.MkDir(), "test.txt")
file, err := os.Create(testPath)
c.Assert(err, IsNil)
defer file.Close()

file.Seek(int64(os.Getpagesize()*2-1), 0)
file.Write([]byte{'x'})

mmap, err := Map(file.Fd(), PROT_READ|PROT_WRITE, MAP_PRIVATE)
c.Assert(err, IsNil)
defer mmap.UnsafeUnmap()

// Not entirely a stable test, but should usually work.

mmap[len(mmap)-1] = 'x'

mapped, err := mmap.IsResident()
c.Assert(err, IsNil)
c.Assert(mapped, DeepEquals, []bool{false, true})

mmap[0] = 'x'

mapped, err = mmap.IsResident()
c.Assert(err, IsNil)
c.Assert(mapped, DeepEquals, []bool{true, true})
}
38 changes: 38 additions & 0 deletions gommap_twopage_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// +build !windows,!freebsd

package gommap

import (
"os"
"path"

. "launchpad.net/gocheck"
)

func (s *S) TestIsResidentTwoPages(c *C) {
testPath := path.Join(c.MkDir(), "test.txt")
file, err := os.Create(testPath)
c.Assert(err, IsNil)
defer file.Close()

file.Seek(int64(os.Getpagesize()*2-1), 0)
file.Write([]byte{'x'})

mmap, err := Map(file.Fd(), PROT_READ|PROT_WRITE, MAP_PRIVATE)
c.Assert(err, IsNil)
defer mmap.UnsafeUnmap()

// Not entirely a stable test, but should usually work.

mmap[len(mmap)-1] = 'x'

mapped, err := mmap.IsResident()
c.Assert(err, IsNil)
c.Assert(mapped, DeepEquals, []bool{false, true})

mmap[0] = 'x'

mapped, err = mmap.IsResident()
c.Assert(err, IsNil)
c.Assert(mapped, DeepEquals, []bool{true, true})
}
3 changes: 3 additions & 0 deletions mmap_linux_386.go → mmap_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// +build linux freebsd
// +build 386

package gommap

import "syscall"
3 changes: 3 additions & 0 deletions mmap_linux_amd64.go → mmap_unix64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// +build linux freebsd
// +build amd64 arm64

package gommap

import "syscall"