malloc 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING CHANGED
@@ -80,7 +80,7 @@ modification follow.
80
80
 
81
81
  "Copyright" also means copyright-like laws that apply to other kinds of
82
82
  works, such as semiconductor masks.
83
-
83
+
84
84
  "The Program" refers to any copyrightable work licensed under this
85
85
  License. Each licensee is addressed as "you". "Licensees" and
86
86
  "recipients" may be individuals or organizations.
@@ -513,7 +513,7 @@ actual knowledge that, but for the patent license, your conveying the
513
513
  covered work in a country, or your recipient's use of the covered work
514
514
  in a country, would infringe one or more identifiable patents in that
515
515
  country that you have reason to believe are valid.
516
-
516
+
517
517
  If, pursuant to or in connection with a single transaction or
518
518
  arrangement, you convey, or propagate by procuring conveyance of, a
519
519
  covered work, and grant a patent license to some of the parties
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'malloc'
10
- PKG_VERSION = '1.4.0'
10
+ PKG_VERSION = '1.5.0'
11
11
  CFG = RbConfig::CONFIG
12
12
  CXX = ENV[ 'CXX' ] || 'g++'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
@@ -22,6 +22,7 @@ BIN_FILES = [ 'README.md', 'COPYING', '.document', SO_FILE ] +
22
22
  RB_FILES + TS_FILES + TC_FILES
23
23
  SUMMARY = %q{Object for raw memory allocation and pointer operations}
24
24
  DESCRIPTION = %q{This Ruby extension defines the class Hornetseye::Malloc. Hornetseye::Malloc#new allows you to allocate memory, using Hornetseye::Malloc#+ one can do pointer manipulation, and Hornetseye::Malloc#read and Hornetseye::Malloc#write provide reading Ruby strings from memory and writing Ruby strings to memory.}
25
+ LICENSE = 'GPL-3+'
25
26
  AUTHOR = %q{Jan Wedekind}
26
27
  EMAIL = %q{jan@wedesoft.de}
27
28
  HOMEPAGE = %q{http://wedesoft.github.com/malloc/}
@@ -81,13 +82,24 @@ end
81
82
  begin
82
83
  require 'yard'
83
84
  YARD::Rake::YardocTask.new :yard do |y|
84
- y.options << '--no-private'
85
- y.files << FileList[ 'lib/**/*.rb' ]
85
+ y.files << RB_FILES
86
86
  end
87
87
  rescue LoadError
88
88
  STDERR.puts 'Please install \'yard\' if you want to generate documentation'
89
89
  end
90
90
 
91
+ begin
92
+ require 'fpm'
93
+ desc 'Create Debian package'
94
+ task :deb => :gem do
95
+ system "fpm -f -s gem -t deb -n #{PKG_NAME} -m '#{AUTHOR} <#{EMAIL}>' " +
96
+ "--deb-priority optional -d ruby1.9.1 " +
97
+ "pkg/#{PKG_NAME}-#{PKG_VERSION}.gem"
98
+ end
99
+ rescue LoadError
100
+ STDERR.puts 'Please install \'fpm\' if you want to create Debian packages'
101
+ end
102
+
91
103
  Rake::PackageTask.new PKG_NAME, PKG_VERSION do |p|
92
104
  p.need_tar = true
93
105
  p.package_files = PKG_FILES
@@ -103,6 +115,7 @@ begin
103
115
  s.date = Date.today.to_s
104
116
  s.summary = SUMMARY
105
117
  s.description = DESCRIPTION
118
+ s.license = LICENSE
106
119
  s.author = AUTHOR
107
120
  s.email = EMAIL
108
121
  s.homepage = HOMEPAGE
@@ -113,7 +126,6 @@ begin
113
126
  s.extensions = %w{Rakefile}
114
127
  s.has_rdoc = 'yard'
115
128
  s.extra_rdoc_files = []
116
- s.rdoc_options = %w{--no-private}
117
129
  s.add_development_dependency %q{rake}
118
130
  end
119
131
  GEM_SOURCE = "#{PKG_NAME}-#{PKG_VERSION}.gem"
@@ -124,6 +136,7 @@ begin
124
136
  s.date = Date.today.to_s
125
137
  s.summary = SUMMARY
126
138
  s.description = DESCRIPTION
139
+ s.license = LICENSE
127
140
  s.author = AUTHOR
128
141
  s.email = EMAIL
129
142
  s.homepage = HOMEPAGE
@@ -133,7 +146,6 @@ begin
133
146
  s.rubyforge_project = %q{hornetseye}
134
147
  s.has_rdoc = 'yard'
135
148
  s.extra_rdoc_files = []
136
- s.rdoc_options = %w{--no-private}
137
149
  end
138
150
  GEM_BINARY = "#{PKG_NAME}-#{PKG_VERSION}-#{$BINSPEC.platform}.gem"
139
151
  desc "Build the gem file #{GEM_SOURCE}"
@@ -40,6 +40,8 @@ VALUE Malloc::init( VALUE rbModule )
40
40
  RUBY_METHOD_FUNC( mallocRead ), 1 );
41
41
  rb_define_method( cRubyClass, "orig_write",
42
42
  RUBY_METHOD_FUNC( mallocWrite ), -1 );
43
+ rb_define_method( cRubyClass, "to_i",
44
+ RUBY_METHOD_FUNC( mallocToI ), 0 );
43
45
  return cRubyClass;
44
46
  }
