diff options
author | Eric Wong <e@yhbt.net> | 2010-09-25 06:25:42 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-09-25 06:34:34 +0000 |
commit | 22a5a39d75faa890048d07ae4ea0d494acd414ce (patch) | |
tree | 79d839333fcd9c505a72dca6e3006b827a180df9 /ext | |
parent | 663111480d8222763e5f553a71166442ef9990cc (diff) | |
download | raindrops-22a5a39d75faa890048d07ae4ea0d494acd414ce.tar.gz |
Rubinius does not include macros for accessing Struct members in the C API. ref: http://github.com/evanphx/rubinius/issues/494
Diffstat (limited to 'ext')
-rw-r--r-- | ext/raindrops/linux_inet_diag.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c index 2c2978b..ac27b19 100644 --- a/ext/raindrops/linux_inet_diag.c +++ b/ext/raindrops/linux_inet_diag.c @@ -7,11 +7,13 @@ #ifndef RSTRING_LEN # define RSTRING_LEN(s) (RSTRING(s)->len) #endif -#ifndef RSTRUCT_PTR -# define RSTRUCT_PTR(s) (RSTRUCT(s)->ptr) -#endif -#ifndef RSTRUCT_LEN -# define RSTRUCT_LEN(s) (RSTRUCT(s)->len) +#ifdef RSTRUCT +# ifndef RSTRUCT_PTR +# define RSTRUCT_PTR(s) (RSTRUCT(s)->ptr) +# endif +# ifndef RSTRUCT_LEN +# define RSTRUCT_LEN(s) (RSTRUCT(s)->len) +# endif #endif #ifndef HAVE_RB_STRUCT_ALLOC_NOINIT @@ -85,11 +87,17 @@ struct nogvl_args { static VALUE rb_listen_stats(struct listen_stats *stats) { VALUE rv = rb_struct_alloc_noinit(cListenStats); - VALUE *ptr = RSTRUCT_PTR(rv); - - ptr[0] = LONG2NUM(stats->active); - ptr[1] = LONG2NUM(stats->queued); + VALUE active = LONG2NUM(stats->active); + VALUE queued = LONG2NUM(stats->queued); +#ifdef RSTRUCT_PTR + VALUE *ptr = RSTRUCT_PTR(rv); + ptr[0] = active; + ptr[1] = queued; +#else /* Rubinius */ + rb_funcall(rv, rb_intern("active="), 1, active); + rb_funcall(rv, rb_intern("queued="), 1, queued); +#endif /* ! Rubinius */ return rv; } |