nio4r 2.5.8 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f8bda8397f00743e7ca6814df9ae0072197fe4a1c9ba49efa74c8b44148ee71
4
- data.tar.gz: c3fb1c470e4d378346f67b0c07fb7ffe4fe5527339097297a3b93ac950202d0b
3
+ metadata.gz: ae8b5e59a799c0161b454b1e4dcd97becc5bdb0b835ec6becf2a3a4488b648b5
4
+ data.tar.gz: e5b186044e74c4ad7c3b9846d6244dd21938b831eb415eccb63a781a4ee5dc9e
5
5
  SHA512:
6
- metadata.gz: 51c13b6c08c436b692b0e858abc704d1e682667a302c55e43635a043daf2b26b8faff4ad67c1ea02ca2d619efad776903497b15ad67d2dd22894dd82a598cd49
7
- data.tar.gz: '08297c9a051369fd39ad02489ddeb35595f1fbba313c3516d24f60e4e4e46db41307da90075a5a3b11ac377ad410bf908719d585ad1e3ba1b7ba867d520e4c0c'
6
+ metadata.gz: c22f5d7466ede134956ab01ea87c4554ce38a950019519f0a7c4a9f16cbe81c5a338de488d885761bd49393cfd72bf20a857204db13b051d6f59f8e5bc52bc1d
7
+ data.tar.gz: 27152f810d81a2f94b7428a3662e991441adb4756e24cb09753addd8d00b1a3a6ea80a2e89580eac76ab5d3328fa368cb43147ccaa9432d70e74a771ce22c863
@@ -14,34 +14,48 @@ jobs:
14
14
  strategy:
15
15
  fail-fast: false
16
16
  matrix:
17
- os: [ ubuntu-20.04, ubuntu-18.04, macos-10.15, windows-2019 ]
18
- ruby: [ head, 3.0, 2.7, 2.6, 2.5, 2.4, jruby, truffleruby-head ]
17
+ os:
18
+ - ubuntu-22.04
19
+ - macos-11
20
+ - windows-2022
21
+ ruby:
22
+ - "2.4"
23
+ - "2.5"
24
+ - "2.6"
25
+ - "2.7"
26
+ - "3.0"
27
+ - "3.1"
28
+ - "3.2"
29
+ - "head"
30
+ - "jruby"
31
+ - "truffleruby"
19
32
  include:
20
- - { os: ubuntu-16.04, ruby: 3.0 }
21
- - { os: ubuntu-16.04, ruby: 2.4 }
33
+ - {os: ubuntu-20.04, ruby: "3.2"}
34
+ - {os: windows-2019, ruby: "3.2"}
35
+ - {os: windows-2022, ruby: ucrt}
22
36
  exclude:
23
- - { os: windows-2019, ruby: head }
24
- - { os: windows-2019, ruby: jruby }
25
- - { os: windows-2019, ruby: truffleruby-head }
37
+ - {os: windows-2022, ruby: head}
38
+ - {os: windows-2022, ruby: jruby}
39
+ - {os: windows-2022, ruby: truffleruby}
26
40
 
27
41
  steps:
28
- - name: repo checkout
29
- uses: actions/checkout@v2
42
+ - uses: actions/checkout@v3
30
43
 
31
- - name: load ruby
32
- uses: ruby/setup-ruby@v1
44
+ - name: set JAVA_HOME
45
+ if: |
46
+ startsWith(matrix.ruby, 'jruby')
47
+ shell: bash
48
+ run: |
49
+ echo JAVA_HOME=$JAVA_HOME_11_X64 >> $GITHUB_ENV
50
+
51
+ - uses: ruby/setup-ruby@v1
33
52
  with:
34
53
  ruby-version: ${{matrix.ruby}}
54
+ bundler-cache: true
35
55
 
36
- - name: RubyGems, Bundler Update
37
- run: gem update --system --no-document --conservative
38
-
39
- - name: bundle install
40
- run: bundle install --path .bundle/gems --without development
41
-
42
- - name: compile
56
+ - name: Compile
43
57
  run: bundle exec rake compile