45
47
 
@@ -105,3 +107,9 @@ VALUE Malloc::mallocWrite( int argc, VALUE *rbArgv, VALUE rbSelf )
105
107
  return retVal;
106
108
  }
107
109
 
110
+ VALUE Malloc::mallocToI( VALUE rbSelf )
111
+ {
112
+ char *self; Data_Get_Struct( rbSelf, char, self );
113
+ return LONG2NUM((long)self);
114
+ }
115
+
@@ -27,6 +27,7 @@ public:
27
27
  static VALUE mallocPlus( VALUE rbSelf, VALUE rbOffset );
28
28
  static VALUE mallocRead( VALUE rbSelf, VALUE rbLength );
29
29
  static VALUE mallocWrite( int argc, VALUE *rbArgv, VALUE rbSelf );
30
+ static VALUE mallocToI( VALUE rbSelf );
30
31
  };
31
32
 
32
33
  #endif
@@ -29,7 +29,7 @@ class String
29
29
  end
30
30
 
31
31
  end
32
-
32
+
33
33
  end
34
34
 
35
35
  # Namespace of the Hornetseye project.
@@ -60,6 +60,26 @@ module Hornetseye
60
60
 
61
61
  private :orig_new
62
62
 
63
+ # Create new Malloc object with aligned memory
64
+ #
65
+ # Allocate memory with specified alignment
66
+ #
67
+ # @example Allocate raw memory
68
+ # m = Malloc.align 256, 16
69
+ # # Malloc(256)
70
+ #
71
+ # @param [Integer] size Number of bytes to allocate.
72
+ # @param [Integer] alignment Page size of memory to align with
73
+ # @return [Malloc] A new Malloc object.
74
+ #
75
+ # @see Malloc
76
+ def align size, alignment
77
+ offset = alignment - 1
78
+ retval = Malloc.new size + offset
79
+ incr = ((retval.to_i + offset) & ~offset) - retval.to_i
80
+ retval + incr
81
+ end
82
+
63
83
  end
64
84
 
65
85
  # Number of bytes allocated
@@ -77,4 +77,9 @@ class TC_Malloc < Test::Unit::TestCase
77
77
  assert_raise( RuntimeError ) { ( m + 2 ).read 5 }
78
78
  end
79
79
 
80
+ def test_align
81
+ m = Malloc.align 256, 16
82
+ assert_equal 0, m.to_i & 15
83
+ end
84
+
80
85
  end
metadata CHANGED
@@ -1,88 +1,79 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: malloc
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 4
8
- - 0
9
- version: 1.4.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Jan Wedekind
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-12-30 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2015-05-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :development
32
- version_requirements: *id001
33
- description: This Ruby extension defines the class Hornetseye::Malloc. Hornetseye::Malloc#new allows you to allocate memory, using Hornetseye::Malloc#+ one can do pointer manipulation, and Hornetseye::Malloc#read and Hornetseye::Malloc#write provide reading Ruby strings from memory and writing Ruby strings to memory.
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: This Ruby extension defines the class Hornetseye::Malloc. Hornetseye::Malloc#new
31
+ allows you to allocate memory, using Hornetseye::Malloc#+ one can do pointer manipulation,
32
+ and Hornetseye::Malloc#read and Hornetseye::Malloc#write provide reading Ruby strings
33
+ from memory and writing Ruby strings to memory.
34
34
  email: jan@wedesoft.de
35
35
  executables: []
36
-
37
- extensions:
36
+ extensions:
38
37
  - Rakefile
39
38
  extra_rdoc_files: []
40
-
41
- files:
39
+ files:
42
40
  - Rakefile
43
41
  - README.md
44
42
  - COPYING
45
43
  - .document
46
44
  - lib/malloc_ext.rb
47
- - ext/malloc.cc
48
45
  - ext/init.cc
46
+ - ext/malloc.cc
47
+ - ext/error.hh
49
48
  - ext/malloc.hh
50
49
  - ext/rubyinc.hh
51
- - ext/error.hh
52
50
  - test/ts_malloc.rb
53
51
  - test/tc_malloc.rb
54
- has_rdoc: yard
55
52
  homepage: http://wedesoft.github.com/malloc/
56
- licenses: []
57
-
53
+ licenses:
54
+ - GPL-3+
58
55
  post_install_message:
59
- rdoc_options:
60
- - --no-private
61
- require_paths:
56
+ rdoc_options: []
57
+ require_paths:
62
58
  - lib
63
59
  - ext
64
- required_ruby_version: !ruby/object:Gem::Requirement
60
+ required_ruby_version: !ruby/object:Gem::Requirement
65
61
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
72
- required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
67
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- segments:
78
- - 0
79
- version: "0"
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
80
72
  requirements: []
81
-
82
73
  rubyforge_project: hornetseye
83
- rubygems_version: 1.3.7
74
+ rubygems_version: 1.8.23
84
75
  signing_key:
85
76
  specification_version: 3
86
77
  summary: Object for raw memory allocation and pointer operations
87
- test_files:
78
+ test_files:
88
79
  - test/tc_malloc.rb