@@ -43,13 +43,13 @@ static VALUE NIO_Selector_closed(VALUE self);
4343static VALUE NIO_Selector_is_empty (VALUE self );
4444
4545/* 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 );
4747static 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 );
5353
5454static int NIO_Selector_run (struct NIO_Selector * selector , VALUE timeout );
5555static 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 *
6262#define BUSYWAIT_INTERVAL 0.01
6363
6464/* Selectors wait for events */
65- void Init_NIO_Selector ()
65+ void Init_NIO_Selector (void )
6666{
6767 mNIO = rb_define_module ("NIO" );
6868 cNIO_Selector = rb_define_class_under (mNIO , "Selector" , rb_cObject );
@@ -285,7 +285,7 @@ static VALUE NIO_Selector_backend(VALUE self)
285285}
286286
287287/* 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 )
289289{
290290 VALUE current_thread , lock_holder , lock ;
291291
@@ -298,10 +298,10 @@ static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VA
298298 rb_ivar_set (self , rb_intern ("lock_holder" ), current_thread );
299299
300300 /* 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 );
302302 } else {
303303 /* We already hold the selector lock, so no need to unlock it */
304- return func (args );
304+ return func (arg );
305305 }
306306}
307307
@@ -321,17 +321,18 @@ static VALUE NIO_Selector_unlock(VALUE self)
321321/* Register an IO object with the selector for the given interests */
322322static VALUE NIO_Selector_register (VALUE self , VALUE io , VALUE interests )
323323{
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 );
326326}
327327
328328/* 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 )
330330{
331331 VALUE self , io , interests , selectables , monitor ;
332332 VALUE monitor_args [3 ];
333333 struct NIO_Selector * selector ;
334334
335+ VALUE * args = (VALUE * )_args ;
335336 self = args [0 ];
336337 io = args [1 ];
337338 interests = args [2 ];
@@ -361,15 +362,16 @@ static VALUE NIO_Selector_register_synchronized(VALUE *args)
361362/* Deregister an IO object from the selector */
362363static VALUE NIO_Selector_deregister (VALUE self , VALUE io )
363364{
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 );
366367}
367368
368369/* 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 )
370371{
371372 VALUE self , io , selectables , monitor ;
372373
374+ VALUE * args = (VALUE * )_args ;
373375 self = args [0 ];
374376 io = args [1 ];
375377
@@ -396,27 +398,26 @@ static VALUE NIO_Selector_is_registered(VALUE self, VALUE io)
396398static VALUE NIO_Selector_select (int argc , VALUE * argv , VALUE self )
397399{
398400 VALUE timeout ;
399- VALUE args [2 ];
400401
401402 rb_scan_args (argc , argv , "01" , & timeout );
402403
403404 if (timeout != Qnil && NUM2DBL (timeout ) < 0 ) {
404405 rb_raise (rb_eArgError , "time interval must be positive" );
405406 }
406407
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 );
411410}
412411
413412/* 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 )
415414{
416415 int ready ;
417416 VALUE ready_array ;
418417 struct NIO_Selector * selector ;
419418
419+ VALUE * args = (VALUE * )_args ;
420+
420421 Data_Get_Struct (args [0 ], struct NIO_Selector , selector );
421422
422423 if (selector -> closed ) {
@@ -504,14 +505,13 @@ static VALUE NIO_Selector_wakeup(VALUE self)
504505/* Close the selector and free system resources */
505506static VALUE NIO_Selector_close (VALUE self )
506507{
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 );
509509}
510510
511- static VALUE NIO_Selector_close_synchronized (VALUE * args )
511+ static VALUE NIO_Selector_close_synchronized (VALUE self )
512512{
513513 struct NIO_Selector * selector ;
514- VALUE self = args [ 0 ];
514+
515515 Data_Get_Struct (self , struct NIO_Selector , selector );
516516
517517 NIO_Selector_shutdown (selector );
@@ -522,14 +522,13 @@ static VALUE NIO_Selector_close_synchronized(VALUE *args)
522522/* Is the selector closed? */
523523static VALUE NIO_Selector_closed (VALUE self )
524524{
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 );
527526}
528527
529- static VALUE NIO_Selector_closed_synchronized (VALUE * args )
528+ static VALUE NIO_Selector_closed_synchronized (VALUE self )
530529{
531530 struct NIO_Selector * selector ;
532- VALUE self = args [ 0 ];
531+
533532 Data_Get_Struct (self , struct NIO_Selector , selector );
534533
535534 return selector -> closed ? Qtrue : Qfalse ;
0 commit comments