From af73ca855100a9aadad9bf60de45df62e8aa44e2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 11 Mar 2011 16:12:17 -0800 Subject: cleanup struct initialization to avoid ifdefs Too hard to maintain. --- ext/raindrops/linux_inet_diag.c | 19 +------------------ ext/raindrops/rstruct_19.h | 17 ----------------- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 ext/raindrops/rstruct_19.h diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c index 18f5ce8..7e978f5 100644 --- a/ext/raindrops/linux_inet_diag.c +++ b/ext/raindrops/linux_inet_diag.c @@ -2,15 +2,10 @@ #ifdef __linux__ /* Ruby 1.8.6+ macros (for compatibility with Ruby 1.9) */ -#ifndef RSTRING_PTR -# define RSTRING_PTR(s) (RSTRING(s)->ptr) -#endif #ifndef RSTRING_LEN # define RSTRING_LEN(s) (RSTRING(s)->len) #endif -#include "rstruct_19.h" - /* partial emulation of the 1.9 rb_thread_blocking_region under 1.8 */ #ifndef HAVE_RB_THREAD_BLOCKING_REGION # include @@ -68,19 +63,10 @@ struct nogvl_args { /* creates a Ruby ListenStats Struct based on our internal listen_stats */ static VALUE rb_listen_stats(struct listen_stats *stats) { - VALUE rv = rb_struct_alloc_noinit(cListenStats); VALUE active = ULONG2NUM(stats->active); VALUE queued = ULONG2NUM(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; + return rb_struct_new(cListenStats, active, queued); } /* inner loop of inet_diag, called for every socket returned by netlink */ @@ -386,9 +372,6 @@ void Init_raindrops_linux_inet_diag(void) rb_define_module_function(mLinux, "tcp_listener_stats", tcp_listener_stats, 1); -#ifndef HAVE_RB_STRUCT_ALLOC_NOINIT - id_new = rb_intern("new"); -#endif page_size = getpagesize(); assert(OPLEN <= page_size && "bytecode OPLEN is not <= PAGE_SIZE"); diff --git a/ext/raindrops/rstruct_19.h b/ext/raindrops/rstruct_19.h deleted file mode 100644 index f156206..0000000 --- a/ext/raindrops/rstruct_19.h +++ /dev/null @@ -1,17 +0,0 @@ -#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 -static ID id_new; -static VALUE rb_struct_alloc_noinit(VALUE class) -{ - return rb_funcall(class, id_new, 0, 0); -} -#endif /* !defined(HAVE_RB_STRUCT_ALLOC_NOINIT) */ -- cgit v1.2.3-24-ge0c7