44
58
 
45
- - name: test
59
+ - name: Test
46
60
  run: bundle exec rake spec
47
61
  timeout-minutes: 10
data/.mailmap ADDED
@@ -0,0 +1,16 @@
1
+ Sadayuki Furuhashi <frsyuki@users.sourceforge.jp>
2
+ Shannon Skipper <shannonskipper@gmail.com>
3
+ Anatol Pomozov <anatol.pomozov@gmail.com>
4
+ Hiroshi Shibata <shibata.hiroshi@gmail.com>
5
+ John Thornton <ubergeek3141@gmail.com>
6
+ Upekshe Jayasekera <usmj000@gmail.com>
7
+ Upekshe Jayasekera <upekshej.11@cse.mrt.ac.lk>
8
+ Usaku Nakamura <usa@garbagecollect.jp>
9
+ Tomoya Ishida <tomoyapenguin@gmail.com>
10
+ Tiago Cardoso <cardoso_tiago@hotmail.com>
11
+ Ravil Bayramgalin <brainopia@evilmartians.com>
12
+ Gregory Longtin <Greg.mpls@gmail.com>
13
+ Gregory Longtin <Greg.mpls@gmail.com> <MSP-Greg@users.noreply.github.com>
14
+ Elad Eyal <elad.eyal@intel.com>
15
+ Boaz Segev <bo@bowild.com>
16
+ Tao Luo <luotao.ruby@gmail.com>
data/Gemfile CHANGED
@@ -6,13 +6,14 @@ gemspec
6
6
 
7
7
  gem "jruby-openssl" if defined? JRUBY_VERSION
8
8
 
9
- group :development do
10
- gem "pry", require: false
9
+ group :maintenance, optional: true do
10
+ gem "bake"
11
+ gem "bake-gem"
12
+ # gem "bake-modernize"
11
13
  end
12
14
 
13
15
  group :development, :test do
14
- gem "coveralls", require: false
15
- gem "rake-compiler", require: false
16
+ gem "rake-compiler", "~> 1.1.9", require: false
16
17
  gem "rspec", "~> 3.7", require: false
17
18
  gem "rubocop", "0.82.0", require: false
18
19
  end
