ffi-mmap 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Dockerfile +10 -0
- data/LICENSE +21 -0
- data/Makefile +4 -0
- data/README.md +1 -1
- data/Rules.mk +31 -0
- data/lib/ffi/mmap/mmap.rb +38 -0
- data/lib/ffi/mmap/version.rb +1 -1
- metadata +25 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca3fcd22ae6344e7390d268af857c836e48e8f67
|
4
|
+
data.tar.gz: a2bc0a92a1078c8dacebecc32244952c71010985
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6cadf86e57880efb9323f24a3b19c290a805b280cca4c91a78f9759be371ca8866d218543d0f35f426c36d0ee981369f2061e67b49ef0c9b5c78aaa3b8bff2fd
|
7
|
+
data.tar.gz: e4946825a79ab8c3653289fd41c76f70d184b2cee492fdce67c64fc0aaa5cb4d0fd63b67ac622e60e1d7ebd19dc300268e2d40724d954d6003c25cc7a596532c
|
data/Dockerfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Hokstad Consulting Ltd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/Makefile
ADDED
data/README.md
CHANGED
@@ -36,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
36
36
|
|
37
37
|
## Contributing
|
38
38
|
|
39
|
-
1. Fork it ( https://github.com/
|
39
|
+
1. Fork it ( https://github.com/hokstadconsulting/ffi-mmap/fork )
|
40
40
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
41
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
42
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rules.mk
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
DR=docker run -t -i -v ${PWD}:/app ${IMAGE}
|
2
|
+
B=${DR} bundle
|
3
|
+
BE=${B} exec
|
4
|
+
|
5
|
+
build: container
|
6
|
+
echo Building gem
|
7
|
+
${BE} rake build
|
8
|
+
|
9
|
+
push: build
|
10
|
+
gem push `/bin/ls -q pkg/* | tail -n1`
|
11
|
+
|
12
|
+
container: Dockerfile
|
13
|
+
docker build -t ${IMAGE} .
|
14
|
+
|
15
|
+
update: container
|
16
|
+
${B} update
|
17
|
+
|
18
|
+
bundle: container
|
19
|
+
${B} install --binstubs ./bin --path=./vendor/bundle
|
20
|
+
|
21
|
+
rdoc:
|
22
|
+
rm -rf doc
|
23
|
+
${BE} rdoc --main=README.md -O -U -x'~' README.md lib
|
24
|
+
|
25
|
+
.PHONY: spec
|
26
|
+
spec:
|
27
|
+
${BE} rspec ./spec
|
28
|
+
|
29
|
+
|
30
|
+
cli:
|
31
|
+
${DR} /bin/bash -l
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
module FFI
|
3
|
+
class Mmap
|
4
|
+
# FFI interface to the C library.
|
5
|
+
module Internal
|
6
|
+
extend FFI::Library
|
7
|
+
ffi_lib FFI::Library::LIBC
|
8
|
+
|
9
|
+
attach_function :mmap, [ :pointer, :ulong, :int, :int, :int, :uint ], :pointer
|
10
|
+
attach_function :munmap, [:pointer, :ulong], :int
|
11
|
+
end
|
12
|
+
|
13
|
+
PROT_READ=1
|
14
|
+
MAP_SHARED=1
|
15
|
+
|
16
|
+
def initialize(filename, mode, flags)
|
17
|
+
@f = File.open(filename, mode)
|
18
|
+
@size = @f.size
|
19
|
+
@m = FFI::AutoPointer.new(Internal.mmap(nil,@size,PROT_READ, flags,@f.fileno,0),
|
20
|
+
self.method(:munmap))
|
21
|
+
raise "Mmap failed" if @m.address == 0xffffffffffffffff
|
22
|
+
end
|
23
|
+
|
24
|
+
# Called automatically on gc thanks to FFI::AutoPointer wrapper around @m
|
25
|
+
def munmap(_)
|
26
|
+
Internal.munmap(@m,@len)
|
27
|
+
@m = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def[] ndx
|
31
|
+
first = ndx.first
|
32
|
+
last = ndx.last
|
33
|
+
last = @size-1 if last >= 0 && last >= @size
|
34
|
+
@m.get_bytes(first, last - first+1)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/lib/ffi/mmap/version.rb
CHANGED
metadata
CHANGED
@@ -1,78 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-mmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Vidar Hokstad
|
9
8
|
autorequire:
|
10
9
|
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: ffi
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bundler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '1.9'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '1.9'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '10.0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '10.0'
|
78
69
|
description: FFI-based interface to mmap
|
@@ -82,39 +73,45 @@ executables: []
|
|
82
73
|
extensions: []
|
83
74
|
extra_rdoc_files: []
|
84
75
|
files:
|
85
|
-
- .gitignore
|
86
|
-
- .rspec
|
87
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Dockerfile
|
88
80
|
- Gemfile
|
81
|
+
- LICENSE
|
82
|
+
- Makefile
|
89
83
|
- README.md
|
90
84
|
- Rakefile
|
85
|
+
- Rules.mk
|
91
86
|
- bin/console
|
92
87
|
- bin/setup
|
93
88
|
- ffi-mmap.gemspec
|
94
89
|
- lib/ffi/mmap.rb
|
90
|
+
- lib/ffi/mmap/mmap.rb
|
95
91
|
- lib/ffi/mmap/version.rb
|
96
92
|
homepage: https://github.com/hokstadconsulting/ffi-mmap
|
97
93
|
licenses: []
|
94
|
+
metadata:
|
95
|
+
allowed_push_host: 'TODO: Set to ''http://mygemserver.com'' to prevent pushes to
|
96
|
+
rubygems.org, or delete to allow pushes to any server.'
|
98
97
|
post_install_message:
|
99
98
|
rdoc_options: []
|
100
99
|
require_paths:
|
101
100
|
- lib
|
102
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
102
|
requirements:
|
105
|
-
- -
|
103
|
+
- - ">="
|
106
104
|
- !ruby/object:Gem::Version
|
107
105
|
version: '0'
|
108
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
107
|
requirements:
|
111
|
-
- -
|
108
|
+
- - ">="
|
112
109
|
- !ruby/object:Gem::Version
|
113
110
|
version: '0'
|
114
111
|
requirements: []
|
115
112
|
rubyforge_project:
|
116
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.6.6
|
117
114
|
signing_key:
|
118
|
-
specification_version:
|
115
|
+
specification_version: 4
|
119
116
|
summary: FFI-based interface to mmap
|
120
117
|
test_files: []
|