@@ -43,13 +43,13 @@ static VALUE NIO_Selector_closed(VALUE self);
43
43
static VALUE NIO_Selector_is_empty (VALUE self );
44
44
45
45
/* Internal functions */
46
- static VALUE NIO_Selector_synchronize (VALUE self , VALUE (* func )(VALUE * args ), VALUE * args );
46
+ static VALUE NIO_Selector_synchronize (VALUE self , VALUE (* func )(VALUE arg ), VALUE arg );
47
47
static VALUE NIO_Selector_unlock (VALUE lock );
48
- static VALUE NIO_Selector_register_synchronized (VALUE * args );
49
- static VALUE NIO_Selector_deregister_synchronized (VALUE * args );
50
- static VALUE NIO_Selector_select_synchronized (VALUE * args );
51
- static VALUE NIO_Selector_close_synchronized (VALUE * args );
52
- static VALUE NIO_Selector_closed_synchronized (VALUE * args );
48
+ static VALUE NIO_Selector_register_synchronized (VALUE arg );
49
+ static VALUE NIO_Selector_deregister_synchronized (VALUE arg );
50
+ static VALUE NIO_Selector_select_synchronized (VALUE arg );
51
+ static VALUE NIO_Selector_close_synchronized (VALUE arg );
52
+ static VALUE NIO_Selector_closed_synchronized (VALUE arg );
53
53
54
54
static int NIO_Selector_run (struct NIO_Selector * selector , VALUE timeout );
55
55
static void NIO_Selector_timeout_callback (struct ev_loop * ev_loop , struct ev_timer * timer , int revents );
@@ -62,7 +62,7 @@ static void NIO_Selector_wakeup_callback(struct ev_loop *ev_loop, struct ev_io *
62
62
#define BUSYWAIT_INTERVAL 0.01
63
63
64
64
/* Selectors wait for events */
65
- void Init_NIO_Selector ()
65
+ void Init_NIO_Selector (void )
66
66
{
67
67
mNIO = rb_define_module ("NIO" );
68
68
cNIO_Selector = rb_define_class_under (mNIO , "Selector" , rb_cObject );
@@ -285,7 +285,7 @@ static VALUE NIO_Selector_backend(VALUE self)
285
285
}
286
286
287
287
/* Synchronize around a reentrant selector lock */
288
- static VALUE NIO_Selector_synchronize (VALUE self , VALUE (* func )(VALUE * args ), VALUE * args )
288
+ static VALUE NIO_Selector_synchronize (VALUE self , VALUE (* func )(VALUE arg ), VALUE arg )
289
289
{
290
290
VALUE current_thread , lock_holder , lock ;
291
291
@@ -298,10 +298,10 @@ static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VA
298
298
rb_ivar_set (self , rb_intern ("lock_holder" ), current_thread );
299
299
300
300
/* We've acquired the lock, so ensure we unlock it */
301
- return rb_ensure (func , (VALUE )args , NIO_Selector_unlock , self );
301
+ return rb_ensure (func , (VALUE )arg , NIO_Selector_unlock , self );
302
302
} else {
303
303
/* We already hold the selector lock, so no need to unlock it */
304
- return func (args );
304
+ return func (arg );
305
305
}
306
306
}
307
307
@@ -321,17 +321,18 @@ static VALUE NIO_Selector_unlock(VALUE self)
321
321
/* Register an IO object with the selector for the given interests */
322
322
static VALUE NIO_Selector_register (VALUE self , VALUE io , VALUE interests )
323
323
{
324
- VALUE args [3 ] = { self , io , interests };
325
- return NIO_Selector_synchronize (self , NIO_Selector_register_synchronized , args );
324
+ VALUE args [3 ] = {self , io , interests };
325
+ return NIO_Selector_synchronize (self , NIO_Selector_register_synchronized , ( VALUE ) args );
326
326
}
327
327
328
328
/* Internal implementation of register after acquiring mutex */
329
- static VALUE NIO_Selector_register_synchronized (VALUE * args )
329
+ static VALUE NIO_Selector_register_synchronized (VALUE _args )
330
330
{
331
331
VALUE self , io , interests , selectables , monitor ;
332
332
VALUE monitor_args [3 ];
333
333
struct NIO_Selector * selector ;
334
334
335
+ VALUE * args = (VALUE * )_args ;
335
336
self = args [0 ];
336
337
io = args [1 ];
337
338
interests = args [2 ];
@@ -361,15 +362,16 @@ static VALUE NIO_Selector_register_synchronized(VALUE *args)
361
362
/* Deregister an IO object from the selector */
362
363
static VALUE NIO_Selector_deregister (VALUE self , VALUE io )
363
364
{
364
- VALUE args [2 ] = { self , io };
365
- return NIO_Selector_synchronize (self , NIO_Selector_deregister_synchronized , args );
365
+ VALUE args [2 ] = {self , io };
366
+ return NIO_Selector_synchronize (self , NIO_Selector_deregister_synchronized , ( VALUE ) args );
366
367
}
367
368
368
369
/* Internal implementation of register after acquiring mutex */
369
- static VALUE NIO_Selector_deregister_synchronized (VALUE * args )
370
+ static VALUE NIO_Selector_deregister_synchronized (VALUE _args )
370
371
{
371
372
VALUE self , io , selectables , monitor ;
372
373
374
+ VALUE * args = (VALUE * )_args ;
373
375
self = args [0 ];
374
376
io = args [1 ];
375
377
@@ -396,27 +398,26 @@ static VALUE NIO_Selector_is_registered(VALUE self, VALUE io)
396
398
static VALUE NIO_Selector_select (int argc , VALUE * argv , VALUE self )
397
399
{
398
400
VALUE timeout ;
399
- VALUE args [2 ];
400
401
401
402
rb_scan_args (argc , argv , "01" , & timeout );
402
403
403
404
if (timeout != Qnil && NUM2DBL (timeout ) < 0 ) {
404
405
rb_raise (rb_eArgError , "time interval must be positive" );
405
406
}
406
407
407
- args [0 ] = self ;
408
- args [1 ] = timeout ;
409
-
410
- return NIO_Selector_synchronize (self , NIO_Selector_select_synchronized , args );
408
+ VALUE args [2 ] = {self , timeout };
409
+ return NIO_Selector_synchronize (self , NIO_Selector_select_synchronized , (VALUE )args );
411
410
}
412
411
413
412
/* Internal implementation of select with the selector lock held */
414
- static VALUE NIO_Selector_select_synchronized (VALUE * args )
413
+ static VALUE NIO_Selector_select_synchronized (VALUE _args )
415
414
{
416
415
int ready ;
417
416
VALUE ready_array ;
418
417
struct NIO_Selector * selector ;
419
418
419
+ VALUE * args = (VALUE * )_args ;
420
+
420
421
Data_Get_Struct (args [0 ], struct NIO_Selector , selector );
421
422
422
423
if (selector -> closed ) {
@@ -504,14 +505,13 @@ static VALUE NIO_Selector_wakeup(VALUE self)
504
505
/* Close the selector and free system resources */
505
506
static VALUE NIO_Selector_close (VALUE self )
506
507
{
507
- VALUE args [1 ] = { self };
508
- return NIO_Selector_synchronize (self , NIO_Selector_close_synchronized , args );
508
+ return NIO_Selector_synchronize (self , NIO_Selector_close_synchronized , self );
509
509
}
510
510
511
- static VALUE NIO_Selector_close_synchronized (VALUE * args )
511
+ static VALUE NIO_Selector_close_synchronized (VALUE self )
512
512
{
513
513
struct NIO_Selector * selector ;
514
- VALUE self = args [ 0 ];
514
+
515
515
Data_Get_Struct (self , struct NIO_Selector , selector );
516
516
517
517
NIO_Selector_shutdown (selector );
@@ -522,14 +522,13 @@ static VALUE NIO_Selector_close_synchronized(VALUE *args)
522
522
/* Is the selector closed? */
523
523
static VALUE NIO_Selector_closed (VALUE self )
524
524
{
525
- VALUE args [1 ] = { self };
526
- return NIO_Selector_synchronize (self , NIO_Selector_closed_synchronized , args );
525
+ return NIO_Selector_synchronize (self , NIO_Selector_closed_synchronized , self );
527
526
}
528
527
529
- static VALUE NIO_Selector_closed_synchronized (VALUE * args )
528
+ static VALUE NIO_Selector_closed_synchronized (VALUE self )
530
529
{
531
530
struct NIO_Selector * selector ;
532
- VALUE self = args [ 0 ];
531
+
533
532
Data_Get_Struct (self , struct NIO_Selector , selector );
534
533
535
534
return selector -> closed ? Qtrue : Qfalse ;
0 commit comments