@@ -1,3 +1,40 @@
1
+ ## 2.6.2
2
+
3
+ * Convert NIO objects to TypedData API.
4
+
5
+ ## 2.6.1
6
+
7
+ * Don't update `io` which is subsequently stored. Retain the original.
8
+
9
+ ## 2.6.0
10
+
11
+ * Fix conversion loses int precision.
12
+ * Avoid direct access to IO internals.
13
+ * Resolve issue loading both nio and nio4r gems.
14
+
15
+ ## 2.5.9 (2023-04-02)
16
+
17
+ https://github.com/socketry/nio4r/compare/v2.5.8..v2.5.9
18
+
19
+ ## 2.5.8 (2021-08-03)
20
+
21
+ * [#276](https://github.com/socketry/nio4r/pull/276)
22
+ Fix missing return statement in function returning non-void (issue [#275](https://github.com/socketry/nio4r/pull/275))
23
+ ([@ioquatix])
24
+ * Remove `guard-rspec` from development dependencies ([@ioquatix])
25
+
26
+ ## 2.5.7 (2021-03-04)
27
+
28
+ * [#267](https://github.com/socketry/nio4r/pull/267)
29
+ Don't try to link universal extension
30
+ ([@ioquatix])
31
+
32
+ ## 2.5.6 (2021-03-04)
33
+
34
+ * [#268](https://github.com/socketry/nio4r/pull/268)
35
+ Prefer kqueue when on OSX >= v10.12.2
36
+ ([@jcmfernandes])
37
+
1
38
  ## 2.5.5 (2021-02-05)
2
39
 
3
40
  * [#256](https://github.com/socketry/nio4r/pull/256)
@@ -1,6 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ # Released under the MIT License.
5
+ # Copyright, 2012-2016, by Tony Arcieri.
6
+ # Copyright, 2016, by Jun Aruga.
7
+ # Copyright, 2019, by Zhang Kang.
8
+ # Copyright, 2020, by Thomas Dziedzic.
9
+ # Copyright, 2023, by Samuel Williams.
10
+
4
11
  $LOAD_PATH.push File.expand_path("../lib", __dir__)
5
12
  require "nio"
6
13
  require "socket"
@@ -8,8 +8,8 @@ static VALUE cNIO_ByteBuffer_MarkUnsetError = Qnil;
8
8
 
9
9
  /* Allocator/deallocator */
10
10
  static VALUE NIO_ByteBuffer_allocate(VALUE klass);
11
- static void NIO_ByteBuffer_gc_mark(struct NIO_ByteBuffer *byteBuffer);
12
- static void NIO_ByteBuffer_free(struct NIO_ByteBuffer *byteBuffer);
11
+ static void NIO_ByteBuffer_free(void *data);
12
+ static size_t NIO_ByteBuffer_memsize(const void *data);
13
13
 
14
14
  /* Methods */
15
15
  static VALUE NIO_ByteBuffer_initialize(VALUE self, VALUE capacity);
@@ -36,6 +36,26 @@ static VALUE NIO_ByteBuffer_inspect(VALUE self);
36
36
 
37
37
  #define MARK_UNSET -1
38
38
 
39
+ /* Compatibility for Ruby <= 3.1 */
40
+ #ifndef HAVE_RB_IO_DESCRIPTOR
41
+ static int
42
+ io_descriptor_fallback(VALUE io)
43
+ {
44
+ rb_io_t *fptr;
45
+ GetOpenFile(io, fptr);
46
+ return fptr->fd;
47
+ }
48
+ #define rb_io_descriptor io_descriptor_fallback
49
+ #endif
50
+
51
+ static void
52
+ io_set_nonblock(VALUE io)
53
+ {
54
+ rb_io_t *fptr;
55
+ GetOpenFile(io, fptr);
56
+ rb_io_set_nonblock(fptr);
57
+ }
58
+
39
59
  void Init_NIO_ByteBuffer()
40
60
  {
41
61
  mNIO = rb_define_module("NIO");
@@ -72,28 +92,46 @@ void Init_NIO_ByteBuffer()
72
92
  rb_define_method(cNIO_ByteBuffer, "inspect", NIO_ByteBuffer_inspect, 0);
73
93
  }
74
94
 
95
+ static const rb_data_type_t NIO_ByteBuffer_type = {
96
+ "NIO::ByteBuffer",
97
+ {
98
+ NULL, // Nothing to mark
99
+ NIO_ByteBuffer_free,
100
+ NIO_ByteBuffer_memsize,
101
+ },
102
+ 0,
103
+ 0,
104
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
105
+ };
106
+
75
107
  static VALUE NIO_ByteBuffer_allocate(VALUE klass)
76
108
  {
77
109
  struct NIO_ByteBuffer *bytebuffer = (struct NIO_ByteBuffer *)xmalloc(sizeof(struct NIO_ByteBuffer));
78
110
  bytebuffer->buffer = NULL;
79
- return Data_Wrap_Struct(klass, NIO_ByteBuffer_gc_mark, NIO_ByteBuffer_free, bytebuffer);
111
+ return TypedData_Wrap_Struct(klass, &NIO_ByteBuffer_type, bytebuffer);
80
112
  }
81
113
 
82
- static void NIO_ByteBuffer_gc_mark(struct NIO_ByteBuffer *buffer)
114
+ static void NIO_ByteBuffer_free(void *data)
83
115
  {
116
+ struct NIO_ByteBuffer *buffer = (struct NIO_ByteBuffer *)data;
117
+ if (buffer->buffer)
118
+ xfree(buffer->buffer);
119
+ xfree(buffer);
84
120
  }
85
121
 
86
- static void NIO_ByteBuffer_free(struct NIO_ByteBuffer *buffer)
122
+ static size_t NIO_ByteBuffer_memsize(const void *data)
87
123
  {
124
+ const struct NIO_ByteBuffer *buffer = (const struct NIO_ByteBuffer *)data;
125
+ size_t memsize = sizeof(struct NIO_ByteBuffer);
88
126
  if (buffer->buffer)
89
- xfree(buffer->buffer);
90
- xfree(buffer);
127
+ memsize += buffer->capacity;
128
+ return memsize;
91
129
  }
92
130
 
93
131
  static VALUE NIO_ByteBuffer_initialize(VALUE self, VALUE capacity)
94
132
  {
95
133
  struct NIO_ByteBuffer *buffer;
96
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
134
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
97
135
 
98
136
  buffer->capacity = NUM2INT(capacity);
99
137
  buffer->buffer = xmalloc(buffer->capacity);
@@ -106,7 +144,7 @@ static VALUE NIO_ByteBuffer_initialize(VALUE self, VALUE capacity)
106
144
  static VALUE NIO_ByteBuffer_clear(VALUE self)
107
145
  {
108
146
  struct NIO_ByteBuffer *buffer;
109
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
147
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
110
148
 
111
149
  memset(buffer->buffer, 0, buffer->capacity);
112
150
 
@@ -120,7 +158,7 @@ static VALUE NIO_ByteBuffer_clear(VALUE self)
120
158
  static VALUE NIO_ByteBuffer_get_position(VALUE self)
121
159
  {
122
160
  struct NIO_ByteBuffer *buffer;
123
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
161
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
124
162
 
125
163
  return INT2NUM(buffer->position);
126
164
  }
@@ -129,7 +167,7 @@ static VALUE NIO_ByteBuffer_set_position(VALUE self, VALUE new_position)
129
167
  {
130
168
  int pos;
131
169
  struct NIO_ByteBuffer *buffer;
132
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
170
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
133
171
 
134
172
  pos = NUM2INT(new_position);
135
173
 
@@ -153,7 +191,7 @@ static VALUE NIO_ByteBuffer_set_position(VALUE self, VALUE new_position)
153
191
  static VALUE NIO_ByteBuffer_get_limit(VALUE self)
154
192
  {
155
193
  struct NIO_ByteBuffer *buffer;
156
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
194
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
157
195
 
158
196
  return INT2NUM(buffer->limit);
159
197
  }
@@ -162,7 +200,7 @@ static VALUE NIO_ByteBuffer_set_limit(VALUE self, VALUE new_limit)
162
200
  {
163
201
  int lim;
164
202
  struct NIO_ByteBuffer *buffer;
165
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
203
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
166
204
 
167
205
  lim = NUM2INT(new_limit);
168
206
 
@@ -190,7 +228,7 @@ static VALUE NIO_ByteBuffer_set_limit(VALUE self, VALUE new_limit)
190
228
  static VALUE NIO_ByteBuffer_capacity(VALUE self)
191
229
  {
192
230
  struct NIO_ByteBuffer *buffer;
193
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
231
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
194
232
 
195
233
  return INT2NUM(buffer->capacity);
196
234
  }
@@ -198,7 +236,7 @@ static VALUE NIO_ByteBuffer_capacity(VALUE self)
198
236
  static VALUE NIO_ByteBuffer_remaining(VALUE self)
199
237
  {
200
238
  struct NIO_ByteBuffer *buffer;
201
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
239
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
202
240
 
203
241
  return INT2NUM(buffer->limit - buffer->position);
204
242
  }
@@ -206,7 +244,7 @@ static VALUE NIO_ByteBuffer_remaining(VALUE self)
206
244
  static VALUE NIO_ByteBuffer_full(VALUE self)
207
245
  {
208
246
  struct NIO_ByteBuffer *buffer;
209
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
247
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
210
248
 
211
249
  return buffer->position == buffer->limit ? Qtrue : Qfalse;
212
250
  }
@@ -216,7 +254,7 @@ static VALUE NIO_ByteBuffer_get(int argc, VALUE *argv, VALUE self)
216
254
  int len;
217
255
  VALUE length, result;
218
256
  struct NIO_ByteBuffer *buffer;
219
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
257
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
220
258
 
221
259
  rb_scan_args(argc, argv, "01", &length);
222
260
 
@@ -244,7 +282,7 @@ static VALUE NIO_ByteBuffer_fetch(VALUE self, VALUE index)
244
282
  {
245
283
  int i;
246
284
  struct NIO_ByteBuffer *buffer;
247
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
285
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
248
286
 
249
287
  i = NUM2INT(index);
250
288
 
@@ -263,7 +301,7 @@ static VALUE NIO_ByteBuffer_put(VALUE self, VALUE string)
263
301
  {
264
302
  long length;
265
303
  struct NIO_ByteBuffer *buffer;
266
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
304
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
267
305
 
268
306
  StringValue(string);
269
307
  length = RSTRING_LEN(string);
@@ -281,19 +319,19 @@ static VALUE NIO_ByteBuffer_put(VALUE self, VALUE string)
281
319
  static VALUE NIO_ByteBuffer_read_from(VALUE self, VALUE io)
282
320
  {
283
321
  struct NIO_ByteBuffer *buffer;
284
- rb_io_t *fptr;
285
322
  ssize_t nbytes, bytes_read;
286
323
 
287
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
288
- GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
289
- rb_io_set_nonblock(fptr);
324
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
325
+
326
+ io = rb_convert_type(io, T_FILE, "IO", "to_io");
327
+ io_set_nonblock(io);
290
328
 
291
329
  nbytes = buffer->limit - buffer->position;
292
330
  if (nbytes == 0) {
293
331
  rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full");
294
332
  }
295
333
 
296
- bytes_read = read(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes);
334
+ bytes_read = read(rb_io_descriptor(io), buffer->buffer + buffer->position, nbytes);
297
335
 
298
336
  if (bytes_read < 0) {
299
337
  if (errno == EAGAIN) {
@@ -305,25 +343,24 @@ static VALUE NIO_ByteBuffer_read_from(VALUE self, VALUE io)
305
343
 
306
344
  buffer->position += bytes_read;
307
345
 
308
- return INT2NUM(bytes_read);
346
+ return SIZET2NUM(bytes_read);
309
347
  }
310
348
 
311
349
  static VALUE NIO_ByteBuffer_write_to(VALUE self, VALUE io)
312
350
  {
313
351
  struct NIO_ByteBuffer *buffer;
314
- rb_io_t *fptr;
315
352
  ssize_t nbytes, bytes_written;
316
353
 
317
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
318
- GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
319
- rb_io_set_nonblock(fptr);
354
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
355
+ io = rb_convert_type(io, T_FILE, "IO", "to_io");
356
+ io_set_nonblock(io);
320
357
 
321
358
  nbytes = buffer->limit - buffer->position;
322
359
  if (nbytes == 0) {
323
360
  rb_raise(cNIO_ByteBuffer_UnderflowError, "no data remaining in buffer");
324
361
  }
325
362
 
326
- bytes_written = write(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes);
363
+ bytes_written = write(rb_io_descriptor(io), buffer->buffer + buffer->position, nbytes);
327
364
 
328
365
  if (bytes_written < 0) {
329
366
  if (errno == EAGAIN) {
@@ -335,13 +372,13 @@ static VALUE NIO_ByteBuffer_write_to(VALUE self, VALUE io)
335
372
 
336
373
  buffer->position += bytes_written;
337
374
 
338
- return INT2NUM(bytes_written);
375
+ return SIZET2NUM(bytes_written);
339
376
  }
340
377
 
341
378
  static VALUE NIO_ByteBuffer_flip(VALUE self)
342
379
  {
343
380
  struct NIO_ByteBuffer *buffer;
344
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
381
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
345
382
 
346
383
  buffer->limit = buffer->position;
347
384
  buffer->position = 0;
@@ -353,7 +390,7 @@ static VALUE NIO_ByteBuffer_flip(VALUE self)
353
390
  static VALUE NIO_ByteBuffer_rewind(VALUE self)
354
391
  {
355
392
  struct NIO_ByteBuffer *buffer;
356
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
393
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
357
394
 
358
395
  buffer->position = 0;
359
396
  buffer->mark = MARK_UNSET;
@@ -364,7 +401,7 @@ static VALUE NIO_ByteBuffer_rewind(VALUE self)
364
401
  static VALUE NIO_ByteBuffer_mark(VALUE self)
365
402
  {
366
403
  struct NIO_ByteBuffer *buffer;
367
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
404
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
368
405
 
369
406
  buffer->mark = buffer->position;
370
407
  return self;
@@ -373,7 +410,7 @@ static VALUE NIO_ByteBuffer_mark(VALUE self)
373
410
  static VALUE NIO_ByteBuffer_reset(VALUE self)
374
411
  {
375
412
  struct NIO_ByteBuffer *buffer;
376
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
413
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
377
414
 
378
415
  if (buffer->mark < 0) {
379
416
  rb_raise(cNIO_ByteBuffer_MarkUnsetError, "mark has not been set");
@@ -387,7 +424,7 @@ static VALUE NIO_ByteBuffer_reset(VALUE self)
387
424
  static VALUE NIO_ByteBuffer_compact(VALUE self)
388
425
  {
389
426
  struct NIO_ByteBuffer *buffer;
390
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
427
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
391
428
 
392
429
  memmove(buffer->buffer, buffer->buffer + buffer->position, buffer->limit - buffer->position);
393
430
  buffer->position = buffer->limit - buffer->position;
@@ -400,7 +437,7 @@ static VALUE NIO_ByteBuffer_each(VALUE self)
400
437
  {
401
438
  int i;
402
439
  struct NIO_ByteBuffer *buffer;
403
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
440
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
404
441
 
405
442
  if (rb_block_given_p()) {
406
443
  for (i = 0; i < buffer->limit; i++) {
@@ -416,7 +453,7 @@ static VALUE NIO_ByteBuffer_each(VALUE self)
416
453
  static VALUE NIO_ByteBuffer_inspect(VALUE self)
417
454
  {
418
455
  struct NIO_ByteBuffer *buffer;
419
- Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
456
+ TypedData_Get_Struct(self, struct NIO_ByteBuffer, &NIO_ByteBuffer_type, buffer);
420
457
 
421
458
  return rb_sprintf(
422
459
  "#<%s:%p @position=%d @limit=%d @capacity=%d>",
data/ext/nio4r/extconf.rb CHANGED
@@ -1,10 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2011-2020, by Tony Arcieri.
5
+ # Copyright, 2014, by Hiroshi Shibata.
6
+ # Copyright, 2014, by Sergey Avseyev.
7
+ # Copyright, 2015, by Daniel Berger.
8
+ # Copyright, 2017, by Jun Aruga.
9
+ # Copyright, 2017, by Usaku Nakamura.
10
+ # Copyright, 2017, by Lars Kanis.
11
+ # Copyright, 2019-2023, by Samuel Williams.
12
+ # Copyright, 2020, by Gregory Longtin.
13
+ # Copyright, 2020, by Boaz Segev.
14
+ # Copyright, 2020, by Joao Fernandes.
15
+ # Copyright, 2021, by Jeffrey Martin.
16
+
3
17
  require "rubygems"
4
18
 
5
19
  # Write a dummy Makefile on Windows because we use the pure Ruby implementation there
6
20
  if Gem.win_platform?
7
- require "devkit" if RUBY_PLATFORM.include?("mingw")
21
+ begin
22
+ require "devkit" if RUBY_PLATFORM.include?("mingw")
23
+ rescue LoadError => e
24
+ end
8
25
  File.write("Makefile", "all install::\n")
9
26
  File.write("nio4r_ext.so", "")
10
27
  exit
@@ -13,6 +30,7 @@ end
13
30
  require "mkmf"
14
31
 
15
32
  have_header("unistd.h")
33
+ have_func("rb_io_descriptor")
16
34
 
17
35
  $defs << "-DEV_USE_LINUXAIO" if have_header("linux/aio_abi.h")
18
36
  $defs << "-DEV_USE_IOURING" if have_header("linux/io_uring.h")